logoalt Hacker News

jlouislast Friday at 3:34 PM3 repliesview on HN

It's not that they can't. It's that it's a waste of time in most cases.

Compilers are moving targets because hardware changes. There's a considerable maintenance upkeep in a compiler.

So if you are interested in programming language semantics, you can opt to skip the compiler part. This lets you iterate language designs without the added baggage of translating said program to machine code.

You can also argue there's no need. If you present your programming language in operational semantics, then it's trivial to write that up as a prolog program and run it on a prolog interpreter. Then you can employ a partial evaluator, and the first Futamura-projection gives you a compiler. You can choose to host your prolog program in a programming language which already has access to a partial evaluator, and you are essentially done before you even started.


Replies

ux266478last Friday at 4:44 PM

I'm someone who has used Prolog in the past, but this is the first time I'm learning of Futamura's work[1]. I knew it was great for building executable grammars, but I hadn't ever really tried to do so thus have absolutely no knowledge on the usual techniques. What an absolutely fascinating methodology, I can see exactly how it maps to Prolog.

[1] - https://static.aminer.org/pdf/PDF/001/006/665/partial_evalua...

randomNumber7yesterday at 3:56 PM

You could just target LLVM IR (or even simpler transpile to C). Should not take that much time for s.o. who knows what he is doing.

juancnlast Friday at 5:10 PM

But even a toy compiler would be useful to inspire someone else to pick up the concepts.

It doesn't have to be production grade, just as a communication tool.

show 1 reply