« BackWASM Is the New CGIroborooter.comSubmitted by burglins 11 hours ago
  • layer8 7 minutes ago

    To expand the premise in the title, to be a true heir to that lineage, I would say that WASM needs to be as easy to host as PHP applications are (or used to be) on the LAMP stack of any random hosting provider. I suspect that’s not quite the case yet?

    • tantalor an hour ago

      > Amazon started the serverless age of compute with Lambda

      Google App Engine (2008) predates Lambda (2014) by 6 years!

      • junto 9 hours ago

        Can someone explain to me what the difference really is between WASM and older tech like Java Applets, ActiveX, Silverlight and Macromedia Flash, because they don’t really sound much different to me. Maybe I’m just old, but I thought we’d learnt our lesson on running untrusted third party compiled code in a web browser. In all of these cases it’s pitched as improving the customer experience but also conveniently pushes the computational cost from server to client.

        • vbezhenar 9 hours ago

          Java and Flash failed to deliver its promise of unbreakable sandbox where one could run anything without risking compromising host. They tried, but their implementations were ridden with vulnerabilities and eventually browsers made them unusable. Other mentioned technologies didn't even promise that, I think.

          JavaScript did deliver its promise of unbreakable sandbox and nowadays browser runs JavaScript, downloaded from any domain without asking user whether he trusts it or not.

          WASM builds on JavaScript engine, delivering similar security guarantees.

          So there's no fundamental difference between WASM and JVM bytecode. There's only practical difference: WASM proved to be secure and JVM did not.

          So now Google Chrome is secure enough for billions of people to safely run evil WASM without compromising their phones, and you can copy this engine from Google Chrome to server and use this strong sandbox to run scripts from various users, which could share resources.

          An alternative is to use virtualization. So you can either compile your code to WASM blob and run it in the big WASM server, or you can compile your code to amd64 binary, put it along stripped Linux kernel and run this thing in the VM. There's no clear winner here, I think, for now, there are pros and cons for every approach.

          • jasode 2 hours ago

            >So there's no fundamental difference between WASM and JVM bytecode. There's only practical difference: WASM proved to be secure and JVM did not.

            There's more to it than just the sandbox security model. The JVM bytecode doesn't have pointers which has significant performance ramifications for any language with native pointers. This limitation was one of the reasons why the JVM was never a serious compilation target platform for low-level languages like C/C++.

            E.g. Adobe compiled their Photoshop C++ code to WASM but not to the JVM to run in a Java JRE nor the Java web applet. Sure, one can twist a Java byte array to act as a flat address space and then "emulate" pointers to C/C++ but this extra layer of indirection which reduces performance wasn't something software companies with C/C++ codebases were interested in. Even though the JVM was advertised as "WORA Write-Once-Run-Anywhere", commercial software companies never deployed their C/C++ apps to the JVM.

            In contrast, the motivation for asm.js (predecessor to WASM) was to act as a reasonable and realistic compilation target for C/C++. (https://blog.mozilla.org/luke/2013/03/21/asm-js-in-firefox-n....)

            So the WASM-vs-JVM story can't be simplified to "just security" or "just politics". There were actual different technical choices made in the WASM bytecode architecture to enable lower-level languages like C/C++. That's not to say the Sun Java team's technical choices for the JVM bytecode were "wrong"; they just used different assumptions for a different world.

            • adamc an hour ago

              Also, the start-up time for the JVM made running applets very sluggish. Java quickly became a synonym for "slow".

              • tromp a minute ago

                Lack of 64-bit ints didn't help either...

            • norswap an hour ago

              > WASM proved to be secure and JVM did not.

              This is an oversimplification — there's nothing about the JVM bytecode architecture making it insecure. In fact, it is quite simpler as an architecture than WASM.

              Applets were just too early (you have to remember what the state of tech looked like back then), and the implementation was of poor quality to boot (owing in part to some technical limitations — but not only).

              But worst of all, it just felt jank. It wasn't really part of the page, just a little box in it, that had no connection to HTML, the address bar & page history, or really anything else.

              The Javascript model rightfully proved superior, but there was no way Sun could have achieved it short of building their own browser with native JVM integration.

              Today that looks easy, just fork Chromium. But back then the landscape was Internet Explorer 6 vs the very marginal Mozilla (and later Mozilla Firefox) and proprietary Opera that occasionally proved incompatible with major websites.

              • skybrian 15 minutes ago

                Yes it’s true that there’s more to the story, but also, Java really is more complicated and harder to secure than WASM. You need to look at the entire attack surface and not just the bytecode.

                For example, Java was the first mainstream language with built-in threading and that resulted in a pile of conconcurrency bugs. Porting Java to a new platform was not easy because it often required fixing threading bugs in the OS. By contrast, JavaScript and WASM (in the first version) are single-threaded. For JavaScript it was because it was written in a week, but for WASM, they knew from experience to put off threading to keep things simple.

                Java also had a security manager that few people understand and sensitive native methods that relied on stack-walking to make sure they weren’t called in the wrong place. The API at the security boundary was not well-designed.

                A lot of this is from being first at a lot of things and being wildly ambitious without sufficent review, and then having questionable decisions locked in by backward compatibility concerns.

              • DanielHB 7 hours ago

                > WASM proved to be secure and JVM did not.

                It is interesting to ask why that is the case, from my point of view the reason is that the JVM standard library is just too damn large. While WASM goes on a lower-level approach of just not having one.

                To make WASM have the capabilities required the host (the agent running the WASM code) needs to provide them. For a lot of languages that means using WASI, moving most of the security concerns to the WASI implementation used.

                But if you really want to create a secure environment you can just... not implement all of WASI. So a lambda function host environment can, for example, just not implement any filesystem WASI calls because a lambda has no business implementing filesystem stuff.

                > An alternative is to use virtualization. So you can either compile your code to WASM blob and run it in the big WASM server, or you can compile your code to amd64 binary, put it along stripped Linux kernel and run this thing in the VM.

                I think the first approach gives a lot more room for the host to create optimizations, to the point we could see hardware with custom instructions to make WASM faster. Or custom WASM runtimes heavily tied to the hardware they run on to make better JIT code.

                I imagine a future where WASM is treated like LLVM IR

                • kaba0 4 hours ago

                  > I think the first approach gives a lot more room for the host to create optimizations, to the point we could see hardware with custom instructions to make WASM faster

                  Heh, there were literally CPUs with some support for the JVM! But it turns out that “translating” between different forms is not that expensive (and can be done ahead of time and cached), given that CPUs already use a higher level abstraction of x86/arm to “communicate with us”, while they do something else in the form of microcode. So it didn’t really pay off, and I would wager it wouldn’t pay off with WASM either.

                • perching_aix 4 hours ago

                  > JavaScript did deliver its promise of unbreakable sandbox

                  Aren't its VM implementations routinely exploited? Ranging from "mere" security feature exploits, such as popunders, all the way to full on proper VM escapes?

                  Like even in current day, JS is ran interpreted on a number of platforms, because JIT compiling is not trustworthy enough. And I'm pretty sure the interpreters are no immune either.

                  • esrauch 3 hours ago

                    I think "routinely" is overstating it, billions people are running arbitrary JS on a daily basis and no meaningful number of them are being infected by malware.

                    Browser surface attracts the most intense security researcher scrutiny so they do find really wild chains of like 5 exploits that could possibly zero day, but it more reflects just how much scrutiny it has for hardening, realistically anything else will be more exploitable than that, eg your Chromecast playing arbitrarily video streams must he more exploitable than JS on a fully patched Chrome.

                    • mmis1000 2 hours ago

                      Both chrome and firefox lock down the javascript that site is running into their own box. By using a standalone process and whatever mechanism system provided. A pwned site alone isn't enough to cause damage. You also need to overcome other layer of defenses (unlike something like flash that can be owned from it's script engine alone)

                      It usually require multi 0 day to overcome all those defense and do anything useful. (And it is also the highest glory in defcon)

                      The browser is surely frequently attacked due to the high rewards. But it also get patched really fast. (As long as you are not using a browser from 10 years ago).

                      • tightbookkeeper an hour ago

                        Flash/applets could have been isolated in a process too, right?

                      • mdhb 4 hours ago

                        There were a bunch of things missing from OPs description around the security considerations of Wasm but it has a lot of other stuff on top of what the browser provides when it’s executing JavaScript.

                        The primary one is its idea of a “capability model” where it basically can’t do any kinds of risky actions (I.e touch the outside world via the network or the file system for example) unless you give it explicit permissions to do so.

                        Beyond that it has things like memory isolation etc so even an exploit in one module can’t impact another and each module has its own operating environment and permission scope associated with it.

                        • emporas 3 hours ago

                          I was surprised when google has agreed to implement the capabilities model for Chrome. I would guess that asking the user for permission to access the microphone would not sit well with google. In smartphones they own the OS so they can ignore wasm's security model as much as they like.

                          • mdhb 3 hours ago

                            I feel there’s a bit of a disconnect here between Google’s Ads division who are looking to basically do the bare minimum to avoid getting repeatedly spanked primarily by the EU but also now with talk of a breakup in the US and most other parts of Google who I say this entirely unironically are by far the best of all major options with regards to security in both the browser and their public cloud offerings. I’d even extend that possibly to operating systems as well. ChromeOS is miles in front of anything else out there currently but on mobile Android has historically lagged behind iOS although that gap is close to indistinguishable in 2024.

                            • themoonisachees 2 hours ago

                              It is not my intention to be contrarian, but honestly this might be the most incorrect comment I've ever read on hacker news, in several different ways. Sure, some of these might be subjective, but for example chromeOS is Linux with a shiny coat in top, how could it be any better than, well, Linux, let alone miles ahead?

                      • silvestrov 7 hours ago

                        Most of all the problem with Java Applets was that they were very slow to load and required so many resources that the computer came to a halt.

                        They also took much longer to develop than whatever you could cook up in plain html and javascript.

                        • gnz11 4 hours ago

                          Too be fair, they were slow to load if you didn’t have the browser extension and correct JRE installed.

                          • kaba0 4 hours ago

                            Funnily enough, wasm also has the problem of “slow to load”. In that vein, a higher level bytecode would probably result in smaller files to transport. And before someone adds, the JVM also supports loading stuff in a streaming way - one just has to write a streaming class loader, and then the app can start immediately and later on load additional classes.

                          • BobbyTables2 2 hours ago

                            JavaScript is all fun and games until a type confusion bug in V8 allows arbitrary code execution from a simple piece of JavaScript code…

                          • foobarian 2 hours ago

                            > There's only practical difference: WASM proved to be secure and JVM did not.

                            The practical reasons have more to do with how the JVM was embedded in browsers than the actual technology itself (though Flash was worse in this regard). They were linked at binary level and had same privileges as the containing process. With the JS VM the browser has a lot more control over I/O since the integration evolved this way from the start.

                            • kaba0 5 hours ago

                              I would add that most of it was politics.

                              The JVM is not fundamentally insecure the same say as neither is any Turing-complete abstraction like an x86 emulator or so. It’s always the attached APIs that open up new attack surfaces. Since the JVM at the time was used to bring absolutely unimaginable features to the otherwise anemic web, it had to be unsafe to be useful.

                              Since then, the web improved a huge amount, like a complete online FPS game can literally be programmed in just JS almost a decade ago. If a new VM can just interact with this newfound JS ecosystem and rely on these to be the boundaries it can of couse be made much safer. But it’s not inherently due to this other VM.

                            • pdpi 9 hours ago

                              Unlike ActiveX, Silverlight, or Flash, it's an open standard developed by a whole bunch of industry players, and it has multiple different implementations (where Java sits on that spectrum is perhaps a bit fuzzier). That alone puts it heads and shoulders above any of the alternatives.

                              Unlike the JVM, WASM offers linear memory, and no GC by default, which makes it a much better compilation target for a broader range of languages (most common being C and C++ through Emscripten, and Rust).

                              > Maybe I’m just old, but I thought we’d learnt our lesson on running untrusted third party compiled code in a web browser.

                              WASM is bytecode, and I think most implementations share a lot of their runtime with the host JavaScript engine.

                              > In all of these cases it’s pitched as improving the customer experience but also conveniently pushes the computational cost from server to client.

                              The whole industry has swung from fat clients to thin clients and back since time immemorial. The pendulum will keep swinging after this too.

                              • DougMerritt 8 hours ago

                                > The whole industry has swung from fat clients to thin clients and back since time immemorial. The pendulum will keep swinging after this too.

                                Indeed, graphics pioneer and all-around-genius Ivan Sutherland observed (and named) this back in 1968:

                                "wheel of reincarnation "[coined in a paper by T.H. Myer and I.E. Sutherland On the Design of Display Processors, Comm. ACM, Vol. 11, no. 6, June 1968)] Term used to refer to a well-known effect whereby function in a computing system family is migrated out to special-purpose peripheral hardware for speed, then the peripheral evolves toward more computing power as it does its job, then somebody notices that it is inefficient to support two asymmetrical processors in the architecture and folds the function back into the main CPU, at which point the cycle begins again.

                                "Several iterations of this cycle have been observed in graphics-processor design, and at least one or two in communications and floating-point processors. Also known as the Wheel of Life, the Wheel of Samsara, and other variations of the basic Hindu/Buddhist theological idea. See also blitter."

                                https://www.catb.org/jargon/html/W/wheel-of-reincarnation.ht...

                                • justanotherjoe 6 hours ago

                                  That was why i stopped using the word 'tech' to refer to these things. You don't suddenly go back to stop using the wheel after a time, or suddenly think that printing press was a bad idea after all. Those are techs. Many of the things we call techs nowadays are just paradigms. And frameworks are defnitely not 'new technology'.

                                  • artikae 5 hours ago

                                    All it takes for something to be replaced is something that does the job better. You can only really apply your definition in hindsight, after something has stood the test of time. You can't tell the difference between sails and wheels until after the rise of the steam engine.

                                    • wolvesechoes 6 hours ago

                                      > Many of the things we call techs nowadays are just paradigms

                                      More like fads sold to milk even more money from people.

                                    • anthk an hour ago
                                    • pjmlp 5 hours ago

                                      WasmGC is there no matter what, unless we are talking about an incomplete implementation, also plenty of linear memory based bytecodes since 1958.

                                      • pdpi 3 hours ago

                                        WasmGC is a feature you can opt in to, rather than a core feature of the platform. It's more of an enabler for languages that expect a GC from their host platform (for things like Dart and Kotlin). Inversely, other forms of bytecode might have linear memory, but the JVM isn't one of those.

                                        For the purposes of OP's question, the memory model difference is one of the key reasons why you might want to use wasm instead of a java applet.

                                        • pjmlp 2 hours ago

                                          JVM is one bytecode among many since 1958, no need to keep bashing against it as way to champion WASM.

                                          Opt-in or not, it is there on the runtime.

                                          • swsieber an hour ago

                                            It seems relevant since we are in a thread asking to compare WASM to java applets.

                                    • BiteCode_dev 18 minutes ago

                                      WASM is a child of the browser community and built on top of existing infra.

                                      Java was an outsider trying to get in.

                                      The difference is not in the nature of things, but rather who championed it.

                                      • Laremere 9 hours ago

                                        Wasm has a great benefits over those technologies:

                                        - Wasm has verification specification that wasm bytecode must comply to. This verified subset makes security exploits seen in those older technologies outright impossible. Attacks based around misbehaving hardware like heartbleed or rowhammer might still be possible, but you, eg, can't reference memory outside of your wasm's memory by tricking the VM to interpret a number you have as a pointer to memory that doesn't belong to you.

                                        - Wasm bytecode is trivial (as it gets) to turn into machine code. So implementations can be smaller and faster than using a VM.

                                        - Wasm isn't owned by a specific company, and has an open and well written specification anyone can use.

                                        - It has been adopted as a web standard, so no browser extensions are required.

                                        As for computation on clients versus serves, that's already true for Javascript. More true in fact, since wasm code can be efficient in ways that are impossible for Javascript.

                                        • kgeist 7 hours ago

                                          Btw, is WASM really more secure? JVM and .NET basically have capability-based security thanks to their OOP design together with bytecode verification: if you can't take a reference to an object (say, there's a factory method with a check), you can't access that object in any way (a reference is like an access token).

                                          As far as I understand, in WASM memory is a linear blob, so if I compile C++ to WASM, isn't it possible to reference a random segment of memory (say, via an unchecked array index exploit) and then do whatever you want with it (exploit other bugs in the original C++ app). The only benefit is that access to the OS is isolated, but all the other exploits are still possible (and impossible in JVM/.NET).

                                          Am I missing something?

                                          • igrunert 26 minutes ago

                                            When discussing security it's important to keep in mind the threat model.

                                            We're mostly concerned with being able to visit a malicious site, and execute wasm from that site without that wasm being able to execute arbitrary code on the host - breaking out of the sandbox in order to execute malware. You say the only benefit is that access to the OS is isolated, but that's the big benefit.

                                            Having said that, WebAssembly has some design decisions that make your exploits significantly more difficult in practice. The call stack is a separate stack from WebAssembly memory that's effectively invisible to the running WebAssembly program, so return oriented programming exploits should be impossible. Also WebAssembly executable bytecode is separate from WebAssembly memory, making it impossible to inject bytecode via a buffer overflow + execute it.

                                            If you want to generate WebAssembly code at runtime, link it in as a new function, and execute it, you need participation from the host, e.g. https://wingolog.org/archives/2022/08/18/just-in-time-code-g...

                                            • adrian17 3 hours ago

                                              AFAIK you’re correct.

                                              Also see: https://www.usenix.org/conference/usenixsecurity20/presentat...

                                              „We find that many classic vulnerabilities which, due to common mitigations, are no longer exploitable in native binaries, are completely exposed in WebAssembly. Moreover, WebAssembly enables unique attacks, such as overwriting supposedly constant data or manipulating the heap using a stack overflow.”

                                              My understanding is that people talking about wasm being more secure mostly talk about the ability to escape the sandbox or access unintended APIs, not integrity of the app itself.

                                              • lifthrasiir 6 hours ago

                                                For now, (typical) WASM is indeed more secure than (typical) JVM or .NET bytecodes primarily because external operations with WASM are not yet popular. WASM in this regard has the benefit of decades' worth of hindsight that it can carve its own safe API for interoperation, but otherwise not technically superior or inferior. Given that the current web browser somehow continues to ship and keep such APIs, I think the future WASM with such APIs is also likely to remain safer, but that's by no means guaranteed.

                                              • kgeist 7 hours ago

                                                >Wasm has verification specification. This verified subset makes security exploits seen in those older technologies outright impossible

                                                Both Java and .NET verify their bytecode.

                                                >Wasm bytecode is trivial (as it gets) to turn into machine code

                                                JVM and .NET bytecodes aren't supercomplicated either.

                                                Probably the only real differences are: 1) WASM was designed to be more modular and slimmer from the start, while Java and .NET were designed to be fat; currently there are modularization efforts, but it's too late 2) WASM is an open standard from the start and so browser vendors implement it without plugins

                                                Other than that, it feels like WASM is a reinvention of what already existed before.

                                                • flohofwoe 7 hours ago

                                                  AFAIK the big new thing in WASM is that it enforces 'structured control flow' - so it's a bit more like a high level AST than an assembly-style virtual ISA. Not sure how much of that matters in practice, but AFAIK that was the one important feature that enabled the proper validation of WASM bytecode.

                                                  • iainmerrick 7 hours ago

                                                    I don't think there's any significant advance in the bytecode beyond e.g. JVM bytecode.

                                                    The difference is in the surface area of the standard library -- Java applets exposed a lot of stuff that turned out to have a lot of security holes, and it was basically impossible to guarantee there weren't further holes. In WASM, the linear memory and very simple OS interface makes the sandboxing much more tractable.

                                                    • titzer 5 hours ago

                                                      I worked on JVM bytecode for a significant number of years before working on Wasm. JVM bytecode verification is non-trivial, not only to specify, but to implement efficiently. In Java 6 the class file format introduced stack maps to tame a worst-case O(n^3) bytecode verification overhead, which had become a DoS attack vector. Structured control flow makes Wasm validation effectively linear and vastly simpler to understand and vet. Wasm cleaned up a number of JVM bytecode issues, such as massive redundancy between class files (duplicate constant pool entries), length limitations (Wasm uses LEBs everywhere), typing of locals, more arithmetic instructions, with signedness and floating point that closer matches hardware, addition of SIMD, explicit tail calls, and now first-class functions and a lower-level object model.

                                                      • kaba0 4 hours ago

                                                        Are they validating code to the same degree though? Like, there are obviously learned lessons in how WASM is designed, but at the same time JVM byte code being at a slightly higher level of abstraction can outright make certain incorrect code impossible to express, so it may not be apples to oranges.

                                                        What I’m thinking of is simply memory corruption issues from the linear memory model, and while these can only corrupt the given process, not anything outside, it is still not something the JVM allows.

                                                        • titzer a minute ago

                                                          Wasm bytecode verification is more strict than JVM bytecode verification. For example, JVM locals don't have declared types, they are inferred by the abstract interpretation algorithm (one of the reasons for the afore-mentioned O(n^3) worst case). In Wasm bytecode, all locals have declared types.

                                                          Wasm GC also introduces non-null reference types, and the validation algorithm guarantees that locals of declared non-null type cannot be used before being initialized. That's also done as part of the single-pass verification.

                                                          Wasm GC has a lower-level object model and type system than the JVM (basically structs, arrays, and first-class functions, to which object models are lowered), so it's possible that a higher-level type system, when lowered to Wasm GC, may not be enforceable at the bytecode level. So you could, e.g. screw up the virtual dispatch sequence of a Java method call and end up with a Wasm runtime type error.

                                              • dspillett an hour ago

                                                > Can someone explain to me what the difference really is between WASM and older tech like Java Applets, ActiveX, Silverlight and Macromedia Flash

                                                As well as the security model differences other are debating, and WASM being an open standard that is easy to implement and under no control from a commercial entity, there is a significant difference in scope.

                                                WebAssemply is just the runtime that executes byte-code compiled code efficiently. That's it. No large standard run-time (compile in everything you need), no UI manipulation (message passing to JS is how you affect the DOM, and how you ready DOM status back), etc. It odes one thing (crunch numbers, essentially) and does it well.

                                                • tptacek 9 hours ago

                                                  Java Applets and ActiveX had less-mediated (Applets, somewhat; ActiveX, not at all) access to the underlying OS. The "outer platform" of WASM is approximately the Javascript runtime; the "outer platform" of Applets is execve(2).

                                                  • afavour an hour ago

                                                    The big conceptual difference is that Flash, ActiveX etc allowed code to reach outside of the browser sandbox. WASM remains _inside_ the browser sandbox.

                                                    Also no corporate overlord control.

                                                    • mike_hearn 3 hours ago

                                                      Conceptually, they aren't that different. The details do matter though.

                                                      WASM on its own isn't anything special security-wise. You could modify Java to be as secure or actually more secure just by stripping out features, as the JVM is blocking some kinds of 'internal' security attacks that WASM only has mitigations for. There have been many sandbox escapes for WASM and will be more, for example this very trivial sandbox escape in Chrome:

                                                      https://microsoftedge.github.io/edgevr/posts/Escaping-the-sa...

                                                      ... is somewhat reminiscent of sandbox escapes that were seen in Java and Flash.

                                                      But! There are some differences:

                                                      1. WASM / JS are minimalist and features get added slowly, only after the browser makers have done a lot of effort on sandboxing. The old assumption that operating system code was secure is mostly no longer held whereas in the Flash/applets/pre-Chrome era, it was. Stuff like the Speech XML exploit is fairly rare, whereas for other attempts they added a lot of features very fast and so there was more surface area for attacks.

                                                      2. There is the outer kernel sandbox if the inner sandbox fails. Java/Flash didn't have this option because Windows 9x didn't support kernel sandboxing, even Win2K/XP barely supported it.

                                                      3. WASM / JS doesn't assume any kind of code signing, it's pure sandbox all the way.

                                                      • tsimionescu 9 hours ago

                                                        Pushing compute to the client is the whole point, and is often a major improvement for the end user, especially in the era in which phones are faster than the supercomputers of the 90s.

                                                        And otherwise, WASM is different in two ways.

                                                        For one, browsers have gotten pretty good at running untrusted 3rd party code safely, which Flash or the JVM or IE or.NET were never even slightly adequate for.

                                                        The other difference is that WASM is designed to allow you to take a program in any language and run it in the user's browser. The techs you mention were all available for a single language, so if you already had a program in, say, Python, you'd have to re-write it in Java or C#, or maybe Scala or F#, to run it as an applet or Silverlight program.

                                                        • pjmlp 3 hours ago

                                                          CLR means Common Language Runtime for a reason.

                                                          From 2001,

                                                          "More than 20 programming tools vendors offer some 26 programming languages — including C++, Perl, Python, Java, COBOL, RPG and Haskell — on .NET."

                                                          https://news.microsoft.com/2001/10/22/massive-industry-and-d...

                                                          • tsimionescu an hour ago

                                                            It's not the same thing though. All of these languages have specific constructs for integrating with the CLR, the CLR is not just a compilation target like WASM is. C++/CLR even has a fourth kind of variable compared to base C++ (^, managed references of a type, in addition to the base type, * pointers to the type, and & references to the type). IronPython has not had a GIL since its early days. I'm sure the others have significant differences, but I am less aware of them.

                                                        • flohofwoe 8 hours ago

                                                          > untrusted third party compiled code in a web browser.

                                                          WASM makes that safe, and that's the whole point. It doesn't increase the attack surface by much compared to running Javascript code in the browser, while the alternative solutions where directly poking through into the operating system and bypassing any security infrastructure of the browser for running untrusted code.

                                                          • pajamaboin 9 hours ago

                                                            This article is about WASM on the server so to answer your question it's different because it's not pushing computational cost from the server to the client. It can, but it doesn't in all cases. That's a huge difference. Others have already commented others (better sandboxing, isolation, etc)

                                                            • sebastianconcpt 2 hours ago

                                                              For starters, in that it gives you memory safe bytecodes computation that aren't coupled with one specific language.

                                                              • palmfacehn 9 hours ago

                                                                There have also been exploits of Chrome's JS sandbox. For me the greatest difference is that WASM is supported by the browser itself. There isn't the same conflict of interest between OS vendors and 3rd party runtime providers.

                                                                • SkiFire13 9 hours ago

                                                                  The replacement for those technologies is arguably javascript. WASM is more focused on performance by providing less abstractions and an instruction set closer to assembly (hence the name).

                                                                  The issue with those older technologies was that the runtime itself was a third-party external plugin you had to trust, and they often had various security issues. WASM however is an open standard, so browser manifacturers can directly implement it in browser engines without trusting other third-parties. It is also much more restricted in scope (less abstractions mean less work to optimize them!) which helps reducing the attack surface.

                                                                  • freetonik 9 hours ago

                                                                    Not an answer, but I think it’s unfair to group Flash with the others because it was both the editor/compiler and the player were proprietary. I guess same applies to Silverlight at least.

                                                                    • Kwpolska 9 hours ago

                                                                      The ActiveX "player" (Internet Explorer) was also proprietary. And I'm not sure if you could get away without proprietary Microsoft tools to develop for it.

                                                                    • Starlevel004 7 hours ago

                                                                      You can't easily decompile WASM so it makes it harder to block inline ads.

                                                                      • afiori 5 hours ago

                                                                        You can alreay compile javascript into https://jsfuck.com/ and you could also very easily recompile the wasm into js.

                                                                        Obsuscation and transpilation are not new in jsland

                                                                      • IshKebab 9 hours ago

                                                                        ActiveX wasn't sandboxed so it was a security joke. Flash and Silverlight were full custom runtimes that a) only worked with a specific language, and b) didn't integrate well with the existing web platform. WASM fixes all of that.

                                                                        • tightbookkeeper an hour ago

                                                                          But that’s missing a few steps. First they banned all those technologies saying JavaScript was sufficient, then only later made wasm.

                                                                          There never was a wasm vs applet debate.

                                                                      • torginus 8 hours ago

                                                                        Just in Time (JIT) compilation is not possible as dynamic Wasm code generation is not allowed for security reasons.

                                                                        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.

                                                                        • bhelx 2 hours ago

                                                                          The statement is correct. Wasm cannot mark memory as executable. It's effectively a Harvard Architecture. The code and memory are split. Furthermore you cannot jump to arbitrary points in code. There isn't even a jump instruction.

                                                                          > 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.

                                                                          JIT here is referring to compiling native code at runtime and executing it. This would be a huge security compromise in the browser or in a wasm sandbox.

                                                                          > I don't see any technical reason why this couldn't be possible. If this were a security measure, it could be trivially bypassed.

                                                                          It's not because it's baked into the design and instruction set. You can read some more about how it works here: https://webassembly.org/docs/security/

                                                                          > Also, WASM bytecode is very similar conceptually to .NET IL, Java bytecode etc., things designed for JIT compilation.

                                                                          Yes, and like with Wasm, the engine is responsible for JITting. But giving the user the power to escape the runtime and emit native code and jump to it is dangerous.

                                                                          • flohofwoe 8 hours ago

                                                                            > Just in Time (JIT) compilation is not possible as dynamic Wasm code generation is not allowed for security reasons.

                                                                            Browsers definitely use a form of JIT-ing for WASM (which is a bit unfortunate, because just as with JITs, you might see slight 'warmup stutter' when running WASM code for the first time - although this has gotten a lot better over the years).

                                                                            ...also I'm pretty sure you can dynamically create a WASM blob in the browser and then dynamically instantiate and run that - not sure if that's possible in other WASM runtimes though, and even in the browser you'll have to reach out Javascript, but that's needed for accessing any sort of 'web API'.

                                                                            • torginus 8 hours ago

                                                                              >Browsers definitely use a form of JIT-ing for WASM

                                                                              I (and the article) wasn't referring to this kind of JIT. I was referring to the ability to dynamically create or modify methods or load libraries while the app is running (like `DynamicMethod` in .NET).

                                                                              Afaik WASM even in the browser does not allow modifying the blob after instantiation.

                                                                              The thing you are referring to puzzles me as well. I initially thought that WASM would be analogous to x86 or ARM asm and would be just another architecture emitted by the compiler. Running it in the browser would just involve a quick translation pass to the native architecture (with usually 1-to-1 mapping to machine instructions) and some quick check to see that it doesn't do anything naughty. Instead it's an LLVM IR analog that needs to be fed into a full-fledged compiler backend.

                                                                              I'm sure there are good technical reasons as to why it was designed like this, but as you mentioned, it comes with tangible costc like startup time and runtime complexity.

                                                                              • flohofwoe 7 hours ago

                                                                                > Afaik WASM even in the browser does not allow modifying the blob after instantiation.

                                                                                ...not your own WASM blob, but you can build a new WASM blob and run that.

                                                                                > The thing you are referring to puzzles me as well...

                                                                                Yes, compilers emit WASM, but that WASM is just a bytecode (similar to JVM or .NET bytecode but even higher level because WASM enforces 'structured control flow') and needs to be compiled to actual machine code on the client before it can run, and this isn't a simple AOT compilation - in browsers at least (it used to be for a while in Firefox, but that caused issues for large projects like Unity games, which might take dozens of seconds to AOT compile).

                                                                                AFAIK all browsers now use a tiered approach. The WASM-to-machine-code compilation doesn't happen on the whole WASM blob at once, but function by function. For the first time a WASM function is called, a fast compilation will happen which may have slow runtime performance, from then on, 'hot functions' will be compiled with a higher tier backend which does additional optimization, is slow to compile but has better runtime performance - and AFAIK this is also quite similar to how Javascript JIT-ing works.

                                                                                Also from what I understand WASM compilation is more complex than just translating bytecode instructions to native instructions. It's more like compiling an AST into machine code - at least if you want any performance out of it.

                                                                                The only difference to JS might be that WASM functions are never 'de-optimized'.

                                                                                • torginus 3 hours ago

                                                                                  I feel like I need to be a bit more frank

                                                                                  > WASM is just a bytecode (similar to JVM or .NET bytecode but even higher level ...

                                                                                  Yes, and I think this was a poor engineering choice on behalf of WASM engineering team, instead of using something much closer to actual assembly. And we are grappling with long startup times and lots of compiler infra pushed into the client because of that.

                                                                                  > ...not your own WASM blob, but you can build a new WASM blob and run that.

                                                                                  another baffling limitation, considering you can modify your C#, Java or even native code at runtime.

                                                                                  Unless they are working around some constraint unknown to me, in which case I'd love to know about what it is, they made bad technical decisions in the design.

                                                                                  • flohofwoe 3 hours ago

                                                                                    > they made bad technical decisions in the design

                                                                                    Considering that the most important design requirement was to have a security model that's good enough for running untrusted code in web browsers at near native performance, I think the WASM peeps did a pretty good job.

                                                                                    Your requirements may be different, but then maybe WASM simply isn't the right solution for you (there are plenty of alternatives outside web browsers after all).

                                                                                    • torginus 3 hours ago

                                                                                      PNacl also had the same sandboxing requirement, yet had many of the features still missing today from WAsm (threads, 3d graphics API support, access to other native APIs), and it didn't suffer from slow startup times. It had pretty nice and quick uptake considering the tooling was very similar to native toolchains.

                                                                                      According to this benchmark (first Google result I found), it was even faster:

                                                                                      https://apryse.com/blog/wasm/wasm-vs-pnacl

                                                                                      While it might not have been perfect, WASM is yet to catch up in many ways, and some of its limitations might come from its design.

                                                                                      • flohofwoe 2 hours ago

                                                                                        I had been working both with NaCl and PNaCl back then, and truth be told, once Google made the switch from NaCl to PNaCl most advantages just disappeared. The compilation of the PNaCl bytecode on start (which was more or less just a subset of LLVM IR) took longer than even the first WASM implementations.

                                                                                        PNaCl definitely suffered hard from slow startup times because it ran LLVM for compilation from PNaCl bytecode to native code on startup, and LLVM is slow (I even noticed this compilation process on startup on my absolutely trivial test code). Only the predecessor NaCl didn't suffer from this problem.

                                                                                        There was no 'access to other native APIs', PNaCl created its own set of wrapper APIs to access browser features, and while some of those were better than their standardized web API counterparts, some NaCl/PNaCl APIs were worse than the web APIs they replaced - and for the future, PNaCl would have to create more non-standard APIs for every little feature available in browsers, because:

                                                                                        Integration with the webpage and Javascript was done via message passing, which was just terrible when compared to how easy and fast it is to call between WASM and JS.

                                                                                        The NaCl/PNaCl multithreading feature would have been hit just as hard by Spectre/Meltdown as the SharedArrayBuffer based threading in WASM.

                                                                                        Finally, when you look at the PNaCl toolchain versus Emscripten, Emscripten definitely comes out on top because Emscripten was much more concerned about integrating well with existing build systems and simplify porting of existing code, while NaCl/PNaCl had its own weird build system (in old Google NIH tradition). Working with NaCl/PNaCl felt more like working with the Android NDK, which is pretty much the worst developer experience in the world.

                                                                          • jillesvangurp 8 hours ago

                                                                            WASM replaces a language specific vm (javascript) with a general purpose one anywhere javascript vms are currently used. But not exclusively just there. General purpose here means it can run just about anything with a compiler or interpreter for it. Including javascript. So anything, anywhere.

                                                                            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.

                                                                            • marcyb5st 8 hours ago

                                                                              While I don't have a problem with Javascript, I have a problem with the ecosystem around publishing JS for the web. There are so many tools that do more or less the same thing and whose boundaries are unclear. Additionally, when you eventually manage to get everything working it feels brittle (IMHO). For someone that doesn't do that professionally, it is daunting.

                                                                              Nowadays, the few times I need to build something for the web I use leptos which has a much nicer DX and even if it didn't reach 1.x yet, it feels more stable that chaining like 5 tools to transpile, uglify, minify, pack, ... your JS bundle.

                                                                            • fallous 9 hours ago

                                                                              This article really does remind me of an old Law of Software that we used to invoke: Any sufficiently large and long-lived application will eventually re-implement the entire software stack it runs on, including the operating system.. and it will re-implement it poorly.

                                                                              I'm unsure of the source for this Law, but it certainly proves correct more often than not.

                                                                              • PoignardAzur 5 hours ago

                                                                                The witty version is known as Greenspun's tenth rule:

                                                                                "Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp."

                                                                                The general pattern is called the Inner-Platform Effect.

                                                                                • fallous an hour ago

                                                                                  YES! The Inner-Platform Effect is exactly what I was trying to dig up through my fossilized neurons. Thank you.

                                                                                  • anthk an hour ago

                                                                                    And a complete TCL spec.

                                                                                • cheema33 9 hours ago

                                                                                  I have a different take on this. I think local-first is the future. This is where the apps runs mostly within user's browser with little to no help from the server. Apps like Figma, Linear and Superhuman use this model very successfully. And to some degree Stackblitz does as well.

                                                                                  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.

                                                                                  • llm_trw 9 hours ago

                                                                                    >Serverless is mostly there to make money for Amazon and Azures of the world and will eventually go the way of the CGI.

                                                                                    CGI empowers users and small sites. No one talks about it because you can't scale to a trillion add impressions a second on it. Serverless functions add 10 feet to Bazoz's yacht every time someone writes one.

                                                                                    • mattdesl 9 hours ago

                                                                                      I’m not sure I’d call Figma local first. If I’m offline or in a spotty wifi area, I can’t load my designs. And unless it’s recently changed, if you lose wifi and quit the browser after some edits, they won’t be saved.

                                                                                      • pen2l 4 hours ago

                                                                                        A better example than Figma is Rive, made with Flutter.

                                                                                        Works well local-first, and syncs with the cloud as needed. Flutter space lends itself very well to making local-first apps that also play well in the cloud.

                                                                                        • curtisblaine 9 hours ago

                                                                                          That's intentional: they need you and your data tied to the server to make money. But there's no reason why it couldn't be local first (except the business model), since the bulk of execution is local.

                                                                                          Incidentally, I think that's why local-first didn't take off yet: it's difficult to monetize and it's almost impossible to monetize to the extent of server-based or server-less. If your application code is completely local, software producers are back to copy-protection schemes. If your data is completely local, you can migrate it to another app easily, which is good for the user but bad for the companies. It would be great to have more smaller companies embracing local-first instead of tech behemoths monopolizing resources, but I don't see an easy transition to that state of things.

                                                                                          • llm_trw 9 hours ago

                                                                                            >Incidentally, I think that's why local-first didn't take off yet

                                                                                            Local first is what we had all throughout the 80s to 10s. It's just that you can make a lot more from people who rent your software rather than buy it.

                                                                                            • baq 7 hours ago

                                                                                              The sweet, sweet ARR. Investors love it, banks love it, employees should also love it since it makes their paychecks predictable.

                                                                                              It sucks for customers, though.

                                                                                              • OtomotO 9 hours ago

                                                                                                More and more reliably.

                                                                                                When people have an abo that cannot be quit every month it gives more financial security to the company.

                                                                                                Previously people would buy e.g. the creative suite from Adobe and then work with that version for many, many years to come

                                                                                                • curtisblaine 8 hours ago

                                                                                                  Previously people would crack CS from Adobe then work with that version for many, many years to come :)

                                                                                                  • llm_trw 6 hours ago

                                                                                                    Previously amateurs would crack Adobe software and then get a letter telling them they needed to pay or be sued when they went professional.

                                                                                                    The cracked software was there to onramp teens into users. Adobe has burned this ramp and now no one under 14 uses it any more which is quite the change from when I was 14.

                                                                                                    • actionfromafar 7 hours ago

                                                                                                      True but do all those peeople now pay $100 a month to Adobe? Hardly.

                                                                                                      • auggierose 7 hours ago

                                                                                                        If they need what Adobe offers, yes.

                                                                                            • consteval an hour ago

                                                                                              It truly depends on the application. If you have a LOB database-centered application that's pretty much impossible to make "local first".

                                                                                              Figma and other's work because they're mostly client-side applications. But I couldn't, for example, do that with a supply chain application. Or a business monitoring application. Or a ticketing system.

                                                                                              • torginus 9 hours ago

                                                                                                Hehehe, so the future is how we used to run applications from before the era of the web.

                                                                                                • flohofwoe 9 hours ago

                                                                                                  Except with runtime safety, no installation process, no pointless scare popups when trying to run an app directly downloaded from the internet, and trivial distribution without random app store publishing rules getting in the way.

                                                                                                  In a way - yes - it's almost like it was before the internet, but mostly because other ways to distribute and run applications have become such a hassle, partly for security reasons, but mostly for gatekeeping reasons by the "platform owners".

                                                                                                  • torginus 8 hours ago

                                                                                                    Apps like these were incredibly common on Windows from the late 90s-early 2010s era. They could do all this (except for the sandboxing thing). You just downloaded a single .exe file, and it ran self-contained, with all its dependencies statically linked, and it would work on practically any system.

                                                                                                    On MacOS, the user facing model is still that you download an application, drop it in the Applications folder, and it works.

                                                                                                    • consteval an hour ago

                                                                                                      Yes and Windows in that time period had massive issues with security and culture. The culture of downloading and running EXEs from the internet quickly caught up to everyone, and not in a good way.

                                                                                                      Also the "big idea" is that those applications aren't portable. Now that primary computers for most people are phones, portable applications are much more important.

                                                                                                      • afiori 5 hours ago

                                                                                                        > They could do all this (except for the sandboxing thing).

                                                                                                        The sandbox is very very important, it is the reason I mostly do not worry about clicking random links or pasting random urls in a browser.

                                                                                                        There are many apps that I would have liked to try if not for the security risk.

                                                                                                        • d3VwsX 5 hours ago

                                                                                                          The download of a single EXE to keep had a nice side-effect though, that it made it trivial to store (most) apps (or their installers) for future use. Not so sure if in-browser apps can do that (yet?) except maybe by saving an entire virtual machine containing the web browser with the app installed.

                                                                                                        • flohofwoe 8 hours ago

                                                                                                          > You just downloaded a single .exe file, and it ran self-contained, with all its dependencies statically linked, and it would work on practically any system.

                                                                                                          Yeah, but try that today (and even by 2010 that wouldn't work anymore). Windows will show a scare popup with a very hard to find 'run anyway' button, unless your application download is above a certain 'reputation score' or is code-signed with an expensive EV certificate.

                                                                                                          > On MacOS, the user facing model is still that you download an application, drop it in the Applications folder, and it works.

                                                                                                          Not really, macOS will tell you that it cannot verify that the app doesn't do any harm and helpfully offer to move the application into the trash bin (unless the app is signed and notarized - for which you'll need an Apple developer account, and AFAIK even then there will be a 'mild' warning popup that the app has been downloaded from the internet and whether you want to run it anyway). Apple is definitely nudging developers towards the app store, even on macOS.

                                                                                                      • bigstrat2003 8 hours ago

                                                                                                        Except worse, because everything has to run in a gigantic web browser even if it could be a small native app.

                                                                                                        • adwn 7 hours ago

                                                                                                          Except better, because it doesn't only work on Windows, and because I don't invite a dozen viruses into my computer.

                                                                                                          • jauntywundrkind 6 hours ago

                                                                                                            Every native app has to be run in a gigantic special OS when it could be a small webapps running in a medium sized browser.

                                                                                                            Many many ChromeOS (web based consumer OS) laptops are 4GB of ram. You do not want to try that with any normal OSes.

                                                                                                            • dkersten 5 hours ago

                                                                                                              That’s because windows is loaded with trash. You can easily run desktop Linux with 4 GB or RAM, and people have been doing it for decades.

                                                                                                              • VyseofArcadia 4 hours ago

                                                                                                                But the browser is running in that gigantic special OS. It's not like the OS magically disappears.

                                                                                                                • jauntywundrkind 4 hours ago

                                                                                                                  I've already mentioned ChromeOS as one counter-example.

                                                                                                                  SerenityOS and Ladybird browser forked but until recently had a lot of overlap.

                                                                                                                  LG's WebOS is used on a range of devices, derived from the Palm Pre WebOS released in 2009.

                                                                                                                  The gigantic special OS is baggage which already has been cut loose numberous times. Yes you can run some fine light Linux OS'es in 4GB but man, having done the desktop install for gnome or kde, they are not small at all, even if their runtime is ok. And most users will then go open a web browser anyways. It's unclear to me why people clutch to the legacy native app world, why this other not-connected mode of computing has such persistent adherency to it. The web ran a fine mobile OS in 2009; Palm Pre rocked. It could today.

                                                                                                                  • VyseofArcadia 2 hours ago

                                                                                                                    I for one don't want to use web apps. I want the speed, convenience, and availability of native apps. I want to use applications that work if the internet isn't. I want to use applications that store my data locally. I want to use unglamorous applications that just work and use a native GUI toolkit instead of torturing a poor, overburdened document display engine into pretending it's a sane place for apps to run.

                                                                                                                    Not to mention, from the perspective of a developer, the relative simplicity of native apps. Why should I jump through all the hoops of distributed computing to, for example, edit a document in a WYSIWYG editor? This is something I could do comfortably on a Packard Bell in 1992.

                                                                                                                    • consteval an hour ago

                                                                                                                      The Web is portable, operating systems are not. Windows and Mac, being short-sighted, did this to themselves. Nobody can agree on anything, Microsoft is constantly deprecating UI frameworks, and it's not convenient at all to write local apps.

                                                                                                                      It's only JUST NOW we have truly portable UI frameworks. And it's only because of the Web.

                                                                                                                      • VyseofArcadia 16 minutes ago

                                                                                                                        QT has been around for decades. So has GTK. Bindings for whatever language you could possibly want. Runs on whatever OS you want. We've had "truly portable" UI frameworks since the late 90s. This has not been an issue for my entire adult life. 20 years ago, I was using desktop applications that ran on Mac OS X, Windows, and *nix with no modifications. They were written in Python, used GTK, and just worked.

                                                                                                                        Web apps are popular because 1) people don't like installing things anymore for some reason and 2) it's easier to justify a subscription pricing model.

                                                                                                            • wolvesechoes 6 hours ago

                                                                                                              There is no other industry that is equally driven by fad and buzzword. Try to hide a simple fact that a whole motivation behind SaaS preaching is greed, and bait users with innovative "local-first" option.

                                                                                                              It is actually kinda funny to read cries about "enshitiffication" and praises for more web-based bullshittery on the same site, although both are clearly connected and supporting each other. Good material for studying false consciousness among dev proletariat.

                                                                                                            • smolder 9 hours ago

                                                                                                              I also support the development of client side applications, but I don't think they should necessarily be run in a browser or sandbox or be bought through an app store, and it's definitely not a new idea.

                                                                                                              • moi2388 9 hours ago

                                                                                                                > 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.

                                                                                                                Might be true, but both will be more than fast enough. We develop Blazer WASM. When it comes to performance, dotnet is not the issue

                                                                                                                • jmull 2 hours ago

                                                                                                                  I thought the problem was the hefty upfront price to pay for loading the runtime.

                                                                                                                  • josephg 8 hours ago

                                                                                                                    Yep. And when wasmgc is stable & widely adopted, apps built using blazer will probably end up smaller than their equivalent rust+wasm counterparts, since .net apps won’t need to ship an allocator.

                                                                                                                  • sausagefeet 4 hours ago

                                                                                                                    > I think local-first is the future. This is where the apps runs mostly within user's browser with little to no help from the server. Apps like Figma, Linear and Superhuman use this model very successfully.

                                                                                                                    The problem is: Figma and Linear are not local-first in the way people who are local-first proponents explain local-first. Both of them require a centralized server, that those companies run, for synchronization. This is not what people mean when they talk about "local-first" being the future, they are talking about what Martin Kleppman defined it as, which is no specialized synchronization software required.

                                                                                                                    • csomar 9 hours ago

                                                                                                                      At the end of the day, all you are doing is syncing state with the server. In the future, you'll have a local state and a server state and the only server component is a sync Wasm binary hehe.

                                                                                                                      Still, you'll be coding your front-end with Wasm/Rust, so get in on the Rust train :)

                                                                                                                      • meow_catrix 9 hours ago

                                                                                                                        Rust frontend dev is not going to become mainstream, no matter what.

                                                                                                                        • bryanrasmussen 8 hours ago

                                                                                                                          metaphorically, Rust train does not sound enticing.

                                                                                                                        • jgord 5 hours ago

                                                                                                                          I definitely view the browser as an app delivery system... one of the benefits being you don't have to install and thus largely avoid dependency hell.

                                                                                                                          Recently I wrote an .e57 file uploader for quato.xyz - choose a local file, parse its binary headers and embedded xml, decide if it has embedded jpg panoramas in it, pull some out, to give a preview .. and later convert them and upload to 'the cloud'.

                                                                                                                          Why do that ? If you just want a panorama web tour, you only need 1GB of typically 50GB .. pointclouds are large, jpgs less so !

                                                                                                                          I was kind of surprised that was doable in browser, tbh.

                                                                                                                          We save annotations and 3D linework as json to a backend db .. but I am looking for an append-only json archive format on cloud storage which I think would be a simpler solution, especially as we have some people self hosting .. then the data will all be on their intranet or our big-name-cloud provider... they will just download and run the "app" in browser :]

                                                                                                                          • adrianN 8 hours ago

                                                                                                                            CGI is alive and well. It’s still the easiest way to build small applications for browsers.

                                                                                                                            • chgs 4 hours ago

                                                                                                                              Nobody talks about it because people who use it just use it and get on with their life. It’s painfully easy to develop and host.

                                                                                                                              However it’s likely that generations who weren’t making websites in the days of Matt’s script archive don’t even know about cgi, and end up with massive complex frameworks which go out of style and usability for doing simple tasks.

                                                                                                                              I’ve got cgi scripts that are over 20 years old which run on modern servers and browsers just as the did during the dot com boom.

                                                                                                                            • silvestrov 7 hours ago

                                                                                                                              > Figma can [...] then I think vast majority of the apps out there can

                                                                                                                              This doesn't follow. If Figma has the best of the best developers then most businesses might not be able to write just as complex apps.

                                                                                                                              C++ is a good example of a language that requires high programming skills to be usable at all. This is one of the reasons PHP became popular.

                                                                                                                              • OtomotO 9 hours ago

                                                                                                                                I have a different take on this:

                                                                                                                                It depends on what you're actually building.

                                                                                                                                For the business applications I build SSR (without any JS in the stack, but just golang or Rust or Zig) is the future.

                                                                                                                                It saves resources which in turn saves money, is way more reliable (again: money) and less complex (again: money) to syncing state all the time and having frontend state diverge from the actual (backend) state.

                                                                                                                                • boomskats 8 hours ago

                                                                                                                                  I have a different take on this:

                                                                                                                                  Business applications don't care about client side resource utilisation. That resource has already been allocated and spent, and it's not like their users can decide to walk away because their app takes an extra 250ms to render.

                                                                                                                                  Client-side compute is the real money saver. This means CSR/SPA/PWA/client-side state and things like WASM DuckDB and perspective over anything long-lived or computationally expensive on the backend.

                                                                                                                                • createaccount99 8 hours ago

                                                                                                                                  The frontend space is moving away from client-side state, not toward it.

                                                                                                                                  • bryanrasmussen 8 hours ago

                                                                                                                                    the frontend space is always moving in every direction at the same time, this is known as Schrodinger's frontend, depending on when you look at it and what intentions you have - you may think you're looking at the backend.

                                                                                                                                  • jamil7 9 hours ago

                                                                                                                                    I work on an iOS app like this right now, it predates a lot of these newer prebuilt solutions. There are some really nice features of working and building features this way, when it works well you can ignore networking code entirely. There are some tradeoffs though and a big one has been debugging and monitoring as well as migrations. There is also some level of end user education because the apps don’t always work the way they’re expecting. The industry the app serves is one in which people are working in the field, doing data entry on a tablet or phone with patchy connections.

                                                                                                                                    • lagrange77 4 hours ago

                                                                                                                                      > WASM could succeed as well.

                                                                                                                                      I would guess WASM is a big building block of the future of apps you imagine. Figma is a good example.

                                                                                                                                      • oscargrouch 5 hours ago

                                                                                                                                        I worked on something in this space[1], using a heavily modified Chrome browser years ago, but I consider I was too early and I bet something in this lines (probably simpler) will take off when the time is right.

                                                                                                                                        Unfortunately I got a little of a burnout for working some years on it, but I confess I have a more optimized and more to the point version of this. Also having to work on Chrome for this with all its complexity is a bit too much.

                                                                                                                                        So even though is a lot of work, nowadays I think is better to start from scratch and implement the features slowly.

                                                                                                                                        1 - https://github.com/mumba-org/mumba

                                                                                                                                        • curtisblaine 8 hours ago

                                                                                                                                          Some applications are inherently hard to make local-first. Social media and Internet forums come to mind. Heavily collaborative applications maybe too.

                                                                                                                                          • swiftcoder 8 hours ago

                                                                                                                                            I feel like social media is one of the main things folks want to be local-first. Own your own data, be able to browse/post while offline, and then it all syncs to the big caches in the sky on reconnect...

                                                                                                                                            • curtisblaine 7 hours ago

                                                                                                                                              But how do you do that without essentially downloading the whole social network to your local machine? Are other people's comments, quotes, likes, moderation signals something that should stay on the server or should be synced to the client for offline use? In the first case, you can't really use the social network without connecting to a server. The second case is a privacy and resources nightmare (privacy, because you can hold posts and comments from users that have deleted their data or banned you, you can see who follows who etc. Resources, because you need to hold the whole social graph in your local client).

                                                                                                                                              • swiftcoder 5 hours ago

                                                                                                                                                Usually folks looking for this sort of social network are also looking for a more intimate social experience, so we're not necessarily talking about sync'ing the whole Twitter feed firehose.

                                                                                                                                                I don't think it's unreasonable from a resources perspective to sync the posts/actions of mutual followers, and from a privacy standpoint it's not really any worse than your friend screenshotting a text message from you.

                                                                                                                                                • curtisblaine 4 hours ago

                                                                                                                                                  Sure, but they're a tiny fraction of the mainstream users and you can already have that sort of experience with blogging and microblogging. Relevant social networks as the public knows them are hard to develop local-first. Even the humble forum where strangers meet to discuss is really hard to do that way. If it needs centralized moderation, or a relevance system via karma / votes, it's hard.

                                                                                                                                                • curtisblaine 7 hours ago

                                                                                                                                                  (unless you want another paradigm of social networking in which you don't have likes, public follows, replies etc., which won't probably fly because it has a much worse UX compared to established social networks)

                                                                                                                                          • rpcope1 10 hours ago

                                                                                                                                            So basically we're reinventing the JVM and it's ecosystem?

                                                                                                                                            • thot_experiment 9 hours ago

                                                                                                                                              Sort of yes, but WASM is designed with a different set of constraints in mind that make more sense when you just want to shove the runtime into your whatever. Sometimes reinventing X with lessons learned is actually a great idea.

                                                                                                                                              • flohofwoe 8 hours ago

                                                                                                                                                In a way yes, except that WASM supports many more languages (e.g. back when I started to look into running C/C++ code in the browser - around 2010 or so - it was absolutely impossible to compile C/C++ to the JVM, which at the time would have been nice because Java Applets still were a thing - of course WASM didn't exist yet either, but Emscripten did, which eventually led to the creation of WASM via asm.js).

                                                                                                                                                • epistasis 9 hours ago

                                                                                                                                                  The JVM is great and all, but that doesn't mean that it is the be-all end-all of the genre. And having mucked with class loaders and writing directly in JVM assembly in the 2000s as part of programming language classes, I'm not sure that the JVM is even a very high point in the genre.

                                                                                                                                                  Sure, it allowed a large ecosystem, but holy crap is the whole JVM interface to the external world a clunky mess. For 20+ years I have groaned when encountering anything JVM related.

                                                                                                                                                  Comparing the packaging and ecosystem of Rust to that of Python, or shudder C++, shows that reinvention, with lessons learned in prior decades, can be a very very good thing.

                                                                                                                                                  • singularity2001 9 hours ago

                                                                                                                                                    except that WASM has a huge classloader / linker problem: It's still very hard to combine two wasm files into one and get the memory merger right. Maybe component model can fix it but it comes with so much bloated nonsense that an adaption in Safari might take forever.

                                                                                                                                                    • bhelx an hour ago

                                                                                                                                                      I agree that it's a problem and I definitely agree with the concern about component model. But maybe Wasm doesn't need 1-1 replacement of all capabilities in the native world. At least not right now. As someone who mostly uses it for plug-in systems, this hasn't been a big issue for us.

                                                                                                                                                      • iainmerrick 6 hours ago

                                                                                                                                                        It's a problem for some use cases, but is it really a "huge" problem in general?

                                                                                                                                                        You can't easily publish a library in WASM and link it into another application later. But you can publish it as C++ source (say) and compile it into a C++ application, and build the whole thing as WASM.

                                                                                                                                                        What are the scenarios where you really really want libraries in WASM format?

                                                                                                                                                        • flohofwoe 5 hours ago

                                                                                                                                                          The only situation I can think of is a plugin system for native applications, where 'WASM DLLs' would solve a lot of issues compared to native DLLs.

                                                                                                                                                          But those WASM plugins would be self-contained and wouldn't need to dynamically load other WASM 'DLLs', so that situation is trivial even without the WASM Component Model thingie (which I also think is massively overengineered and kinda pointless - at least from my PoV, maybe other people have different requirements though).

                                                                                                                                                          • nilslice an hour ago

                                                                                                                                                            this is exactly what we created Extism[0] and XTP[1] for!

                                                                                                                                                            [0]: https://extism.org [1]: https://getxtp.com

                                                                                                                                                            XTP is the first (afaik) platform of its kind meant to enable an app to open up parts of its codebase for authorized outside developers to “push” wasm plugin code extensions directly into the app dynamically.

                                                                                                                                                            We created a full testing and simulation suite so the embedding app can ensure the wasm plugin code does what it’s supposed to do before the app loads it.

                                                                                                                                                            I believe this is an approach to integration/customization that exceeds the capabilities of Webhooks and HTTP APIs.

                                                                                                                                                          • fwsgonzo 4 hours ago

                                                                                                                                                            I have to say that yes, it's a PITA. Ever tried to enable exceptions in one part, and disabled in the other? It simply won't load.

                                                                                                                                                            Or any other option. Really. So many investigations, so much time wasted.

                                                                                                                                                        • mlhpdx 9 hours ago

                                                                                                                                                          Yes, and the .Net CLR, etc.

                                                                                                                                                          • palmfacehn 9 hours ago

                                                                                                                                                            If your webserver is already JVM based, there's no context switch between the webserver and the application. Not sure how this would be solved with WASM.

                                                                                                                                                            • SkiFire13 9 hours ago

                                                                                                                                                              This doesn't make sense, WASM is supposed to run on the client, which is generally a different machine than the webserver, while a context switch is an event that happens within a single machine.

                                                                                                                                                              • mlnj 8 hours ago

                                                                                                                                                                WASM on the server also means that an execution engine that containerizes and runs server code in one of the many languages without the overhead of an entire OS like we do with containers now.

                                                                                                                                                                • palmfacehn 8 hours ago

                                                                                                                                                                  From the article:

                                                                                                                                                                  >Wasm on the Server

                                                                                                                                                                  >Why on earth are we talking about Wasm? Isn't it for the browser?

                                                                                                                                                                  >And I really hope even my mention of that question becomes dated, but I still hear this question quite often so it's worth talking about. Wasm was initially developed to run high performant code in the web browser.

                                                                                                                                                              • pjmlp 9 hours ago

                                                                                                                                                                Yeah, by folks that most likely used to bash Application Servers from early 2000's.

                                                                                                                                                                Not only JVM, also CLR, BEAM, P-Code, M-Code, and every other bytecode format since UNCOL came to be in 1958, but lets not forget about the coolness of selling WASM instead.

                                                                                                                                                                • iforgotpassword 9 hours ago

                                                                                                                                                                  That's a bit oversimplified. I had this thought too and tried to figure out why this is different, and I think there are some major points. The biggest one is in which order they were built and designed. If we take Java and ask why applets didn't take off since they could do everything WASM offers and more, two things come to mind: it was fucking slow on contemporary machines, and the gui framework sucked. WASM is the complete opposite. The gui framework is HTML/CSS, which despite its idiocy in many places had a long time to mature and we've generally came to accept the way it works. Now we just tacked a powerful VM onto it so we don't need to target slow Javascript. There isn't even a new language to learn, just compile whatever you want to WASM, which means you can use a familiar and mature dev environment.

                                                                                                                                                                  The other point is that WASM is way more open than any of the mentioned predecessors were. They were mostly proprietary crap by vendors who didn't give a shit (flash: security, Microsoft: other platforms) so inevitably someone else would throw their weight around (Apple) to kill them, and with good reason. WASM is part of the browser, so as a vendor you're actually in control regarding security and other things, and are not at the mercy of some lazy entity who doesn't give a damn because they think their product is irreplaceable.

                                                                                                                                                                  • kaba0 4 hours ago

                                                                                                                                                                    Wasm is more open, because we effectively have 1.5 browsers left, and whatever google decides will be the de facto “web standard” everyone should follow. If google were pushing for a slightly revamped jvm/applet model, that would be the standard (as the JVM is as open/standardized as it gets)

                                                                                                                                                                    • pjmlp 3 hours ago

                                                                                                                                                                      Ironically if it was today instead of 2010, Mozilla refusing to adopt PNaCL would hardly matter.

                                                                                                                                                                    • pjmlp 5 hours ago

                                                                                                                                                                      Same premise of many other bytecode formats since 1958, a matter of implementation and marketing.

                                                                                                                                                                      • singularity2001 9 hours ago

                                                                                                                                                                        Any reasonable interaction between WASM and JS/DOM gets postponed seemingly indefinitely though.

                                                                                                                                                                      • thot_experiment 9 hours ago

                                                                                                                                                                        The coolness of WASM is that I can run WASM on like 99.999% of the targets I care to run code on with zero friction. Everyone (well it's HN so someone is probably on LYNX) reading this page is doing so in a browser with a WASM runtime. That has tremendous value.

                                                                                                                                                                        • anthk an hour ago

                                                                                                                                                                          Not Lynx as it doesn't show up the correct layout on comments.

                                                                                                                                                                          But Dillo works perfectly fine. No JS, no WASM, crazy fast on a n270 netbook.

                                                                                                                                                                          I can't barely run WASM programs that could be run fine under a Pentium 3-4.

                                                                                                                                                                          • pjmlp 5 hours ago

                                                                                                                                                                            Applies to most bytecode formats, it is a matter of implementation.

                                                                                                                                                                            • marcosdumay 32 minutes ago

                                                                                                                                                                              It never applied to any web bytecode formats, and applies to very few local local ones (arguably, none).

                                                                                                                                                                              It's just a matter of having everybody agree to install the same interpreter, yes. That never happened before.

                                                                                                                                                                          • SkiFire13 9 hours ago

                                                                                                                                                                            All of those bytecode formats were designed to support higher abstractions. WASM on the other hand was born from asm.js, which tried to remove abstraction to make code run faster. Ultimately the goal for WASM was to run code faster, hopefully near native speed, which is not a priority for all the bytecodes you mentioned. If that wasn't needed then Javascript would have been enough.

                                                                                                                                                                            • pjmlp 5 hours ago

                                                                                                                                                                              Revealing lack of knowledge, some of those bytecode formats were designed for low level languages like Pascal, Modula-2, C, C++, among others.

                                                                                                                                                                        • openrisk 7 hours ago

                                                                                                                                                                          It is challenging to forecast how client-server architectures would evolve on the basis of technical merit, even if we restrict to "web architectures" (this itself being a bundle of multiple options).

                                                                                                                                                                          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.

                                                                                                                                                                          • DanielHB 7 hours ago

                                                                                                                                                                            I have been thinking we would be heading for a world where WASM replaces code running lambda functions on the cloud for a long time. WASM is traditionally seen as running on a host platform, but there is no reason it needs to be this way.

                                                                                                                                                                            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).

                                                                                                                                                                            • slt2021 9 hours ago

                                                                                                                                                                              putting everything in WASM really drains the battery on mobile.

                                                                                                                                                                              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

                                                                                                                                                                              • thot_experiment 9 hours ago

                                                                                                                                                                                WASM is a double edged sword, if you're compiling fast implementations of heavy lift functions to WASM and calling them in lieu of a JS impl you're going to end up saving battery life.

                                                                                                                                                                                If you're generating bindings for some legacy disaster and shipping it to clients as a big WASM blob you're going to hell.

                                                                                                                                                                              • wokwokwok 9 hours ago

                                                                                                                                                                                What the article actually says:

                                                                                                                                                                                > 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. :)

                                                                                                                                                                                • tantalor an hour ago

                                                                                                                                                                                  [2022]

                                                                                                                                                                                  • superkuh 2 hours ago

                                                                                                                                                                                    Anything that requires executing arbitrary untrusted code from arbitrary untrusted sources automatically is bad and is definitely not filling the same role as server side CGI.

                                                                                                                                                                                    • smolder 10 hours ago

                                                                                                                                                                                      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 which is meant to be a universal code representation for a universal virtual machine. Have I missed something?

                                                                                                                                                                                      • jblecanard 8 hours ago

                                                                                                                                                                                        Totally agree there, the article makes complete confusion between the execution model and the tech used to execute. Especially since it says « not CGI as the protocol but as the model ».

                                                                                                                                                                                        As far as model goes, the serverless one is not a different model. It is still a flavor of the CGI concept. But the underlying tech is different. And not that much. It is only serverless for you as a customer. Technically speaking, it runs on servers in micro-VMs.

                                                                                                                                                                                        Those are orthogonal matters, and even if such tech as the middleware mentioned get some wind, the execution model is still the same and is not new.

                                                                                                                                                                                        • waynecochran 10 hours ago

                                                                                                                                                                                          The use of wasm makes sense to me in context of the article.

                                                                                                                                                                                          • smolder 10 hours ago

                                                                                                                                                                                            The article does not seem to support the title. You'll have to show me how it does. 'serverless' is a wholly different concept that doesn't have much to do with wasm. You could say it's CGI as a service, but that has nothing to do with wasm.

                                                                                                                                                                                            • svieira 9 hours ago

                                                                                                                                                                                              It's quite buried amid a lot of extra paragraphs expositing about WASM and the future of serverless functions in general, but the article does contain this quote:

                                                                                                                                                                                              > One of the many effect of how [WASM] modules are isolated is that you can "pause" a module, and save its memory as a data segment. A similar concept to a Snapshot of a virtual machine. You can then start as many copies of the paused module as you like. (As I tell friends, it's like saving your game in an emulator.)

                                                                                                                                                                                              > The snapshotted module has no extra startup time ...

                                                                                                                                                                                              > 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.

                                                                                                                                                                                              • smolder 9 hours ago

                                                                                                                                                                                                This is not like CGI. Calling it "the new CGI" seems to me like a way to confuse people, since CGI was a response to individual requests and carrying state across requests was always extra work. None of this has to do with WASM in particular.

                                                                                                                                                                                                • networked 2 hours ago

                                                                                                                                                                                                  WASI CGI is the new CGI. :-)

                                                                                                                                                                                                  https://codeberg.org/valpackett/caddy-wasm-wcgi

                                                                                                                                                                                                  Sorry, I'll use this rare opportunity to bring up WCGI for Caddy. :-) It is a Caddy web server plugin that runs CGI applications compiled to Wasm, which includes scripting language runtimes. The project isn't mine, and I haven't tried it for anything beyond a "Hello, world!". I think it is a neat hack.

                                                                                                                                                                                                  • svieira 9 hours ago

                                                                                                                                                                                                    With CGI the developer of the script could pretend that the-only-thing-which-existed was this request and do all kinds of things that would bring down a persistent process (leak memory, mutate globals, etc.) The problem was that spinning up a process per-request was expensive and slow. Now, with WASM's memory model it becomes possible to have a process that both does all the slow work initialization work once and has the ease-of-reasoning properties of CGI's "a single process for a single request" serving model.

                                                                                                                                                                                                    • smolder 9 hours ago

                                                                                                                                                                                                      Edit to say: thanks for your answer. I'll preserve the rest since I still think wheels are being reinvented here.

                                                                                                                                                                                                      Bridging state across requests is not new. If "the new CGI" means more efficiently sharing state between requests, that's a really arbitrary qualifier and is not unique to WASM or serverless or anything like that. The article is myopic, it doesn't take into consideration what is established practice done over and over.

                                                                                                                                                                                            • Muromec 9 hours ago

                                                                                                                                                                                              You might have missed wasi

                                                                                                                                                                                            • feverzsj 8 hours ago

                                                                                                                                                                                              Companies choose wasm to avoid crawlers.

                                                                                                                                                                                              • tightbookkeeper an hour ago

                                                                                                                                                                                                And Google probably wanted to ban applets etc because they were negatively impacting search

                                                                                                                                                                                                That doesn’t mean there weren’t good technical reasons, but that’s not necessarily the driver,

                                                                                                                                                                                                For example, ssl is obviously good, but ssl required also raises the cost of making a new site above zero, greatly reducing search spam (a problem that costs billions otherwise).

                                                                                                                                                                                                • ram_rattle 6 hours ago

                                                                                                                                                                                                  I do not understand this, can you please explain

                                                                                                                                                                                                  • nicce 4 hours ago

                                                                                                                                                                                                    Probably just a typical cat and mouse game. Some crawlers support React based websites already, for example, so they can render the content and crawl based on that. I believe crawlers do not execute yet the WASM code. But in time, they will.

                                                                                                                                                                                                • EGreg 3 hours ago

                                                                                                                                                                                                  WASM runs on the client side.

                                                                                                                                                                                                  WASM is basically the new Microsoft Common Language Runtime, or the new JVM etc.

                                                                                                                                                                                                  But OPEN!

                                                                                                                                                                                                • akoboldfrying 4 hours ago

                                                                                                                                                                                                  I don't know much about Wasm so this was helpful, thanks. It does seem like having the same language on both server and browser must make software delivery more flexible.

                                                                                                                                                                                                  >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.)

                                                                                                                                                                                                  • Tepix 3 hours ago

                                                                                                                                                                                                    I disagree. In particular for me the allure for CGI was its simplicity. Have you played around with WASM in the browser? It involves way too many steps to get it integrated into the web page and to interact with it.

                                                                                                                                                                                                    I let chatgpt do the tedious work, have a look at a minimal example:

                                                                                                                                                                                                    https://chatgpt.com/share/6707c2f3-5840-8008-96eb-e5002e2241...

                                                                                                                                                                                                    • flohofwoe 3 hours ago

                                                                                                                                                                                                      The part of loading and instantiating the WASM blob is 3 lines of Javascript, and two of those are for the fetch() call. Calling into the WASM module is a regular JS function call. Not sure how this could be simplified much further, it is much simpler than dealing with FFI in other runtime environments (for instance calling into native code from Java or Kotlin on Android).

                                                                                                                                                                                                      • Tepix an hour ago

                                                                                                                                                                                                        The WASM code doesn't have access to the DOM, if you want to have a web app that interacts with the user (intriguing, isn't it?) you'll end up writing a lot of javascript glue code.

                                                                                                                                                                                                        • flohofwoe 26 minutes ago

                                                                                                                                                                                                          There are enough binding libraries by now where you don't need to write a single line of JS (e.g. https://rustwasm.github.io/wasm-bindgen/examples/dom.html).

                                                                                                                                                                                                          For better or worse, browser APIs have been designed to be used with Javascript so some FFI magic needs to happen when called from other languages, with or without WASM.

                                                                                                                                                                                                          And if each web API would automatically come with a C API specification (like WebGPU kinda does for instance), Rust people would complain anyway that they need to talk to an 'archaic' C API instead of a 'modern' Rust API etc etc...

                                                                                                                                                                                                    • TekMol 9 hours ago

                                                                                                                                                                                                      I don't see WASM as a significant step forward. In fact, I question its purpose altogether.

                                                                                                                                                                                                      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.

                                                                                                                                                                                                      • DanielHB 7 hours ago

                                                                                                                                                                                                        > Before WASM you could already compile code from other languages into JavaScript. And have the same benefits as you have with WASM.

                                                                                                                                                                                                        If you are referring to asm.js you must be joking. asm.js was basically a proof of concept and is worse in every way compared to WASM.

                                                                                                                                                                                                        Like parsing time overhead alone makes it a non-option for most large applications.

                                                                                                                                                                                                        You seem to imply you should just do it in plain JS instead for "deployment, execution and debugging" benefits. Imagine if you could be free to use those python ML libs in any language of your choice, that alone is enough of an argument. No one is going to reimplement them in JS (or any other environemtn) unless there is a huge ecosystem movement around it.

                                                                                                                                                                                                        • tsimionescu 9 hours ago

                                                                                                                                                                                                          Debugging a Rust program compiled to Javascript is MUCH harder than debugging one compiled to WASM. That is the whole point. And even making the program work when compiled to JS is iffy, as JS has a few breaking constraints, notably that it is single threaded.

                                                                                                                                                                                                          Sure, native JS is easier still. But there is a huge wealth of code already written in languages that are not JS. If you want a web app that needs this code, you'll develop it many times faster by compiling the pre-existing code to WASM than by manually rewriting them in JS, and the experience will be significantly better than compiling that code to JS.

                                                                                                                                                                                                          • thot_experiment 9 hours ago

                                                                                                                                                                                                            ngl I've tried using Rust -> WASM and it's been an awful experience, I'm much much happier with C. Rust generates enormous blobs because you have to include stdlib, and if you don't you don't get any of the benefits of using Rust. I'm probably overrotating on binary size but it sure is nice being able to just read the WASM and make sense of it, which is generally the case for WASM made from C and is absolutely not the case if you're building from Rust.

                                                                                                                                                                                                            • therein 8 hours ago

                                                                                                                                                                                                              Did you run the output through wasm-opt? The size isn't terribly bad. I have a whole complex GUI with realtime charts, based on egui, under 4MB uncompressed. This includes three fonts and even some images.

                                                                                                                                                                                                          • pulse7 9 hours ago

                                                                                                                                                                                                            When computers become faster, WASM will still be twice the speed of JavaScript, because untyped languages limit the optimizations.

                                                                                                                                                                                                            • thot_experiment 9 hours ago

                                                                                                                                                                                                              Bad take. Yes, you can probably optimize a lot of algos in JS such that they are pretty fast, but THAT is cumbersome. I'd much rather write the things I need to go fast in a language that's good at that (I use C for this). I'm currently working on a toolpath optimizer and I'm compiling just the optimizer function to WASM, it's a couple kilobytes and will probably be an order of magnitude faster than the JS implementation while being FAR LESS cumbersome to write. My JS doesn't change at all because i can just call the "native function" from JS, replacing my original JS impl.

                                                                                                                                                                                                              • TekMol 9 hours ago

                                                                                                                                                                                                                    probably be an order of magnitude
                                                                                                                                                                                                                    faster than the JS implementation
                                                                                                                                                                                                                
                                                                                                                                                                                                                What makes you think so?
                                                                                                                                                                                                                • thot_experiment 9 hours ago

                                                                                                                                                                                                                  Off the rip because I didn't spend time to make the JS implementation keep all of it's data in a typed array that I manually manage, because it's tedious to do that in JS and it's straightforward in C. Though I'm betting there are other benefits I'll get from -O2 and static analysis.

                                                                                                                                                                                                                  • TekMol 9 hours ago

                                                                                                                                                                                                                    Compiling your C to WASM might make it run twice as fast as compiling it to JS.

                                                                                                                                                                                                                    That's all. All other aspects of the workflow are the same.

                                                                                                                                                                                                                    • thot_experiment 9 hours ago

                                                                                                                                                                                                                      I will try but I suspect the final score will be

                                                                                                                                                                                                                          1. WASM
                                                                                                                                                                                                                          2. JS handwritten for speed
                                                                                                                                                                                                                          3. C compiled to JS
                                                                                                                                                                                                                      
                                                                                                                                                                                                                      and the gaps will be greater than 2x
                                                                                                                                                                                                                      • flohofwoe 8 hours ago

                                                                                                                                                                                                                        You forgot 'C compiled to the asm.js subset of Javascript', that would be on second place right after WASM (the switch from asm.js to WASM was hardly noticeable in my C/C++ code performance-wise - some browsers had special 'fast paths' for the asm.js subset though).

                                                                                                                                                                                                                        • TekMol 9 hours ago

                                                                                                                                                                                                                          Awesome. I will notice when you reply here, no matter when. I routinely check for new replies even to old comments.

                                                                                                                                                                                                                  • xnorswap 9 hours ago

                                                                                                                                                                                                                    Javascript is incredibly well optimised, I'm surprised if there's an order of magnitude difference between JS and WASM without a fundamental difference in algorithm chosen.

                                                                                                                                                                                                                    • consteval an hour ago

                                                                                                                                                                                                                      When it comes to GC languages they can often appear very fast for use cases that don't use a lot of memory.

                                                                                                                                                                                                                      If you use an algorithm that near exhausts memory, that's where you'll start seeing that "order of magnitude" difference between JS and something like C++. The same goes for Java and C#.

                                                                                                                                                                                                                      At low memory utilization, the GC can just put off collection, which saves execution time, so the runtime appears fast. But if you're close to the limit, then the GC has no choice but to pause often before continuing. Not very many algorithms will encounter this, but applications might, depending on what they do.

                                                                                                                                                                                                                      • thot_experiment 9 hours ago

                                                                                                                                                                                                                        I will likely spend time implementing my solver in several different styles because this is a project I'm tackling largely to make some points about how I think WASM should be used. I'm far from final benchmarks on this but my suspicion is that the gap will be large.

                                                                                                                                                                                                                        Yes javascript is very well optimized, but as someone who's spent a lot of time writing javascript where speed matters, it's not easy, and it's not predictable. You're at the mercy of arcane optimizations in V8 which might not work for your specific situation because you did something weird, and if you're taking a lot of care not to do anything weird, and manually managing your memory with typed arrays, well, then you might as well write C and compile to WASM.

                                                                                                                                                                                                                    • winternewt 9 hours ago

                                                                                                                                                                                                                      It's difficult or impossible to compile many languages into JavaScript. WASM is more general.

                                                                                                                                                                                                                      • swiftcoder 7 hours ago

                                                                                                                                                                                                                        Do you have a source for this?

                                                                                                                                                                                                                        asm.js (the spiritual precursor to WASM) worked pretty much the same, and an awful lot of languages were compiled to it.

                                                                                                                                                                                                                        WASM does provide a more predictable compilation target to be sure, but I don't think it actually opens any new possibilities re what languages can be compiled.

                                                                                                                                                                                                                        • winternewt 6 hours ago

                                                                                                                                                                                                                          Multithreading and 64-bit integers come to mind as creating difficulty, and I imagine "raw" memory buffer access having much higher latency to the point where it's completely impractical. For example, a quick search gave me this library [1] that compiles FFMpeg into Asm.js but the author says it is almost a factor 10 slower. Asm.js would also become extremely verbose for any larger code base (imagine compiling a AAA PC game to Asm.js).

                                                                                                                                                                                                                          It may be as you say that there are no new theoretical possibilities being opened by WASM, but to me it is a natural step forward to resolve inefficiencies and ergonomic problems in ASM.js and make it all less painful. And hopefully WASM won't be frozen in time either - the platform needs to keep improving to make more use-case scenarios practical.

                                                                                                                                                                                                                          [1] https://github.com/Kagami/webm.js/

                                                                                                                                                                                                                        • TekMol 9 hours ago

                                                                                                                                                                                                                          Theoretically or because of the tooling landscape?

                                                                                                                                                                                                                        • flohofwoe 8 hours ago

                                                                                                                                                                                                                          > WASM is much more cumbersome to handle than plain JS when it comes to deployment, execution and debugging.

                                                                                                                                                                                                                          For some of us it's much easier than dealing with Javascript though (for instance debugging C/C++ in Visual Studio is much nicer than debugging JS in Chrome - and that's possible by simply building for a native target, and then just cross-compile to WASM - but even the WASM debugging situation has improved dramatically with https://marketplace.visualstudio.com/items?itemName=ms-vscod...)

                                                                                                                                                                                                                          • jamil7 9 hours ago

                                                                                                                                                                                                                            You’re assuming a lot of things in this comment, it seems like you believe every software engineer is working with the same constraints, language and platform as yourself.

                                                                                                                                                                                                                            • TekMol 9 hours ago

                                                                                                                                                                                                                              No. I say we could build the same dev experience to non-js coders by offering them compile-2-js tools instead of compile-2-wasm tools.

                                                                                                                                                                                                                              • jamil7 7 hours ago

                                                                                                                                                                                                                                Not really because then you need a JS environment everywhere you want to run your code. If I write a Rust module I have the possibility to compile to WASM or machine code. This is what I meant in my other comment, your assumption is everyone is making browser apps in Javascript that don't have any performance or resource constraints.

                                                                                                                                                                                                                                • TekMol 6 hours ago

                                                                                                                                                                                                                                      possibility to compile to WASM or machine code
                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                  How is this better than "possibility to compile to JS or machine code"?
                                                                                                                                                                                                                            • IshKebab 9 hours ago

                                                                                                                                                                                                                              The days of computers doubling in speed every 2 years are loooong gone.

                                                                                                                                                                                                                              Look into the history of WASM. They did try compiling everything into JS with asm.js, but then sensibly decided to do things properly. I don't know why anyone would object to proper engineering.

                                                                                                                                                                                                                              • pjmlp 5 hours ago

                                                                                                                                                                                                                                Only because Mozilla refused to adopt PNaCL.

                                                                                                                                                                                                                              • vbezhenar 9 hours ago

                                                                                                                                                                                                                                You can probably optimize JS to run as fast in most cases.

                                                                                                                                                                                                                                What actually WASM brings is predictable performance.

                                                                                                                                                                                                                                If you're JS wizard, you can shuffle code around, using obscure tricks to make current browser to run it really fast. The problem is: JS wizards are rare and tomorrow browser might actually run the same code much slower if some particular optimization changed.

                                                                                                                                                                                                                                WASM performance is pretty obvious and won't change significantly across versions. And you don't need to be wizard, you just need to know C and write good enough code, plenty of people can do that. Clang will do the rest.

                                                                                                                                                                                                                                I agree that using WASM instead of JS without reasons probably is not very wise. But people will abuse everything and sometimes it works out, so who knows... The whole modern web was born as abuse of simple language made to blink the text.