WASM Is the New CGI
WebAssembly (Wasm) is transforming web application development by enhancing performance, enabling efficient code execution, and addressing serverless cold start issues, despite limitations like lack of native threading and JIT compilation.
Read original articleWebAssembly (Wasm) is emerging as a transformative technology in web application development, akin to the role of the Common Gateway Interface (CGI) in the early web. While CGI allowed for the creation of interactive web applications, Wasm is set to enhance performance and ease of development for both client and server applications. The evolution of web application models has consistently aimed for high performance and maintainability, with Wasm representing the next significant shift. Unlike CGI, which involved executing scripts on demand, Wasm enables the compilation of various programming languages into a binary format that can run efficiently in both browsers and server environments. This capability allows for lightweight isolation of untrusted code, reducing the overhead associated with traditional virtual machines or containers. Wasm's architecture supports the creation of modules that can be paused and resumed, eliminating the cold start issues often faced in serverless computing. However, Wasm does have limitations, such as the lack of native threading and the inability to perform Just-In-Time (JIT) compilation, which can affect performance. Despite these challenges, the potential of Wasm to streamline web application development and execution is significant, positioning it as a key player in the future of web technologies.
- WebAssembly (Wasm) is poised to revolutionize web application development, similar to CGI's impact in the past.
- Wasm allows for high-performance applications by compiling various programming languages into a binary format.
- It provides lightweight isolation for untrusted code, reducing overhead compared to traditional VMs.
- Wasm modules can be paused and resumed, addressing cold start issues in serverless environments.
- Limitations include the lack of native threading and JIT compilation, which may affect performance.
Related
What Happens When You Put a Database in the Browser?
WebAssembly (Wasm) enhances browser capabilities, enabling high-performance apps like DuckDB for ad-hoc queries and Python environments. DuckDB Wasm boosts performance in interfaces like lakeFS, Evidence, and Count. MotherDuck enables local querying, emphasizing efficient data processing.
Dynamic Translation of Smalltalk to WebAssembly
The article explores Smalltalk code translation to WebAssembly (WASM) within the Catalyst project. It details levels of Smalltalk, JavaScript, and WASM, focusing on direct Smalltalk to WASM optimization. A new translator, WATCompiledMethodTranslator, aids in this process, exemplified by a Smalltalk expression conversion. Creation of a WASM module for Smalltalk methods is explained, highlighting performance advantages and potential future comparisons with dynamic JS translations. Collaboration in the Smalltalk community is encouraged for further advancement.
Compilation of JavaScript to WASM, Part 2: Ahead-of-Time vs. JIT
Chris Fallin's blog post discusses his AOT compiler for JavaScript to WebAssembly, achieving 3-5x performance improvements while addressing challenges like dynamic typing and Wasm platform constraints.
Compilation of JavaScript to WASM, Part 3: Partial Evaluation
The article concludes a series on compiling JavaScript to WebAssembly, discussing challenges, proposing a portable interpreter for debugging, and introducing the Futamura projection for program compilation and analysis.
Notes on running Go in the browser with WebAssembly
Eli Bendersky's article explores integrating Go with WebAssembly, showcasing examples of calling Go functions from JavaScript, using TinyGo for smaller binaries, and employing Web Workers to maintain UI responsiveness.
- Many commenters draw parallels between Wasm and older technologies like Java Applets and CGI, questioning the security and practicality of running untrusted code in browsers.
- There is skepticism about Wasm's advantages over JavaScript, with some arguing that it complicates deployment and debugging without significant performance benefits.
- Some users express concerns about Wasm's impact on mobile performance and battery life, highlighting issues with heavy websites.
- Several comments discuss the potential for Wasm to replace server-side functions, suggesting it could simplify deployment and improve performance in serverless architectures.
- Overall, there is a mix of optimism and skepticism about Wasm's future, with some believing it will become a standard while others doubt its necessity.
Google App Engine (2008) predates Lambda (2014) by 6 years!
This sounds.. not right. Honestly,this is an essential feature for allowing workloads like hot reloading code cleanly.
I'm quite convinced the alleged security argument is bull. You can hot reload JS (or even do wilder things like codegen) at runtime without compromising security. Additionally, you can emulate codegen or hot reload, by dynamically reloading the entire Wasm runtime and preserving the memory, but the user experience will be clunky.
I don't see any technical reason why this couldn't be possible. If this were a security measure, it could be trivially bypassed.
Also, WASM bytecode is very similar conceptually to .NET IL, Java bytecode etc., things designed for JIT compilation.
I kind of dislike WASM. It's a project lacking strong direction and will to succeed in a timely manner. First, the whole idea is conceptually unclear, its name suggests that it's supposed to be 'assembly for the web', a machine language for a virtual CPU, but it's actually an intermediate representation meant for compiler backends, with high-level features planned such as GC support. It's still missing basic features, like the aforementioned hot reload, non-hacking threading, native interfacing with the DOM (without Javascript ideally), low-overhed graphics/compute API support, low-level audio access etc. You can't run a big multimedia app without major compromises in it.
Since it is generally implemented as part of the javascript engine, it inherits a lot of stuff that comes with it like sandboxing and access to the APIs that come with it. Standardizing access to that is a bit of an ongoing process but the end state here is that anything that currently can only be done in Javascript will also be possible in WASM. And a lot more that is currently hard or impossible in Javascript. And it all might run a little faster/smoother.
That makes WASM many things. But the main thing it does is remove a lot of restrictions we've had on environments where Javascript is currently popular. Javascript is a bit of a divisive language. Some people love it, some people hate it. It goes from being the only game in town to being one of many things you can pick to do a thing.
It's been styled as a Javascript replacement, as a docker replacement, as a Java replacement, a CGI replacement (this article), etc. The short version of it is that it is all of these things. And more.
I'm unsure of the source for this Law, but it certainly proves correct more often than not.
If somewhat complex apps like Figma can run almost entirely within user's browser, then I think vast majority of the apps out there can. Server side mostly is there to sync data between different instances of the app if the user uses it from different locations.
The tooling for this is in the works, but is not yet mature. e.g Electric-SQL. Once these libraries are mature, I think this space will take off.
Serverless is mostly there to make money for Amazon and Azures of the world and will eventually go the way of the CGI.
WASM could succeed as well. But mostly in user's browser. Microsoft uses it today for C#/Blazor. But it isn't the correct approach as dotnet in browser will likely never be as fast as Javascript in the browser.
Because of the sandbox nature of WASM technically it could even run outside an operating system or in ring0 bypassing a lot of OS overhead.
Compiling to WASM makes a whole range of deployment problems a lot simpler for the user and gives a lot of room for the hosting environment to do optimizations (maybe even custom hardware to make WASM run faster).
Massive scaling with minimal resources is certainly one important enabler. If you were, e.g., to re-architect wikipedia with the knowledge and hardware of today how would you do it with wasm (on both desktop and mobile). How about a massive multiplayer game etc.
On the other hand you have the constraints and costs of current commercial / business model realities and legacy patterns that create a high bar for any innovation to flurish. But high does not mean infinitely high.
I hate to be the person mentioning AI on every HN thread but its a good example of the long stagnation and then torrential change that is the hallmark of how online connected computing adoption evolves: e.g., we could have had online numerically very intensive apps and API's a long time ago already (LLM's are not the only useful algorithm invented by humankind). But we didnt. It takes engineering a stampede to move the lazy (cash) cows to new grass land.
So it does feel that at some point starting with a fresh canvas might make sense (as in, substantially expand what is possible). When the cruft accumulates sometimes it collapses under its own weight.
I hate WASM heavy websites as often they have bloat of javascript and site is very slow, especially during scrolling, zooming due to abuse of event listeners and piss poor coding discipline.
I kinda miss sometimes server rendered index.php
Currently it is a huge PITA to have to update and redeploy your AWS Lambda apps whenever a Node.js or Python version is deprecated. Of course, usually the old code "just works" in the new runtime version, but I don't want to have to worry about it every few years. I think applications should work forever if you want them to, and WASM combined with serverless like Lambda will provide the right kind of platform for that.
>Just in Time (JIT) compilation is not possible as dynamic Wasm code generation is not allowed for security reasons.
I don't follow -- is the Wasm runtime VM forbidden from JITing? (How could such a prohibition even be specified?) Assuming this is the case, I'm surprised that this is considered a security threat, given that TTBOMK JVMs have done this for decades, I think mostly without security issues? (Happy to be corrected, but I haven't heard of any.)
> If we go back to thinking about our Application Server models; this allows us to have a fresh process but without paying the startup costs of a new process. Essentially giving us CGI without the downsides of CGI. Or in more recent terms, serverless without cold starts. This is how Wasm is the new CGI.
^ It's not a frivolous claim.
> Wasm improves performance, makes process level security much easier, and lowers the cost of building and executing serverless functions. It can run almost any language and with module linking and interface types it lowers the latency between functions incredibly.
^ Not unreasonable.
I don't agree that its necessarily totally 'game changing', but if you read this article and you get to the end and you dont agree with:
> When you change the constraints in a system you enable things that were impossible before.
Then I'm left scratching my head what it was you actually read, or what the heck you're talking about.
> Serverless is mostly there to make money for Amazon and Azures of the world and will eventually go the way of the CGI.
There's... just no possible future, in which AWS and Azure just go away and stop selling something which is making them money, when a new technology comes along and makes it easier, safer and cheaper to it.
> I kind of like this variety of headline for it's ability to stimulate discussion but it's also nonsense. CGI can be any type of code responding to an individual web request, represented as a set of parameters. It has basically nothing to do with wasm
*shakes head sadly...*
...well, time will tell, but for alllll the naysayers, WASM is here to stay and more and more people are using it for more and more things.
Good? Bad? Dunno. ...but it certainly isn't some pointless niche tech that no one cares about is about to disappear.
CGI enabled a lot of things. WASM does too. The comparison isn't totally outrageous. It'll be fun to see where it ends up. :)
It's amazing how just one sentence can be so utterly wrong.
WSGI actually predates rack by several years: first WSGI spec was published in 2003 [0], rack was split from Rails in 2007 [1].
Flask is not an "application server", it is one of the web frameworks that implements WSGI interface. Another popular framework that also implements it is Django. Flask is not the first WSGI implementation, so I'm not sure why author decided to mention Flask specifically. It's probably one of the most popular WSGI implementations but there is nothing special about it, it hasn't introduced any new concepts or a new paradigm or anything like that.
I'm not sure if the rest of the article is even worth reading if the author can't even get the basic facts right but for some reason feels the need to make up total nonsense in their place.
WASM is basically the new Microsoft Common Language Runtime, or the new JVM etc.
But OPEN!
I let chatgpt do the tedious work, have a look at a minimal example:
https://chatgpt.com/share/6707c2f3-5840-8008-96eb-e5002e2241...
Before WASM you could already compile code from other languages into JavaScript. And have the same benefits as you have with WASM.
The only benefit WASM brings is a bit faster execution time. Like twice the speed. Which most applications don't need. And which plain JavaScript offers about two years later because computers become faster.
And you pay dearly for being these two years ahead in terms of execution time. WASM is much more cumbersome to handle than plain JS when it comes to deployment, execution and debugging.
In IT we see it over and over again that saving developer time is more important than saving CPU cycles. So I think chosing WASM over plain JS is a net negative.
Related
What Happens When You Put a Database in the Browser?
WebAssembly (Wasm) enhances browser capabilities, enabling high-performance apps like DuckDB for ad-hoc queries and Python environments. DuckDB Wasm boosts performance in interfaces like lakeFS, Evidence, and Count. MotherDuck enables local querying, emphasizing efficient data processing.
Dynamic Translation of Smalltalk to WebAssembly
The article explores Smalltalk code translation to WebAssembly (WASM) within the Catalyst project. It details levels of Smalltalk, JavaScript, and WASM, focusing on direct Smalltalk to WASM optimization. A new translator, WATCompiledMethodTranslator, aids in this process, exemplified by a Smalltalk expression conversion. Creation of a WASM module for Smalltalk methods is explained, highlighting performance advantages and potential future comparisons with dynamic JS translations. Collaboration in the Smalltalk community is encouraged for further advancement.
Compilation of JavaScript to WASM, Part 2: Ahead-of-Time vs. JIT
Chris Fallin's blog post discusses his AOT compiler for JavaScript to WebAssembly, achieving 3-5x performance improvements while addressing challenges like dynamic typing and Wasm platform constraints.
Compilation of JavaScript to WASM, Part 3: Partial Evaluation
The article concludes a series on compiling JavaScript to WebAssembly, discussing challenges, proposing a portable interpreter for debugging, and introducing the Futamura projection for program compilation and analysis.
Notes on running Go in the browser with WebAssembly
Eli Bendersky's article explores integrating Go with WebAssembly, showcasing examples of calling Go functions from JavaScript, using TinyGo for smaller binaries, and employing Web Workers to maintain UI responsiveness.