3 ms·
1. LISP is an ideal language for code generation. For example, producing high quality C code (e.g., arthur whitney or djb's, imo); this is difficult or tedious
by ised 13y ago
1. LISP is an ideal language for code generation.
For example, producing high quality C code (e.g., arthur whitney or djb's, imo); this is difficult or tedious when done "by hand" but can be made easier by using code generation. There is a beautiful conciseness and consistency to the "model" C code I prefer (e.g. by the above authors). It is well-suited to being generated by a "custom interpreters" and a "DSL". Next to Flex, LISP is my personal favorite for constructing such a code generation system.
Python devotees already follow a similar path when they use Cython. But what do you think the quality of the generated C code is like? Have a look at it.
2. LISP is also a great prototyping language. The final application may not be written in LISP. Or at least parts of it might be in other languages.
Selecting from a limited collection of libraries written (perhaps poorly) by others, as is done with many popular languages, strikes me as a "top-down" approach, not building from the ground up. The collection of libraries defines what you can and cannot do. Now, if you just want to do what everyone else is already doing, this is perfectly acceptable. However if you want to break new ground, you will likely have to write some functions yourself. And, personally, I'd rather do this in LISP.
Maybe it's better to learn to use SWIG or a similar codegen tool and wrap any C library function of your choosing for use in LISP, or Lua, or another language that lacks "batteries"?
It's encouraging to me when I see programmers express dislike for LISP in online forums. Because I take it as a sign that this is a worthwhile language to master. I've seen similar expressed distaste for what I know to be good quality C code. It goes something like this: Programmer at large in online forum can't understand [insert code/language], therefore [said code/language] is somehow defective.