3 ms·
If your goal is to learn about how program execution works or memory and other low-level things I suspect learning how to build a compiler targeting a VM (and b
by agentultra 3y ago
If your goal is to learn about how program execution works or memory and other low-level things I suspect learning how to build a compiler targeting a VM (and building the VM) is a good way to learn these things. You'll end up learning how to emit VM instructions to store data and the address of the program counter, jump to the function code, then jump back and unpack all that data, etc. You'll learn how to implement those VM instructions for a target hardware platform. You'll learn how difficult it is to design a good instruction set that covers the platforms you want to support.
The nand2tetris course is a pretty good one; you'll design the hardware itself in the first part and in the second you'll build a compiler/VM/etc for it.
And then you'll gain an appreciation for how C works and why it's useful.
And also why higher-level languages are useful.
I don't think you need to learn C any more than you need to learn separation logic or category theory though.
Update The problem with "learning C" is that it has a ton of warts and you might injure yourself in the effort to master it. The language is coupled tightly to libc, the specification is small as far as modern ISO standards go but it still leaves a lot to the imagination (and the implementors). It's really quite a complex language to learn well due to all of the sharp edges.
And of course, C isn't the royal road. There are lots of other models for thinking about programs that aren't based on imperative procedures. It's just a language.
If you want to think about programming and PLT... there are a lot more sophisticated tools.