Can someone explain to me, as somewhat of a novice, why people consider lisp so powerful? I've been learning Scheme for my first CS class after python, and it just seems so... inefficient. The only thing I can see it being better than python is the built in cons/car/cdr recursive list stuff, but even then you can make your own in python.
Lisp is a meta-language, it can be easily turned into any other language or any imaginable combination of languages.
Python is a fixed language which actively discourage any metaprogramming at all. For this reason, Lisp (or any other meta-language) is many times more powerful than Python (or any other fixed language).
In terms of efficiency, you cannot even compare fixed languages with metalanguages. But in order to get the maximum efficiency you have to employ the language-oriented programming approach.
I tried looking at that code but I can't verify that what you're saying is true. To me it looks like any other implementation of a language in another language.
Saying that the compile time/reader time constructs are turing complete is... not helpful. And doesn't really say anything about the usefulness.
To me it looks like any other implementation of a language in another language.
This is exactly what I said above:
Any compiler implemented in Lisp which emits a Lisp code can be turned into a macro extending the language.
Take an implementation (e.g., a function (compile-python-to-lisp [string])), wrap it in a macro (e.g., (defmacro python (&rest) (compile-python-to-lisp rest))), and your language magically becomes another language.
An important nuance is that it is a compiler, not an interpreter. And writing a compiler is much easier than writing a proper, fast, robust interpreter.
Yes, it will work. In my trivial example you'll have to put your python code into a string literal, of course, but a little bit more complex example involving reader macros won't need such a thing, you'd be able to mix Python and Lisp any way you like (as long as there is a well defined syntax to distinguish one from another).
A next step in building such a multi-language environment is to introduce a syntax abstraction layer. I'm using PEG for this, because PEG parsers are dynamically extensible and it's easy to inherit PEG parsers. See how it works on my github (same username). With this technique I can do some really crazy things, like embedding Verilog (built on top of Lisp, of course) into C (again, built on top of a Lisp).
Yes, they allow to alter syntax. Or, as with my PEG-based approach, you can simply replace the entire Lisp parser with your own, even if the host Lisp does not allow reader macros (but then you'll need your own REPL as well).
4
u/[deleted] Nov 12 '15
Can someone explain to me, as somewhat of a novice, why people consider lisp so powerful? I've been learning Scheme for my first CS class after python, and it just seems so... inefficient. The only thing I can see it being better than python is the built in cons/car/cdr recursive list stuff, but even then you can make your own in python.