From Ruby to Elixir
Unleash the Full Potential of Functional Programming
by Stephen Bussey
Elixir will change the way you think about programming. Use your Ruby
experience to quickly get up to speed so you can see what all of the
buzz is about. Go from zero to production applications that are
reliable, fast, and scalable. Learn Elixir syntax and pattern matching
to conquer the basics. Then move onto Elixir’s unique process model that
offers a world-class way to go parallel without fear. Finally, use the
most common libraries like Ecto, Phoenix, and Oban to build a real-world
SMS application. Now’s the time. Dive in and learn Elixir.
Whether you’re a seasoned Ruby developer looking to expand your skill
set or a programming beginner looking for a solid foundation in Elixir,
this book has what you need to get up to speed quickly. Elixir is a
functional language with a fairly small footprint. This makes it easier
to learn and put into production than other languages. Plus, it’s built
on forty-year-old foundations that give your applications rock-solid
stability.
The first part of this book is all about developing expertise in the
language. Learn about the core data types, build application data
structures, enumerate over data, and use pattern matching to control the
flow of an application. Elixir has an amazing process model that allows
for (actually) easy parallel processing. Learn how to tap into this
process model so you can leverage that power yourself.
The second part of this book builds a real-world application using the
most important libraries in a web developer’s toolbox. Each library is
compared to its similar Ruby library so you’ll quickly see similarities
and differences. We’ll use Ecto, Phoenix, and Oban to build a SMS
application powered by Twilio.
What are you waiting for? Tap into your Ruby knowledge and start
building scalable Elixir applications today.
What You Need
You’ll need Elixir 1.14+ and Erlang/OTP 24+ installed on a Mac OS X,
Linux, or Windows machine.
Resources
Releases:
2024/06/03
P1.0
First printing.
2024/01/26
B4.0
*Added chapters 9 and 10.
*The book is content-complete and headed to copyedit and indexing.
2023/11/15
B3.0
*Added chapter 8.
*Project changed from using Twilio
API to a provided mock server, due to
SMS regulation changes.
*Twilio registration section removed from chapter 7.
*UI Templates for project updated. Follow instructions in chapter 8 to get a clean version of the project.
*These changes only affect minor parts of the project prior to chapter 8. Existing material is not affected.
2023/08/31
B2.0
*Added chapter 7.
*Small updates based on your submitted feedback, thanks and keep it coming!
- Introduction

- Fundamentals of Elixir
- Why Elixir? Why Now?
excerpt
- The Joy of Ruby
- The Case for Elixir
- Erlang, OTP, Elixir, and Friends
- Install Elixir on Your Computer
- Write Your First Elixir Code
- Wrapping Up
- New Language, New Syntax
- The Big Picture
- Data Types
- Operators
- Module and Function Basics
- Fun with Functions
- Capturing Functions
- Advanced Module Keywords
- Compile Time vs. Runtime
- Wrapping Up
- Working with Data
- Lists—Not Arrays
- Maps—Your Data Layer Foundation
- Implementing Data Structures
- Enumerating Data Structures
- Wrapping Up
- Pattern Matching Your Way to Success
excerpt
- Pattern Matching Basics
- Use Patterns for Control Flow
- Level Up Your Functions
- Wrapping Up
- GenServers: Build Cities, Not Skyscrapers
- Parallelism vs. Concurrency
- Explore Elixir Processes
excerpt

- Go Parallel with GenServers
- Be Parallel, Be Cautious
- Build Cities, Not Skyscrapers
- Wrapping Up
- Tools of the Trade
- Persisting Data with Ecto
- What Will We Build?
- The Foundations of Ecto
- Write an Ecto Schema
- Use Migrations to Create Database Tables
- Use Changesets to Persist Data
- Query Data with Ecto.Query
- Put Everything in a Context
- Wrapping Up
- Serving Requests with Phoenix
- Explore the Foundations of Phoenix
- Route Requests Through Phoenix
- Serve Requests with Phoenix Controllers
- Manage Static Assets
- Use Components to Keep Your User Interface Clean
- Phoenix Is More Than Controllers
- Wrapping Up
- Outbound HTTP Requests with Req
- Decide on Which HTTP Client to Use
- Prep Your Project for Req
- Use Req to Make Requests
- See Your App in Action
- Wrapping Up
- Asynchronous Jobs with Oban
- Understand Async Job Systems
- Explore Asynchronous Jobs in Elixir
- Implement an Oban Worker
- More About Oban
- Wrapping Up
- Testing Elixir
- Create Your First Test
- Test an Ecto Query
- Test External API Requests
- Test Phoenix Requests
- Test Oban Jobs
- Wrapping Up
- The Future of Elixir
- Deployment and Observability
- Real-Time Apps with LiveView
- GraphQL with Absinthe
- Machine Learning with Nx and Bumblebee
- Type Systems
- Wrapping Up
- The End of Our Journey
Author
Steve Bussey is a software architect turned startup founder. He led
the introduction of Elixir to an all-Ruby team, resulting in successful
adoption of Elixir. Now, he uses Elixir to build his startup—Supered.
He wrote Real-Time
Phoenix,
which teaches readers how to build scalable real-time Elixir
applications. Steve is passionate about sharing Elixir due to the
positive impact it has had on how he designs and develops applications.