Full Stack Is Back! Elixir & Phoenix LiveView

Full Stack Is Back! Elixir & Phoenix LiveView

Scott Hickey September 08, 2022
Full Stack Is Back! Elixir & Phoenix LiveView

As front-end, back-end and hosting technologies have become more complex over time, the concept of a full-stack engineer had faded. Elixir and Phoenix LiveView reverses that trend.

Lately, hiring a true full stack software engineer has felt like the proverbial unicorn search. It sounds like it should be easy. Developers just need to know three things: JavaScript, AWS and server side REST using Java or Python. What’s the big deal?

Unfortunately, mastering just one of those areas turns into a full time career. As developers, we’ve become desensitized to blog posts with titles like “The 40 Best JavaScript Libraries and Frameworks for 2022”. The running joke used to be, just wait 5 minutes and another JavaScript framework is born. However, practitioners of server side development languages and frameworks shouldn’t throw rocks at the glass house: Java 8/9/11/17/18, Maven, Gradle, SQL, NoSQL, Hibernate, JDBC, jOOQ, Jackson, Spring Boot, Micronaut, Guice Checkstyle, PMD, Sonar, Clover, JaCoCo, JHipster, Lombock, Apache String/Number/Date/ BeanUtils, HTTP clients, Quartz, Logging, POI, FOP, iText, Akka, vert.x, RxJava, JUnit, Spock, JBehave, H2, Geb, JMeter, Gatling…I could go on.

Thank goodness we now have the cloud to make our lives so much easier: Lambda, Step Functions, EC2, Containers, Virtual Network, SQS, SNS, DynamoDB, S3, RDS, Cognito, API Gateway, Kinesis, ELB, ElastiCache, DevOps, Security, IAM, monitoring… and of course it is very easy run and test all of this on your workstation.

Complexity is The Culprit

For even the simplest applications, the starting position for modern applications is frustratingly complex. For several years now, I’ve been amazed watching intelligent professionals in this industry accept and promote this complexity into nearly every single application that we build. It seems like we’ve forgotten about the distinction between essential complexity and accidental complexity. Every application will have some inherent complexity driven by the application domain and the requirements like a responsive UI, data storage and access, etc… The problem is, the accidental complexity of browser side, server side and cloud platform frameworks now dwarfs the essential complexity of even the most basic applications. For those of us who have managed some proficiency in all the technical complexity, we seem to wear the accomplishment like a badge of honor.

As engineers, wouldn’t it be better not to have all of this stuff in the first place?

Less is More: Elixir and Phoenix

Elixir is a modern programming language that lowers the barrier to entry for functional programming. It was designed to be an approachable language for all developers while providing the legendary reliability and scalability of the Erlang runtime. Using an expressive language like Elixir results in less code that is easier to comprehend. This has proven to be a powerful foundation for building modern web applications. Companies like BleacherReport have scaled to millions of users while reducing their cloud footprint by 95% after they migrated to Elixir from Ruby on Rails.

Phoenix is a powerful web framework built on top of Elixir. It enables the productivity and features that most developers expect from a modern web framework. What isn’t typical is Phoenix LiveView. Watch this 4 minute video to understand how LiveView delivers SPA performance and responsiveness without the complexity of a Javascript SPA framework.

Delivering a responsive web app using Elixir and Phoenix LiveView feels great. Drastically reducing the complexity of the typical web application architecture will be a shock the first time you build a LiveView app. Deploy your app using only one artifact - into the cloud using Gigalixir or Fly.io, and it almost feels like cheating to deliver such rich functionality with so little code.

Developer Bliss

Recently, I built and deployed a production application for a customer using a stack that was refreshingly simple. It was a small web application that checked all the modern boxes:

  • Single Page Application responsiveness
  • API integration
    • Accessed government per diem reimbursement rates using a public API
    • Accessed the customer’s SaaS sales system API for pulling and pushing data
  • Utilized a SQL database for data not stored in the SaaS system
  • Deployed into the cloud

The combination of Elixir and Phoenix LiveView enabled me to write a performant UI using just HTML, CSS and Elixir. It enabled me to build server-side code that accessed APIs and a SQL database using only Elixir. All of it could be unit tested using Elixir, without the need to simulate cloud based services on my workstation. I implemented the full stack without worrying about React, Spring or AWS. The results were fantastic. The application had Single Page Application responsiveness yet required no JavaScript. Only one artifact was deployed to the cloud using a GitHub pipeline. The experience was pure joy.

What To Expect

If you’re a developer who has never used a functional programming language, it can be uncomfortable at first. As Paul Graham pointed out over 20 years ago, “programming languages vary in power”. You may find yourself looking up the power continuum and thinking Elixir is “weird”. It is hard because “programming languages are not just technology, but what programmers think in”. However, the rewards are powerfully satisfying and there’s a reason why developers who use functional programming languages wax rhapsodic about it. Once you get it, you have moved up the power continuum, and you’ll never want to go back.

If you’re a manager wondering about Elixir, take a look at “Ten Companies That Use Elixir in Production”. The stories in this blog post highlight reducing cloud footprint by 95% and delivering world-class apps with small development teams; they are compelling. Also, I encourage managers to read Paul Graham’s essay “Beating the Averages”. This essay is a wake-up call for understanding how a more powerful programming language can enable productivity that is not matched by the “average” corporate IT shop. Just as significantly, it also addresses why developers are resistant to change.

Getting Started

As an experienced developer, my favorite tutorial to date has been Dave Thomas’ “Elixir for Programmers” video course. It is worth it to work through each exercise; he does a great job of guiding you down the path of thinking differently. For a more in-depth course, take a look at the excellent Pragmatic Studio LiveView course.

It’s been a long time since I’ve thought it was fun to build a web application. Elixir and Phoenix LiveView have put the fun back in doing full-stack web development.

Scott can be reached here: