• Skip to main content
  • Skip to after header navigation
  • Skip to site footer

Free-Mail

  • Events
  • Images
    • Instagram Goodness
  • Music
  • News
  • Software

Start developing for WebAssembly with our new guide

Start developing for WebAssembly with our new guide: Start developing for WebAssembly with our new guide sethkenlon Thu, 02/09/2023 – 03:00

Over the past few decades, the web browser has endured as the most popular cross-platform application. Looking at the browser from a different angle, it is one of the most popular platforms for application delivery. Think of all the websites you use that take the place of activities you used to do with software running on your desktop. You’re still using software, but you’re accessing it through a browser, and it’s running on somebody else’s Linux server. In the eternal effort to optimize the software we all use, the world of software development introduced WebAssembly back in 2019 as a way to run compiled code through a web browser. Application performance is better than ever, and the options for coding go far beyond the usual list of PHP, Python, and JavaScript.

Programming and development
Red Hat Developers Blog
Programming cheat sheets
Try for free: Red Hat Learning Subscription
eBook: An introduction to programming with Bash
Bash shell scripting cheat sheet
eBook: Modernizing Enterprise Java
An open source developer’s guide to building applications

A target and a language

One of the powerful but also most confusing things about WebAssembly is that the term “webassembly” refers to both a language and a target. WebAssembly is an assembly language, but not many people choose to write code directly in assembly. Even the assembly language is ultimately converted to a binary format, which is what a computer requires to run code. This binary format is also called WebAssembly. This is good, though, because it means that you can use your choice of languages to write something that’s ultimately delivered in WebAssembly, including C, C++, Rust, Javascript, and many others.

The gateway into WebAssembly is Emscripten, an LLVM compiler toolchain that produces WebAssembly from your code.

Install Emscripten

To install Emscripten on your Linux or macOS computer, use Git:

 $   git clone \ https://github.com/emscripten-core/emsdk.git

Change directory into the emsdk directory and run the install command:

 $   ./emsdk install latest $   ./emsdk activate latest

Everything in the Emscripten toolchain is installed within the emsdk directory and has no effect on the rest of your system. For this reason, before you use emsdk, you must source its environment:

 $   source ./emsdk_env.sh

If you plan on using emsdk often, you can also source its environment setup script in .bashrc.

To install Emscripten on Windows, you can run Linux in the WSL environment.

Visit the Emscripten website for more information on installation.

Hello world

Here’s a simple “hello world” application in written in C++.

 #include   using namespace std;  int main() {     cout << "Hello world";     return 0; }

Test it as a standard binary for your system first:

 $   g++ hello.cpp -o world $   ./world Hello world

Seeing that it works as expected, use emcc to build it as WebAssembly:

 $   emcc hello.cpp -o world.html

Finally, run it with emrun:

 $   emrun ./world.html

The emrun utility is a convenience command for local testing. When you host your application on a server, emrun isn't necessary.

Learning more about WebAssembly

Developing for WebAssembly can go in many different directions, depending on what you already know and what you're trying to build. If you know C or C++, then you can write your project using those. If you're learning Rust, then you can use Rust. Even Python code can use the Pyodide module to run as WebAssembly. You have lots of options, and there's no wrong way to start (there's even a COBOL-to-WebAssembly compiler). If you're keen to get started with WebAssembly, download our complimentary eBook.

Developing for WebAssembly can go in many different directions, depending on what you already know and what you're trying to build. Download our new guide to WebAssembly.

Programming at a browser, orange hands
Image by:

opensource.com

Programming

What to read next
A guide to WebAssembly

Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.
Register or Login to post a comment.

: Opensource.com sethkenlon

Supporting Open Source.

Have you tried: Visiting Port Elizabeth?

Share this:

  • Share on Facebook (Opens in new window) Facebook
  • Share on X (Opens in new window) X
  • Share on Pinterest (Opens in new window) Pinterest
  • Email a link to a friend (Opens in new window) Email
  • More
  • Share on Tumblr (Opens in new window) Tumblr
  • Print (Opens in new window) Print
  • Share on LinkedIn (Opens in new window) LinkedIn
  • Share on Reddit (Opens in new window) Reddit
Published on 9 February 2023 by Alan Category: SoftwareTag: Developing, Guide, Start, WebAssembly

Prosecco-flavoured Pringles: did festive snack break EU law?

Prosecco-flavoured Pringles: did festive snack break EU law?: Kellogg Prosecco and pink peppercorn: …

Read moreProsecco-flavoured Pringles: did festive snack break EU law?

Monegros Desert Festival Tardienta

Monegros Desert Festival Tardienta – a Culture interest event taking place on 2021-07-31 …

Read moreMonegros Desert Festival Tardienta

Cape Town, South Africa

Check out this Cape Town image: Cape Town, South Africa Image by flowcomm Image automatically …

Read moreCape Town, South Africa

About Alan

Previous Post:Seven ways to protect your health when cooking with gas
Next Post:En Tunisie, le populisme à l’épreuve du pouvoir

Reach Trust

Reach Trust is a holding trust for a number of companies within the Stratlec Group.

Copyright © 2026 · Free-Mail · All Rights Reserved · Powered by Straton Electrical

Back to top