Elixir & Phoenix for Beginners

17h 24m 18s
English
Paid
October 30, 2023

The above statement is conventional wisdom that I'm sure most of us programmers would generally agree with, but let me ask you this, do you think each of the 20 most popular programming languages are different tools meant for different jobs? For example, consider the following five programming languages: Java, Python, Ruby, JavaScript, and C#.

More

Are these five languages so unique that you'd call them different tools meant for different jobs or do they seem more alike than they are different?

There was a time when you could say "JavaScript is a language that runs in the browser", however that statement doesn't work anymore... Today JavaScript is a language that you can use almost everywhere: Browsers, Servers, Embedded Devices, Databases... So is JavaScript the right tool for every job? NO, of course not! but people keep trying

I think if you squint your eyes, the vast majority of popular programming languages look more similar than different. Sure, they all have different styles and idioms, that may or may not resonate with you, but I still think most popular languages, fundamentally aren't all that different.

Why do I think this?

Because most popular languages were designed to be general-purpose, sequential languages that can solve all sorts of problems. I mean, if you think about it, languages only become popular, when they have broad appeal, and can be used to solve many different problems... right?

But here's the thing, you can't write a programming language that's excellent at solving all possible problems, just like you'll never be able to make a meal that everyone likes.

Ok, so what am I getting at?

This course teaches you the Elixir programming language, which you should know, isn't like any other popular languages.

Elixir is a modern concurrent functional programming language, that solves certain types of problems, in a unique, novel and a very effective way... In other words, Elixir is clearly a different tool, meant for certain types of jobs.

I'm going to explain what Elixir is really good at in a moment, but before I do, ponder the following statement:

Elixir is a language that allows you to write software that can effectively "run forever"...

Ok before you send me a nasty email, nothing runs forever... I know that, but programs written with Elixir can have ridiculous uptimes, far longer than any other languages except for Erlang, but I'll talk more about Erlang in a moment.

So, how is it that Elixir programs can effectively "run forever"?

Well, it doesn't happen by accident... this is possible in Elixir because in part, that's what it was designed to do.

So when would you use Elixir? In other words, what kind of "problems" is it good at solving?

Well, Elixir is excellent for creating web applications and APIs that are fast, massively concurrent, fault-tolerant and distributed.

Elixir is also really good at creating embedded software, but in this course, we'll focus on Elixir, in the context of web development.

Ok, you might be thinking, "I can create web applications and APIs in plenty of languages, so how's Elixir different?"

If I had to give just one answer to this question, my answer would be: "Elixir handles concurrency far better than any other popular language!"

I'll give you some examples:

A few years ago B/R (Bleacher Report), a sports news site, was experiencing significant growth (billions of monthly page views) and was running into scaling issues. B/R was originally created with ROR (Ruby on Rails), which offers a great developer experience and productivity, but it kind of sucks at scaling and concurrency.

Some companies have been able to scale ROR, by effective use of caching, but caching isn't something B/R could use, because each B/R user has a personalized news feed, which doesn't lend itself to caching.

Initially, B/R dealt with their growth challenges, by adding more and more servers, but eventually they decided to look at alternatives to ROR, that could help them address their scaling challenges, so they looked at a few different languages such as JavaScript/Node.js and Golang, but they eventually chose Elixir, and they started migrating from ROR to Elixir & Phoenix.

After migrating the resource-intensive services from ROR to Elixir, B/R was able to go from 150 ROR servers, down to just 5 Elixir servers, and they felt like they could have gone down to just 2 Elixir servers, but they were extra cautious and they preferred to over-provisioning a bit.

Going from 150 to just 5 servers is pretty impressive, but there's more to Elixir than just scaling, but I'll get to that in a moment.

Let's look at another Elixir success story in Discord which is a startup that provides a text chat and voice service for gamers.

Discord knew from the very beginning, that they'd need to build a highly concurrent system and they boldly chose Elixir from the start... I say boldly because they committed to Elixir very early, well before it was a proven technology.

After about 2 years of service, Discord was servicing 5 million concurrent users, then a couple years later, they were servicing 11 million concurrent users.

Now, Discord is at a scale most of us will never have to deal with, and as such, they've found several hot spots in their code that required creative solutions, but they've been able to make it work quite well, and here's the kicker, when they had 5 million concurrent users, they only had 4 infrastructure engineers.

Ok, you might be saying to yourself "I don't have scaling challenges like B/R and Discord, so why would I use Elixir"?

Well, even if you don't have scaling challenges today, it's nice to know you're creating software that can scale when needed, but even if you never need the massive concurrency that Elixir offers, you should still consider Elixir for a bunch of other reasons. I'll describe a few of the big ones:

  • Concurrency: because of how concurrency is handled with Elixir, there are features you get in Elixir that other languages can't offer. For example, implementing real-time features in Elixir and Phoenix is trivial, especially compared to other popular languages.
  • Responsiveness: Elixir is very fast and offers consistent low-latency responses because of features like preemptive scheduling and how garbage collection is implemented... in other words, with Elixir you'll be able to offer more consistent, stable and reliable services.
  • Availability: it's relatively easy to create highly available services with Elixir because distributed computing/clustering is a native feature.
  • Fault-tolerance: because of how fault-tolerance works in Elixir, errors and bugs are isolated and typically have no impact on other parts of the system. In other words, it's virtually impossible to have bugs that take down your whole server, and with Elixir, you won't find yourself restarting servers to recover from bad errors or bugs.

By the way, if you wanted to write software that could "run forever", you'd need all the features I just described, right?

Elixir is a very capable language that offers many unique and interesting features, but it also offers an excellent developer experience, similar to what Ruby on Rails offers... Basically, with Elixir you can create excellent systems, with unique features, that scale well and are maintainable, and you'll find yourself very productive and you'll probably really enjoy using it.

"Ok, but Elixir is young, so I'm sure there are plenty of growing pains you'll need to endure, right?"

Well no, not exactly, let me explain.

Programs you write in Elixir, are compiled into bytecode that runs in a virtual machine. The virtual machine that Elixir uses wasn't created for Elixir, it was originally created over 3 decades ago for a language called Erlang.

The truth is, Elixir is nothing without the Erlang Virtual Machine, in fact Elixir wouldn't even exist, without Erlang.

Now, Erlang has most of the same features that Elixir has, which might make you wonder, why not just use Erlang?

Well, if you look at Erlang, it isn't the nicest language to read and use... In fairness, most languages that were created over 3 decades ago, can't really compete aesthetically with modern languages. Now, some people actually like Erlang, but I suspect most people who take a cursory look at Erlang are quickly turned off by it's syntax.

The reason I'm telling you about Erlang is because its virtual machine (which Elixir uses) is mature, battle-tested and rock-solid, so even though Elixir is a relatively new language, it's runtime is more mature and proven than pretty much every other runtime.

"Ok, but what about changes to the language and the APIs? Are they stable?"

Recently, José Valim, the creator of Elixir, was asked:

"Is Elixir done?"

José's answer was effectively Yes... well he didn't say yes, he preferred to call it stable... Basically, there are no big features or breaking changes on the roadmap, and there are no firm plans for a version 2.0... well, I bet there will be a version 2.0 at some point, but hopefully, you get the sentiment, about the maturity of the language.

I'm pretty sure we're past most of the growing pains with Elixir, and it's a great time to learn and start using Elixir, but don't take my word for it, look at what others are saying, like InfoQ and Gartner Research, who say it's ready for prime-time and they're suggesting that organizations start considering Elixir because it can provide a competitive advantage.

"Do many companies use Elixir? i.e. are there many Elixir Jobs?"

Yep, you can find hundreds of companies that use Elixir, in this list, but I suspect there are actually thousands of companies using Elixir, with more adopting it every day... You're probably familiar with some of the companies that use Elixir, such as Pinterest, Moz, Slack, Pepsi, PagerDuty, AdRoll, Bleacher Report, and Discord.

"What will I learn in this course?"

We'll start with the basics, and work our way through the major features in Elixir, then we'll start learning the Phoenix web framework.

There are more than 150 videos, totaling ~17.5 hours of video content that covers the following topics, and much more:

  • Data Types
  • Pattern matching
  • Flow Control

    • If/Then, Unless
    • Cond
    • Case
  • Functions

    • Anonymous and Named
    • Higher Order Functions
    • Pattern matching & Guards
    • Pure vs Impure
    • Pipe Operator
    • Recursion
    • Tail Call Optimization
  • Collection Processing

    • Map, Filter, Reduce, etc
    • Composition with the pipe operator
    • Streams
    • Comprehensions
  • Protocols
  • Macros
  • Build tools
  • Testing
  • Functional Programming Concepts
  • Processes

    • Long-Lived & Short-Lived
    • Sending and Receiving Messages
    • Error Handling
    • Supervisors
  • OTP

    • GenServers
    • Supervisors
    • Applications
    • Agents & Tasks
  • Phoenix Web Framework

After you've learned the basics, you'll put what you've learned into practice by building an interesting final project.

"What's the final project?"

Imagine that you and I are on a team that just landed a big contract to build an exit polling application.

"What is exit polling?"

Well, it's a way of estimating how people are voting on election day, and the estimates are determined by asking a sampling of voters who they voted for, immediately after they leave the polling booth.

This project is a bit scary, because, before election day almost nobody will be using our application, however, on election day, our app will experience a massive spike in usage... somewhere between 10,000 to 100,000 concurrent users.

Let me explain the expected usage pattern, in more detail.

Leading up to election day, there will be just a few users, setting up the master data... In other words, adding the voting districts, the questions to ask voters, and the valid choices for each question.


Watch Online Elixir & Phoenix for Beginners

Join premium to watch
Go to premium
# Title Duration
1 Introduction 08:38
2 Who is this course for? 02:22
3 Why was Elixir Created? 05:22
4 Thinking about concurrency 09:12
5 Concurrency In Sequential Languages 12:39
6 Installing Elixir 02:13
7 Install Elixir on Mac OS 02:53
8 Install Elixir on Windows 01:10
9 Install Elixir on Ubuntu 01:21
10 What we installed 03:04
11 Integers 05:28
12 Floats 03:29
13 Atoms 08:48
14 Boolean 05:15
15 Strings 07:08
16 Maps 11:27
17 Lists 07:07
18 List Operations 11:45
19 Tuples 10:29
20 Keyword Lists 08:50
21 Structs 12:22
22 Immutable Data 11:43
23 Variables 08:38
24 Pattern Matching Introduction 06:00
25 Pattern Matching Strings 07:34
26 Pattern Matching Maps 06:22
27 Pattern Matching Structs 02:12
28 Pattern Matching Lists 04:42
29 Pattern Matching Tuples 04:28
30 Elixir Source Files 10:04
31 Control Flow Introduction 10:21
32 Control Flow Cond 06:26
33 Control Flow Case 09:47
34 Control Flow Unless 06:15
35 Anonymous Functions 08:25
36 Named Functions 05:12
37 Function Pattern Matching 11:31
38 Function & Module Docs 09:51
39 Private Functions 05:52
40 Anonymous Function Pattern Matching 05:07
41 Anonymous Function Dot Syntax 07:49
42 Higher Order Functions 10:18
43 Higher Order Functions Continued 07:33
44 Odds & Ends 11:55
45 Challenge Review 05:10
46 Guards 03:27
47 Sigils 06:37
48 Pure vs Impure Functions 11:39
49 Pipe Operator 03:41
50 Recursion 09:06
51 Tail Call Optimization 10:00
52 Collection Processing Intro 02:16
53 Map 10:34
54 Filter 07:51
55 Reduce 07:16
56 Composition with |> 11:31
57 Streams 08:06
58 Comprehensions 10:18
59 Protocols 12:11
60 Macros Introduction 10:22
61 Macro Quote and Unquote 05:49
62 Macro Example 10:17
63 "Using" Macro 03:38
64 Mix 09:59
65 What is Functional Programming 06:56
66 First Elixir App Overview 02:25
67 Building Apps - Thought Process / Planning 06:03
68 Mix Project and Data Structures 04:00
69 First App View 05:04
70 First App View Body 08:36
71 Review Challenge & Compose View Functions 05:08
72 Update Functions 04:42
73 Add Candidate Command 05:18
74 Review Challenge 06:11
75 Tie Things Together 08:59
76 Testing 11:41
77 First App Summary 02:21
78 Process Introduction 05:41
79 What's a Process? 11:32
80 Process Life time 17:13
81 Process Links 09:47
82 Long Lived Processes 11:46
83 Improving the Counter 11:07
84 Error Handling 11:35
85 Supervisor Introduction 07:49
86 Basic HTTP Server 11:11
87 Supervisor 05:26
88 The Actor Model 01:57
89 Introduction to OTP 03:03
90 Introduction to GenServers 08:54
91 GenServer Callbacks 03:39
92 A more Idiomatic GenServer 05:00
93 OTP Supervisor 10:18
94 Cache GenServer 09:07
95 Application Behavior 13:55
96 Dynamic Supervisor 06:17
97 Agents & Tasks 02:40
98 Introduction to Phoenix 03:31
99 Installing Phoenix 03:49
100 Phoenix Overview/Mental Model 04:02
101 First Phoenix Project 17:19
102 Hello Phoenix 08:42
103 Databases & Phoenix 08:11
104 Review the Auto Generated Files 07:45
105 Planning 07:16
106 Poller Project Planning 04:19
107 Poller Project Data 03:30
108 Poller Project Functions 07:54
109 Try out the Structs and Functions 04:25
110 Poll GenServer 08:30
111 Try out PollServer GenServer 01:47
112 Create Supervisor for PollServer 04:44
113 Poller Application Behavior 02:53
114 Poller Dal Project Intro 05:17
115 Ecto Introduction 02:08
116 Getting Started with the Poller Dal Project 03:54
117 Adding A Repository 05:31
118 Add A Table 05:25
119 Changesets 06:00
120 Database CRUD API 05:59
121 Question Table and Functions 07:50
122 Choices 01:38
123 Users 05:37
124 Hash User Password 06:59
125 User API 04:33
126 Phoenix Project Intro 06:09
127 Districts Index Page 08:55
128 Create Districts Form 10:29
129 Edit Districts Form 07:08
130 Delete Districts 06:40
131 Question Pages 04:38
132 Create Question Form 03:24
133 Edit & Delete Questions 02:45
134 Choice Pages 02:59
135 Review Choice Pages Solution 03:46
136 Authentication & Access Control Introduction 02:36
137 Login Form 07:45
138 Auth Plugs 08:08
139 Nav Bar Links (Login/Logout) 05:49
140 Rest API 06:01
141 Vote Endpoint 06:06
142 Initialize Poll GenServer 09:09
143 Save Votes to Database 07:36
144 Connect the Reactjs App 08:08
145 Phoenix Channels Intro 03:00
146 Phoenix Channels 06:22
147 Channel Callbacks 08:03
148 PubSub 10:21
149 Integrate PubSub 10:06
150 Final Thoughts 04:31

Similar courses to Elixir & Phoenix for Beginners

JWT Authentication with Elixir & Phoenix

JWT Authentication with Elixir & Phoenix

Duration 2 hours 54 minutes 2 seconds
The Complete Elixir and Phoenix Bootcamp

The Complete Elixir and Phoenix Bootcamp

Duration 17 hours 22 minutes 4 seconds
Elixir for Programmers

Elixir for Programmers

Duration 7 hours 19 minutes 57 seconds
Developing With Elixir/OTP

Developing With Elixir/OTP

Duration 6 hours 42 minutes 4 seconds
Full-Stack GraphQL with Absinthe, Phoenix, and React

Full-Stack GraphQL with Absinthe, Phoenix, and React

Duration 4 hours 28 minutes 38 seconds
Master the Linux Command-Line & Bash Scripting

Master the Linux Command-Line & Bash Scripting

Duration 7 hours 56 minutes 19 seconds