by agentultra · 6y ago · 0 comments
Can also do 'bare metal' as well.
I think the advantage to Lisp is that the programmer can generate and evaluate arbitrary expression trees at run time.
I'm not sure about the others but I recall Haskell has some difficulty with this. It's possible but it's not supported and not trivial to do.
That's the one! Code is data - data is code. While this can be done in other languages, it isn't done without considerable effort or going 'off road' so to speak, macros are Lisp. cheers.
Is there anything special Lisp does to prevent user input from getting into eval'ed data-code? Or any sandboxing provided by Lisp's eval?
The most annoying part was that what they wanted to do didn’t even require eval and they refused to fix it even after I’d found a safe, non-eval way to do it.
Lisp has macros, read-macros, and eval. These things enable DSLs. You're saying strongly-typed functional languages have features of equivalent power for this purpose?
Also .NET has attributes, compiler plugins and expression trees, which allow to do some kind of similar stuff even for C#, although not as straightforward as in Lisp.
On the Java side, you also get the attributes (aka annotations), compiler plugins, AOP (yay CLOS interceptors).
Haskell has Template Haskell and OCaml has ppx extensions.
Many DSLs are written on Haskell (Elm and Purescript come to mind) as well.
For Lisp users, it's like holding the knife by the handle. For them it's like holding the knife by the blade.
Not exactly equivalent, but monad-based DSLs have almost the same power as Lisp macros.
You can't escape the syntax restrictions, the same way you can't escape Lisp's syntax restrictions. And it's a bonus for Lisp (in power) that its syntax is much more flexible. But in semantics they are equivalent.