If Ruby has really slow performance how come Elixir is fast?

I’ve listened to a couple tech talks explaining how Ruby was super slow prior to Rails and I am wondering, if Elixir’s syntax is partially inspired from Ruby, how come Elixir is fast? Thanks.

Don’t look too much at the syntax, they are completely different…

  • Ruby is interpreted, Object oriented

  • Elixir is compiled, Functional language.

If You want speed with Ruby syntax, You might look at Crystal


Languages do not have “speed”, never. Implementations of interpreters/compilers have “speed”. And syntax is part of the language, which mean that this do not affect the performance in any way.


While the syntax is similar more or less everything else works very differently to Ruby, generally in ways that are faster than the approach that Ruby has taken. Thankfully syntax doesn’t have any impact on performance :slight_smile:


Hmm, interesting.
But if syntax doesn’t affect performance then why does minifying JS/HTML/CSS code allegedly help with performance?

Minifying JS/HTML/CSS code doesn’t help with performance other than the browser can start interpreting it a bit faster (being smaller in size it gets downloaded faster).


Keep in mind, that those languages are also distributed in source, and that syntax does not affect runtime speed, but parsing speed.

And then we also have languages like HTML and CSS that do not have “runtime” speed at all, they are parsed into an internal representation once. Then it’s more or less a static database that gets queried. Only JS makes HTML change, and then the complexity of the databases affect how fast the JS can do it’s job.


It impacts how long it takes to parse and load the code. In the browser this matters because it happens on every page load! With Ruby or Elixir it doesn’t matter because this happens once before the user has a chance to interact with the program (as it’s not yet serving traffic).

That’s not really true, as semantics of a language restrict the implementations in ways that deeply affect performance.

For instance in our dynamic languages (Ruby, Erlang/Elixir, Python, Javascript) all “objects” are open maps, which means that every access to an element has to go through some kind lookup. While in C++/Rust/Java, instead of calculating a hash or walking a tree, the same operation is a fixed offset into a single chunk of memory.

Similar differences apply to calling functions. (And modern Javascript JIT goes to great lengths to optimize away those differences; but there are still vestiges of overhead left at runtime.)


Still, reflection and run time changes are possible in most of these languages anyway (even in C/C++ as we can clearly see in Erlang via NIFs). So I would still say that in the end, the syntax and semantics have almost no impact on the performance, especially in JITed VMs that are already hot.

1 Like

Of course you can build those things in C/C++ (after all, that’s how the BEAM/JVM/Ruby runtimes are built). What you cannot do is get the low-level performance of doing without those in Erlang, Elixir, or Ruby. And you can’t really get them in the Javascript VM, because it still has to allow for the flexibility of change. (As opposed to the Java VM, where you really can get that performance after it’s hot.)

So yes, the semantics of the language absolutely do impose requirements that are reflected in performance, and some of them have huge impacts on performance.


Looks can be deceptive :lol:

You could say Elixir inherited it’s mother’s (Ruby’s!) good looks, but has the mindset of its father (Erlang!) :003:

A bit like me actually …just kidding :043:


Honestly I’d say Elixir inherited more from Clojure than Ruby!


Had Elixir not been invented, I’d probably be using Clojure…

[EDIT] and I mean I’d be happy doing so

1 Like

I haven’t looked at Clojure for a while …does it use def ends?

I think that’s why many people feel Elixir resembles Ruby because on the face of it, without digging deeper, it looks like Ruby the most. Similarly, Phoenix feels quite a lot like Rails in many ways too.

Whether intentional or not, I personally think it was a great move - Ruby and Rails have a very strong following precisely because of these ‘shared’ features/appearance :smiley:

Clojure is a lisp dialect and therefore just uses parentheses.


It’s a Lisp, so very different syntax. The semantics and tooling of the languages are similar in many ways though


Elixir is what you get if Erlang, Ruby and Clojure had a baby and it wasn’t a mistake.

To be more specific in Elixir we have Erlang semantics, Ruby syntax and Clojure’s macros and protocols.


You are right. Crystal is the better option if we want speed

This somewhat depends on what the workload is. For IO bound tasks I would bet the BEAM can perform better as Crystal’s concurrency features and garbage collection are not quite as mature, and they don’t yet have parallelism.

1 Like

Sorry Louis the post you were replying to got deleted - there was a post in the review queue that looked like spam and the user’s IP was different to the location set in their profile (classic spam pattern) so I rejected post and chose the delete account option, which would result in any other posts they made being deleted as well if below a certain threshold. I hope they weren’t a genuine user! :icon_redface:

I’ve added their post into yours as a quote though, but can remove your post as well if you would prefer.

(If the deleted user is reading this and you are in fact not a spammer, please email us to get you set back up - sorry for the inconvenience!)

1 Like