To be fair, I believe Bellard's JS x86 emulator predates this (and WASM, and to my knowledge also possibly emscripten) by several years :) It has a very interesting history itself:
> I wrote the initial version of JSLinux[...] in Javascript
> [...] I modified it to use the asm.js Javascript subset [...]
> [...] so I converted the JSLinux asm.js code to C and converted it back to Javascript with emscripten!
It's worth mentioning that the initial version of this didn't use WebAssembly. Bellard literally implemented i386/PC emulation in pure JavaScript (ES5) back in 2011.
It did require W3C Typed Arrays to perform decently, but I remember with polyfills it even ran in the contemporary version of Internet Explorer (9 if memory serves correctly?)
"Can I access to the network from the virtual machine ?
Yes it is possible. It uses the websocket VPN offered by Benjamin Burns (see his blog[2]). The bandwidth is capped to 40 kB/s and at most two connections are allowed per public IP address. Please don't abuse the service.
"
Too bad there isn't a way to use the network of the machine running the browser... Maybe one could write some code that intercepts any outgoing network traffic from the VM, and instead of sending it via websockets to that 3rd party VPN, instead just finds packets that are part of a HTTP call and rewrites them to XMLHttpRequests. Would obviously only work for HTTP traffic, but that's probably a big majority. Might not work for HTTPS though. Oh, and DNS would have to respond with some sort of fantasy IP's that the Javascript host would have to keep track of.
HTTP support seems possible, but it’s unlikely to be useful by itself. HTTPS is probably the majority and that’s a lot trickier (you’d have to MITM TLS in JS).
DNS is comparable to HTTP probably, since you could just use DNS-over-HTTPS and intercept DNS packets.
Wait until the emulator can run a modern kernel with eBPF support. Then use eBPF to intercept the SSL calls pre encryption, push via a map the requests to userspace, and then translate them to HTTP as you wish. Simple! ;P
This guy again?! Fabrice Bellard gives me serious imposter syndrome. He's built QEMU, ffmpeg, and the Tiny C Compiler that can run off of a floppy. Ugh. If I build one thing in my career that's as cool as any one of those, I'll be delighted.
Don't worry there are just a handful of people like him world wide. But the software industry needs myrads, no, millions of people.
Given some arbitrary metric it's generally not the best to compare yourself with the best of the best (on that metric), just doing the best you can do and striving to learn and improve (and live and be there for your family etc.) is more then good enough.
I feel similarly. At the same time, comparing oneself to one of the, what, top ten (?) hackers alive might not be a recipe for happiness.
Fabrice seems to know an insane amount about how computers work, knows all the CS stuff, has a tight grasp of all kinds of algorithms, great math intuition, and a lot of time on his hands to write OSS code. I bet he spent a lot of time learning the basics.
Also note that, this site is like any other social media sites. The top posts are naturally going to be talented people who seem to effortlessly accomplish things we can only dream about.
I would not at all feel bad about not measuring up anywhere close to Fabrice Bellard. Be happy with what you've done.
If necessary take time away from social media, including HN. Personally I've stopped visiting most social media and simultaneously feel more satisfied, less harried, and also have had more time to accomplish some small personal projects.
I have heard that Alpine is really light on resources. Would it be practical for Rust, Node, Python projects in general? Or am I better off sticking with Ubuntu? I know that projects often have extra dependencies and I believe Ubuntu is still very good as far as those being easily available with the package manager. Or maybe about the same thing goes for Debian.
It's great for packaging a project in containers. The package management is actually pretty good specifically for anything server/service related, you just have to be a bit more hands on since it doesn't come with all of the bells and whistle dependencies.
The only issue I've really had is libc vs musl for some of my dependencies.
Its _tiny_ compared to ubuntu.
I haven't looked at daily driving it because it doesn't feel like it's really meant for desktop use (although I'm sure it'll work), Something like arch makes more sense if you want something more lightweight while also having decent documentation and support for desktop use, and better packaging for things like chrome, vscode, etc. Especially because of musl I suspect you'll run into a lot of issues in general.
EDIT: Also most images like python have alpine variants now which is really nice.
> Also most images like python have alpine variants now which is really nice.
You probably don’t want to use Alpine for Python containers. Many packages don’t provide wheels for Alpine (the Python version of prebuilt binaries), so you’ll have to build them from source, countering the space savings.
You’re often better just using something like Debian-slim or something.
I would use whatever Alpine-y containers the official Python docker hub has, and switch to a Debian-based one if there are bugs. Building extra wheels isn't necessarily an issue, you can squash layers with a multistage build from scratch.
I hit some nasty segfaults in musl, with gRPC above it in the stack trace while doing some rather heavy YouTube API operations-- opted to switch to a glibc distribution rather than track down that mess. The segfaults were gone after that.
The big issue with alpine is that it uses musl libc instead of glibc. Python and other languages work just fine on it but the problem is when you install packages from pip, conda or other package managers, if those packages have binaries they're likely not compatible with musl libc and won't work. You have to find alpine-specific packages which can be difficult or annoying.
For code that compiles into a binary like Rust, distroless is another option for a minimal image that doesn't run into the compiling issues of Alpine. (Python and Node are supported but lose benefits rapidly depending on any added dependencies)
Just to clarify for anyone who isn't aware, the "compiling issues", at least historically, have been that Alpine uses musl, and PyPI's manylinux wheels are built against old glibc versions. So stuff like numpy that would trivially and quickly install from whl on glibc distros (like a bare-bones Ubuntu image) trigger compilations and the installation of build-only dependencies/toolchains on Alpine.
I use it for Node all the time. There are published docker images with Alpine as the base and just Node and any required packages installed. I've had to manually install a handful of libraries to support image processing, or anything else that NPM might not install itself.
Same here. It's a great base image for node projects.
the Node 19 release alpine image is ~175mb, the same release on debian (bullseye) is roughly 1gb (998mb). Still ~80MB smaller than the bullseye-slim release (247mb).
---
That said - if the ask was for using it as a daily driver on a machine (primary OS), I'd probably still pick a more fully featured distro (ex: my daily driver is Arch, not Alpine). The available packages and tooling in Alpine aren't really geared towards daily use as an OS, although some folks definitely do it.
My guess is the most weight is probably coming from linux-headers (~10mb), python3 (~50mb), and nodejs (~60mb). Plus 1 to 10 mb for each of the other pacakges, and you end up right there around 175mb.
Yeah, I looked again and it looks like they're actually only pulling those packages in when they need to build node for the current ARCH. (that's what I get for just scanning to the first call to apk add)
They also appear to be cleaning them up, so I'm not actually sure where all that extra weight is coming from.
Node itself is fairly trimmed down in the packages for alpine (40MB installed), but they're not using that package, they're pulling in their own version from their download sources - so it's possible they're including a lot of extra junk there. They also add yarn which is another 10mb.
But in general - I agree, there's about 100mb of weight I can't actually explain in that image from a very quick look.
I'd run it mostly for cloud projects that need to be lightweight. I just ran into a quite unpleasant issue with Alpine and Go where Go compiled as a shared library with musl cannot work in Alpine. In fact it segfaults and doesn't give any indication as to why it segfaults (the stack is even corrupted if you try to use gdb). You can read about it here: https://github.com/golang/go/issues/13492
Of course one could argue that's mostly Go's fault...
Aside from packaging, do also look into any potential issues with musl libc. It's fixed now, but the malloc in musl made Python noticably slower for some real world tasks roughly three years ago and earlier. This fixed it: https://git.musl-libc.org/cgit/musl/commit/?id=ea6d7847ac128...
Alpine is strong in package availability, but needs some manual work for a usable desktop. Also I did some browser benchmarks, uses less RAM but it's not noticeably faster and some situations slower
You would be better trying Xubuntu, MX linux, NixOS...
Void Linux is also worth trying. It's lightweight, fast boot times with runit, stable rolling release, and a unique packaging system xbps. Comes with either glibc or musl.
I've only used Alpine when creating containers with docker and has worked for me. Not sure about it being a daily driver though, prob best to stick with Ubuntu.
https://copy.sh/v86/
To be fair, I believe Bellard's JS x86 emulator predates this (and WASM, and to my knowledge also possibly emscripten) by several years :) It has a very interesting history itself:
> I wrote the initial version of JSLinux[...] in Javascript
> [...] I modified it to use the asm.js Javascript subset [...]
> [...] so I converted the JSLinux asm.js code to C and converted it back to Javascript with emscripten!
[1] https://bellard.org/jslinux/tech.html