logoalt Hacker News

A minimal kernel in Swift, running in QEMU

48 points • by surprisetalk • last Tuesday at 12:20 PM • 9 comments • view on HN

Comments

aseipp • today at 2:49 AM

Embedded Swift is honestly very cool. I never really used Swift itself before, but I think it's a good niche since embedded dev could stand for another tool and the language is pretty nice. It also doesn't really suffer from most of the issues people have historically brought up with Swift (cross platform, slow compiles) etc as it is so small, at least to me. :)

If you're starting from scratch I've found you can actually write ~everything in Swift quite easily (reset vectors, compiler emitted intrinsics, etc). But beyond that I think the best feature is that the C/C++ interop works really well and comes out of the box. Makes two-way adoption easy. I wrote a small boot firmware for a simulator and for fun decided to add signatures to the boot process (mldsa44+jq255). You can just copy the .c and .h files and import them into a modulemap file and you're off to the races. You can just get simple .o files and pass them to the linker. There are only 4-5 "freestanding" functions you have to implement. You can turn off heap allocation. Etc.

It would probably be pretty cool and quite easy for instance to write Zephyr or U-Boot drivers, etc in Swift using these techniques.

Narishma • today at 2:30 AM

More of a hello world than a kernel.

mannyv • today at 3:20 AM

Just pound values into registers! I love it, so old school!

In fact, that's how i/o worked before DMA on many systems. Good times!

➕ show 1 reply
qubex • last Tuesday at 12:38 PM

“machine emulators for hackers”

“Hack the Planet!”? “Mess with the best die like the rest”? WTF?

➕ show 2 replies
77rushi77 • today at 4:23 AM

[flagged]

21-DOT-DEV • today at 2:31 AM

[dead]