Acknowledgments....10
Introduction....12
Who Should Read This Book?....13
About This Book....14
About the Code....15
Online Resources....16
Part I. Fundamentals of Elixir....17
1. Why Elixir? Why Now?....18
The Joy of Ruby....19
The Case for Elixir....21
Erlang, OTP, Elixir, and Friends....25
Install Elixir on Your Computer....29
Write Your First Elixir Code....31
Wrapping Up....33
2. New Language, New Syntax....35
The Big Picture....36
Data Types....38
Operators....41
Module and Function Basics....44
Fun with Functions....49
Capturing Functions....54
Advanced Module Keywords....57
Compile Time vs. Runtime....61
Wrapping Up....63
3. Working with Data....65
Lists—Not Arrays....66
Maps—Your Data Layer Foundation....71
Implementing Data Structures....77
Enumerating Data Structures....80
Wrapping Up....86
4. Pattern Matching Your Way to Success....88
Pattern Matching Basics....90
Use Patterns for Control Flow....97
Level Up Your Functions....104
Wrapping Up....110
5. GenServers: Build Cities, Not Skyscrapers....111
Parallelism vs. Concurrency....113
Explore Elixir Processes....118
Go Parallel with GenServers....126
Be Parallel, Be Cautious....132
Build Cities, Not Skyscrapers....134
Wrapping Up....136
Part II. Tools of the Trade....138
6. Persisting Data with Ecto....139
What Will We Build?....141
The Foundations of Ecto....145
Write an Ecto Schema....148
Use Migrations to Create Database Tables....155
Use Changesets to Persist Data....160
Query Data with Ecto.Query....165
Put Everything in a Context....175
Wrapping Up....178
7. Serving Requests with Phoenix....181
Explore the Foundations of Phoenix....182
Route Requests Through Phoenix....188
Serve Requests with Phoenix Controllers....193
Manage Static Assets....203
Use Components to Keep Your User Interface Clean....206
Phoenix Is More Than Controllers....212
Wrapping Up....214
8. Outbound HTTP Requests with Req....217
Decide on Which HTTP Client to Use....219
Prep Your Project for Req....224
Use Req to Make Requests....227
See Your App in Action....231
Wrapping Up....234
9. Asynchronous Jobs with Oban....236
Understand Async Job Systems....238
Explore Asynchronous Jobs in Elixir....243
Implement an Oban Worker....248
More About Oban....256
Wrapping Up....259
10. Testing Elixir....261
Create Your First Test....263
Test an Ecto Query....268
Test External API Requests....271
Test Phoenix Requests....275
Test Oban Jobs....281
Wrapping Up....285
11. The Future of Elixir....287
Deployment and Observability....288
Real-Time Apps with LiveView....290
GraphQL with Absinthe....291
Machine Learning with Nx and Bumblebee....292
Type Systems....294
Wrapping Up....296
The End of Our Journey....298
Bibliography....300
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.
You'll need Elixir 1.14+ and Erlang/OTP 24+ installed on a Mac OS X, Linux, or Windows machine.