舉報

會員
Learn WebAssembly
Mike Rourke 著
更新時間:2021-08-13 15:39:50
開會員,本書免費(fèi)讀 >
WebAssemblyisabrand-newtechnologythatrepresentsaparadigmshiftinwebdevelopment.Thisbookteachesprogrammerstoleveragethistechnologytowritehigh-performanceapplicationsthatruninthebrowser.ThisbookintroducesyoutopowerfulWebAssemblyconceptstohelpyouwriteleanandpowerfulwebapplicationswithnativeperformance.Youstartwiththeevolutionofwebprogramming,thestateofthingstoday,andwhatcanbedonewiththeadventandreleaseofWebAssembly.WetakealookatthejourneyfromJavaScripttoasm.jstoWebAssembly.WethenmoveontoanalyzetheanatomyofaWebAssemblymoduleandtherelationshipbetweenbinaryandtextformats,alongwiththecorrespondingJavaScriptAPI.Furtheron,you'llimplementallthetechniquesyou'velearnedtobuildahigh-performanceapplicationusingCandWebAssembly,andthenportanexistinggamewritteninC++toWebAssemblyusingEmscripten.Bytheendofthisbook,youwillbewell-equippedtocreatehigh-performanceapplicationsandgamesforthewebusingWebAssembly.
最新章節(jié)
- Leave a review - let other readers know what you think
- Other Books You May Enjoy
- Further reading
- Questions
- Summary
- Reference types
品牌:中圖公司
上架時間:2021-08-13 15:14:42
出版社:Packt Publishing
本書數(shù)字版權(quán)由中圖公司提供,并由其授權(quán)上海閱文信息技術(shù)有限公司制作發(fā)行
- Leave a review - let other readers know what you think 更新時間:2021-08-13 15:39:50
- Other Books You May Enjoy
- Further reading
- Questions
- Summary
- Reference types
- Garbage collection
- Host bindings
- Threads
- The standardization process
- Upcoming features
- Debugging Web Workers
- Interacting with the application
- Compiling the C files
- Building and running the application
- The web assets
- Loading the application in index.js
- Interacting with Wasm in WasmWorker.js
- Defining thread execution in worker.js
- The JavaScript code
- The C code
- Overview of the code
- Limitations in Google Chrome
- The WebAssembly workflow
- Creating a worker
- Web Workers and WebAssembly
- Parallel Wasm with Web Workers
- WebAssembly Studio
- WebAssembly Explorer
- WasmFiddle
- Online tooling
- Compiling and running the example
- The HTML file
- The C++ file
- The example code
- The installation process
- Compiling with LLVM
- Binaryen
- WABT – the WebAssembly binary toolkit
- WABT and Binaryen
- Advanced Tools and Upcoming Features
- Further reading
- Questions
- Summary
- Running the tests
- Tests file review
- Testing configuration
- The code being tested
- Testing WebAssembly modules with Jest
- Running the start script
- Testing the build
- Building and running the application
- Component rendering
- Component mounting
- Wasm initialization
- Component state
- The import statements
- The JavaScript code
- The updateRectLocation() function
- The start() function
- Definitions and declarations
- The C code
- Configuring loaders and plugins in webpack.config.js
- Dependencies overview
- Installing and configuring Webpack
- What is Webpack?
- Overview of the project
- Client-side WebAssembly with Webpack
- Starting and testing out the application
- Building the application
- Building and running the application
- Transaction operations in assign-routes.js
- Wrapping interaction in Transaction.js
- Interacting with the WebAssembly module
- Creating a mock database
- Instantiating a Wasm module with Node.js
- Express configuration
- Overview of the project
- Server-side WebAssembly with Express
- Development with npm
- Complementary technologies
- Seamless integration
- Why Node.js?
- Integrating with Node.js
- Further reading
- Questions
- Summary
- Running the game
- Building with a Makefile
- Building with VS Code tasks
- Building and running the game
- Updating the constants file
- Porting the existing code
- Adding the web assets
- What's changing?
- Preparing for porting
- Porting to Emscripten
- The main file
- The loop() function
- The constructor and destructor
- The Game class
- The displayScore() function
- The unite() function
- The isCollision() function
- The constructor and draw() function
- The Board class
- The getColumn() and getRow() functions
- The move() rotate() and isBlock() functions
- The constructor and draw() function
- The piece class
- The constants file
- Breaking the code into objects
- The code base in depth
- The game in action
- Building the native project
- Getting the code
- A note about porting
- The source of the source
- What is Tetris?
- Overview of the game
- Porting a Game with Emscripten
- Further reading
- Questions
- Summary
- Wrap up
- Testing the Charts tab
- Editing an existing transaction
- Deleting an existing transaction
- Creating a new transaction
- Changing initial balances
- Testing it out
- Start it up!
- Validating the /src folder
- Running the application
- The ChartsTab
- The TransactionsTab
- The BalancesBar
- The App component
- The structure of a Vue component
- Creating the Vue components
- Adding the web assets
- Loading the application in main.js
- Store initialization
- Balances calculation
- TransactionModal management
- Transactions operations
- The import and store declarations
- Managing global state in store.js
- Utilizing the API in api.js
- Interacting with Wasm in WasmTransactions.js
- Creating a Wasm instance in initializeWasm.js
- A note about browser compatibility
- Overview
- Building the JavaScript portion
- Compiling to Wasm
- Category calculations
- transactions calculations
- transactions operations
- Linked list operations
- Declarations
- C file contents
- A note regarding workflow
- Overview
- Building the C portion
- The final result
- Downloading the C stdlib Wasm
- Setting up a mock API
- Configuring the build step
- Adding files and folders
- Configuring for Node.js
- Setting up the project
- C and the build process
- Other libraries
- Data-driven documents
- Lodash
- UIkit
- Vue
- JavaScript libraries used
- Overview and functionality
- Cook the Books – making WebAssembly accountable
- Creating an Application from Scratch
- Further reading
- Questions
- Summary
- Using source maps
- High-level overview
- Debugging in the browser
- Fetch API
- File System API
- Embind
- Advanced Emscripten features
- Compiling and serving the result
- The HTML code
- The C++ code
- An example without glue code
- Calling imported functions in C/C++
- Passing JavaScript to C/C++ using the import object
- Interacting with JavaScript without glue code
- Compiling and serving the result
- The HTML code
- The C code
- Examples of using glue code
- Reusing inline JavaScript with EM_JS()
- Executing inline JavaScript with EM_ASM()
- Executing strings with emscripten_run_script()
- Interacting with JavaScript using glue code
- Calling JavaScript functions from C/C++
- Calling functions from a WebAssembly instance
- C++ and name mangling
- Module.cwrap()
- Module.ccall()
- Calling functions from a Module
- Calling compiled C/C++ functions from JavaScript
- Differences with the WebAssembly object
- Default methods in the glue code
- What is the Emscripten module?
- The Emscripten module versus the WebAssembly object
- Interacting with JavaScript and Debugging
- Further reading
- Questions
- Summary
- Serving it all up
- The HTML page
- Common JavaScript loading code
- Fetching and instantiating a Wasm file
- Compiling with a Build Task in VS Code
- C code for WebAssembly
- Compiling C without the glue code
- Writing custom loading code
- Pre-generated loading code
- Loading the Emscripten module
- Outputting glue code with no HTML
- Outputting HTML with glue code
- Compiling the example C code
- Writing the example C code
- Compiling C with Emscripten glue code
- Creating and Loading a WebAssembly Module
- Further reading
- Questions
- Summary
- Compiling the C code
- The C code
- Testing the compiler
- Configuration in VS Code
- Installation and configuration on Windows
- Installation on macOS and Ubuntu
- Installation process across all platforms
- Installing and configuring the EMSDK
- Installing the prerequisites on Windows
- Installing the prerequisites on Ubuntu
- Installing the prerequisites on macOS
- Common prerequisites
- Installing the prerequisites
- Where does the EMSDK fit in?
- Emscripten overview
- Emscripten and the EMSDK
- Integrating Tooling into the workflow
- Steps in the workflow
- The development workflow
- Installing the Required Dependencies
- Further reading
- Questions
- Summary
- Zsh and Oh-My-Zsh
- cmder for Windows
- Terminator for Ubuntu
- iTerm2 for macOS
- Other tools
- Validating other browsers
- Validating Mozilla Firefox
- Validating Google Chrome
- Validating your browser
- Installing a local server
- Cloning the book examples repository
- Setting up for the web
- Material Icon theme and Atom One Light theme
- Bracket pair colorizer
- Auto rename tag
- Other useful extensions
- WebAssembly Toolkit for VSCode
- Configuring C/C++ for VS Code
- Installing C/C++ for VS Code
- Configuration for C/C++ and WebAssembly
- Extensions overview
- Managing settings and customization
- Configuring VS Code
- Installing VS Code on Windows
- Installing Visual Studio Code on Ubuntu
- Installing Visual Studio Code on macOS
- VS Code
- Installing rimraf
- Installing GNU make on Windows
- Installing GNU Make on Ubuntu
- Installing GNU Make on macOS
- GNU Make on macOS and Ubuntu
- GNU make and rimraf
- Installing Node.js using nvm
- Installing nvm on Windows
- Install nvm on Ubuntu
- Installing nvm on macOS
- nvm
- Node.js
- Installing Git on Windows
- Installing Git on Ubuntu
- Installing Git on macOS
- Git
- Chocolatey for Windows
- Apt for Ubuntu
- Homebrew for macOS
- Package managers
- Windows
- Ubuntu
- macOS
- Operating systems and hardware
- Installing the development tooling
- Setting Up a Development Environment
- Further reading
- Questions
- Summary
- Wasm to JavaScript
- C code to Wat
- What is WasmFiddle?
- Connecting the dots with WasmFiddle
- WebAssembly errors (CompileError LinkError RuntimeError)
- WebAssembly.Table
- WebAssembly.Memory
- WebAssembly.Instance
- WebAssembly.Module
- WebAssembly objects
- Loading a module and the WebAssembly namespace methods
- WebAssembly store and object caches
- The JavaScript and Web APIs
- Module sections
- Definition and module overview
- Binary format and the module file (Wasm)
- Role in the development process
- Values types and instructions
- Definitions and S-expressions
- Wat
- Common structure and abstract syntax
- Elements of WebAssembly - Wat Wasm and the JavaScript API
- Further reading
- Questions
- Summary
- The EMSDK and Binaryen
- Emscripten's role
- How does it relate to Emscripten?
- No support in older browsers
- No direct DOM access
- No garbage collection
- What are the limitations?
- Other languages
- Rust
- C and C++
- What languages are supported?
- Where can I use it?
- So will it replace JavaScript?
- The JavaScript and Web APIs
- Semantic phases
- Language concepts
- The core specification
- Portable target for compilation
- Binary instruction format
- Official definition
- What exactly is WebAssembly and where can I use it?
- WebAssembly is born
- Mozilla and asm.js
- Google and Native Client
- The evolution of JavaScript
- The road to WebAssembly
- What is WebAssembly?
- Reviews
- Get in touch
- Conventions used
- Download the color images
- Download the example code files
- To get the most out of this book
- What this book covers
- Who this book is for
- Preface
- Packt is searching for authors like you
- About the reviewers
- About the author
- Contributors
- PacktPub.com
- Why subscribe?
- PacktPub.com
- Dedication
- Learn WebAssembly
- Copyright and Credits
- Title Page
- 封面
- 封面
- Title Page
- Copyright and Credits
- Learn WebAssembly
- Dedication
- PacktPub.com
- Why subscribe?
- PacktPub.com
- Contributors
- About the author
- About the reviewers
- Packt is searching for authors like you
- Preface
- Who this book is for
- What this book covers
- To get the most out of this book
- Download the example code files
- Download the color images
- Conventions used
- Get in touch
- Reviews
- What is WebAssembly?
- The road to WebAssembly
- The evolution of JavaScript
- Google and Native Client
- Mozilla and asm.js
- WebAssembly is born
- What exactly is WebAssembly and where can I use it?
- Official definition
- Binary instruction format
- Portable target for compilation
- The core specification
- Language concepts
- Semantic phases
- The JavaScript and Web APIs
- So will it replace JavaScript?
- Where can I use it?
- What languages are supported?
- C and C++
- Rust
- Other languages
- What are the limitations?
- No garbage collection
- No direct DOM access
- No support in older browsers
- How does it relate to Emscripten?
- Emscripten's role
- The EMSDK and Binaryen
- Summary
- Questions
- Further reading
- Elements of WebAssembly - Wat Wasm and the JavaScript API
- Common structure and abstract syntax
- Wat
- Definitions and S-expressions
- Values types and instructions
- Role in the development process
- Binary format and the module file (Wasm)
- Definition and module overview
- Module sections
- The JavaScript and Web APIs
- WebAssembly store and object caches
- Loading a module and the WebAssembly namespace methods
- WebAssembly objects
- WebAssembly.Module
- WebAssembly.Instance
- WebAssembly.Memory
- WebAssembly.Table
- WebAssembly errors (CompileError LinkError RuntimeError)
- Connecting the dots with WasmFiddle
- What is WasmFiddle?
- C code to Wat
- Wasm to JavaScript
- Summary
- Questions
- Further reading
- Setting Up a Development Environment
- Installing the development tooling
- Operating systems and hardware
- macOS
- Ubuntu
- Windows
- Package managers
- Homebrew for macOS
- Apt for Ubuntu
- Chocolatey for Windows
- Git
- Installing Git on macOS
- Installing Git on Ubuntu
- Installing Git on Windows
- Node.js
- nvm
- Installing nvm on macOS
- Install nvm on Ubuntu
- Installing nvm on Windows
- Installing Node.js using nvm
- GNU make and rimraf
- GNU Make on macOS and Ubuntu
- Installing GNU Make on macOS
- Installing GNU Make on Ubuntu
- Installing GNU make on Windows
- Installing rimraf
- VS Code
- Installing Visual Studio Code on macOS
- Installing Visual Studio Code on Ubuntu
- Installing VS Code on Windows
- Configuring VS Code
- Managing settings and customization
- Extensions overview
- Configuration for C/C++ and WebAssembly
- Installing C/C++ for VS Code
- Configuring C/C++ for VS Code
- WebAssembly Toolkit for VSCode
- Other useful extensions
- Auto rename tag
- Bracket pair colorizer
- Material Icon theme and Atom One Light theme
- Setting up for the web
- Cloning the book examples repository
- Installing a local server
- Validating your browser
- Validating Google Chrome
- Validating Mozilla Firefox
- Validating other browsers
- Other tools
- iTerm2 for macOS
- Terminator for Ubuntu
- cmder for Windows
- Zsh and Oh-My-Zsh
- Summary
- Questions
- Further reading
- Installing the Required Dependencies
- The development workflow
- Steps in the workflow
- Integrating Tooling into the workflow
- Emscripten and the EMSDK
- Emscripten overview
- Where does the EMSDK fit in?
- Installing the prerequisites
- Common prerequisites
- Installing the prerequisites on macOS
- Installing the prerequisites on Ubuntu
- Installing the prerequisites on Windows
- Installing and configuring the EMSDK
- Installation process across all platforms
- Installation on macOS and Ubuntu
- Installation and configuration on Windows
- Configuration in VS Code
- Testing the compiler
- The C code
- Compiling the C code
- Summary
- Questions
- Further reading
- Creating and Loading a WebAssembly Module
- Compiling C with Emscripten glue code
- Writing the example C code
- Compiling the example C code
- Outputting HTML with glue code
- Outputting glue code with no HTML
- Loading the Emscripten module
- Pre-generated loading code
- Writing custom loading code
- Compiling C without the glue code
- C code for WebAssembly
- Compiling with a Build Task in VS Code
- Fetching and instantiating a Wasm file
- Common JavaScript loading code
- The HTML page
- Serving it all up
- Summary
- Questions
- Further reading
- Interacting with JavaScript and Debugging
- The Emscripten module versus the WebAssembly object
- What is the Emscripten module?
- Default methods in the glue code
- Differences with the WebAssembly object
- Calling compiled C/C++ functions from JavaScript
- Calling functions from a Module
- Module.ccall()
- Module.cwrap()
- C++ and name mangling
- Calling functions from a WebAssembly instance
- Calling JavaScript functions from C/C++
- Interacting with JavaScript using glue code
- Executing strings with emscripten_run_script()
- Executing inline JavaScript with EM_ASM()
- Reusing inline JavaScript with EM_JS()
- Examples of using glue code
- The C code
- The HTML code
- Compiling and serving the result
- Interacting with JavaScript without glue code
- Passing JavaScript to C/C++ using the import object
- Calling imported functions in C/C++
- An example without glue code
- The C++ code
- The HTML code
- Compiling and serving the result
- Advanced Emscripten features
- Embind
- File System API
- Fetch API
- Debugging in the browser
- High-level overview
- Using source maps
- Summary
- Questions
- Further reading
- Creating an Application from Scratch
- Cook the Books – making WebAssembly accountable
- Overview and functionality
- JavaScript libraries used
- Vue
- UIkit
- Lodash
- Data-driven documents
- Other libraries
- C and the build process
- Setting up the project
- Configuring for Node.js
- Adding files and folders
- Configuring the build step
- Setting up a mock API
- Downloading the C stdlib Wasm
- The final result
- Building the C portion
- Overview
- A note regarding workflow
- C file contents
- Declarations
- Linked list operations
- transactions operations
- transactions calculations
- Category calculations
- Compiling to Wasm
- Building the JavaScript portion
- Overview
- A note about browser compatibility
- Creating a Wasm instance in initializeWasm.js
- Interacting with Wasm in WasmTransactions.js
- Utilizing the API in api.js
- Managing global state in store.js
- The import and store declarations
- Transactions operations
- TransactionModal management
- Balances calculation
- Store initialization
- Loading the application in main.js
- Adding the web assets
- Creating the Vue components
- The structure of a Vue component
- The App component
- The BalancesBar
- The TransactionsTab
- The ChartsTab
- Running the application
- Validating the /src folder
- Start it up!
- Testing it out
- Changing initial balances
- Creating a new transaction
- Deleting an existing transaction
- Editing an existing transaction
- Testing the Charts tab
- Wrap up
- Summary
- Questions
- Further reading
- Porting a Game with Emscripten
- Overview of the game
- What is Tetris?
- The source of the source
- A note about porting
- Getting the code
- Building the native project
- The game in action
- The code base in depth
- Breaking the code into objects
- The constants file
- The piece class
- The constructor and draw() function
- The move() rotate() and isBlock() functions
- The getColumn() and getRow() functions
- The Board class
- The constructor and draw() function
- The isCollision() function
- The unite() function
- The displayScore() function
- The Game class
- The constructor and destructor
- The loop() function
- The main file
- Porting to Emscripten
- Preparing for porting
- What's changing?
- Adding the web assets
- Porting the existing code
- Updating the constants file
- Building and running the game
- Building with VS Code tasks
- Building with a Makefile
- Running the game
- Summary
- Questions
- Further reading
- Integrating with Node.js
- Why Node.js?
- Seamless integration
- Complementary technologies
- Development with npm
- Server-side WebAssembly with Express
- Overview of the project
- Express configuration
- Instantiating a Wasm module with Node.js
- Creating a mock database
- Interacting with the WebAssembly module
- Wrapping interaction in Transaction.js
- Transaction operations in assign-routes.js
- Building and running the application
- Building the application
- Starting and testing out the application
- Client-side WebAssembly with Webpack
- Overview of the project
- What is Webpack?
- Installing and configuring Webpack
- Dependencies overview
- Configuring loaders and plugins in webpack.config.js
- The C code
- Definitions and declarations
- The start() function
- The updateRectLocation() function
- The JavaScript code
- The import statements
- Component state
- Wasm initialization
- Component mounting
- Component rendering
- Building and running the application
- Testing the build
- Running the start script
- Testing WebAssembly modules with Jest
- The code being tested
- Testing configuration
- Tests file review
- Running the tests
- Summary
- Questions
- Further reading
- Advanced Tools and Upcoming Features
- WABT and Binaryen
- WABT – the WebAssembly binary toolkit
- Binaryen
- Compiling with LLVM
- The installation process
- The example code
- The C++ file
- The HTML file
- Compiling and running the example
- Online tooling
- WasmFiddle
- WebAssembly Explorer
- WebAssembly Studio
- Parallel Wasm with Web Workers
- Web Workers and WebAssembly
- Creating a worker
- The WebAssembly workflow
- Limitations in Google Chrome
- Overview of the code
- The C code
- The JavaScript code
- Defining thread execution in worker.js
- Interacting with Wasm in WasmWorker.js
- Loading the application in index.js
- The web assets
- Building and running the application
- Compiling the C files
- Interacting with the application
- Debugging Web Workers
- Upcoming features
- The standardization process
- Threads
- Host bindings
- Garbage collection
- Reference types
- Summary
- Questions
- Further reading
- Other Books You May Enjoy
- Leave a review - let other readers know what you think 更新時間:2021-08-13 15:39:50