Webassembly for Web Developers

Total Page:16

File Type:pdf, Size:1020Kb

Webassembly for Web Developers Bachelor Degree Project WebAssembly for Web Developers Author: Olle Lauri Boström ​ Supervisor: Francis Palma ​ Semester. VT 2019 ​ Subject: Computer Science ​ Abstract One of the latest tools in the strive troughwards a fast and secure Web is called WebAssembly. It is a low-level, assembly-like language that can run in the browser alongside JavaScript. WebAssembly is designed to load fast and aims to execute at near-native speed. Being a compilation target for system languages like C, C++, and Rust, WebAssembly is not very accessible from a Web developer perspective. This project explores ways to generate WebAssembly directly from JavaScript code, in order to lower the learning curve, and allow for a more widespread adoption of WebAssembly. This has resulted in a utility tool called Esmbly, which can turn simple JavaScript ​ ​ ​ programs into WebAssembly binaries by collecting and utilizing type information from various flavours of statically typed JavaScript. Keywords: WebAssembly, Web developers, JavaScript, TypeScript, ​ Flow, JSDoc, V8, Transpiler Contents 1 Introduction 5 1.1 Background 6 1.1.1 Static vs dynamic types 6 1.1.2 JavaScript type systems 7 1.1.3 TypeScript 7 1.1.4 Flow 7 1.1.5 JSDoc 8 1.1.6 V8 runtime type information 9 1.1.7 Compiler 9 1.1.8 Transpiler 9 1.1.9 Abstract syntax tree 9 1.2 Related work 10 1.3 Problem formulation 11 1.4 Motivation 11 1.5 Objectives 12 1.6 Scope 13 1.7 Target group 14 1.8 Outline 14 2 Method 15 2.1 Design Science 15 2.2 Evaluation 15 3 Implementation 16 3.1 Project overview 16 3.1.1 Packages 16 3.1.2 Mono repository 16 3.1.3 TypeScript 17 3.2 Esmbly core 17 3.2.1 Run configuration 18 3.2.2 Parsing 18 3.3 Transformers 18 3.3.1 Parser options 19 3.3.2 Input and Output formats 19 3.3.3 Transforming the AST 19 3.3.4 Creating output files 20 3.4 Flow transformer 20 3.5 JSDoc transformer 20 3.6 V8 transformer 21 3.7 WebAssembly transformer 21 3.8 Examples 21 3.8.1 Example of ‘Add’ function 22 3.8.2 Example of ‘Conway's Game of Life’ 22 3.8.3 Example of Insertion sort 22 3.8.4 Example of ‘String pad’ 22 3.8.5 Example of ‘Radians’ 23 3.8.6 Example of ‘String repeat’ 23 3.8.7 Example of ‘Custom rule’ 23 3.8.8 Example of ‘Custom transformer’ 23 3.8.9 Example of ‘Browser’ 23 3.9 Documentation and guides 23 3.10 Tests 24 3.11 Integration with WebAssembly Studio 24 4 Results 25 4.1 Transforming the examples 25 4.1.1 Add example 25 4.1.2 Conway's Game of Life example 25 4.1.3 Insertion sort example 25 4.1.4 String pad example 25 4.1.5 Radians example 26 4.1.6 String repeat example 26 4.2 Transforming popular open source projects 26 4.2.1 Yarn 26 4.2.2 Lodash 26 4.2.3 ms 27 4.3 Extensibility 27 4.4 A tool for both Node.js and the Browser 27 4.5 Limitations 28 4.5.1 Flow transformer 28 4.5.2 JSDoc transformer 28 4.5.3 V8 transformer 28 4.5.4 WebAssembly transformer 28 5 Analysis 30 5.1 Lowers the WebAssembly-barrier for Web developers 30 5.2 Beyond the basics 30 5.3 A useful tool for migrating between (and working with) different type systems 31 6 Discussion 32 7 Conclusion 33 7.1 Future work 34 References 35 Appendix 38 A1 Add example 38 A2 Insertion sort example 40 A3 String pad example 42 A4 Radians example 44 A5 String repeat example 45 1 Introduction As the capabilities of the Web Platform increases, being able to write fast and secure code for the Web has become more important than ever. Demanding applications including 3D visualizations, virtual reality and games, which are traditionally built using native techniques, are now being built for the Web. Even though the performance progress of JavaScript, in terms of execution speed, has been high for the last ten years, the language is not very well suited for many of these demanding use cases [1][2]. One of the latest tools for writing fast and secure Web applications is called WebAssembly, a collaborative effort by the four major browser vendors (i.e., Google, Mozilla, Microsoft, and Apple). It is a low-level, assembly-like language which can run in the browser alongside JavaScript. WebAssembly is designed to load fast and aims to execute at near-native speed. WebAssembly works as a compilation target for system languages like C, C++, and Rust which means that it is now possible to take a piece of code written in one of these languages, compile it to WebAssembly, and run it on the Web. WebAssembly aims to bring native speed to the Web, but for a large majority of Web developers who are not familiar with any of the initially supported system languages, getting started can be hard. This thesis aims to make it easier for Web developers to start working with WebAssembly, by implementing a tool which can generate WebAssembly directly from JavaScript code. 1.1 Background 1.1.1 Static vs dynamic types Most system languages like C, C++, and Rust are statically typed. This ​ ​ means that variable types are specified by the programmer and known at compile time [4]. This is a requirement for compilation to WebAssembly. JavaScript, on the other hand, is dynamically typed without any built-in way ​ of expressing variable types. This means that type information is not available until the program is running [5]. 1.1.2 JavaScript type systems Even though JavaScript lacks a built-in way of expressing variable types, most code is written with a certain type in mind. This has lead to the development of several external type systems. Even though these type ​ ​ systems differ in their goals, all of them lets the programmer specify variable types. Using a type system, commonly referred to as statically typed ​ JavaScript has become increasingly popular over the past few years [6]. The State of JavaScript Survey 2018 shows that almost half of the responding developers have used TypeScript and that they are excited about using it again [6]. This project targets the three most popular type systems at the moment, TypeScript, Flow, and JSDoc. These are presented below. 1.1.3 TypeScript TypeScript is a superset of the JavaScript language which adds support for optional static types. TypeScript code compiles to JavaScript, and any type errors are caught at compile time. TypeScript is developed and maintained by Microsoft and released under an open source Apache license [7]. Figure 1.1 shows an example the TypeScript syntax. Figure 1.1: Code example showing a simple JavaScript function and the corresponding implementation in TypeScript. 1.1.4 Flow Flow is an static type checker developed by Facebook, released under an open source MIT license [8]. Flow uses a syntax that is similar to TypeScript, but unlike TypeScript it is not a programming language. Type annotations are added to the source code to specify variable types, which enables Flow to check for any type errors. Flow does not include a compiler like TypeScript, but there are tools for automatically removing the type annotations and output plain JavaScript. Figure 1.2 shows an example of a JavaScript function with Flow annotations. Figure 1.2: Code example showing a simple JavaScript function and the corresponding implementation with Flow annotations. 1.1.5 JSDoc JSDoc is different from TypeScript and Flow in several ways. Firstly, as suggested by the name, JSDoc is mainly a way of documenting JavaScript code as opposed to TypeScript and Flow, which focuses on type checking. Furthermore, TypeScript and Flow syntax is not valid JavaScript which means that the code cannot run before it has been transformed to plain JavaScript. JSDoc on the other hand is written in the form of regular JavaScript comments. This makes code that is annotated with JSDoc comments runnable without the need of any transformation. JSDoc is released under an open source Apache license and has been around for many years [9]. Figure 1.3 shows an example of a JavaScript function that has been annotated with a JSDoc comment. Figure 1.3: Code example showing a simple JavaScript function annotated with a JSDoc comment. 1.1.6 V8 runtime type information V8 is an open source JavaScript engine developed by Google that is used to power both Google Chrome and Node.js [10]. V8 exposes run time type ​ ​ information through the inspector protocol [11]. This means that when a ​ ​ JavaScript program is running on the V8 engine, we can use the inspector protocol to find out the parameter and return types in a program. This project aims to utilize this by experimenting with ways of collecting a type profile during test runs and use it to output WebAssembly. 1.1.7 Compiler A compiler is a computer program which transforms source code written in one programming language to another. Most commonly, this transformation is performed from a high-level programming language to a low-level language like assembly or machine code to create an executable program [12]. Like from instance, transforming a C program to WebAssembly. 1.1.8 Transpiler A transpiler is a source-to-source compiler. It transforms source code written in one high-level language to another (or the same) high-level language [12].
Recommended publications
  • Differential Fuzzing the Webassembly
    Master’s Programme in Security and Cloud Computing Differential Fuzzing the WebAssembly Master’s Thesis Gilang Mentari Hamidy MASTER’S THESIS Aalto University - EURECOM MASTER’STHESIS 2020 Differential Fuzzing the WebAssembly Fuzzing Différentiel le WebAssembly Gilang Mentari Hamidy This thesis is a public document and does not contain any confidential information. Cette thèse est un document public et ne contient aucun information confidentielle. Thesis submitted in partial fulfillment of the requirements for the degree of Master of Science in Technology. Antibes, 27 July 2020 Supervisor: Prof. Davide Balzarotti, EURECOM Co-Supervisor: Prof. Jan-Erik Ekberg, Aalto University Copyright © 2020 Gilang Mentari Hamidy Aalto University - School of Science EURECOM Master’s Programme in Security and Cloud Computing Abstract Author Gilang Mentari Hamidy Title Differential Fuzzing the WebAssembly School School of Science Degree programme Master of Science Major Security and Cloud Computing (SECCLO) Code SCI3084 Supervisor Prof. Davide Balzarotti, EURECOM Prof. Jan-Erik Ekberg, Aalto University Level Master’s thesis Date 27 July 2020 Pages 133 Language English Abstract WebAssembly, colloquially known as Wasm, is a specification for an intermediate representation that is suitable for the web environment, particularly in the client-side. It provides a machine abstraction and hardware-agnostic instruction sets, where a high-level programming language can target the compilation to the Wasm instead of specific hardware architecture. The JavaScript engine implements the Wasm specification and recompiles the Wasm instruction to the target machine instruction where the program is executed. Technically, Wasm is similar to a popular virtual machine bytecode, such as Java Virtual Machine (JVM) or Microsoft Intermediate Language (MSIL).
    [Show full text]
  • Interaction Between Web Browsers and Script Engines
    IT 12 058 Examensarbete 45 hp November 2012 Interaction between web browsers and script engines Xiaoyu Zhuang Institutionen för informationsteknologi Department of Information Technology Abstract Interaction between web browser and the script engine Xiaoyu Zhuang Teknisk- naturvetenskaplig fakultet UTH-enheten Web browser plays an important part of internet experience and JavaScript is the most popular programming language as a client side script to build an active and Besöksadress: advance end user experience. The script engine which executes JavaScript needs to Ångströmlaboratoriet Lägerhyddsvägen 1 interact with web browser to get access to its DOM elements and other host objects. Hus 4, Plan 0 Browser from host side needs to initialize the script engine and dispatch script source code to the engine side. Postadress: This thesis studies the interaction between the script engine and its host browser. Box 536 751 21 Uppsala The shell where the engine address to make calls towards outside is called hosting layer. This report mainly discussed what operations could appear in this layer and Telefon: designed testing cases to validate if the browser is robust and reliable regarding 018 – 471 30 03 hosting operations. Telefax: 018 – 471 30 00 Hemsida: http://www.teknat.uu.se/student Handledare: Elena Boris Ämnesgranskare: Justin Pearson Examinator: Lisa Kaati IT 12 058 Tryckt av: Reprocentralen ITC Contents 1. Introduction................................................................................................................................
    [Show full text]
  • Stable/Build) • --Port PORT - Set the PORT Number (Default: 8000)
    Pyodide Release 0.18.1 unknown Sep 16, 2021 CONTENTS 1 Using Pyodide 3 1.1 Getting started..............................................3 1.2 Downloading and deploying Pyodide..................................6 1.3 Using Pyodide..............................................7 1.4 Loading packages............................................ 12 1.5 Type translations............................................. 14 1.6 Pyodide Python compatibility...................................... 25 1.7 API Reference.............................................. 26 1.8 Frequently Asked Questions....................................... 50 2 Development 55 2.1 Building from sources.......................................... 55 2.2 Creating a Pyodide package....................................... 57 2.3 How to Contribute............................................ 64 2.4 Testing and benchmarking........................................ 74 2.5 Interactive Debugging.......................................... 76 3 Project 79 3.1 About Pyodide.............................................. 79 3.2 Roadmap................................................. 80 3.3 Code of Conduct............................................. 82 3.4 Governance and Decision-making.................................... 83 3.5 Change Log............................................... 85 3.6 Related Projects............................................. 95 4 Indices and tables 97 Python Module Index 99 Index 101 i ii Pyodide, Release 0.18.1 Python with the scientific stack, compiled to WebAssembly.
    [Show full text]
  • Javascript API Deprecation in the Wild: a First Assessment
    JavaScript API Deprecation in the Wild: A First Assessment Romulo Nascimento, Aline Brito, Andre Hora, Eduardo Figueiredo Department of Computer Science Federal University of Minas Gerais, Brazil romulonascimento, alinebrito, andrehora,figueiredo @dcc.ufmg.br { } Abstract—Building an application using third-party libraries of our knowledge, there are no detailed studies regarding API is a common practice in software development. As any other deprecation in the JavaScript ecosystem. software system, code libraries and their APIs evolve over JavaScript has become extremely popular over the last years. time. In order to help version migration and ensure backward According to the Stack Overflow 2019 Developer Survey1, compatibility, a recommended practice during development is to deprecate API. Although studies have been conducted to JavaScript is the most popular programming language in this investigate deprecation in some programming languages, such as platform for the seventh consecutive year. GitHub also reports Java and C#, there are no detailed studies on API deprecation that JavaScript is the most popular language in terms of unique in the JavaScript ecosystem. This paper provides an initial contributors to both public and private repositories2. The npm assessment of API deprecation in JavaScript by analyzing 50 platform, the largest JavaScript package manager, states on popular software projects. Initial results suggest that the use of 3 deprecation mechanisms in JavaScript packages is low. However, their latest survey that 99% of JavaScript developers rely on wefindfive different ways that developers use to deprecate API npm to ease the management of their project dependencies. in the studied projects. Among these solutions, deprecation utility This survey also points out the massive growth in npm usage (i.e., any sort of function specially written to aid deprecation) and that started about 5 years ago.
    [Show full text]
  • Lightweight Django USING REST, WEBSOCKETS & BACKBONE
    Lightweight Django USING REST, WEBSOCKETS & BACKBONE Julia Elman & Mark Lavin Lightweight Django LightweightDjango How can you take advantage of the Django framework to integrate complex “A great resource for client-side interactions and real-time features into your web applications? going beyond traditional Through a series of rapid application development projects, this hands-on book shows experienced Django developers how to include REST APIs, apps and learning how WebSockets, and client-side MVC frameworks such as Backbone.js into Django can power the new or existing projects. backend of single-page Learn how to make the most of Django’s decoupled design by choosing web applications.” the components you need to build the lightweight applications you want. —Aymeric Augustin Once you finish this book, you’ll know how to build single-page applications Django core developer, CTO, oscaro.com that respond to interactions in real time. If you’re familiar with Python and JavaScript, you’re good to go. “Such a good idea—I think this will lower the barrier ■ Learn a lightweight approach for starting a new Django project of entry for developers ■ Break reusable applications into smaller services that even more… the more communicate with one another I read, the more excited ■ Create a static, rapid prototyping site as a scaffold for websites and applications I am!” —Barbara Shaurette ■ Build a REST API with django-rest-framework Python Developer, Cox Media Group ■ Learn how to use Django with the Backbone.js MVC framework ■ Create a single-page web application on top of your REST API Lightweight ■ Integrate real-time features with WebSockets and the Tornado networking library ■ Use the book’s code-driven examples in your own projects Julia Elman, a frontend developer and tech education advocate, started learning Django in 2008 while working at World Online.
    [Show full text]
  • An Execution Model for Serverless Functions at the Edge
    An Execution Model for Serverless Functions at the Edge Adam Hall Umakishore Ramachandran Georgia Institute of Technology Georgia Institute of Technology Atlanta, Georgia Atlanta, Georgia ach@gatech:edu rama@gatech:edu ABSTRACT 1 INTRODUCTION Serverless computing platforms allow developers to host single- Enabling next generation technologies such as self-driving cars or purpose applications that automatically scale with demand. In con- smart cities via edge computing requires us to reconsider the way trast to traditional long-running applications on dedicated, virtu- we characterize and deploy the services supporting those technolo- alized, or container-based platforms, serverless applications are gies. Edge/fog environments consist of many micro data centers intended to be instantiated when called, execute a single function, spread throughout the edge of the network. This is in stark contrast and shut down when finished. State-of-the-art serverless platforms to the cloud, where we assume the notion of unlimited resources achieve these goals by creating a new container instance to host available in a few centralized data centers. These micro data center a function when it is called and destroying the container when it environments must support large numbers of Internet of Things completes. This design allows for cost and resource savings when (IoT) devices on limited hardware resources, processing the mas- hosting simple applications, such as those supporting IoT devices sive amounts of data those devices generate while providing quick at the edge of the network. However, the use of containers intro- decisions to inform their actions [44]. One solution to supporting duces some overhead which may be unsuitable for applications emerging technologies at the edge lies in serverless computing.
    [Show full text]
  • The Uch Enmek Example(Altai Republic,Siberia)
    Faculty of Environmental Sciences Institute for Cartography Master Thesis Concept and Implementation of a Contextualized Navigable 3D Landscape Model: The Uch Enmek Example(Altai Republic,Siberia). Mussab Mohamed Abuelhassan Abdalla Born on: 7th December 1983 in Khartoum Matriculation number: 4118733 Matriculation year: 2014 to achieve the academic degree Master of Science (M.Sc.) Supervisors Dr.Nikolas Prechtel Dr.Sander Münster Submitted on: 18th September 2017 Faculty of Environmental Sciences Institute for Cartography Task for the preparation of a Master Thesis Name: Mussab Mohamed Abuelhassan Abdalla Matriculation number: 4118733 Matriculation year: 2014 Title: Concept and Implementation of a Contextualized Navigable 3D Landscape Model: The Uch Enmek Example(Altai Republic,Siberia). Objectives of work Scope/Previous Results:Virtual Globes can attract and inform websites visitors on natural and cultural objects and sceneries.Geo-centered information transfer is suitable for majority of sites and artifacts. Virtual Globes have been tested with an involvement of TUD institutes: e.g. the GEPAM project (Weller,2013), and an archaeological excavation site in the Altai Mountains ("Uch enmek", c.f. Schmid 2012, Schubert 2014).Virtual Globes technology should be flexible in terms of the desired geo-data configuration. Research data should be controlled by the authors. Modes of linking geo-objects to different types of meta-information seems evenly important for a successful deployment. Motivation: For an archaeological conservation site ("Uch Enmek") effort has already been directed into data collection, model development and an initial web-based presentation.The present "Open Web Globe" technology is not developed any further, what calls for a migra- tion into a different web environment.
    [Show full text]
  • Netscape 6.2.3 Software for Solaris Operating Environment
    What’s New in Netscape 6.2 Netscape 6.2 builds on the successful release of Netscape 6.1 and allows you to do more online with power, efficiency and safety. New is this release are: Support for the latest operating systems ¨ BETTER INTEGRATION WITH WINDOWS XP q Netscape 6.2 is now only one click away within the Windows XP Start menu if you choose Netscape as your default browser and mail applications. Also, you can view the number of incoming email messages you have from your Windows XP login screen. ¨ FULL SUPPORT FOR MACINTOSH OS X Other enhancements Netscape 6.2 offers a more seamless experience between Netscape Mail and other applications on the Windows platform. For example, you can now easily send documents from within Microsoft Word, Excel or Power Point without leaving that application. Simply choose File, “Send To” to invoke the Netscape Mail client to send the document. What follows is a more comprehensive list of the enhancements delivered in Netscape 6.1 CONFIDENTIAL UNTIL AUGUST 8, 2001 Netscape 6.1 Highlights PR Contact: Catherine Corre – (650) 937-4046 CONFIDENTIAL UNTIL AUGUST 8, 2001 Netscape Communications Corporation ("Netscape") and its licensors retain all ownership rights to this document (the "Document"). Use of the Document is governed by applicable copyright law. Netscape may revise this Document from time to time without notice. THIS DOCUMENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN NO EVENT SHALL NETSCAPE BE LIABLE FOR INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY KIND ARISING FROM ANY ERROR IN THIS DOCUMENT, INCLUDING WITHOUT LIMITATION ANY LOSS OR INTERRUPTION OF BUSINESS, PROFITS, USE OR DATA.
    [Show full text]
  • Quickly Documentation Release 0.1
    Quickly Documentation Release 0.1 Michael Spencer March 28, 2016 Contents 1 Offline Reading 3 1.1 Tutorial..................................................3 1.2 QMLify Transpiler............................................5 1.3 Core JS Modules.............................................5 1.4 Distributing your Module........................................8 2 Indices and tables 11 i ii Quickly Documentation, Release 0.1 Quickly is a build tool and QML module with provides an NodeJS-like ES6 environment for Javascript used in QML. The goal of the project is to allow you to write awesome modern ES6 Javascript taking advantage of classes, decorators, arrow functions, and best of all, many of the vast array of NPM packages available using the standard ES6 module imports. You can then take that code and use in directly from QML, just as you would with plain, old, QML-specific Javascript. You can even build a library using ES6 and NPM packages, and then distribute that as a standard QML module or QPM package for other developers to use in regular QML or QML-specific Javascript. For those who would prefer to stick with standard QML-specific Javascript, you can also do that and still use the Quickly library, which gives you promises, the fetch API, and many polyfills. This is great for longtime QML devel- opers or existing projects that just want to drop in some easy-to-use features from modern JS core libraries. Tutorial A quick guide to get you up and running with Quickly. QMLify Transpiler How to use qmlify, the Quickly transpiler. Core JS Modules How to use the core JS modules. Distributing your Module Distributing your awesome new module for other developers to use.
    [Show full text]
  • Casperjs Documentation Release 1.1.0-DEV Nicolas Perriault
    CasperJs Documentation Release 1.1.0-DEV Nicolas Perriault February 04, 2016 Contents 1 Installation 3 1.1 Prerequisites...............................................3 1.2 Installing from Homebrew (OSX)....................................3 1.3 Installing from npm...........................................4 1.4 Installing from git............................................4 1.5 Installing from an archive........................................4 1.6 CasperJS on Windows..........................................5 1.7 Known Bugs & Limitations.......................................5 2 Quickstart 7 2.1 A minimal scraping script........................................7 2.2 Now let’s scrape Google!........................................8 2.3 CoffeeScript version...........................................9 2.4 A minimal testing script......................................... 10 3 Using the command line 11 3.1 casperjs native options.......................................... 12 3.2 Raw parameter values.......................................... 13 4 Selectors 15 4.1 CSS3................................................... 15 4.2 XPath................................................... 16 5 Testing 17 5.1 Unit testing................................................ 17 5.2 Browser tests............................................... 18 5.3 Setting Casper options in the test environment............................. 19 5.4 Advanced techniques........................................... 20 5.5 Test command args and options....................................
    [Show full text]
  • Webassembly a New World of Native Exploits on the Web Agenda
    WebAssembly A New World Of Native Exploits On The Web Agenda • Introduction • The WebAssembly Platform • Emscripten • Possible Exploit Scenarios • Conclusion Wasm: What is it good for? ● Archive.org web emulators ● Image/processing ● Video Games ● 3D Modeling ● Cryptography Libraries ● Desktop Application Ports Wasm: Crazy Incoming ● Browsix, jslinux ● Runtime.js (Node), Nebulet ● Cervus ● eWASM Java Applet Joke Slide ● Sandboxed ● Virtual Machine, runs its own instruction set ● Runs in your browser ● Write once, run anywhere ● In the future, will be embedded in other targets What Is WebAssembly? ● A relatively small set of low-level instructions ○ Instructions are executed by browsers ● Native code can be compiled into WebAssembly ○ Allows web developers to take their native C/C++ code to the browser ■ Or Rust, or Go, or anything else that can compile to Wasm ○ Improved Performance Over JavaScript ● Already widely supported in the latest versions of all major browsers ○ Not limited to running in browsers, Wasm could be anywhere Wasm: A Stack Machine Text Format Example Linear Memory Model Subtitle Function Pointers Wasm in the Browser ● Wasm doesn’t have access to memory, DOM, etc. ● Wasm functions can be exported to be callable from JS ● JS functions can be imported into Wasm ● Wasm’s linear memory is a JS resizable ArrayBuffer ● Memory can be shared across instances of Wasm ● Tables are accessible via JS, or can be shared to other instances of Wasm Demo: Wasm in a nutshell Emscripten ● Emscripten is an SDK that compiles C/C++ into .wasm binaries ● LLVM/Clang derivative ● Includes built-in C libraries, etc. ● Also produces JS and HTML code to allow easy integration into a site.
    [Show full text]
  • Learning Javascript Design Patterns
    Learning JavaScript Design Patterns Addy Osmani Beijing • Cambridge • Farnham • Köln • Sebastopol • Tokyo Learning JavaScript Design Patterns by Addy Osmani Copyright © 2012 Addy Osmani. All rights reserved. Revision History for the : 2012-05-01 Early release revision 1 See http://oreilly.com/catalog/errata.csp?isbn=9781449331818 for release details. ISBN: 978-1-449-33181-8 1335906805 Table of Contents Preface ..................................................................... ix 1. Introduction ........................................................... 1 2. What is a Pattern? ...................................................... 3 We already use patterns everyday 4 3. 'Pattern'-ity Testing, Proto-Patterns & The Rule Of Three ...................... 7 4. The Structure Of A Design Pattern ......................................... 9 5. Writing Design Patterns ................................................. 11 6. Anti-Patterns ......................................................... 13 7. Categories Of Design Pattern ............................................ 15 Creational Design Patterns 15 Structural Design Patterns 16 Behavioral Design Patterns 16 8. Design Pattern Categorization ........................................... 17 A brief note on classes 17 9. JavaScript Design Patterns .............................................. 21 The Creational Pattern 22 The Constructor Pattern 23 Basic Constructors 23 Constructors With Prototypes 24 The Singleton Pattern 24 The Module Pattern 27 iii Modules 27 Object Literals 27 The Module Pattern
    [Show full text]