2023年04月13日

Running Programming Languages Other Than JavaScript in the Browser Using WebAssembly

カテゴリー:システム開発, テクノロジー

タグ:サービス開発, システム開発, プログラミング

Knowledge_seci_model

WebAssembly is a dynamic programming execution environment that guarantees execution in the browser outside of JavaScript. WebAssembly is not a programming language but creates binaries that can be run in WebAssembly from languages such as Rust, C, and C++.

Several attempts have been made to WebAssemble programming language execution environments and run programming languages other than JavaScript in the browser.

In this article, we will look at which languages can be executed in the browser.

Ruby

Ruby has officially supported WebAssembly since version 3.2. You can run Ruby in the browser by simply loading the supplied JavaScript file.

You can even try it out on the TryRuby playground.

Python

Pyodide is a WebAssembly version of CPython. It has a console where you can actually execute code.

JupyterLite is a software based on Pyodide that allows you to run Jupyter Notebook, which is commonly used in Python, in a browser.

PHP

PHP is probably the most widely used programming language in the web industry. It has been WebAssembled using Emscript.

WordPress runs in the browser using PHP + SQLite. What’s unique is that it emulates the application server inside the browser.

Node.js

Why implement Node.js when there is already a JavaScript engine in the browser? Perhaps because there is a need for an environment that can run user-created macros. JavaScript can be safely executed through sandboxing.

QuickJS is a JavaScript execution environment that supports ES2020. You can even try it out on this page.

Julia

Julia is a programming language commonly used in fields such as computer science and numerical analysis. It is faster than Python in terms of execution speed.

It is a relatively new programming language that first appeared in 2012. You can try it out in this playground.

Perl

Perl is a programming language with a long history. It was common to write applications in Perl during the CGI era.

Today, PHP is more commonly used to write web applications, but Perl is still used for server-side processing. WebPerl is a WebAssembly-enabled version of Perl.

Swift

Swift is a programming language developed by Apple and positioned as a replacement language for Objective-C. It is a language used for iOS and macOS application development, but can also be used for server-side development.

SwiftWasm is a WebAssemblyified version of Swift’s execution engine, allowing it to be run.

Conclusion

Although there have been attempts to run different languages in the browser in the past, they required plugins (such as Flash, ActiveX, and Java applets) or were mostly done by writing execution engines in JavaScript. Both had problems with security, browser compatibility, and execution speed and did not become mainstream.

The current WebAssembly runs fast enough and can use the assets written in C, which is a big advantage. As support for peripheral libraries expands in the future, it may become natural to build Web applications using languages other than JavaScript.

役に立ったら、記事をシェアしてください