3 ms·
Lisp is everywhere because compilers use ASTs?
by CurtHagenlocher 12y ago
Lisp is everywhere because compilers use ASTs?
- progman 12y agoProbably because more people realize how powerful Lisp actually is.
- AnimalMuppet 12y agoLisp uses ASTs. Not all uses of ASTs are Lisp, though. And no matter how many people realize how powerful Lisp is, all ASTs still won't be Lisps. People realizing that Lisp is powerful does not fix the underlying logical fallacy.
- progman 12y agoI didn't claim that Lisp's CST (concrete syntax tree) is equivalent to C++'s AST. I just wanted to point out that more and more modern languages adopt features of Lisp, or try to embed Lisp. C++ praises lambda expressions as new feature while this feature has been around in the Lisp world for more than 50 years. Background information about CST/AST: http://lambda-the-ultimate.org/node/1040 http://lambda-the-ultimate.org/node/1040
- AnimalMuppet 12y agoYeah, that bugged me, too. Lisp code is written as an AST? True. C++ (and other) compilers convert code to an AST? Also true. Therefore "No matter if you are programming in Python or C++, Lisp is invariably what holds up the scaffolding behind the scenes. This is true because Lisp is the Lingua Franca of your compiler"? Non sequitur (literally, "it does not follow"). That logic boils down to "A is a C, and B is a C, therefore A is a B". No, it isn't. It would be equally (il)logical to claim that "B is an A", that is, that Lisp was a C++ compiler.
- greyfade 12y agoIn my reading, it appears to be an assumption based on GCC, which apparently uses lisp-like code to represent its AST. (Is this true? I don't know, I haven't looked.)
- jobu 12y agoSome references or more examples of compilers that use Lisp would be helpful. It was my understanding that compilers used tools based on LEX & YACC (Flex & Bison for GCC). The author mentions Clang, but Google couldn't find anything definitive that says Clang uses Lisp internally. http://dinosaur.compilertools.net/ http://dinosaur.compilertools.net/ http://www.tldp.org/HOWTO/GCC-Frontend-HOWTO-3.html http://www.tldp.org/HOWTO/GCC-Frontend-HOWTO-3.html
- thegeomaster 12y agoIt only has to do with the internal usage of ASTs (abstract syntax trees) within compilers. Lisp code can be likened to an abstract syntax tree, and GCC just uses the familiar Lisp indenting rules and parenthesis syntax to output its ASTs. Therefore, I don't think compilers really use Lisp internally, it's just that they boil the code down to a form that resembles Lisp and can be conveniently output as so.