Pilgrim's Progress to the Promised Land by Robert Virding

37
www.erlang-solutions.com Pilgrim's Progress to the Promised Land Robert Virding

Transcript of Pilgrim's Progress to the Promised Land by Robert Virding

Page 1: Pilgrim's Progress to the Promised Land by Robert Virding

www.erlang-solutions.com

Pilgrim's Progress to the Promised Land

Robert Virding

Page 2: Pilgrim's Progress to the Promised Land by Robert Virding

www.erlang-solutions.com

2

You have heard the Prophets and their followers extolling Erlang/Elixir as the true path to the Promised

Land of concurrent, fault-tolerant and scalable systems and have decided to make the pilgrimage.

The Pilgrimage to the Promised Land

Page 3: Pilgrim's Progress to the Promised Land by Robert Virding

www.erlang-solutions.com

Are You Following the Right Prophets?

Page 4: Pilgrim's Progress to the Promised Land by Robert Virding

www.erlang-solutions.com

4

Have you chosen the right path?Is Erlang/Elixir the right language/system for you?

Are You Following the Right Prophets?

Page 5: Pilgrim's Progress to the Promised Land by Robert Virding

www.erlang-solutions.com

5

‣Handling of a very large number of concurrent activities

‣Actions must be performed at a certain point in time or within a certain time

‣System distributed over several computers

‣Interaction with hardware

‣Very large software systems

‣Complex functionality such as feature interaction

‣Continuous operation over many years

‣Software maintenance (reconfiguration etc.) without stopping the system

‣Stringent quality and reliability requirements

‣Fault tolerance both to hardware failures and software errorsBjarne Däcker, November 2000 - Licentiate Thesis

Are You Following the Right Prophets?

‣Handling of a very large number of concurrent activities

‣Actions must be performed at a certain point in time or within a certain time

‣System distributed over several computers

‣Interaction with hardware

‣Very large software systems

‣Complex functionality such as feature interaction

‣Continuous operation over many years

‣Software maintenance (reconfiguration etc.) without stopping the system

‣Stringent quality and reliability requirements

‣Fault tolerance both to hardware failures and software errorsBjarne Däcker, November 2000 - Licentiate Thesis

Not just telecom

Page 6: Pilgrim's Progress to the Promised Land by Robert Virding

www.erlang-solutions.com

6

Erlang/OTP, and hence Elixir, are designed for systems with properties:

▸ Lightweight, massive concurrency▸ Fault-tolerance must be provided▸Timing constraints▸Continuous operation for a long time▸Continuous maintenance/evolution of the system▸Distributed systems

Are You Following the Right Prophets?

Page 7: Pilgrim's Progress to the Promised Land by Robert Virding

www.erlang-solutions.com

7

Erlang/OTP and Elixir are not good for systems with:

▸Heavy number crunching▸Global, shared, mutable data▸ ...

Are You Following the Right Prophets?

BUTwe are good at interacting with other systems

Page 8: Pilgrim's Progress to the Promised Land by Robert Virding

www.erlang-solutions.com

The Joy of the First Experiment

Page 9: Pilgrim's Progress to the Promised Land by Robert Virding

www.erlang-solutions.com

9

You have downloaded the system, used the tools and have written your first simple Erlang or Elixir server or

Phoenix webpage, and it works.

The Joy of the First Experiment

Page 10: Pilgrim's Progress to the Promised Land by Robert Virding

www.erlang-solutions.com

The Village of Confusion

Page 11: Pilgrim's Progress to the Promised Land by Robert Virding

www.erlang-solutions.com

11

Yes, your system is working but behaving strangely. Did you really listen to the prophets when they were

describing the language/system?

The Village of Confusion

Page 12: Pilgrim's Progress to the Promised Land by Robert Virding

www.erlang-solutions.com

12

▸ Elixir may look like Ruby, but it is not Ruby

▸ Erlang/Elixir is not OO

▸ Erlang/Elixir has "strange" handling of data

▸ Erlang/Elixir has "strange" way of building systems

The Village of Confusion

Page 13: Pilgrim's Progress to the Promised Land by Robert Virding

www.erlang-solutions.com

The Hill of Functional

Page 14: Pilgrim's Progress to the Promised Land by Robert Virding

www.erlang-solutions.com

14

There is now a hill we must climb to gain understanding of the language. It is not high.

The Hill of Functional

Page 15: Pilgrim's Progress to the Promised Land by Robert Virding

www.erlang-solutions.com

15

Erlang/Elixir are functional languages with:

▸ Immutable data▸ Pattern matching▸Recursion▸ ...

The Hill of Functional

Page 16: Pilgrim's Progress to the Promised Land by Robert Virding

www.erlang-solutions.com

The Mountain of Concurrency

Page 17: Pilgrim's Progress to the Promised Land by Robert Virding

www.erlang-solutions.com

17

There is now a mountain we must climb to start gaining understanding of building systems. It is not

high though the path may feel different.

The Mountain of Concurrency

Page 18: Pilgrim's Progress to the Promised Land by Robert Virding

www.erlang-solutions.com

18

Erlang/Elixir has a different way of structuring systems:

▸ Isolated processes▸No sharing of data▸No global data▸Communication through asynchronous messages▸We aren't scared of creating lots of processes▸We aren't scared of crashing things

The Mountain of Concurrency

Page 19: Pilgrim's Progress to the Promised Land by Robert Virding

www.erlang-solutions.com

The Mist of Frameworks

Page 20: Pilgrim's Progress to the Promised Land by Robert Virding

www.erlang-solutions.com

20

Using frameworks and tools can create a deep mist which we need to make our way through as we build

our system.

The Mist of Frameworks

Page 21: Pilgrim's Progress to the Promised Land by Robert Virding

www.erlang-solutions.com

21

Frameworks can help by▸ Encapsulating behaviour▸Hiding boilerplate code▸ Providing default handling▸Hiding internal system structure

The Mist of Frameworks

BUTThis can make it difficult to understand what is going on.

Especially when things go wrong, or if I need to combine this framework with another one.

Page 22: Pilgrim's Progress to the Promised Land by Robert Virding

www.erlang-solutions.com

The Marsh of Fault-Tolerant Systems

Page 23: Pilgrim's Progress to the Promised Land by Robert Virding

www.erlang-solutions.com

23

There is a big marsh which we need to make our way through by building a fault-tolerant system. There are

many paths but we need to pick the best one

The Marsh of Fault-Tolerant Systems

Page 24: Pilgrim's Progress to the Promised Land by Robert Virding

www.erlang-solutions.com

24

The path of OTP is the obvious choice:

▸ It was designed to support building fault-tolerant systems▸Many of things we have probably already used are part of OTP▸The underlying system is built on it.▸ Elixir already extensively uses it and has extended it▸OTP is extensible when necessary

The Marsh of Fault-Tolerant Systems

BUTIt does require thinking about how your should behave WHEN

things go wrong

Page 25: Pilgrim's Progress to the Promised Land by Robert Virding

www.erlang-solutions.com

The Double-Edged Sword of Metaprogramming

Page 26: Pilgrim's Progress to the Promised Land by Robert Virding

www.erlang-solutions.com

26

You have been carrying the Sword of Metaprogramming and already used its effects without realising its power. It has the power to do both good,

and EVIL.

The Double-Edged Sword of Metaprogramming

Page 27: Pilgrim's Progress to the Promised Land by Robert Virding

www.erlang-solutions.com

27

Macros are a powerful tool which lets you build code at runtime▸Used wisely they can really be helpful▸Used unwisely they can lead to totally incomprehensible code▸You are already using macros:▹ defmodule, def and defp

▸Remember when macros are evaluated - they run at compile-time

The Double-Edged Sword of Metaprogramming

Page 28: Pilgrim's Progress to the Promised Land by Robert Virding

www.erlang-solutions.com

The Language Heaven is Multilingual

Page 29: Pilgrim's Progress to the Promised Land by Robert Virding

www.erlang-solutions.com

29

On your travels you have probably heard tales that the Language Heaven of the Promised Land is multilingual

and that there is squabbling between the language gods and between their followers.

DON'T DESPAIR!

The Language Heaven is Multilingual

Page 30: Pilgrim's Progress to the Promised Land by Robert Virding

www.erlang-solutions.com

30

The Language Heaven is Multilingual

By following "the rules" the languages openly interact with, and support, each other making the whole system more powerful than any individual language can ever be

The Language Heaven of the Promised Land is really the ERLANG ECOSYSTEM with all the languages built/running on top of the BEAM, Erlang and OTP.

Page 31: Pilgrim's Progress to the Promised Land by Robert Virding

www.erlang-solutions.com

31

The Language Heaven is Multilingual

The whole system can interact with other

systems

Page 32: Pilgrim's Progress to the Promised Land by Robert Virding

www.erlang-solutions.com

The Pool of Introspection

Page 33: Pilgrim's Progress to the Promised Land by Robert Virding

www.erlang-solutions.com

33

Sit by the pool and in the reflections of its waters look inside your system while it runs, introspect and gain

understanding.

The Pool of Introspection

Page 34: Pilgrim's Progress to the Promised Land by Robert Virding

www.erlang-solutions.com

34

There are a number of tools that allow you to introspect running systems:

▸Observer - part of the standard release▸Dbg - part of the standard release▸Recon - common 3rd party▸Redbug - common 3rd party▸WombatOAM - commercial product

These work in Erlang but the mapping to Elixir is very straightforward.

The Pool of Introspection

Page 35: Pilgrim's Progress to the Promised Land by Robert Virding

www.erlang-solutions.com

The Joy of Arrival

Page 36: Pilgrim's Progress to the Promised Land by Robert Virding

www.erlang-solutions.com

36

You have built your first REAL system and it works. It can handle all the load, survive errors and just keep

going.Rejoice, and realise the path wasn't really as difficult as

it at first seemed.

The Joy of Arrival

Page 37: Pilgrim's Progress to the Promised Land by Robert Virding

www.erlang-solutions.com

Robert [email protected]@erlang-solutions.com@rvirding