5 ms·
The idea of the m-expressions might be coming back though, two of the popular newcomers are homoiconic languages (depending on your definition), Elixir as a fun
by ddragon 7y ago
The idea of the m-expressions might be coming back though, two of the popular newcomers are homoiconic languages (depending on your definition), Elixir as a functional programming language and Julia as an imperative CLOS inspired language.
Being not as powerful (able to create any valid syntax due to more complex and rigid parsing rules) and trivial to manipulate code as data as s-expression is considered a feature, as it helps preventing the proliferation of language extensions while still allowing them when their benefits outweighs the costs. Even the main elixir metaprogramming book starts with saying: "the first rule of macros: don't use macros", and in Julia you have to attach a @ to call a macro to make it clear that the normal rules of the language do not apply ahead. Those languages also focus in providing everything the user needs without the use of macros, which are for more advanced purposes.
While people who use Lisp eventually see the advantages of s-expressions (or at least of writing more idiomatic code in those languages), being attractive to new users coming from the more popular languages is very important (and like clojure interoperate with java, it might be even easier to make a lisp that has perfect interoperability with Elixir for example, so both groups can coexist).
- _delirium 7y agoRe: "trivial to manipulate code as data as s-expression is considered a feature" Although Julia goes further in other directions, just changing the surface syntax of s-expressions, like this proposal, doesn't really interfere with this feature. With alternate syntax, you can still write macros and stick to the code-as-data idea in pretty much the same way. In Lisps with a programmable reader (like Common Lisp and some Schemes), you can set up the reader to recognize something like foo[bar,baz] as an sexp, and once read, it'll be represented internally exactly as if (foo bar baz) had been read with the default reader. Then any macros and even code-walking code continue to work the same as before.
- ddragon 7y agoI meant that macros being a little harder to use and the result being a little more restricted is the feature, a small protection against the Lisp Curse (if every custom language is just as good as the base language, then no one can agree what the base language should be). Kinda like newer languages kinda avoid inheritance because while it's powerful, it's kinda easy to misuse (though Elixir special 'using' macro is a fantastic simple way to share behavior between modules). And while programmable reader macros allow Lisp to have any syntax you want, they go even further in producing heterogeneous environments in which not even the parsing rules are shared. But you can't just only know the algol/infix way of programming in Lisp since you'll have to see other people code and documentation, and when you use these alternate parsers/extensions other people have to understand the quirks of your unique parser/extension before understanding your code. Everyone using the exact same language is definitely a feature, and those languages (and clojure who dropped programmable reader macros and asks people to use macros more judiciously) have a point in their belief. But as a curiosity, Julia also has it's own version of reader macros [1], which can be used to give it s-expression syntax [2]. [1] https://docs.julialang.org/en/v1/manual/metaprogramming/#Non-Standard-String-Literals-1 https://docs.julialang.org/en/v1/manual/metaprogramming/#Non... [2] https://github.com/swadey/LispSyntax.jl https://github.com/swadey/LispSyntax.jl
- breck 7y agoI think you’ll appreciate Tree Notation, which is a dead simple “base language”, that I think we will get people to agree on.
- logicprog 7y agoI don't think Elixir is homoiconic.
- ddragon 7y agoYou're probably right, I didn't really go deep in with the macros, mostly just injecting code with 'quote' to remove occasional boilerplate. The point was more about the ability to easily manipulate the code within the code to create DSLs (like Ecto for SQL) in a "lispy" way, which Elixir is notably good at. In that sense we can add D, Rust and Nim as well, all somewhat recent languages that also provide that feature.
- logicprog 7y agoYeah I had just read some stuff about Elixir not being homoiconic and wanted to just point that out (in essence, I was being pedantic), it doesn't really ding your point.