HACKER Q&A
📣 mrbait

What is must-have for a systems programming language?


Obviously, any systems language must have predictable memory layout for at least a subset of its types, including atomic (as in primitive) and composite types -- but probably it's not quite necessary (nor possible) for function types.

What are other language features that are similarly crucial? I'd argue even arrays are kinda optional, since they can be encoded as `Array = exists (n: Size, a: Type); (repeat a > take n > reduce ((x, y) -> (x, y)))`


  👤 mikewarot Accepted Answer ✓
It has to be able to link to and/or predictably generate machine code, for all the bootstrapping sections.

Ideally, it has to support a return stack, and a data stack.

I've seen ROM code that couldn't assume a return stack... not fun.

It would be really, REALLY nice if it could manage reference counted, counted, automatically allocated, strings, so that you could just use them without needing to allocate/free them, etc... just return a string like you return an integer.


👤 horsh1
For a systems language execution environment there is a huge list of crucial questions: what is a library, what is a package, how does linking works, how do you interact with different build systems, how you separately compile having only interface declarations, how to manage alternative libraries for the same interface, how to tweak compilation for multiple targets, how do you ffi?

The answers to all of the above will have an impact on your language features: how you import, how you declare foreign entities, what visibilities are possible, what data storage classes are theere, what is the module initialization order, what code can be executed during module initialization, what is your conditional compilation mechanisms?


👤 mrbait
Is automatic register allocation necessary? Would anybody contest that?

Procedures? In and out parameters? Return values? Pointers? References? Integers? Signed? Unsigned? Structs? Unions? Arrays? Goto? Loops?

Do you enjoy implementing variable length encodings? What do you imagine would make that less error-prone?

What an application language can't have that a systems language can? What a systems language cannot ever afford and how to cope with that? What a systems language can afford lacking that an application language won't get away with?

I need your hottest takes!


👤 Doctor-R
You need to be able to generate any machine instruction. like clear the cache, turn interrupts off and on, access the hardware bits on the I/O cards, access privileged instructions, etc. The language needs to use every instruction. In C, there is a feature to embed/call assembly language instructions which are architecture dependent.

👤 082349872349872
I'd say a low-to-no dependency build: unless you're planning on cross-compiling everything, you'll want to be using your systems language to bring up other toolchains, not need to already have some other toolchain in place to bring up your systems language.

👤 eimrine
Pointers?