Top
Best
New

Posted by ananas-dev 8 hours ago

UEFI Bindings for JavaScript(codeberg.org)
180 points | 94 comments
fnimick 6 hours ago|
Oh hey, we've reached the "Metal" stage! https://www.destroyallsoftware.com/talks/the-birth-and-death...
p0w3n3d 2 hours ago||
I don't know if it's only me, but did this guy... Did this guy make a huge mistake?

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

pwdisswordfishy 1 hour ago||
Those apps are not consuming 300MB of RAM because they are written in JS. JS is running on microcontrollers and the James Webb Space Telescope.

They are consuming 300MB of RAM because they are built on Electron and the NPM ecosystem.

monax 6 hours ago|||
I'm doing my part ∠(‘-‘)
ruined 6 hours ago|||
thank u 4 ur serves
kiddico 6 hours ago|||
Thank you for the reminder to do my yearly viewing of that video lol
epistasis 5 hours ago||
Whoa, I haven not been following ASM.js stuff in any detail.

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

faxmeyourcode 7 hours ago||
Love this. An example of complete and total dominion over the machine. Great quote here too lol

> Prometheus stole fire from the gods and gave it to man. For this he was chained to a rock and tortured for eternity.

falcor84 1 hour ago|
Talking about quotes, I also absolutely loved this note at the end of the readme:

> If this makes you grin, you are probably holding the torch.

catapart 7 hours ago||
Can someone break this down for me? Looks like it's using... C? to load a js interpreter which bootstraps an API around all UEFI features? Do I have that right?

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?

tatskaari 6 hours ago||
You don't need a JS bootloader to write an OS in JS. The bootloader just drops the machine into some memory address for it to start executing your OS init script. that bit could be a Javascript interpreter. You can't do much with the architecture in Javascript though, because it doesn't allow you to map memory directly to your types (unless there's some ungodly nonesense I'm not aware of) so you'll have to drop into C/asm to e.g. interact with the ports/registers/tables to set up userspace.
Zambyte 5 hours ago|||
An OS doesn't need to have a user space :)
monocasa 2 hours ago|||
You should be able to write a meta circular VM in JavaScript that targets bare metal without any C or asm.
asveikau 6 hours ago|||
> And, if so, does that mean that once the API has been bootstrapped, one could actually write an OS in js?

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.

gwbas1c 6 hours ago|||
Automatic Garbage Collection in a kernel probably won't work:

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.

asveikau 4 hours ago||
> I vaguely remember hearing about someone trying to use .Net in the Windows kernel.

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.

danudey 34 minutes ago|||
Another part of it was, IIRC, that Longhorn was based off of the Windows XP core, i.e. the non-server stuff. While the Windows Server development continued apace, with lots of security and hardening to make for a reliable OS to build upon, the Windows Non-Server team continued with the existing mess of a codebase, not prioritizing security features or stability in favor of trying to manage feature creep. Longhorn was meant as a stopgap between XP and 'Blackcomb', but a lot of Blackcomb stuff started creeping backwards, bogging them down.

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

anonymars 1 hour ago|||
> trying to use .Net in the Windows kernel.

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

asveikau 1 hour ago||
My source for that is I was on the Windows team at Microsoft from 2008-2011. I learned a bunch of this history from talking to coworkers who were there. I specifically recall people talking about c# in the kernel.
leoedin 6 hours ago|||
You'd need to write an entire hardware abstraction layer to do anything useful. There's projects that do this for microcontrollers - eg MicroPython and Espruino.
tracker1 1 hour ago||
Should be able to do similar with MicroQuickJS or maybe just QuickJS...
hajile 6 hours ago|||
I'm pretty sure someone already compiled Linux to asm.js a few years ago. As asm.js is/was a subset of JS, you could say it's already been done. In theory, you could continue work from there in JS.

https://medium.com/@retrage/lkl-js-running-linux-kernel-on-j...

monax 7 hours ago|||
Depending on your definition of OS, yeah you could do that :)
nxobject 7 hours ago||
Hey, when Apple transitioned from m68k to PowerPC, it took them a hell of a long time to rewrite massive parts of their OS. It's a low bar, though...
DustinBrett 6 hours ago||
OS in JS, ok I am interested now...
my_throwaway23 7 hours ago||
I presume you'll add the network stack next, so that I can use my favourite, most useful packages?

  import isOdd from "https://unpkg.com/is-odd";
p_l 7 hours ago||
Well, there's a network stack already there, including HTTP and HTTPS on newer firmwares.
monax 7 hours ago||
We are getting isOdd in the bootloader before GTA-IV
spiffyk 7 hours ago||
Wait, when did I time-travel?
monax 7 hours ago||
oops typo
eqvinox 6 hours ago||
> If this makes you grin, you are probably holding the torch.

What if it makes me recoil in horror? screams into the void

redvulps 8 hours ago||
next step is to create a UEFI TUI using react (please don't)
tracker1 1 hour ago||
Considering how bad some of the Gamer-ish firmware UIs are now, it might be an improvement.
aruametello 7 hours ago|||
you may just have casted a curse on our future motherboards, damn you
monax 8 hours ago||
OMG we can use ink for that
bayindirh 7 hours ago||
This project will go places. Like every silly project not intended for production. :)
edward28 8 hours ago||
Wow, this is cursed.
lnenad 8 hours ago||
I think the proper term is blursed.
monax 8 hours ago||
I think r/unixporn will love it once it gets DOM support :^)
kijin 8 hours ago||
Finally, we can create splash screen animations in pure CSS!
javascriptfan69 15 minutes ago||
Beautiful
GranPC 7 hours ago|
"The Birth and Death of JavaScript" is coming true after all.
marijnz0r 6 hours ago|
I was going to post this as well! A direct link to the video: https://www.destroyallsoftware.com/talks/the-birth-and-death...
More comments...