OTP

OTP




What's in this preview?

We want you to get the feel for typical Groxio content and the reasons we provide each type of content. Each Groxio module comes in four scheduled releases consisting of the central PDF, videos, and resource links. Later releases have projects as well. You can see part of the first release here.

Did you try turning it off and on again?



Buy Course Today!



Preview PDF!




Release Schedule: 2020-05-13 through 2020-07-01

Version: July 1, 2020


Just $70.00, A La Carte
(other options available)




Programmer Passport OTP






Why a book?

The scientific teaching method we follow is the Dreyfus learning model. Books provide the metaphors experts need to build context, step-by-step instructions for beginners, and the exercises that intermediates need to learn.

Description

Elixir has near legendary status as a reliable language because of the OTP library. OTP is the heart and soul of Elixir’s concurrency and reliability. This is the core feature that gets employers excited, and learning it will make you a much more valuable programmer.


OTP has a reputation for being tough to learn by some, but this course will help you find the break through you are looking for by going beyond the basic library to present the core abstractions, bit by bit. Then, it shows you how to design your code in layers, the way experts do.

History

In 1988, Joe Armstrong, Robert Virding, and Michael Williams were working on making software more reliable at Ericsson. They built a library called the Open Telecom Protocol. That acronym was an exercise in marketing, but the acronym was eventually dropped.


The project was opensourced as part of the Erlang project, and the popularity of the programming framework began to pick up. In 2012, Elixir was created, expanding OTP’s footprint. Scala’s Akka framework extends OTP to the Java virtual machine.


Videos

Public & Private




Why videos?

Groxio language modules have two kinds of videos. Our overview videos set the history and context of a language, or wrap up the work we've done, and are free to support language ecosystems. Our coding instruction videos, mostly starting with the second release, are paid content, and each one offers a live coding project.

Every learning level benefits from pair programming. Our videos are professional, but do not scrub away every tiny mistake. That way, you can see how experienced programmers deal with errors and changes in code organization.

Video

OTP Basics

In this updated OTP Elixir series, we work through design, abstractions, and . This video covers the initial OTP concepts including the callbacks for handle call and init. We also work through the general idea of OTP. We also have some basic code examples.
Subscriber content

Elixir Behaviours

OTP GenServers are based on behaviours. In this video, we walk through two metaphors Behaviours are plugins with contracts. Without OTP, we build a basic looping mechanism to separate the concepts of looping machinery, and the code that occurs in each iteration of the loop.

Video

Functional Cores

The OTP GenServer uses callbacks designed to consume plugins built in a particular way. We focus on building core code shaped to integrate to GenServers using a technique focused on reduce called CRC. These design concepts will help to build code that is easier to design, maintain, and debug.
Subscriber content

Video

GenServer Message Callbacks

GenServer message callbacks have cryptic names, but the arguments and tuples are designed with logical, consistent arguments. In this video, we walk through the basic message callbacks and show you how they relate to the server and client processes.
Subscriber content

Video

CRC: Construct, Reduce, Convert

In this video, we carefully walk through the integration of CRC concepts into a basic OTP application. We look at exactly where converters, reducers, and constructors plug into existing GenServer callbacks.
Subscriber content

Video

Basic Abstraction

GenServers are implemented in Erlang. In this video, we build a basic GenServer using Elixir primitives. Then, we walk through how this basic abstraction relates to generic GenServers. We use many of the big concurrency abstractions including processes, recursion, and message passing.
Subscriber content

Video

Links and Monitors

Under the hood, OTP uses links and monitors to ensure that different processes in a concurrent system behave in a uniform, logical way. Part of this theory is that related processes should be linked so that they all succeed or all fail together. In this video, we show you how.
Subscriber content

Supervisors

OTP: Did you try turning it off and on again? OTP is the fundamental abstraction that is responsible for Elixir's self-healing, fault-tolerant systems. When a system fails, it is brought down completely and brought back up in a known good state. This video shows you how.

Video

Child Specs

Elixir's childspec in OTP is a shorthand feature describing everything needed to start a GenServer. In this video, we learn three different forms of childspecs. We use a simple module name, a two tuple, and a full map. Each one has increasing flexibility and decreasing ceremony.
Subscriber content

Video

Restart Strategies

In this OTP video, we look at restart strategies. If supervisors manage lifecycles, restart strategies say how to do so. In this video, we put this concept through its paces, using the observer to see what happens when we change the supervisor's strategies.
Subscriber content

Video

Dynamic Supervisors

OTP's supervisor makes it easy to start processes at system startup time. Dynamic supervisors are custom server-starters that start processes on demand. This video shows you how, walking you through an example step-by-step.
Subscriber content

Video

Registries

OTP's supervisors use registries to refer to processes by name, which must be an atom by default. In this video, we look at a via tuple, a strategy for naming processes using names of an arbitrary type, waling through a basic example.
Subscriber content

Video

When Not to OTP

OTP is a wonderful tool for managing processes and their lifecycles. It's not the right tool for every job. This video walks you through some of the traps you might encounter, such as using OTP as a code organization tool.
Subscriber content

Video

Backpressure

Sometimes, OTP processes can get overwhelmed with messages. Whether a client sends too many or a server takes too long to receive them, backpressure can build in control by forcing clients to acknowledge that a service has completed.
Subscriber content

Video

Tasks

Tasks are short-lived GenServers our code can spin up to handle intermediate jobs concurrently. These genservers don't hold state indefinitely or process loops. Instead, they do a concurrent job and return a result.
Subscriber content

Video

Agents

Agents are simple GenServers that use processes to track shared state. Using functions to specify an initial value or update old ones, agents can provide basic services like counters or registries.
Subscriber content

Video

Word Ladder Project: Files and Words

This first project video is the first of our implementation of the Chicago Tribune's Word Ladder game. We build a word dictionary, and then index the words by position for efficient access.
Subscriber content

Video

Word Ladder Project, CRC

Elixir's OTP lends itself particularly well to Groxio's CRC labeling. In this video, we break down our Word Ladder project into a function with functions that construct, reduce, and convert.
Subscriber content

Video

Word Ladder, Handle Call

Moving through the Word Ladder project, we build our boundary layer, the OTP server. We start with the GenServer and the core API, especially the handle_call callback, using our reducer and converter.
Subscriber content

Video

Word Ladder Word Choice

One of the most interesting parts of the Word Ladder project is the word picker. To solve the problem, we use an index to move from one word to another. Then, we plug it into the init callback.
Subscriber content

Video

Word Ladder Validation

The Word Ladder game has validation rules, and we implement them in a core layer of this video. We check that guessed words are in the dictionary, and that they change only one letter.
Subscriber content

Video

Word Ladder: Validation2

We take the validation code we built in the last video and integrate it into our GenServer. We apply validation to our API rather than callbacks to make sure we supply valid data.
Subscriber content

Video

Command Line UI

We modify our game to provide an API layer to let a single user play the game through the command line. Then, we process each move, showing any errors we see along the way to the user.
Subscriber content

Video

Dynamic Supervisor

We build the second kind of implementation, an API with a dynamic supervisor to let multiple users play the game. We use our lifecycle layer to start a dynamic supervisor, a GenServer-starter.
Subscriber content

v1 1. OTP. Did you try turning it off and on again?

OTP is the reason Erlang developers say to "Just let it crash." In this video, you'll learn why. Rather than building an application in a process and starting it direcly, OTP has a *process server* called a supervisor that's responsible for the whole application lifecycle. In short, the supervisor knows how to "turn it off and on again!"

v1 2. mix new --sup

When the mix tool was created, projects always had a supervisor. Shortly after, supervisors were removed in favor of the --sup flag. This video will show you precisely what happens when you create a project with --sup. You will find out how Elixir builds OTP applications, and what you need to do to integrate them.

Video

v1 3. When Not to OTP

Sometimes, OTP looks too much like a golden hammer. When you have a golden hammer, everything looks like a nail. In this video, you'll learn why some applications are *not* nails. This video will walk you through an example that intentionally builds in a race condition.
Subscriber content

Video

v1 4. Tasks and Agents

Dave Thomas made an interesting contribution to Elixir's OTP ecosystem. He suggested lightweight GenServers for processing state called agents, and functions called tasks. In this session, we use tasks and agents in the context of OTP.
Subscriber content

Video

v1 5. Response Tuples

When you're writing typical OTP applications, the typical responses you use are `:reply` and `:noreply`. Did you know there are other response tuples, and that you can add timeouts or other options as an additional option in a response tuple? Learn to find which responses are allowed, and how to use them.
Subscriber content

Video

v1 6. Backpressure

When you build GenServers, should you use calls or casts? The answer might surprise you. In this video, we talk about backpressure, and how preferring calls to casts will improve reliability by shortening your message queues.
Subscriber content

Video

v1 7: Big Brother, The OTP Supervisor

Big Brother is always watching and OTP supervisors are too. By monitoring our processes with supervisors that know how to manage lifecycles, Elixir can take action when another process crashes or must be shut down. In this video, we'll explore ways to set policy for shut down, start up and restart.
Subscriber content

Video

v1 8: State Machines

In OTP state machines are representations of mathematical constructs. They are ideal for implementing processes that move from state to state. Examples are light switches, web requests, and document routing. In this video we'll build a document routing example using a finite state machine.
Subscriber content

Video

v1 9: Phoenix Dashboard

In this session, we talk about OTP supervisors by building in an intentional error and then watching what happens in the Phoenix LiveView dashboard. LiveView can help us track resources like atoms, memory, and time.
Subscriber content

Video

v1 10: OTP Registries: By any other name...

Building the infrastructure to start, stop, and restart a service is only part of the problem. You also need to be able to register a service and find it once you have done so. We'll discover the services OTP provides to solve this problem.
Subscriber content

Video

v1 11: OTP Dynamic Supervisors in Elixir: In your own time

Starting GenServers and Supervisors with your dependencies at application start time is useful, but it's not the whole story. You also need to be able to start services that you may not know about at compile time. The dynamic supervisor is the tool for the job, and we'll show you how to register and start a dynamic service with an API.
Subscriber content

Video

v1 12: Layers: Do Fun Things with Big Loud Worker-bees

Throughout this grox.io OTP series, we've built up services with single-purpose functions and modules. In this video, we'll refactor one of our programs to use the system of layers built in the book Designing Elixir Systems with OTP, written by James E Gray II and Bruce Tate.
Subscriber content

0. Bring On the Workerbees

If you like what you find here and want to design software concepts that use these systems, you can use this book that teaches you how to build software using the layered approach talked about in these videos and the book. This video talks about the layers you'll find in there.

Community Resources

Cool quick trips for OTP




Why resource links?

Each new chapter has a set of links, separated into three categories. The categories reflect different competency levels and resources that match that stage of learning, for each Groxio release.

Learn It

These resources will get you on the path to learning with background information, tooling and exercises.

Do It

You decide how deep to go. These resources are exercises and projects to cement your learning.

Grok It

These resources will help you put your new knowledge into context so you'll be better at your everyday job.

Projects

Longer Excursions (chapters 3 and 4)






Why projects?

The Dreyfus model is originally instruction for pilots. A typical pilot course is based on reading material to understand context, and then flying a plane. Our videos and PDFs are important, but in the end, programmers need to program in order to learn. Our projects offer different levels of assistance, from "give me the answer" to "make this test pass".