About This Title

Pages: 100
Published: May 2020
ISBN: pending
Edition: 1
Not Yet Printed (NYP)

Programmer Passport: OTP

by Bruce Tate

Did you try turning it off and on again? The same approach that works for your household appliances can work with your software. Elixir and Erlang systems can spawn applications with even hundreds of thousands of processes without skipping a beat and perhaps the most important feature in either of these languages is OTP.

Available exclusive in partnership with our friends at grox.io


OTP is a set of libraries and APIs that enable applications with extraordinary reliability and scalability through concurrency. In the next four releases, we’ll cover the main two abstractions that make up OTP: the boundary and lifecycle layers.

In this first chapter, we’ll build a calculator application without OTP. We’ll use native processes and message passing rather than the OTP library. Using this approach, you will develop an intuition for how OTP works. Then, we’ll wrap the application in an API, and show how we might implement that API using OTP instead.

In chapter two we’ll look at communication between servers. You can think of a GenServer as a template for your code. You can fill in the blanks with callbacks, bits of code you’ll implement in your own modules. When we work with OTP, the GenServer library builds the generic lifecycle management and message loops, leaving the rest to your application.

The GenServer calls your application’s callback functions at certain specific times. When things break down, OTP just turns it off and on again!

What You Need

Resources

Releases:

Contents & Extracts

  • A Basic Handmade Server
    • Build a Server with a Process
    • Build the Boundary Layer
    • Build an OTP Server, With Mix
    • Your Turn
  • Communication Between Servers
    • Anatomy of a GenServer
    • handle_info Processes Nonstandard Messages
    • Schedule an Alarm with handle_cast
    • Implement a Status Message with handle_call
    • Your Turn
  • The Lifecycle and Supervision
    • The Primitive Mechanisms
    • OTP Supervisors Manage GenServer Lifecycles
    • Add Some Children
    • Lifecycle Policy
    • Your Turn
    • Next Time
  • The Power of a Name
    • Add Dynamic Characters to SuperDuper
    • Dynamic Children
    • Dynamic Supervisors
    • The Process Registry: The Power of a Name
    • Your Turn
    • Next Time

Author

Bruce A. Tate is a programmer and CEO of Groxio where he is helping to redefine how computer languages are taught and learned. He’s the author of Seven Languages in Seven Weeks and Programming Phoenix, among other titles, and has been involved with Elixir from the very beginning.

Available exclusive in partnership with our friends at grox.io

Related Titles:

About This Title

Pages: 100
Published: May 2020
ISBN: pending
Edition: 1
Not Yet Printed (NYP)