4 ms·
> Haskell, OCaml, probably F# too. Lisp has macros, read-macros, and eval. These things enable DSLs. You're saying strongly-typed functional languages have
by SeanLuke 7y ago
> Haskell, OCaml, probably F# too.
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?
- hopia 7y agoWriting EDSLs (E for embedded) is fairly common in Haskell. I don't know if it's as easy as with Lisp macros though since I have no exposure to that. Many DSLs are written on Haskell (Elm and Purescript come to mind) as well.
- pjmlp 7y agoYes, for example F# has quotations, type expressions and type providers. 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.
- fmakunbound 7y agoThose are so distant to what Lisp macros achieve. Also, I can't believe you brought up Java annotations in this discussion.
- pjmlp 7y agoThey are, but as they say back home, those who don't have dogs, hunt with cats.
- marcosdumay 7y agoHum... Yes. 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.
- fmakunbound 7y agoIt's all about ergonomics though. In Lisp, it's super easy, and even fun with macros. They can probably do roughly equivalent things in the other languages, but it's so fucking painful it's relegated to rare use and for relatively short code sections. For Lisp users, it's like holding the knife by the handle. For them it's like holding the knife by the blade.