> In terms of syntax flexibility, Ruby has a similar issue where a lot of popular libs implement their own DSLs.
Of course in ruby, nobody is actually adding new syntax, although that's a common misconception. Ruby DSL's are still just ordinary syntax for method calls and block parameters, there's no new syntax at all. Sometimes it can look like it, maybe because ruby method calls don't require parentheses? But no library truly adds syntax to ruby, they just define methods that can be called.
I am not familiar with elixir, I am curious if what we're talking about is an ability in elixir to truly add new syntax, or something more like Ruby so-called "DSLs".
Correct. You can't add new syntax to Elixir either.
FWIW, the meta-programming models are very distinct. Elixir's is based on AST and it works at compile-time (like Lisp but without reader macros). For example, imagine you want to do your html markup in Elixir, you could do this (but don't!):
html do
title "hello world"
body do
...
end
end
In the above, `html` would be a macro that looks at the structure of the code and transforms it into something at compilation time. The macro must exist before being invoked and it has to literally surround the code it changes. Once the code compiles, you can't change it.
Ruby's meta-programming is runtime-based. So the same example above would likely be implemented by calling methods on an object, either pre-defined ones or using method_missing, as you execute the code. In Ruby you can also define (or redefine) methods at any time and it affects the whole runtime.
Both languages also have a similar ability to meta-program a class (in Ruby) or a module (in Elixir). Think Rails' resource macro in a router. But Elixir modules are closed, in contrast to Ruby classes. Many times this is what people refer to as DSLs, even though the term DSL in itself is more general. Python has similar abilities too.
PS: you are certainly aware of the Ruby bits but I went for completeness to be a reference for others. :)
> Of course in ruby, nobody is actually adding new syntax, although that's a common misconception.
This is the argument I usually use for anyone who has a problem with it yet if they've already decided they don't like it, it doesn't do much to pursued them. On the other hand, being able to rewrite operators in Ruby does take it a bit in that direction—While not strictly new syntax, changing the meaning of an operator can really throw people off. As an example in the standard library, there is `Dir[]`. `Dir[]` is a shortcut to `Dir.glob`. Sure, it's technically doing some kind of access, but everyone knows it as hash access and certainly aren't accustom to passing a pattern to it. Elixir libs do stuff like this.
And I'm sorry, I don't know if can actually add new syntax in Elixir, but you can certainly change the meaning of existing syntax (as in Ruby).
Of course in ruby, nobody is actually adding new syntax, although that's a common misconception. Ruby DSL's are still just ordinary syntax for method calls and block parameters, there's no new syntax at all. Sometimes it can look like it, maybe because ruby method calls don't require parentheses? But no library truly adds syntax to ruby, they just define methods that can be called.
I am not familiar with elixir, I am curious if what we're talking about is an ability in elixir to truly add new syntax, or something more like Ruby so-called "DSLs".