Which features Elixir copied from Clojure?


#1

Hi guys,

I was wondering how similar both languages are in features and if Elixir.

Which one is better for web apps in your opinion and why? I know it is hard to deploy.
Not talking about JVM vs VM otp, for comparison, only the language and it’s features.

Is Elixir a Clojure with Ruby syntax?

Thanks.


#2

I’m a big fan of Elixir.

First, you should read my blog post here: https://www.rubberducking.com/2017/01/when-to-use-elixir-over-clojure.html?m=1

The major consideration between Elixir and Clojure should actually be the JVM vs the BEAM VM. Which my blog post covers.

On the language itself, it is Clojure inspired in some places. None of the features are identical per say, but you’ll find many equivalences for things like homoiconicity, AST macros, protocols, lazy sequences, persistent data structures, keywords, etc. Even the names of a lot of functions and keywords in Elixir are the same as found in Clojure.

If you want to know more details about where they differ, I’d refer you to my Quora answer here: https://qr.ae/TW7fuV

When it comes to Web Apps, I think they’ll be pretty similar. Though there’s going to be more available libraries and frameworks for Clojure. Also, if you are interested in doing heavy JavaScript work, or building SPAs, ClojureScript comes in really handy.

I wouldn’t say Elixir is Clojure with Ruby syntax, no. I’m also not sure Clojure can be Clojure without the Lisp syntax, but even if, there’s still enough differences that its not a fair claim to make in my opinion.


#3

Thanks for your input!! I really appreciated!!

I just read on Elixir forum that is way easier to develop a web app on Phoenix than with JS/Node/Express, saying is way faster, then I say this tutorial generating a lot of the code.

It’s about that or it has more features than what is shown on this video?

Does Closure/any framework/libs has it’s features?


#4

Unfortunatly, I don’t have experience with Node/Express or Pheonix, so I can’t speak to them.

Some things to keep in mind:

  • Elixir is a server side language only. Thus it is best suited for server side rendered web apps.
  • With Elixir, you will still need a client-side language, if you intend to have client side functionality. I think some people pair it with Elm, and a lot of folks seem to just use JavaScript and React with it.
  • If you know Rails or Ruby, Elixir will be much more familiar to you then Clojure[Script].
  • If you don’t know functional programming, and have no experience with Lisp syntax. But you do know OOP, and have experience with Algol syntax like JS, Python, C#, Java, Ruby, etc. Elixir will be much more familiar to you then Clojure[Script].
  • Clojure[Script] can be used on the server and on the client. So it is a full stack language. But there are various tooling required for each, which complicates the matter unfortunatly.
  • Elixir is much more beginner friendly. There’s a lot of resources, and the maintainers focus quite a bit on beginners.
  • Elixir is much more a beginner friendly version of Erlang with familiar Ruby syntax. Though in the process, it did improve on some warts of Erlang. So it is inherently designed to attract more users to the BEAM, where Erlang is considered to be too strange and unfamiliar to become popular. Thus, its goal was to be easy and familiar to Ruby devs. While Clojure[Script] is a concurrent and functional Lisp with immutable first design for the JVM, CLR and JS runtimes. As you can tell, nothing here is supposed to be familiar or easy, and that was never the point. It is for people who already know that they want a concurrent, functional, and immutable Lisp for the JVM, CLR or JS. These people tend to be expert. Experts rarely ask what framework they should or shouldn’t use, and you’ll find a lack of guidance in Clojure[Script], or a large amount of mixed messages, because experts all have their own prefered mechanism, if not their own personal framework, and don’t like to just use what’s most popular.
  • TL;DR of the above bullet: Know what you are getting into. Elixir carves an easy trail to hike through the BEAM and Erlang mountain. It’s a relaxed and welcoming hike, where you’ll enjoy the beautiful sceneries of OTP, Actors, Immutability, Functional, Keywords, Sequences, Protocols, etc. Clojure[Script] is a rock solid set of hiking/climbing gear which will allow you to hike and climb off-trail and come up with your own shortest paths to the summit. It’s a hard climb, with steep walls along it, especially in the beginning. You’ll get lots of adrenaline rushes along the way, and if you make it to the top, it will be most rewarding.
  • From what I heard, Pheonix is a quite complete framework, close to Rails. I’m not sure anything like it exist in Clojure[Script]. In Clojure[Script] you’ll have to pick and choose and self assemble most things on your own.

Also, if you are already familiar with Node/Express and JS, and proficient in them. I’m not sure Elixir or Pheonix will make you any more productive. Standard SSR web apps productivity tends to come from how well you know a set of particular frameworks and libs. There’s no hidden magic in Pheonix or any other which somehow build apps for you. That said, it can be argued that the BEAM VM is a superior runtime to Node. It can theoretically scale to handle very high throughputs. And it offers more support in those scenarios, with a battle tested set of libs and patterns in OTP, as well as a by design Actor model, which can make scaling much simpler and less error prone.

Clojure can also be argued to scale to high throughput better then Node, due to the JVM having a similar history of being used and designed for these high scale scenarios. Against BEAM, it’s harder to say which one has a true edge. They follow different models, but the JVM is less opinionated, and offer more choice of models. BEAM forces you into an Actor model, for better or worse. Also, it can be argued the JVM, and Clojure, will in general have lower latencies, at least for CPU or GPU heavy work. So you can get more mileage vertically out of each machine. I wouldn’t split hairs about it though, its not the difference between Ruby and C.

One last thing, ClojureScript also runs on Node. It can target most JS runtimes. The throughput and latencies arguments above were related to JVM vs BEAM vs Node. With Clojure[Script], again, you have more choices. You can go with the JVM or Node (and maybe even make use of Express?). In which case, it brings immutability, functional programming, various concurrency constructs, homoiconicity, and Lisp’s syntax, meta-programming and interactive development capabilities to the Node ecosystem, as well as its own set of libraries and frameworks. If you know Node already, and are looking to learn and make use of any or all of these, ClojureScript on Node can be an attractive path. You won’t be familiar with ClojureScript, but you will with Node. Where in Elixir, you will find it more familiar as a language, but won’t be as familiar with BEAM.

Hope this all helps.


#5

Amazing thanks!!

I really appreciated your help and input.


#6

Here Halgari dicusses even more details about the differences between the two VMs: https://www.reddit.com/r/Clojure/comments/5q2gmi/convince_me_to_use_clojure_over_elixir/dcvvqtt/