Why are Erlang and Elixir such powerful languages?
Erlang was invented to solve a problem. You need to put this in contrast with programming languages in search of a problem. You can not go out, invent a language and then figure out what they are good for. When inventing a language, you need to have a problem domain or use case in mind and by prototyping in iterative processes, reduce the pain points felt by developers working on that problem. This is what makes Erlang so powerful.
Elixir has just turned ten. Despite there being over 30 languages running in the Erlang Ecosystem, it has steadily been gaining traction and is today the most popular one. It differs to Erlang because of the tooling, which encourages a top-down development approach. The package manager encourages reuse of modules and libraries together with frameworks focused on web development and APIs for mobile applications. Its ruby-like syntax induces a sense of familiarity among many of its developers coming from a Ruby background and top class documentation all reduce the barrier to entry and ensure productivity from day one. What has happened with Elixir is that they have taken the power of Erlang, and made it even more powerful by providing a development environment and documentation standards a large group of developers are familiar with.
What are the most common use cases for the Elixir language?
The most common use case, focused on the Phoenix framework, opens the door to developing APIs, mobile backends and websites. Everyone in the ecosystem is using Phoenix for their front-ends. Bleacher Report was one of the first companies to lead the way, migrating their Ruby stack to Elixir, and reducing their hardware footprint by 90%. It would have been more had they not needed extra hardware for redundancy. The Nerves framework opened the door to embedded developers, providing a platform to build, deploy and manage systems which run and control these devices. Farmbot is a great example of a Nerves application, allowing users to engage with precision farming whilst reducing and optimizing resource consumption. Check out their really cool youtube videos if you want to learn more. And finally, keep an eye on the Machine Learning space in Elixir. The components to build Machine Learning frameworks are being put in place, and when paired up with the BEAM Virtual Machine and Nerves, they will be able run in Edge networks and IoT devices. Whilst early days, follow the development of the Axon ML framework on github, as use cases will be announced soon.
Why is Elixir Erlang based?
This goes back to the problem Jose Valim was trying to solve when he created Elixir. His purpose was wanting to bring the power of Erlang and the BEAM to other communities of programmers, starting with the Web, but then moving on to other domains, including embedded and machine learning.
What are the most common Erlang use cases?
Erlang was created to program the next generation of telecommunication switches, at a time when telecom markets were being deregulated, monopolies broken up and privatized and networks digitalised, merging fixed and mobile voice telephony, media and internet into the same infrastructure. That meant that systems Erlang was created for had to be scalable, resilient and handle peak loads predictably whilst keeping support and maintenance costs under control. When the internet came along, pretty much any online system had to display those features. A website would have to predictably go from handling a few page impressions per second to thousands when a page got posted on a popular site, an SMS aggregator would have to deal with an influx of millions of SMSes during TV competition votes or a stock exchange would have to handle tens of thousands of simultaneous buy and sell orders during turbulent markets. Today, we see Erlang (and languages in the Erlang ecosystem) being used in mobile app and website backend development, bank switches, messaging solutions, IP router control systems, 5G network exchanges, blockchain and crypto, massively multiplayer online games, ecommerce solutions, online advertising and video streaming. The list could go on, but I hope you get the picture. They are all systems, which whilst doing very different things, do so having to handle the load reliably, predictably and without failing, and without costing a fortune in maintenance or infrastructure. All of these properties are by default inherited by Elixir.
What is the development time for an erlang based app vs. elixir?
It depends on the problem you want to solve and the frameworks you use. Elixir tends to have more components and frameworks, and as such, more dependencies. You pull them in through the hex package manager, and whilst doing so, lose the flexibility and control on how things are done, but achieve time to market. In Erlang, you tend to work from the ground up, solving complex algorithms and problems, and if successful, glue them together. This gives you more flexibility on your final architecture, and more control, but takes longer.
What is the runtime performance of an elixir based app versus pure erlang?
Elixir is compiled to Erlang, so performance is not an issue. You choose Erlang and Elixir not for speed of execution, but for speed of development. That said, user friendly interfaces towards libraries written in other languages(often C or Rust) where you can offload CPU and GPU intensive computations are being developed (Look at Numerical Elixir https://github.com/elixir-nx/nx), or JIT compiler allowed WhatsApp to reduce its hardware needs by 25% https://twitter.com/wcathcart/status/1385253969522413568 are all making the ecosystem faster. Fast enough these days to start running machine learning algorithms.
What are the machine learning use cases for elixir?
With Axon, I believe they will be targeting similar use cases as PyTorch, but doing so with the accessibility and ease of use you find in Elixir. Think of computer vision and natural language processing, but doing so at the source of your data, in an easy to use framework. This means you do not have the overheads of transporting your data, and can easily run your training algorithms or apply your models in the embedded devices or Edge networks themselves. This starts making sense now that we are gathering more data every year than all previous years put together. It is getting expensive to move this data, so instead, move the compute to the data. Give the community six months, and many of the early adopters will hopefully start talking about their case studies. Right now, it is still too early, as the frameworks and libraries are still being developed.
Can you build api’s and web apps with elixir? Is it good for mobile apps for backend?
Yes, absolutely. These were some of the first use cases, targeted by the Phoenix framework. Phoenix is seen by many as the next generation of Ruby on Rails, with a difference that it scales. WhatsApp achieved two million TCP/IP connections on a single (modified) BEAM VM running on (an also modified) Free BSD in January 2012 (https://blog.whatsapp.com/1-million-is-so-2011). The changes made their way to mainstream OSes and to the BEAM, allowing a Phoenix instance to run with two million simultaneously open Web Sockets on AWS in 2015 (https://phoenixframework.org/blog/the-road-to-2-million-websocket-connections). Phoenix would have scaled further, but what stopped it was the network limitations imposed on them by AWS, as the instance they were using was not maxed out.
Frontend for mobile apps?
No, Elixir is a language for backend. But interesting things are happening in the front-end space with Phoenix LiveView. It provides server-side rendered HTML. Those who have been around a while will see it as history repeating itself. And those who are new to programming will love it, as it allows them to work with front-end in the backend using a language they enjoy working with, with all of the safeguards.
Leave a Reply