Developing With Elixir/OTP

Learn how to think and code functionally by building
an app in Elixir.

Elixir 1.5

Build a complete Elixir app from start to finish

You can do a bunch of cool stuff with the Elixir programming language, from building web apps using the Phoenix framework to embedding code on networked devices. And it's tempting to jump right into these projects and hope for the best. But without a solid understanding of how to write functional programs the Elixir way, you're in for a white-knuckle ride.

Save yourself time, frustration, and the perils of coding by coincidence by learning all the essentials of developing Elixir apps upfront.

“The new @pragmaticstudio Elixir course secretly teaches you how to build a mini version of Phoenix! Really awesome learning experience!”
Bill Peregoy

“I love the pace. It feels more like a series of really good pair programming sessions with a mentor and less like a lecture.”
Hunter Stewart

“I've read almost 3 books on Elixir yet this course taught me small tricks that I didn't know before. I attribute that to the realistic project that is being developed throughout the course...”
John Joseph Sweeney

“Want to learn @elixirlang (and you should), then you owe it to yourself to check out @pragmaticstudio. Awesome!”
Napoleon Ahiable

Course Outline

Go From a New Project to a Complete Elixir/OTP Application
Building an elementary HTTP web server from scratch is a great way to learn many facets of Elixir and functional programming principles.
Since we build this app from scratch, the course outline isn't
organized around Elixir's syntax or libraries. For example, you won't
find a module named "Strings" that shows you everything you can do
with a string. Boring!

Instead, the course outline follows
the timeline of a project as we incrementally add new
features. Syntax and libraries are introduced progressively when we need them to actually get something done. How's that for being pragmatic? :-)

Each module includes a short, focused video that either uses a new aspect of Elixir to accomplish a task or reinforces
something we learned in a previous video but in a slightly different way. You can watch all the videos this afternoon or savor a few each day over lunch or on your commute!

Our web server will make three high-level transformations—parsing, routing, and formatting a response—with each step being a function. We'll set up an initial pipeline using modules, named functions, strings, maps, and the pipe operator.

4. Parse the Request(10:21)

To transform a request into a response, we first need to parse
the request string into a more usable data structure. This presents a great opportunity to learn the match operator, atoms, pattern matching techniques, and built-in functions.

5. Format the Response(6:40)

Formatting the response string takes us deeper into Elixir maps
and introduces us to programming with immutable data, which is a hallmark of functional programming.

6. Route Multiple Requests(6:28)

In Elixir you don't use conditional expressions as often as you would in imperative languages such as Ruby. Instead, it's more idiomatic to control the flow of a program using function clauses and pattern matching. Routing HTTP requests gives us an ideal context for learning how to design code in this declarative style.

7. Request Params and Status Codes(8:45)

Designing a web server presents interesting scenarios that let us explore many of Elixir's features. How do we handle a request that has parameters? What happens if a route doesn't match? And how should we respond? The solutions require more
pattern matching techniques and multi-clause functions.

8. Rewrite Paths and Track 404s(9:31)

Once we have requests flowing through a pipeline, we can
plug in specialized functions that transform requests
and responses in unique ways. And by pattern matching maps we can run these functions conditionally—a powerful techniques that's used extensively in Elixir applications.

9. Serve Static Files(11:27)

Even something as familiar and straightforward as reading a file
involves pattern matching. Serving static files, and properly
handling successes and failures, introduces us to
tuples and case expressions.

10. Module Attributes(3:01)

Sometimes you need to attach metadata to a module, be it
for documentation or to squirrel away a compile-time
constant. In this section we use reserved and
custom module attributes.

11. Organizing Code(6:30)

Modules let us organize functions with similar concerns in a namespace. We'll group related functions in properly named
modules, put them in separate files, and knit it all back together using aliases and imports.

12. Modeling with Structs(11:09)

One of the benefits of modeling our request/response conversation as a struct (as compared to a generic map) is we can ensure that the functions in our pipeline always get the expected type. In this section we compare structs vs. maps and refactor our design to use a struct.

13. Handle POST Requests(10:32)

Handling a POST request means we have to take into account the list of request headers and the POSTed parameters. To do this,
we'll process the request by matching
head and tail patterns: a technique used
pervasively in Elixir apps.

14. Recursion(13:17)

Recursion makes Elixir go 'round and 'round.
You've no doubt seen simple examples of recursion, but what about real-world use cases? Turns out, recursion
is exactly what we need to parse the HTTP headers in our
POST requests. And while Elixir has convenience functions that often let you sidestep using recursion directly, Elixir pros know how to use recursion to their advantage.

15. Slicing and Dicing with Enum(22:16)

You'll find familiar high-order functions in the Enum module for transforming data. But to use
them effectively you need to be comfortable with anonymous functions and how to capture functions. We also put guard clauses to good use as our application begins to take the shape of a familiar
web framework.

16. Comprehensions(11:15)

Now it's time to generate dynamic content by reading and evaluating template files. We make quick work of this using comprehensions to "loop" through collections of data and generate HTML.

17. A Peek At Phoenix(13:12)

Since Elixir is the language you use to build Phoenix web apps, a peek at a Phoenix app reveals a lot of familiar syntax and design concepts. Alas, you discover there
really is no magic after all!

18. Test Automation(15:20)

It's time to automate with ExUnit tests!
We look at two different ways to write unit tests, and various ways to run them. By the end we have green dots across the board.

19. Rendering JSON(06:49)

To build a JSON API, we install an external JSON library and use it to render JSON and handle POSTed JSON data in response to API requests.

20. Web Server Sockets(19:11)

Now that we have a fully-functioning HTTP request handler, it's time to write a TCP socket server so that any HTTP client can interface with our application. To do that, we use Erlang's gen_tcp library and learn how to transcode Erlang to Elixir.
Cue the browser!

21. Concurrent, Isolated Processes(22:28)

At this point our web server can only handle one request at a time. We need a way to handle multiple requests concurrently and also isolate the failure of one request so it doesn't affect other requests. Concurrent, isolated processes are what set Elixir apart from other functional languages! We also look inside the Erlang VM to see how it takes full advantage of multicore computers to achieve remarkable levels of concurrency and parallelism.

22. Sending and Receiving Messages(19:38)

So if processes are isolated and run concurrently, how do they communicate? Just like people! They send asynchronous messages to each other. In our app, we spawn a series of API requests that run in independent processes. They send back their results as messages to be received by the request-handling process. We also look at how to avoid unwanted synchronization points in our code.

23. Asynchronous Tasks(20:19)

With several one-off asynchronous tasks now running and getting results at a later time, we're starting to see a definite pattern. In fact, running functions (or tasks) in a short-lived process is so common that Elixir provides a helpful abstraction: the Task module. By the end you'll know how it works under the hood.

Coming Up Next...

24. Stateful Server Processes

25. OTP Generic Servers (GenServers)

26. Fault Tolerance with OTP Supervisors

This course is not yet complete, but you can get started anyway! We'll incrementally release new videos as they're ready throughout August 2017.

High-Quality Videos

Access to streamable and downloadable, DRM-free videos on
any device.

Notes and Exercises

Each video has a corresponding set of technical notes with bonus
material, exercises, and handy tips.

Source Code

Includes starter files, stepped versions of the app
for each module, and all the source for the final app.

Instant, Never-Ending Access

No monthly subscription or time limit. Revisit all the
material whenever you want!

Learn The Pragmatic Way

Build a Real Project with Real Code
In the Studio, our focus is always on helping you build real applications. Each new topic or technique in the progression of the course is motivated by the next feature we want in the app
we're building.

Learning in the context of building a real application makes a huge difference. By following a project-based approach, you see how all the pieces fit together. You gain a deeper understanding of both the "how" and the "why". Learning this way
makes everything "click"... and it's just more fun!

Here's another difference: We respect your time. In the videos we get right to the point and pace things to keep you
engaged. You don't have to suffer through rambling commentary and annoying typos! We stay on topic and post-produce the videos to the highest quality so you get a streamlined, time-friendly learning experience.

For Developers New To Elixir

To respect your time in the videos, we assume you
have project-level experience with another programming language
such as Ruby. This isn't a first-time programming course.
However, we don't assume you have any prior experience with
functional programming or Elixir. If you're already using Elixir
in earnest, then depending on your experience this course may not be a good fit for you.

We aim for 100% satisfied developers, so if this course turns out not to be a good
fit for you, we'll gladly issue you a 100% refund.

From Mike & Nicole

Hi Folks! Many of you have emailed and tweeted us about an Elixir course. We did a lot of head-scratching coming up with a good
way to teach Elixir. We didn't want a referency, syntax-focused
course because, well, those make us fall asleep. Instead, in
this course we'll actually build something with Elixir. We'd love to have you
join us in the Studio for this great course!
Learn more about us…

Technical Reviewers

Many thanks to
Scott Thompson, Clinton De Young, and Nathan Herald for taking the time to review early drafts of the OTP sections. Your insights and suggestions based on hard-won experience with Elixir/OTP were instrumental in the design of this course. We really appreciate it!

Frequently Asked Questions

Why Elixir?

Glad you asked! It's smart to question why you might need to add another programming language to your repertoire. Here's the thing: Elixir isn't just another programming language. It's unique in that it's built on the Erlang VM which has a long, proven track record of powering concurrent, distributed, and fault-tolerant systems. Elixir gives us the joy and productivity of Ruby with the concurrency and scalability of Erlang.

Do I need this course if I already know Elixir?

Honestly, it depends.

If by "know Elixir" you mean you've read a book and perhaps
experimented with some code, then we think you'll get a lot of
value seeing how to build a complete app from scratch. Folks often
say our courses help them fill in gaps in their understanding.

If you're using Elixir in earnest on a project and feel confident, then frankly this course may be too introductory for you.
Then again, it's always helpful to see other examples of Elixir
in action. And you just might discover one tip, trick, or
explanation that makes it all worth it. :-)

Does the course expire or have a time limit?

Nope! It never expires and you can revisit all the course material
as often as you like.

Why should I get the early access, pre-release version now?

Simply put, so you can get started right away! We'll continue
filming, post-producing, and releasing new videos every week or two, but you don't have to wait until the entire course is done. Plus, you'll get a significant discount as thanks for supporting this course in its early stages!

Will I learn the Phoenix framework?

Not in this course. Elixir is a functional programming language with a fairly steep learning curve. Phoenix is a full-stack web framework built on Elixir. Trying to learn Elixir and Phoenix at the same time is a recipe for confusion. Remember how frustrated you felt stumbling around in Rails before you really knew Ruby?

Will I learn how to integrate Elm with Elixir?

To integrate Elm with Elixir, you would need to use Phoenix which
is beyond the scope of this course. Perhaps in another course. :-)

What if I'm not satisfied?

We aim for 100% satisfied developers, so if this course turns out not to be a good fit for you, we'll gladly issue a 100% refund.

“The new @pragmaticstudio Elixir course secretly teaches you how to build a mini version of Phoenix! Really awesome learning experience!”
Bill Peregoy

“Learned a lot from the pragmaticstudio [Elixir course] and couldn't recommend it highly enough.”
Ralph Bankston

“Really well done course! The recursion explanation was the best example I've come across for us newbs. I like how it was built step-by-step with output, never rushing the discussion.”
Dan McHarness

“I've read almost 3 books on Elixir yet this course taught me small tricks that I didn't know before. I attribute that to the realistic project that is being developed throughout the course instead of the typical book-style teaching in which the language features are presented almost like documentation. This course is taught with just the right amount of detail and speed, and the realistic example project really helps to solidify the concepts being taught. The course notes are well thought-out and thought provoking in that they anticipate questions a developer may have which extend naturally from what is being taught, especially questions like 'could I do this a different way?'”
John Joseph Sweeney

“I love the pace. It feels more like a series of really good pair programming sessions with a mentor and less like a lecture.”
Hunter Stewart

“This is the best Elixir material I've used. You build you a simple HTTP server using Elixir and learn a lot of the core language and architecture choices when writing Elixir code. It doesn't pester you with 'this is an int, this is a string.' You just start building this HTTP server out and learn about Elixir along the way. Thanks Mike and Nicole for writing such a tremendous course! It really cemented my Elixir knowledge and I feel much more comfortable in my Elixir role.”
Sergio Tapia

“Elixir is an itch I've been wanting to scratch for sometime, but having tried to learn it using manuals or website tutorials, I've not found the experience engaging. This course, however, has been so rewarding! The pace, level of detail, assumption of prior knowledge, and depth of explanation are all perfect. The video quality, font sizing, colour scheme and sound reproduction all add to the quality of the whole course. And your approach of developing a web server app in the course and getting to see how all the pieces fit together is so much more absorbing than trying to learn by writing bite size chunks of unrelated code. Well done!”
Tony Sutton

The Pragmatic Studio is where developers have come since 2005 to learn, practice, and improve their craft. In our acclaimed courses, you get the most up-to-date and approachable developer training around!
Learn more…