stratacast

stratacast

Elixir vs Ruby on Rails

I don’t really know how to frame this because I’ve never used Ruby, or Rails, or even looked much into them. I have been avidly working with Elixir these last couple months, and was exposed to it some time last year. So this question comes from complete ignorance of any of the Ruby world.

To my understanding, Elixir is to Ruby as Phoenix is to Ruby on Rails. Is this assessment correct?

The reason why I ask is because in my company there is an interest in Erlang/OTP but no interest in Elixir because Elixir == Rails. From my time in Elixir and my reading, that does not seem correct. However, I want to provide accurate information. When I look at comparisons, pages come up doing comparisons according to my original assessment. I don’t understand the disdain for RoR, but in the applications I’ve been working on, Elixir has been an incredible language and I want to show that Elixir is worthy of consideration (though there really wouldn’t be anything wrong per-se going with raw Erlang)..so in relation to all this, is there a reason why someone who would dislike RoR also dislike Elixir? Syntax aside, since apparently Elixir has a lot of Ruby syntax influence.

Most Liked Responses

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

That is essentially correct, although Phoenix is a lot less of a monolithic framework than rails.

This is definitely wrong. Elixir is a programming language, not a web framework. It doesn’t contain a web framework at all.

I think it’s just the syntax. People see Elixir’s syntax, they see the Ruby influence, and they jump to the conclusion that Elixir “Rubified” Erlang. This is simply not true. Elixir is a function language with immutable data and 0 overhead with respect to the equivalent Erlang, equivalent code compiles to equivalent byte code.

14
Post #2
hauleth

hauleth

Well, actually there is httpd in OTP.

Rails is framework that is actually built from few libraries:

  • ActiveSupport
  • ActiveModel and ActiveRecord
  • ActionView
  • ActionPack

Other parts are helper modules for different aspects and do not really need to be included. In fact even ActiveModel and ActiveRecord aren’t really required parts.

So there is few tightly connected libraries that cannot live without each other (especially almost everything rely on ActiveSupport).

On the other hand Phoenix is just a helper library for Plug with few macros for simpler routing definitions and sockets handling, other than that there is really nothing “big” in it. Even the storage layer - Ecto - is completely independent, and while there are some people working on both, the projects aren’t related to each other in any way. For example most controllers in phoenix can be simplified to:

defmodule MyApp.Controllers.Foo do
  @behaviour Plug

  @impl true
  def init(opts), do: opts

  @impl true
  def call(%Plug.Conn{params: params} = conn, _opts) do
    action = Phoenix.Controller.action_name(conn)
    apply(__MODULE__, action, [conn, params])
  end

  # … 
end

Of course it is very simplified as there is few more things like setting default layout and view or calling Plugs defined within the controller, but very simple version of controller can look like that and for Phoenix there will be no difference, as there in reality is no more magic.

tristan

tristan

Rebar3 Core Team

As someone who prefers Erlang to Elixir I can without a doubt say that their concerns are not valid. If they are interested in Erlang/OTP there is no reason not to consider Elixir, esp if they already have someone at the company who has been working with it.

From the outside looking in on both Rails and Phoenix I’ve seen there is concern about how Rails becomes essentially its own language to learn. Like a Ruby person can’t just jump into a Rails project and a Rails person can’t just jump into a Ruby project. I don’t know how true this is but I do know that it isn’t the case with Phoenix.

Sure, I think the Plug macro pipeline is confusing to read coming from Erlang but that’s about it – again very limited Phoenix exp and no Rails exp, so take this with a grain of salt.

That all said – Elixir/Phoenix is not like what happened with Ruby/Rails – definitely nothing wrong going with straight up Erlang :). Tooling and integration with Elixir projects has improved a lot. I saw someone mentioned Adopting Elixir so I’m obligated to mention Adopting Erlang booksite :slight_smile:

Where Next?

Popular in Discussions Top

vans163
So useless benchmarks aside, Its possible to write a webserver that can serve 300k requests per second (perhaps more with optimizations)....
New
Nvim
Elixir appears to be a superior language to Python. I don’t see any advantage of Python over Elixir. Are there any?
New
Fl4m3Ph03n1x
Background This question comes mainly from my ignorance. Today is Black Friday, one of my favorite days of the year to buy books. One boo...
New
arcanemachine
https://nitter.net/josevalim/status/1744395345872683471 https://twitter.com/josevalim/status/1744395345872683471
New
AlexMcConnell
The reason that Rails is as popular as it is is because it’s very easy for relatively inexperienced developers to get a lot of work done....
588 19568 166
New
fireproofsocks
I’ve been working on an Elixir project that has required a lot of scripting. I usually reach for Elixir because I like it more (and in th...
New
PragTob
Hey everyone, this has been brewing in my head some time and it came up again while reading Adopting Elixir. GenServers, supervisors et...
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
Qqwy
I would like to spark a discussion about the static access operator: .. For whom does not know: it is used in Elixir to access fields of...
New
pdgonzalez872
If this has been asked here before, please point me to where it was asked as I didn’t find it when I searched the forum. Maybe a mailing ...
New

Other popular topics Top

lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30877 112
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 47930 226
New
marick
I had some trouble figuring out how to make many-to-many associations work. Once I got it working, I wrote a blog post. Because I’m a nov...
New
hariharasudhan94
Lets say i have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => "XXX...
New

We're in Beta

About us Mission Statement