top | item 6978793

(no title)

chattoraj | 12 years ago

pg wrote about this years ago.

>If you understand how compilers work, what's really going on is not so much that Lisp has a strange syntax as that Lisp has no syntax. You write programs in the parse trees that get generated within the compiler when other languages are parsed.

source: http://www.paulgraham.com/avg.html

discuss

order

jesstaa|12 years ago

It's as if lisp was originally designed to be an intermediate language for computer generated parse trees....and not a language for people to read.

vog|12 years ago

If you say "S-expressions" instead of "LISP", this is perfectly true! The syntax of S-expressions was only meant to be used for LISP data structures, while programming was meant to happen in another syntax called "M-expressions" [1], which was to be converted to S-expressions by the compiler. However, the programmers liked to use S-expressions directly, so M-expressions were never actually implemented.

In that sense, the LISP syntax (S-expressions) were ideed designed as an intermediate language, not to be used by programmers directly (except for plain data structures).

[1] https://en.wikipedia.org/wiki/M-expression

goldenkey|12 years ago

It's not as if..it is truly the case. That's why only nutters use LISP for large projects. Who really wants to wrap every S-Expression in parenthesis? Talk about painstaking and what an eye-sore. If only M-Expressions caught on, LISP could be decent. But really, it's just making you write your program as a data structure because that makes it easier for the compiler to process.

So...

Ruby: good for developers, bad for the JIT compiler (slow)

LISP: awful for developers, good for the compiler -> machine (fast)

Is the tradeoff worth it? Not at all. Most LISP intros start by convincing you that you'll eventually get used to your code looking like a sack of parenthesis. No thanks, I shouldn't need to get used to staring at overburdened verbosity for the compilers' sake - build something better. Wait..we have other languages that are fast and look nice. And many even process into a well-formed AST. Okay, thank heavens.

velis_vel|12 years ago

Yes, and he's still wrong. You don't write 'directly in parse trees', you write in text that gets converted to parse trees. The conversion is very simple, to be sure, but it still exists.

Chattered|12 years ago

When writing an S-expression of Lisp code, you're just one quote symbol off writing the list literal that evaluates to the code's parse tree. Modulo whitespace, the parse-tree prints as code.

That's what we mean when we say you write directly in parse-trees. You're writing the string representation of those parse-trees.