17 ms·
I think it's people realising that compilers aren't that complicated until you get into the backend. Lots of optimization passes, even, are relatively obvious
by mhh__ 7y ago
I think it's people realising that compilers aren't that complicated until you get into the backend.
Lots of optimization passes, even, are relatively obvious (not necessarily trivial, but they make sense) - to my eye at least, the Voodoo magic is in the scheduling and code generation
- seanmcdirmid 7y agoWith something like the dynamic language runtime, even code generation can be easy. Too bad it hasn’t been copied on other platforms outside of .NET.
- chrisseaton 7y agoWhat does .NET do to make code generation easy?
- seanmcdirmid 7y agoThe DLR as I mentioned is an API for dynamic code generation that hooks into the platform’s JIT. The code you can generate with it runs fairly fast (as fast as other JITTed code)
- chrisseaton 7y agoDo you mean just generating bytecode through an API? That's a completely trivial problem in the first place - just linearise your AST. When people talk about 'code generation' they mean the complexity of native instruction scheduling and selection. And if you want to just generate byetecode doesn't Truffle on Java do that far better than DLR? Truffle seemed to actually achieve what DLR promised but never really managed - genuine support for dynamic languages on .NET/JVM.
- seanmcdirmid 7y agoThe DLR had two parts: support for dynamic languages, and a strongly typed API for generating expression trees at run time. The second component is the one that survived and is fairly robust. It is quick, skipping the bytecode stage completely, and is fully typed.
- DmitrySoshnikov 7y ago> the Voodoo magic is in the scheduling and code generation Yes, for the code generation one needs to well understand semantics of the target language. And when it's a low-level language (Assembly), the "voodoo magic" mainly relates to generic understanding of the lower-level architectures. However, there might be compilation to another high-level language (in case of a transpiler), and by itself code generation at this stage is not that hard, simply because a target language is more understood in this case. Instruction selection topic, and where to place the data -- on the stack, or into registers (and how a register allocator works) also mainly relates to the lower-level. > until you get into the backend Yes, and that's why I think it should be a separate class, specifically for higher-level compilation, and a low-level compilation. We'll be covering this in "Essentials of Compilation".