Take Off With Elixir

Build fault-tolerant, scalable, fast and resilient applications with Elixir.

Watch a Preview

Red:4 Video Edition
Available as an MP4 video with over 3 hours of top-quality, concise, tightly-edited content from the creators of Tekpub.com.

Red:4 Book Edition
Also available as an ebook with over 150 pages of lovingly edited, beautifully laid-out Elixir content. You get all three formats: epub (for iBooks) mobi (Kindle) or HTML (full site).

Red:4 Code
All of the code in the book and video is available to you in our company Github repository. You can download individual chapters, or checkout with Git.

What You Will build

Our science team needs an astrophyics library, and you're going to build it. We need to:

  • Calculate equations for our prototype orbiter, including Escape Velocity for the Earth, Moon and Mars, Orbital Term, and Orbital Acceleration.
  • Track Solar Flare Activity using Ecto and PostgreSQL
  • Store Planet information with Mnesia
  • Use OTP to DDoS our PostgreSQL database so we can oust our new CTO

This is not a tutorial where you get to sit back and watch us code - you're on the hot seat!

Get The Video
Get The Book
Get All Of It

What You'll Get

Video or Book: It's Your Choice


Beautiful, concise, entertaining material designed to keep you engaged and writing elegant Elixir. You'll get epub, mobi, and an HTML site. The book and video contain the same material.


Top-quality, focused, high-production value video tutorials from the creator of Tekpub. Tightly edited with great sound quality - this isn't just a voice in front of a set of boring slides.


All of the code in both the book and the video is available in our company Github repo. Step through the commits, or download entire chapters - it's up to you.


Have a question? Need some help? You can visit our Intern Pool (powered by Discourse) at any time and ask questions of your fellow interns.


You don't learn unless you do, and Rob writes some pretty bad code that you get to fix for us. You will also learn skills to troubleshoot Elixir and OTP.


Now let it work. Mischief, thou art afoot. Take thou what course thou wilt... We think Rob might be up to no good - plotting to take our database offline. You wouldn't help him with that... would you?

Get The Video
Get The Book
Get All Of It

The Chapter List

Welcome To Red:4

In this chapter we'll install Elixir, setup our environment, and take a look at various editors. A good editor is very important - and it turns out there are many for Elixir.

Letting Elixir Soak In

Learning a new programming language takes time, and we don't have it. In this chapter you'll get the firehose and hopefully understand why so many developers are falling in love with Elixir.

Functional Programming Primer

Many developers are new to functional programming - if this is you, we'll take a few minutes to explain some of the core concepts and boring jargon that go into this different way of creating applications.

Setting Up a Project

We get off the ground in this chapter using Mix, creating our new project and having a look around. Each directory has a significance, and we'll also run our tests for the very first time.

Calculate Escape Velocity

We pick up the pace a bit, as the Science Team really needs our help! In this chapter we calculate escape velocity so our orbiter can reach (and stay in) orbit. We'll write our first tests to make sure things work as they should... which they might not...

Pattern Matching Basics

You've been using pattern matching pretty well so far, but the details are probably lacking. In this chapter we take a look at this fascinating aspect of Elixir.

Calculate Orbital Distance and Term

The next part of our Physics library - we need to expand what we're doing and correct some silly errors that Rob introduced to the code. We'll refactor what we did before, having learned some interesting idioms in the previous chapter. You'll fix his silly tests and, hopefully, add a few more to make sure things work.


Fixing borked code is no fun (especially when it's Rob's) - in this chapter we'll take a look at various strategies for debugging common errors (both compiler and runtime). You'll be asked to fix some more broken tests as well as to pretty up some messy code.

Solar Flare Project Setup

The Physics library is looking great! Now it's time to turn our attention to solar flares. We need a tracking system so our astronauts in orbit don't get fried during EVA. We have real solar flare data from tracking stations around the world, now we just need to be sure our calculations are correct.

List and Enumeration Basics

We've setup some test solar flare data and have to decide what the best way is to structure and work with it. You've worked with lists a bit, now let's get into the details.

Recursion and Refactoring Our Solar Flares

The Science Team really likes what we've been doing, but would like to see some alternatives to our approach for finding the deadliest solar flares as well as different ways we can track the no EVA triggers. We'll see 3 different ways to work with our flare list: recursion, the Enum library, and comprehensions.

Using if, unless, and cond

Learning syntax is a great first step - but how do developers who use Elixir every day actually structure their code? In this chapter we'll take a breather and examine various idioms and code smells - all centering around conditional statements. You'll write some tests and decide for yourself which syntactic structure you prefer.

Persisting Data With Elixir

It's time to store our solar flare and planetary data - but where... and how? In this chapter we'll setup Mnesia - the built-in NoSQL store that is part of OTP, the core library you use in both Elixir and Erlang. It's ACID-compliant, fast, and simple to use. You'll set up some tests to see if it will work for us.

A Quick Look at OTP

In the last chapter you setup Mnesia, part of the vast, wonderful OTP (Open Telecomm Platform) framework. When you write applications with Elixir, you use OTP. This is where the true fun starts!

Working With Ecto and PostgreSQL

We could store our data in Mnesia and be quite happy, but our IT department is very fond of PostgreSQL. In this chapter we'll plugin and setup Ecto, the Elixir data access framework. We'll try our best to load up our solar flare data by writing our mix task - and then get deep into the weeds trying to figure out a very difficult OTP error...

Troubleshooting OTP Errors

We've stepped in it now! OTP is amazing, and it's also old. The errors you get tend to be rather terse (by our modern, sugary, dynamic language perspective). In this chapter we'll reason our way through the stack trace and see what we can do to get our task to run.

Bomb's Away!

We've setup PostgreSQL successfully and Ecto is working well. Now we'll get down to business hatching a secret plan to secure Rob's job and yours. OTP is amazingly powerful when it comes to asynchronous, concurrent programming. In the wrong hands, it can bring PostgreSQL to its knees...


You've learned a lot, and it's possible that Rob might have his job back. You've learned everything you need to know to get started at a company writing solid Elixir code - and also where to find help if you need it.
Get The Video
Get The Book
Get All Of It

Sounds Great But...

Is this beginner material?

Sort of. This material is primarily for developers who are curious about working with Elixir but don't have much experience with the language. You should have experience programming, however.

What if it's too advanced/simple or I don't like it?

As always, you get your money back with no questions asked

Do you test along the way?

Absolutely. Testing is core to what we do at Red:4 - that said we don't spend our entire time writing tests. We explore various ways of working with the code then verify our ideas with tests. Moreover, the downloadable code needs your help! Which means you get to write more tests.

Will you update the video and book when things change?

Yes. We need to stay up to date with Elixir so when the language changes we'll update as needed.

Can I ask questions? What if I need a little help?

We have a Discourse-powered forum just for this purpose!

Get The Video
Get The Book
Get All Of It