Space, Solar Flares, Functional Programming and Elixir.

Elixir is Ruby's functional big brother, powered by the Erlang virtual machine (the BEAM). It's ultra scalable and, more than that, elegant and fun to use. Even if you never write a line of Elixir in your day job, the concepts you learn will change your programming forever.

This video is a little outdated. I made it in 2015 and things have changed since then. The approach and ideas are sound and the conceptual stuff (especially WRT to functional programming) is sound. I will be updating this production in the next few months...

Buy Now $20

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

The Videos

welcome.jpg

Welcome to Red:4

Welcome to Red:4 - Where the Future Starts Yesterday. Blah blah blah we hope you like it here blah blah… We don't have a lot of time so let's just get to it shall we?
4 minutes

diving-in.jpg

Letting Elixir Soak In

Elixir syntax can be familiar and weird at the same time, especially if you're coming from Ruby. To prepare for this section, let's clear our minds - let go of familiar syntax cues and 'the way it's done' in the languages you already know.
8 minutes

functional-primer.jpg

Functional Programming Primer

Functional programming has been around forever; it's nothing new. Elixir is a functional language, as is its progenitor, Erlang. If you're coming from an Object-oriented language like Java, Ruby, C#, Python or JavaScript, functional programming will take some getting used to.
11 minutes

project-setup.jpg

I need you to setup a project

You can think of Mix as your Elixir Utility Belt. It builds your projects, runs tasks for you, runs your tests, installs packages - a fascinating tool. That comes later - right now open up your terminal and navigate to a directory where you can save your work.
3 minutes

escape-velocity.jpg

Calculating Escape Velocity

I hope you're prepared to learn on the job. I'm about to ramp things up on you and it's for the simple reason that I'm under the gun - and to be honest *so are you*. We just got a new CTO, she arrived a few weeks after I got the job. She doesn't like me... which I guess isn't all that surprising.
19 minutes

pattern-matching.jpg

Pattern Matching Basics

Pattern Matching in Elixir is one of those things that can be vexxing, interesting, or obvious. Ultimately, however, it will be confusing if you have never dealt with it before.
7 minutes

orbital-distance.jpg

Calculating Orbital Distance

In this part we tidy things up, plugging in Authentication and hooking our download service into Firebase Storage.Nice work so far! The Science Team loves what we're doing and, as you might expect, have given us more work.
21 minutes

debugging.jpg

Debugging

I'm always amazed when I manage to write Elixir code that compiles correctly the first time. It almost never happens! Let's have a look at a normal sequence you might stumble through, and I'll see if I can save you some time.
21 minutes

solar-flare-warning.jpg

Solar Flare Project Setup

We need to get rolling which means we need to setup a project and start cranking out some code! In this video we'll structure our project with tests and get to know the difference between Elixir script files and compilable executables.
24 minutes

list-and-enum.jpg

List and Enumeration Basics

Functional programming is all about transforming data and if we're going to work with Solar Flares, we need to understand how Lists work - how we query, slice, dice, add and remove. That's what we're going to do now.
24 minutes

refactoring-solar-flares.jpg

Recursion and Refactoring Our Solar Flares

Most developers know about recursion and have used it once or twice in their careers; perhaps more. It can be quite difficult to get right - this is not the case with Elixir. With a combination of pattern matching and the head/tail functionality of Lists, recursively iterating over lists is straightforward.
24 minutes

if-unless-cond.jpg

if, unless, and cond

Here's something weird to think about: in a high-level functional language such as Elixir, writing conditional code is not exactly idiomatic. Using a combination of pattern matching and syntax rules we can write extremely clean code free of if statements and conditionals in general
5 minutes

otp.jpg

A Quick Look at OTP

You've seen a lot of Elixir so far and have learned some new concepts, especially if you're new to functional programming. No doubt that along the way you've probably been wondering, however: *how is this all supposed to work together? how can I actually build something?*. I've showed you a few little hints, but it's time to get explicit on this
23 minutes

ecto-postgres.jpg

Working With Ecto and PostgreSQL

You have to store data somewhere and Elixir (and Erlang in general) give you quite a few tools to do so. In this video we'll see how to push data into PostgreSQL using Ecto, the ORM created by the Elixir team.
12 minutes

troubleshooting-otp-errors.jpg

Troubleshooting OTP Errors

We're in the weeds now! Sorry for the pain, but hey, backing over a cliff is what we do as developers isn't it? You *will find yourself completely stuck* when working with Elixir and I need you to be able to reason your way out of this mess.
10 minutes

bombs-away.jpg

Bombs Away!

Developers often confuse *asynchronous* execution with *concurrent* or parallel execution. I do this often! It's something I learn and unlearn, all the time. Let's take a small tangent and discuss the difference.
11 minutes

Functional programming is fun and will change the way you think about programming.

ecommerce

Elixir's friendly syntax and ultra-high powered VM (BEAM, the Erlang VM that powers telecoms) make the adventure into functional programming all the more interesting.

Spend your weekend digging into something completely different and get ready to think differently about the code you write.