We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
In this episode, hosts Ben and Jacob discuss why Elixir is their go-to choice for building web applications at Hired Gun Apps. They explore Elixir's history, its benefits, and how it compares to other popular web frameworks.
Elixir, a language built on top of Erlang, was created to address some of the limitations and complexities of its predecessor. Erlang, developed in 1986 by Ericsson, was specifically designed to solve telecommunication problems, focusing on concurrency and fault tolerance.
Erlang's primary strength lies in its ability to handle massive concurrency and provide the fault tolerance necessary for robust, scalable systems. For instance, in telecommunication, a high number of voice channel processes wouldn't crash an entire server but might only drop a single call. This robustness is due to Erlang running on the BEAM virtual machine, which is known for its lightweight processes and efficient memory management.
Elixir, while building on this strong foundation, introduces modern and expressive syntax similar to Ruby, making it more accessible to developers. This modernization has attracted many developers from the Ruby community, especially as Ruby on Rails has seen a decline in popularity.
Elixir's syntax and development experience stand out for their readability and simplicity. Unlike JavaScript, which often involves long, complex functions, Elixir allows for clean, concise code. One of the key features contributing to this is the piping mechanism, which simplifies chaining functions, making the code easier to read and maintain.
For developers transitioning from object-oriented languages like C++ and Java, moving to Elixir's functional paradigm can require a shift in mindset. However, once this transition is made, many find the functional approach to be a cleaner and more efficient way of writing code. The transition is not as daunting as it might seem, especially for those already familiar with other functional languages like Rust.
Overall, Elixir offers a fun and clean coding experience, making it a compelling choice for modern web development.
At HGA, we often utilize the PETL stack for our projects. PETL stands for Phoenix, Elixir, Tailwind CSS, and LiveView, with PostgreSQL as our database.
Phoenix is a web framework built with Elixir that offers a productive and scalable foundation for web applications. This framework allows us to harness Elixir's strengths, such as concurrency and fault tolerance, making our applications robust and efficient.
Tailwind CSS is a utility-first CSS framework that provides predefined classes for building custom user interfaces. This allows for rapid UI development without the need for extensive custom CSS.
LiveView, another key component of the PETL stack, enables real-time interactive web applications without requiring extensive JavaScript. This means we only need JavaScript for specific tasks like page transitions or minor client-side state management. The combination of these technologies allows us to build powerful, responsive applications efficiently.
Elixir and Phoenix significantly enhance web application performance, primarily due to their server-side rendering capabilities. Server-side rendering takes the rendering load off the client-side JavaScript, making applications faster and more efficient.
For instance, while rebuilding our HGA website, we noticed a substantial performance improvement when using Elixir and Phoenix compared to other frameworks like Svelte. Pages loaded faster, and the user experience was smoother.
Additionally, server-side rendering improves SEO performance. Since the pages are pre-rendered on the server, search engine bots can crawl and index them more effectively. This leads to better search engine rankings and increased visibility.
Overall, the combination of Elixir's concurrency model and Phoenix's efficient rendering engine results in faster, more reliable web applications that perform well under load.
Elixir allows for rapid prototyping and development, even with a small team. You can have a one-person team build a full-stack, responsive web application with real-time updates quickly. For example, I recently started experimenting with the ASH framework and, despite being new to it, I was able to almost complete an entire blog system with an admin panel in just a few hours. This included creating and editing blog posts.
While some might argue that platforms like WordPress offer out-of-the-box solutions, Elixir's code-driven approach provides much more control and customization. This means you can tailor your application precisely to your needs. The benefits of Elixir become more apparent as your project grows, offering unparalleled flexibility and speed in development.
Elixir excels in handling concurrency and fault tolerance, thanks to its foundation on the BEAM VM. Each user interacting with your website operates in their own process. If something goes wrong, only that process crashes, not the entire system. This isolated failure and automatic process restart mechanism ensure high availability and reliability.
For instance, when websites built on platforms like Shopify go viral, they often crash under heavy load. Elixir, however, manages this gracefully. Each user’s interaction is isolated, preventing widespread failure. BEAM VM automatically restarts processes, minimizing downtime to mere lags instead of system-wide failures.
Combining Elixir’s concurrency and fault tolerance with Phoenix’s productivity allows for robust and scalable web applications. This combination ensures your applications can handle high traffic and provide a seamless user experience.
Elixir stands out in terms of cost and scalability, especially when compared to other popular backend frameworks. The BEAM VM, which powers Elixir, offers remarkable concurrency capabilities, making it highly efficient for handling numerous simultaneous connections. This efficiency translates to lower server costs because fewer servers are required to manage the same amount of traffic.
A notable example is Bleacher Report, which migrated its backend from Ruby to Elixir. This transition resulted in a 95% reduction in server costs. They went from using 100 servers to just 5, showcasing the immense savings and scalability benefits Elixir provides. This kind of performance improvement is hard to achieve with other frameworks.
Moreover, Elixir’s ability to handle high concurrency with minimal hardware makes it an excellent choice for businesses looking to scale without incurring exorbitant costs. Even for developers accustomed to frameworks like React, Svelte, or Angular, switching to Elixir can be a refreshing experience due to its ability to solve many common issues out-of-the-box.
In conclusion, Elixir's scalability and cost-efficiency make it a powerful contender in the backend framework space, providing significant advantages over traditional options like Node.js and Ruby.
Elixir has proven its worth in various real-world applications, showing how versatile and powerful it can be. One of the most prominent examples is Bleacher Report, a major sports media company. They migrated their backend from Ruby to Elixir, which resulted in a dramatic reduction in server costs and enhanced performance.
Interestingly, the Bleacher Report team was not composed of Elixir experts when they made the switch. They learned Elixir on the job, which speaks volumes about the language's accessibility and ease of adoption. Despite the initial learning curve, the team managed to achieve significant performance gains and cost savings.
Another example is Pinterest, which uses Elixir for its real-time notifications system. The language's concurrency model and fault tolerance features make it ideal for handling the high volume of notifications sent to millions of users. This ensures that the system remains reliable and performant, even under heavy load.
These examples highlight Elixir's capacity to handle demanding applications efficiently. Its adoption by well-known companies underscores its reliability and effectiveness in production environments.
Elixir hasn't seen widespread adoption because it isn't as battle-tested as Node.js. Senior developers often feel more comfortable with technologies that have a longer track record.
Despite its many advantages, including lower costs and superior concurrency and fault tolerance, Elixir hasn't gained the traction it deserves. People are reluctant to change their systems and update them, even though Elixir offers a better way to handle backend processes.
Many of the problems solved by Phoenix, Elixir's web framework, remain unaddressed in other technologies. A new web framework seems to emerge every week to tackle these issues, but Elixir offers a more stable and efficient solution. However, the lack of comfort and familiarity among senior developers hampers its adoption.
Elixir is highly beneficial for startups and small businesses, contrary to the belief that it’s only for giant enterprises. One of the biggest expenses for startups is hosting costs, and Elixir helps mitigate these significantly.
For example, a multiplayer game running on Elixir can serve 10,000 users with just one server in North America, without even fully utilizing it. Scaling for other regions is as simple as popping up a server nearby, making it cost-effective and efficient.
Elixir's ability to handle large loads with minimal resources makes it ideal for startups looking to scale without incurring high costs. Its concurrency model and fault tolerance ensure that your application remains reliable and performant, even under heavy load.
Join Ben Kimble and Jacob Luetzow on the Big App Energy podcast for more insights on leveraging Elixir for your tech startup. For more episodes, check out the Podcast | Hired Gun Apps.