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
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.
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.
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
You could say Elixir inherited it’s mother’s (Ruby’s!) good looks, but has the mindset of its father (Erlang!)
A bit like me actually …just kidding
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
I haven’t looked at Clojure for a while …does it use
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
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.
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!
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!)