Live data from Hacker News

WebContainers: Run Node.js natively in the browser

blog.stackblitz.com

101–110 of 238 posts

Re: WebContainers: Run Node.js natively in the browser

#101

As far as I understand JS code is being run natively in the browser. Node has been hooked to the native engine, so V8 is not involved. At LeaningTech we have since several months been able to run nodejs, but also python and ruby using our Wasm based x86 VM (CheerpX), the demo is available here: https://repl.leaningtech.com/?nodejs With our solution the full Linux x86 binary of nodejs is running including the whole of…

It looks like the difference is you went for full x86 system call level emulation to handle existing binaries whereas stackblitz decided to build a container for things like Node compiled directly to WASM with no static assumptions of a base system. The latter approach with 1 less level of indirection should be much more efficient, as is evident by startup times of the 2 demos. Not to mention the ability to hook into things above the syscall level.

Re: WebContainers: Run Node.js natively in the browser

#102

Hi all- CEO of StackBlitz/author of this blog post here. Happy to answer any questions! (Also, thanks for posting this bpierre!)

Why do this at all?

With all the security and design problems of Node.js, when there are actually secure and reliable ways (harder ways, yes. Security and reliability are hard) to do all of this. Why?

Re: WebContainers: Run Node.js natively in the browser

#103

totally lost newbie here: but what is the difference between running javascript on the browser and running node.js on the browser?

This is going full inception mode. Nodejs is compiled to wasm (like assembly for your browser), and then loaded inside the browser, which can then run javascript. So a full JS engine is loaded, completely separate from the built-in one.

[deleted]

Re: WebContainers: Run Node.js natively in the browser

#104
This is a really bad idea.

Building on the really good work of the WASM folks, running Node.js, with all its design problems, over the top of it.

I am forever astounded anew by the hubris and naivety of the Node.js crew. It is a example of "It is easier to write than read, easier to talk than listen, easier to build than design"

Re: WebContainers: Run Node.js natively in the browser

#105

"StackBlitz v2 Beta currently works in Chrome and Chromium-based browsers. We’re hoping to add support for more browsers as they implement the necessary Web Platform features." Pretty useless, then. What features are missing? As far as I know Firefox was one of the major contributors to pushing WebASM to the web and has a superior WASM engine in many aspects. I'd be more interested in a post about what WebASM feature…

It looks like the problem isn't WASM features, but web I/O APIs, like the File System Access API.

Re: WebContainers: Run Node.js natively in the browser

#106
post #71

Wow, the PWA is really impressive. Honestly it's starting to get hard to tell the difference between this and Electron-based editors like VS Code. I'm really excited for integration with the File System Access API; that's the final puzzle piece I'd need to use something like this for serious work.

Me too and I was surprised to find that Chrome lists this as "ready" or "released" (I don't recall the exact term). I tried the example web based editor and found that the file system access API worked in Firefox too.

I'm working on a note taking project right now that I think would be great as a web app, but I'd like to store the result in a flat text file and the file system access API looks like it will let me do exactly that.

Re: WebContainers: Run Node.js natively in the browser

#107
post #104

This is a really bad idea. Building on the really good work of the WASM folks, running Node.js, with all its design problems, over the top of it. I am forever astounded anew by the hubris and naivety of the Node.js crew. It is a example of "It is easier to write than read, easier to talk than listen, easier to build than design"

You didn't say anything substantial here about why it's a bad idea. "Design problems." What design problems do you have in mind?

Re: WebContainers: Run Node.js natively in the browser

#108

What about this is "native"? The page says it is "running natively" but also says "All code execution happens inside the browser's security sandbox". Is wasm in a browser somehow considered native now?

The web devs where I work have started calling pretty much everything "native" as long as it interacts with the host in some way since people assume it means fast.

Re: WebContainers: Run Node.js natively in the browser

#109
post #82

Everyone thought WASM would enable developers to write code in any language they wanted (with type checking and higher performance) and deploy it on the web. JS Developers come in: so we can compile node.js to WASM and run that in the browser?! Yay!! Now we can have backend JS running in the browser alongside browser JS! Jokes aside: this is actually quite interesting, the demo is very impressive (except for the "onl…

Browser Javascript suffers from not producing a single "binary" as its build system output. You do get one bundle, but none of the parts know anything about each other, and it limits the ability to optimize. (It is a lot more like the C preprocessor, rather than a C compiler.) Methods that can't possibly ever be called end up being sent to each user, for no reason other than "well someone could write an eval() that needs that". (I was surprised how poorly tree-shaking works in practice, and how even "light" frameworks like Svelte ship a huge runtime to every user, unrelated to what features the code actually uses.)

Meanwhile, WebAssembly suffers from there not being a good programming language that compiles to it natively. I think the Go support is great, but there's no library support for building the webapps that people get paid to build (React, Apollo, etc. all exist for a reason, however much you hate that reason). AssemblyScript was supposed to be this language, but it's just a Typescript-inspired programming language, it's not Typescript and the npm ecosystem.

I don't know what the details of this implementation are, but the direction I'd like to see web development move is having a statically typed language that compiles to VM bytecode. This sounds like the first step for removing Javascript as a Typescript intermediary. Once that happens, then modern programming language features can be bolted on, people can add good compiler optimizations that result in minimal bytes output for users to download, the module system can be made stricter (like "go mod"), etc. Javascript is just a little bit more dynamic than anyone really wants, and it makes the build/deployment tooling complicated and, frankly, kind of bad.

Re: WebContainers: Run Node.js natively in the browser

#110

I used to teach web development and was always frustrated with just how much effort went into setting up a machine. It would be really nice if a developer could just include a script tag in their project that setup a TypeScript compiler inside service worker. I managed to get the basics down, even fixing relative import statements. Requests like localhost:3000/main.tsx would compile and cache on the fly. There were a…

Yes web developing is so hard...

sudo apt install apache2 php libapache2-mod-php; vim /var/www/html/index.php

Post reply on HN