Hacker News new | ask | show | jobs
by copsarebastards 4125 days ago
> And, you do realize that one of the simplest languages for compiler writers, lisp, doesn't have to move heaven/earth to make that calculation work out how you want it.

I've written a C compiler and am currently writing a Lisp compiler, and I'm not sure where you get the idea that Lisp is a simple language for compiler writers. Lisp's simple representation belies a very complicated runtime, to the point that the majority of Lisp implementations don't support compilation at all--they're interpreted only.

1 comments

This seems to get back to the other debate that crops up with "simplest." Just because I posit that it is one of the simplest languages, does not mean I imply it is by definition simple.
I'm pretty comfortable with asserting that there's no reasonable definition of "simple" which would make a mature Lisp compiler simpler than a mature C compiler.
Fair, though I am focusing on the less mature situations. Specifically, a naive lisp evaluator is much easier than a C compiler.

Are there any mature compilers, for any language, that would qualify as simple?

> Specifically, a naive lisp evaluator is much easier than a C compiler.

That's true, but a naive Lisp evaluator is a) not a compiler, and b) not correct. A naive implementation of Lisp leaks memory very rapidly, and obvious memory management schemes fail. Garbage collection was invented for Lisp to deal with these problems, and even assuming an immature implementation, GC isn't trivial. The simplest implementation of mark-and-sweep garbage collection requires a lot of discipline to make sure that objects are correctly allocated so that in-scope objects are kept live and out-of-scope objects are discoverable as dead. Even if you're writing your own allocator for C, that allocator is pretty trivial in comparison.