Why We Moved from Ruby to Elixir

We do the coding, so you don’t have to. Ironically, to keep the Betty Blocks platform quick and easy-to-use for no-coders, we still need professional programmers to write a lot of code. Recently, Betty Blocks made the switch from Ruby on Rails to Elixir. “How come?” many of you asked. Senior developer Paul Engel has the answer. 

Why_Betty_Blocks_Switched_From_Ruby_to_Elixir

The Betty Blocks platform allows both individuals and enterprise-organizations to build complex applications. Although users can create fully functioning software without using any code, at the base of our platform still lies a programming language. Last year we moved to Elixir as our new powerful engine under the hood, and there are some well-founded reasons for that. 

Warning: this might get technical...

01 It allows us to serve an extensive user base

Our founders originally built Betty Blocks in Ruby. But as more and more people started using our platform, we have rewritten the Ruby codebase in accordance to the more sustainable and flexible Elixir. The Elixir language was designed for building scalable, fault-tolerant, and maintainable applications. Let us explain this with a quick dip in the relatively short history of this programming language. 

Elixir was created by software developer José Valim, a member of the Ruby on Rails core team. He noticed that Moore’s law was no longer applicable to software development. Back in the day, the speed of computers and memory would double every two years. That meant that, the code that you wrote would potentially be two times as powerful two years later.

New call-to-action

Those days, you only needed one central processor that went faster, but now - with software increasingly running from the cloud - you’re dependent on a variety of processors. And this profoundly changes the way we write software. It also means that some of the main programming languages - dating back from those good old days - aren’t as effective as they should be. 

 So, back in 2011, Valim started working on Elixir as an alternative for the programming community. It was created to solve all the programming challenges that developers are experiencing right now (like confusingly long strings of spaghetti code, or the need for constant debugging). Elixir started from an open source environment that gave everybody the chance to join in with creative ideas, contribute to, and share the language. 

“I believe that Valim was searching for a programming language that represented a faster and more reliable successor to Ruby,” says Paul Engel, senior software developer at Betty Blocks. “That’s why he chose Erlang VM as the basis for his new language.” 

Erlang VM was originally built by Ericsson in 1986 to improve telecom applications. It was used to connect telephone networks as it allows many nodes to connect in a high concurrency environment. Erlang VM was designed to have the highest uptime while also being as light as possible. This made it one of the most mission critical languages of its day. In 1998, Erlang VM was released as a free and open source software. And Elixir is regarded as the bridge that connects Erlang VM to the Ruby ecosystem. 

With Erlang at its base, Elixir has the potential to connect many existing applications. As of today, the internet is still quite scattered. You can find anything on there, but it’s still in silos. There are apps that are specialized in specific tasks, but there is no one app that can do EVERYTHING - yet. In order to create software that is able to connect to a massive variety of different databases and APIs, you need a powerful language. And Elixir brings the dream of an all-encompassing application closer to reality.

 

02 It improves our cloud computing capabilities 

“Elixir is a great language to have a very large number of connections (in both directions) open all the time,” explains Engel. “Right from the start, Erlang was designed to build concurrent, distributed systems that are mission critical. It was created in support of Ericsson’s telephone switching business and was vital in keeping the system running. You see, in Europe, regulators will fine phone companies when their systems are down for more than a couple of minutes a year. So uptime and reliability play an essential part in keeping a telecom business afloat.”

One of the major advantages of Elixir is that it allows you to write distributed software - i.e. software that runs on more than one machine. You can start the session on one computer, and finish it on the other. This also allows multiple people to work on the same app at the same time, from different locations. 

“The Betty Blocks platform is 100% cloud-based,” says Engel. “That means that building applications happens from within the browser. Apps on the platform are not the result of generated code, but are simply 'configurations' on our platform.”

“With this setup, we removed the need to tie a specific app to a specific piece of hardware. In terms of scaling, this results in the possibility that Betty Blocks could scale up servers at any given moment, for all apps. We have auto-scaling enabled on our infrastructure, so as soon as we detect high load on the infrastructure, we automatically add new servers.”

Furthermore, with Elixir, you don’t need a powerful computer to run your apps: “It can run the software on any type of computer, whether it’s a Raspberry Pi Zero (a $5 computer) or a 40 Core Server.”

Engel continues: “It allows many devices and users to connect to the same program, and only needs one server to accommodate up to 2 million users. Because of Elixir, what previously required 100 servers, now only takes 2. Recently, the developers of freeware platform Discord even managed to use Elixir to scale their system up to 5 million concurrent users.” 

 

03 It’s one of the most functional programming languages

As mentioned earlier, Valim and his crowdsourced contributors explicitly designed Elixir to be the most functional programming language to date. Functional programming promotes a coding style that helps developers write code that is short, concise, and maintainable. 

Functional programming language in general benefits from the fact that code written in them is easier to reason with in terms of correctness and completeness. Moreover, the Elixir environment offers features as hot code reloading (updates without downtime) and dynamic recompilation (i.e. meta programming).

By being a functional programming language, Elixir is able to fully utilize modern multi-core processors, maximizing resource utilization on off-the-shelf (i.e. commodity) hardware and virtualized environments.  

Because of its programming finesse and scalability, Elixir is the driving force behind a lot of large-scale applications. WhatsApp is one of the most successful use cases of Elixir, scaling to almost 1 billion active users with only 50 engineers. 

Another company well-known for using Elixir is Pinterest. It uses Elixir to route more than 30.000 events per second to its in-house rule engine for preventing spam. With more than 200 million active users, Pinterest also uses Elixir to power its rate limit service with sub-millisecond response times in its API endpoints.

 

04 It’s the magic potion! 

It goes without saying that we’re very glad we made the switch to Elixir. We see it as the magic sauce that allows us to elevate our platform as a whole. Whether it’s Actions, Web Services, the Page Builder, or the Data Model, each component is accelerated when it’s driven by Elixir. It has made our platform more reliable, more stable in performance, powerful, scalable, and therefore, more future-proof. 

The results speak for themselves. Engel: “For each Betty Blocks component we transformed from Ruby to Elixir, we achieved over 200% increase in performance. In some cases we increased it by 500%. On top of that, our Elixir codebase needed just 30% of the current Ruby servers we run. Because of the lightweight processes, we can do more computing, and there is a significant increase in performance and stability. ”

So there you have it. Elixir is smart, fast, reliable, and highly scalable, just like our no-code development platform! Naturally, it’s our audacious goal to work towards a future in which we can stop coding altogether. But, as of now, if we had to choose a programming language, Elixir would always be our top choice.

The Developer's Manual of the Betty Blocks Platform