Operating Systems

On this page 6

Kernel code has no runtime underneath it. There is no allocator until you write one, no standard library assumptions to lean on, and no operating system to catch mistakes. Home targets that environment directly, and ships a kernel package of primitives for it.

Freestanding by default

A Home program does not require a runtime to start. There is no collector thread, no start-up initialisation you did not write, and no hidden allocation. That is what makes the language usable before there is an OS to run on.

The kernel package

The kernel package groups the primitives OS work needs, as zero-cost abstractions with compile-time checking:

NamespaceWhat it covers
Kernel.asmAssembly operations and CPU control
Kernel.memoryMemory management primitives
Kernel.interruptsInterrupt and exception handling
Kernel.pagingPage tables and virtual memory
Kernel.atomicAtomic operations and lock-free structures
Kernel.syncSynchronization primitives

Port I/O is typed rather than a cast at the call site:

const value = Kernel.asm.inb(0x60);   // read from the keyboard controller
Kernel.asm.outb(0x3F8, 'A');          // write to the serial port
const data = Kernel.asm.inw(0x1F0);   // read a word from disk

See kernel features for the full surface and kernel architecture for how the pieces fit together.

Why the type system helps here

The failure modes in kernel code are the ones a type system is good at catching, provided the abstractions cost nothing:

Exhaustive interrupt dispatch. A match over an exception enum will not compile with a vector unhandled, so adding a new exception type surfaces every place that has to care.

Errors as values. A page-table walk that can fail returns a Result. There is no unwinding through a fault handler, because there is nothing to unwind with. See error handling.

Ownership without an allocator. Ownership is a compile-time property, so it works the same before you have a heap as after. See the memory model.

Comptime tables. Descriptor tables, page-table constants and interrupt vectors can be built during compilation and land in the binary as data. See comptime.

HomeOS

HomeOS is the operating system built on these primitives and is the main consumer of the kernel package. It is developed at github.com/home-lang/homeos, which is also the best place to see the package used at scale rather than in isolation.

Status

The kernel package targets x86_64 today. The primitives are in place; the language underneath them is still maturing, and native code generation handles single-entrypoint builds with module-graph bundling in progress. This is the most experimental use case on this site, and worth treating as such. The capability matrix is the honest reference.

Released under the MIT License.