UEFI Bindings for JavaScript
codeberg.org
codeberg.org
Seeing that Metal replaces kernel/userspace boundaries with VM protections for memory, meaning that system call overhead is eliminated, at the price of ASM/VM overhead.
What a fascinating idea. Kidding on the square...
I think he was trying to bend reality with words. I can see many apps that are running in electron on my laptop, each consuming 300MB+ (e.g. Spotify), while many other apps are written in native Swift for example, especially with the help of AI, giving the best performance possible...
Edit.
And prices of RAM nowadays...
They are consuming 300MB of RAM because they are built on Electron and the NPM ecosystem.
This might be what you were getting to but I tend to agree with the idea of place all the interaction logic in a high kevel language and get the performance where it's needed.
Electron does not do that and neither does the people developing electron apps most of the time. I doubt many people throwing electron apps together chose to do that so they can put their CPU intensive code in C/C++/Rust/swift, they want to erite everything in JS.
What should happen is the bare minimum needs to be in JS and the rest in an efficient compiled language.
I mean even the browser does that, the DOM API hands off to lower level libraries for multimedia etc.
Granted, yeah, we never (or haven't yet) really transitioned to running "full legacy software" inside the browser, or at least it's not common place. That said, I've seen people compile Wine to wasm, Linux to wasm, and lots of other things to wasm, and run em in a browser. Many of the "fake" demos could be done for real now.
The one aspect that remains thoroughly farcical is an equivalent of Wine for OS X/Cocoa good enough to run a web browser. :-(
[edit] And asm.js kind of died on the vine. Not sure how to feel about that one. Wasm could he described as an evolution of the same idea, but in a lot of ways it's something entirely different.
Probably wouldn’t be too hard to boot Linux (under QEMU compiled for wasm), and then fire up a Windows 95 VM using QEMU TCG …
Could repeat this a few times - Inception style…
> Prometheus stole fire from the gods and gave it to man. For this he was chained to a rock and tortured for eternity.
> If this makes you grin, you are probably holding the torch.
And, if so, does that mean that once the API has been bootstrapped, one could actually write an OS in js? Or are there other abstractions that would need to be migrated first?
I bet somebody has done that.
https://www.google.com/search?q=os+kernel+in+javascript
Seems like a small number of hobbyists have attempted.
I've heard of people doing this with other high level languages. Basically you need enough low level code to bootstrap a VM. Once you have that, you can make the high level language decide some logic that traditionally would be in C code, like manipulating page tables or whatever.
I vaguely remember hearing about someone trying to use .Net in the Windows kernel.
The big problem is garbage collection: If I remember correctly, the fact that "any" operation can fail with an out of memory exception was a huge problem. Another problem was that random pauses for garbage collections in the kernel had major stability issues.
In short, I hope that the js kernel is for amusement and education; otherwise it would need a much more advanced garbage collector then earl 2000's .Net.
Microsoft did that, it was called Longhorn. That release cycle was long delayed and they abandoned most of its ambitious projects, especially C# in the kernel, and the result was Windows Vista.
GC was not the only reason for the failure of that project. Someone could write a book about it. A lot of it was actually more about the organization of people. I also had heard from insiders that lack of ahead of time compilation was an issue. The other issue I remember hearing about was a complaint that Windows components were not layered cleanly and they ended up with circular dependencies when they tried to rewrite them.
I think it's possible to write a kernel with GC, and to still be judicious about memory usage with a GC language. And I say that as someone who happens to think that a big issue with modern software is that too many programmers are spending their whole education and career to depend on GC without thinking about it carefully. That is to say I'm already a skeptic of high-level languages and GC, but I will still afford that it is technically possible.
> Microsoft did that, it was called Longhorn
Do you have any reference for that? Or are you confusing Longhorn with Singularity (https://en.wikipedia.org/wiki/Singularity_(operating_system)) / Midori (https://en.wikipedia.org/wiki/Midori_(operating_system))?
I suspect you're referring to the shell/internals, though, not the kernel (https://longhorn.ms/the-reset/#:~:text=Why%20start%20over,re...)
When security and reliability were suddenly key issues for Microsoft (to the extent that they ever were), it was obvious that what the Longhorn team had built was never going to meet that bar so they started over building off the Windows Server codebase instead.
Most of this story I remember from a video on YouTube of that old guy who worked at Microsoft since forever and left around the time of the Longhorn debacle, but a lot of it is corroborated in the Wikipedia article as well. https://en.wikipedia.org/wiki/Development_of_Windows_Vista
I need to split some hairs for a bit:
Do you mean what is colloquially referred to as "GC", as in the dotnet / Java / Javascript / golang "mark-and-sweep", fully-automatic style?
Or do you mean other automatic memory management systems, which some people technically define as GC, like automatic reference counting? (IE, they clean up memory immediately, and except for requiring some manual form of breaking cyclic loops, generally are fully automatic?)
The latter is pretty much the status quo in terms of the state of the art. Most kernels aren't built with automatic reference counting, reference counted objects are plentiful even if more manual, but the automatic part is trivial to add to a C++ code base using smart pointers for example, and things like rust or apple ARC can also do it.
I think the former (a "true" GC that can resolve cycles) could be done in a kernel, it's just not common.
I'm not well versed in this historical example, did the "lisp machine" not have a GC in its OS?
> These machines had hardware support for various primitive Lisp operations (data type testing, CDR coding) and also hardware support for incremental garbage collection.
That being said, hardware garbage collection never really took off. When I look at GC languages they all have significantly different memory models, so I can see why. (For a more modern take on this, look into why dotnet can't use the proposed WASM garbage collector. Dotnet needs more metadata and finalizers, which WASM's GC doesn't provide.)
But getting back to a Javascript kernel with GC: I would think "stop the world" pauses would cause non-deterministic issues? (IE, if an interrupt has a long pause due to a GC?) It might only work if the kernel borrowed techniques from "real time Java" programming techniques?
https://medium.com/@retrage/lkl-js-running-linux-kernel-on-j...
import isOdd from "https://unpkg.com/is-odd";It's what Claude Code is using.
What if it makes me recoil in horror? screams into the void
1) JavaScript must stay in the box (aka in the browser).
2) JavaScript as a general purpose programming language.
While I can absolutely understand 1), I have had wanted to access the filesystem via JavaScript, just as I do via ruby or python, for local use only. After I googled for a while, they would say that this is not possible unless one uses npm/node. I think this shows that there are use cases here and the "default" JavaScript, aka 1), does not cover these. I do not like JavaScript, but based on my own use cases, I actually favour 2) far more than 1). So from that point of view, being able to access UEFI can also be useful. So why not.
There are some (limited) ways to do so now: https://developer.mozilla.org/en-US/docs/Web/API/File_System...
As for (1) vs (2), it’s not really an issue of JavaScript at all. The main question is, do you want to build something that runs in a browser? If you’re building a web app, you’ll have to use the sandboxed APIs (and probably JavaScript). If you don’t care about the runtime, yeah, you can use Node or Bun or Deno (or use another language altogether).
0) JavaScript must be abolished from the browser
Gnome Shell and Firefox/SeaMonkey/Mozilla Application Suite/Netscape 6+ (and Zotero[1]) are implemented on top of SpiderMonkey.
It's also a single, self-updating executable and includes a lot in the box. Including SQLite3.
Note: 128GB of DRAM may add another million dollars to the build cost by 2027 at the current derivative of the $/GB curve
Mind you I never said anything about quality or performance, obviously doing everything in JavaScript comes with it’s own issues but if you were to say that someone got JavaScript running in the Linux kernel as a POC I wouldn’t even be surprised
>looks inside
>node modules
Pretty neat, though.
Hilarious