Elixir is functional Ruby?

twitter logo github logo ・1 min read

"Elixir is functional Ruby"

I just started digging into elixir and ecosystem and can't get this description for elixir off my head. So I decided to start a discussion here, so I can get opinions of experienced Ruby developers writing elixir, and also elixir devs.

My reasons

  • syntactic similarities
  • Elixir like Ruby has a MVC web applications framework phenoix

What do we think about this?

twitter logo DISCUSS (4)
markdown guide
 

I haven't spent a ton of time with it, but it seems a lot more like Ruby-flavored Erlang than functional Ruby. When I think Ruby, I think OOP, the two are inextricable. An Elixir program is going to have much more in common with an Erlang analogue than a Ruby one. A "functional Ruby" would suggest to me something more like what Scala is to Java, that builds on an OOP base and provides a rich set of functional programming tools as well, and not so much something that involves such a total paradigm shift to use.

Just my $0.02.

 

The most powerful feature of Elixir is OTP and the BEAM, both from Erlang. OTP is a framework to write distributed systems and BEAM is the virtual machine where light processes run. Elixir is much more than just a nice syntax inspired by Ruby. In fact, it's a common misconception to think that Elixir is an "improved Ruby". Firstly because Ruby has its own advantages and different purposes, and secondly because Ruby isn't the only inspiration for Elixir. About Phoenix, I recommend reading dockyard.com/blog/2015/11/18/phoen...
I hope this summary can be helpful :)

Edit: to better understand what BEAM/OTP can provide, I recommend watching youtu.be/JvBT4XBdoUE

 

Elixir, by its own admission, has some nice Ruby-flavored syntax working in its favor. I'd argue that Phoenix isn't as similar to Rails as I thought it would be based on what people told me. They're both MVC but Phoenix feels different enough to me to stray a little ways away from the Rails comparison (as compared to, say, Sails in JavaScript). They share enough that makes it a less imposing leap to make, at least.

Overall, I feel like writing Elixir code has a much different feel than writing Ruby code. Most of this probably has to do with learning my first functional language after having learned object-oriented languages for five years. Pattern matching, recursion as a go-to before looping, working through linked lists — I never dealt with these things much at all before learning Elixir.

Elixir has the feel of its own personality, its own voice separate from Ruby. Granted, I did start with Elixir 1.8, so perhaps it was more comparable to Ruby in earlier versions. I am beginning to cross over from enjoying Elixir over Ruby at this point, however. Its interpreter is in a league of its own, and its built-in build tools are incredibly refreshing. Elixir project structures make more natural sense to me than any language I've learned so far.

Also, I started learning Elixir after returning to college for a CS degree, so maybe the functional programming style is striking a bigger chord for me than it would have a couple of years ago when I was just doing self-taught hobby projects.

 

The macro stuff in Elixir, which does seem to be used fairly regularly by the community, is pretty much straight outta CommonLisp.

Also, although Ruby and Elixir don't have a ton in common, Rails and Pheonix certainly do.

If that makes any sense

Classic DEV Post from Apr 8

Learn To Fold Your JS Arrays

Learn about the Fold, a powerful functional programming pattern, by making it from scratch

Prosper Opara profile image
I have over 2 years experience building web applications, on-campus developer communities, and contributing to open source.

A blogging community of over 100,000 software developers Join dev.to