4 ms·
I've missed the front-page window to ask, but... Can anyone suggest a compiler making nice use of metaprogramming? So many seem more eyeball abstraction over re
by mncharity 4y ago
I've missed the front-page window to ask, but... Can anyone suggest a compiler making nice use of metaprogramming? So many seem more eyeball abstraction over repetition than Tufte minimal ink. Tnx.
I liked TFA's turn to metaprogramming, but have found using a "real" language (instead of C's PP) is usually worth the tooling cost. Metaprogramming is ideally not only more maintainable than raw code, but also clearer.
Nice post.
- mort96 4y agoI have seen a custom DSL used to do code generation once, but... it's not very nice. Here's the VM definition file for the Emerald virtual machine: https://github.com/emerald/old-emerald/blob/master/vm/vm.d https://github.com/emerald/old-emerald/blob/master/vm/vm.d I'm sure there are nicer examples out there.
- mncharity 4y agoHmm. So that vm.d is a source file for a nearby compiler[1] ... written in C. With a .l and .y, and implementations of assorted collection datatypes, and ... basically printf'ing code. Sigh. Better instead say a vm_d.py direct emitter, and skip the vmc? [1] https://github.com/emerald/old-emerald/tree/master/vmc https://github.com/emerald/old-emerald/tree/master/vmc
- mort96 4y agoI'm 100% in agreement. I don't think the idea of one source file with a DSL for sections is a terrible idea, but it could be done as a 10-line python script rather than a giant lex+yacc C project.
- deleted 4y ago[deleted]
- naasking 4y agoThe papers from Alan Kay's VPRI/STEPS are worth a read: https://vpri.org/writings.php https://vpri.org/writings.php The program was all about composing simple, understandable DSLs to build a computing infrastructure, including compilers, graphics subsystems and more, with the larger goal of making computing understandable again from top to bottom. I'm getting gateway timeouts on the actual papers right now though. Edit: papers are loading now.