Why WebAssembly and Deno are so cool
WebAssembly is made for intensive computing. Thus, you can put computationally intensive logic in a WebAssembly binary, but use Deno to do things such as manage workflow, do data access or accommodate request/response traffic. Also, a language such as Rust, which we'll use to create the WebAssembly in this scenario, supports multi-threading. This means you can work with threads, which is not something easily done in Deno. And, your threads will execute in native code. It's a big advantage.
Using Deno to invoke logic represented in a WebAssembly binary created in Rust provides the best of all worlds.
What you will be doing
This scenario already ships with Deno installed. Thus, you will:
- Install the Rust programming environment
- Install Rust's WebAssembly compiler
- Create a WebAssembly binary using existing source code
- Execute a small program in Deno that uses the WebAssembly binary you created.
Executing command line instructions
This scenario is completely interactive. The instructions you'll be given will be executed directly in the terminal window that is embedded directly in the Katacoda interactive learning environment. In the steps to come, when you see a command line instruction with a black background and check mark at the end, like so:
just click on it and the command will execute in the interative terminal window.
START SCENARIO button to continue.
Creating a Rust WebAssembly running under Deno
The objective of lesson is to demonstrate how to install the Rust programming language on a Ubuntu virtual machine.
A version of Visual Studio Code is embedded in this Katacoda interactive learning environment. Just click the
IDE tab at the top of the terminal pane to the right.
Step 1: Wait for the Deno programming environment to be installed. You'll know that the enviornment is ready when you see a command prompt, like so,
Step 2: Run the following
curl command to install Rust.
IMPORTANT: During the Rust installation process you will be asked to select an option. Select option
curl https://sh.rustup.rs -sSf | sh
When you see the prompt to select an option like so...
Current installation options: default host triple: x86_64-unknown-linux-gnu default toolchain: stable profile: default modify PATH variable: yes 1) Proceed with installation (default) 2) Customize installation 3) Cancel installation
.. strike the
You should see output similar to the following:
Rust is installed now. Great!
Step 3: Set the environment variables required by Rust
Intalling the WebAssembly compiler for Rust.