Hacker News new | ask | show | jobs
by cbd1984 4125 days ago
Depends on how you define simple:

If something is simple for the compiler-writer, then simple things do yield simple results.

If something is simple for the programmer, simple things often yield quite complex results.

For example, in a language that's simple for the compiler-writer, (1/10) times 10 is only very rarely 1. 0 is a common answer, as is some fraction which is almost, but not completely, unlike 1.

In a language which is simple for the programmer, Heaven, Earth, and minor deities will be moved to make (1/10) times 10 come out to the obvious, simple answer.

1 comments

It really only depends on if you define simple as "can only derive simple results."

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.

> 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.

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.