alice

alice

Hey,
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.

Showing Posts 1 to 10

kokolegorille

kokolegorille

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

hauleth

hauleth

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.

lpil

lpil

Creator of Gleam

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:

alice

alice OP

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

sfusato

sfusato

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).

NobbZ

NobbZ

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.

lpil

lpil

Creator of Gleam

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).

sribe

sribe

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.)

hauleth

hauleth

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.

sribe

sribe

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.

Where Next? Top

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2977 92995 915
New
caslu
I want to open this thread for you all to discuss and help those who really like Ash but are still hesitant to use it in a real project. ...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
Herve37
We’re evaluating API mocking tools for OpenAPI-based projects and would love to hear what other teams are using. We’re particularly inte...
New
GES233
I’m posting this in response to Jose’s recent tweet (Cr. link) : People are sleeping on Elixir for a coding harness: Hot-code swappi...
New
_mfierro
Hello, I wrote Stop My Hand, a Scattergories-like web application using Phoenix/LiveView as my learning project for Elixir (after readin...
New
nseaSeb
AcmeScript — Writing JS hooks as if I were still using Elixir I’ve been having fun building a little something over the last few days: Ac...
New

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New
webofbits
Aludel - LLM Evaluation Workbench Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews