Some of you mentioned pattern matching, but it is not an Elixir’s feature. I think we want features that Elixir brings on top of Erlang. For me, it’s the mix toolings. Makes lots of tasks easier.
- pattern matching is present in swift
- guard clause as well
- i believe in Erlang is present in ABBA?!
- the BEAM exists in Erlang too
- josevalim is present in … ruby?!
- mix, bundle, npm, yarn … same same, but different?
Is there really a unique Elixir feature?!
All languages just take things from Lisp, the more features they add, the closer to Lisp they actually want to be. ^.^
It’s Greenspun’s Tenth Rule:
“Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp.”
The concurrency version says:
“Any sufficiently complicated concurrent program in another language contains an ad hoc informally-specified bug-ridden slow implementation of half of Erlang.”
Is that Robert Virding’s tenth law then?
No, it’s Virding’s First Rule. With all respect to Greenspun.
Pattern matching is first found in Prolog, which has pattern matching with backtracking. Prolog is an AI programming language but there is no easy way to write functions incorporating logic and enumeration. Elixir puts all the best features from many languages together.
Let it crash.
That is a BEAM feature, not Elixir though. ^.^
Same with pattern matching and so forth.
Come on, Macros are a fantastic Elixir feature, it does it better than most languages by far.
I consider these three the unique things about Elixir:
- How it makes a functional programming something easy to learn for imperative/OO programmers, I’m an example of it!
- How it became a full-featured and well tooled functional programming language, joining all the full-featured OO language features so gracefully, without becoming a Frankenstein.
- The community behind it is awesome and it’s growing, but not just in quantity, in quality too! People like @rvirdind, @pragdave and even @joeerl diving in the language is always a good sign!
A feature of the BEAM is a feature of Elixir since Elixir runs on the BEAM.
You can’t port Elixir to another platform by abandoning things like pattern matching or processes. It wouldn’t be Elixir any more. It would be like removing objects (or at least interfaces) from Java. Pattern matching and processes are all part of the language. The particular way they are implemented is not (for pattern matching the current compiler and for processes a shared-nothing userspace concurrency).
Elixir was designed around the constraints of BEAM. Early prototypes did not fully embrace the runtime and it was not a practical language because of this. Since Elixir was explicitly designed around and for immutability, processes, message passing, code reloading, …, I would say all of these features that are originally from the runtime are also Elixir features.
If Elixir was designed for another platform it would be a different language. Elixir has some specific constraints that, I believe, only exist because the runtime imposes those constraints, for example the limited set of expressions in binary expressions, limited set of guard functions, limited set of types, etc. The runtime constraints are good because the make it easier to build concurrent applications, gives us high reliability, fast pattern matching, fast concurrent GC and so on.
Well this says a single feature in ‘Elixir’, just like I would not say a feature of Java is GC, that is a feature of the JVM, not of Java, Java could easily be ported to something without a GC after all (the
dispose pattern for example), Java is the language, just like Elixir is the language, not the features that the BEAM brings it. Thus the macro’s is an awesome Elixir feature, it is not a BEAM feature.
Well, thinking a little bit more, the question is kind of unfair if you do not ask it for the other languages:
- Is there really a unique Java feature? A VM? Erlang has it too, and a lot earlier.
- Is there really a unique Go feature? The ability to compile to many different platforms? Hmmmm, C with a better syntax?
- Is there really a unique JS feature? It runs in your browser? I do not consider it a feature of JS, actually I really consider this is a bad thing. It’s a shame that W3C do not invest the time http://webassembly.org deserves.
- Is there really a unique Ruby feature? Matz? Well, this is not a feature, people die (sorry for killing Matz, but I don’t know how to express it better), and I guess that there is nothing Matz would want more than to ruby continuing alive after his death.
My conclusion is: there is a lot of languages that do not have a unique feature, which have added no single “feature” to the world and just copied a lot of the features from another language, and that’s OK.
Why be bothered by something like that? We do have a lot of features that born in other languages, and that’s awesome! And also, we do not have features that other languages do. And that’s awesome too, it depends on your point of view!
Only in PHP can you see
"010" == "1E1" being true!
I am sorry to have been misunderstood…
I know how unique Elixir is. And I really like it a lot.
It did a good job to introduce me to the BEAM, something I could not do through Erlang. Even if I start to like Erlang more and more… It did also introduce me to FP, actor model, process programming.
I was just playing devil’s advocate because I felt topic was light (What if…)
BTW Coming from Ruby world, where everything is object, I find refreshing to think different.
But why? Even if I re-interprete the string contents as numbers, it were
8 == 10.
Also, it seems as if
("010" == "1E1") != (010 == 1E1) holds.
"010" == 010 is false,
"010" == 10 is true…
1+2+"3" == 33 is true…