Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Beam me up, scotty (PUG Roma)

Elixir and Erlang share the same VM called BEAM. In this very practical demo, we discover some secrets of BEAM and OTP. This a refreshed version of an old presentations.

  • Be the first to comment

  • Be the first to like this

Beam me up, scotty (PUG Roma)

  1. 1. BEAM me up, Scotty Prepare ship...prepare ship...for LUDICROUS SPEED!!!!
  2. 2. GPad Born to be a developer with an interest in distributed system. I have developed with many languages like C++, C#, js and ruby. I had fallen in love with functional programming, especially with Elixir and Erlang. ● Twitter: https://twitter.com/gpad619 ● Github: https://github.com/gpad/ ● Medium: https://medium.com/@gpad CTO & founder of coders51
  3. 3. Coders51 Is Hiring!!! Write to admin@coders51.com or gpad@coders51.com
  4. 4. BEAM
  5. 5. BEAM From wikipedia: BEAM is the virtual machine at the core of the Erlang Open Telecom Platform (OTP). BEAM is part of the Erlang Run-Time System (ERTS), which compiles Erlang and Elixir source code into bytecode, which is then executed on the BEAM. BEAM bytecode files have the .beam file extension.
  6. 6. BEAM From wikipedia: Originally BEAM was short for Bogdan's Erlang Abstract Machine, named after Bogumil "Bogdan" Hausman, who wrote the original version, but the name may also be referred to as Björn's Erlang Abstract Machine, after Björn Gustavsson, who wrote and maintains the current version. Both developers worked on the system while at Ericsson. The predecessor of the BEAM was JAM (Joe's Abstract Machine), which was the first virtual machine for the Erlang language and was written by Joe Armstrong.
  7. 7. History From http://www.erlang.org/course/history ● 1982 -1985 - First experiment with 20 different languages. ● 1985 - 1986 - Experiments with Lisp,Prolog, Parlog etc. Conclusion: The language must contain primitives for concurrency and error recovery. ● 1987 - First experiment with Erlang.
  8. 8. History From http://www.erlang.org/course/history ● ... ● 1990 - Erlang is presented at ISS'90, which results in several new users. ● 1992 - Erlang is ported to VxWorks, PC, Macintosh etc. Three applications using Erlang are presented at ISS'92. ● 1993 - Distribution is added to Erlang, which makes it possible to run a homogeneous Erlang system on a heterogeneous hardware.
  9. 9. History From https://en.wikipedia.org/wiki/Java_version_history#JDK_Alpha_and_Beta The first alpha and beta Java public releases in 1995 had highly unstable APIs and ABIs. The supplied Java web browser was named WebRunner. From https://en.wikipedia.org/wiki/Java_version_history#JDK_1.0 The first version was released on January 23, 1996 and called Oak.[3][4] The first stable version, JDK 1.0.2, is called Java 1.
  10. 10. History From https://en.wikipedia.org/wiki/.NET_Framework_version_history#.NET_Framework_1.0 The first version of the .NET Framework was released on 13 February 2002 for Windows 98, ME, NT 4.0, 2000, and XP.
  11. 11. History From https://en.wikipedia.org/wiki/PHP PHP is a general-purpose scripting language especially suited to web development. It was originally created by Danish-Canadian programmer Rasmus Lerdorf in 1994.
  12. 12. Why BEAM From http://www.erlang.org/ Erlang is a programming language used to build massively scalable soft real-time systems with requirements on high availability. Some of its uses are in telecoms, banking, e-commerce, computer telephony and instant messaging. Erlang's runtime system has built-in support for concurrency, distribution and fault tolerance.
  13. 13. Why BEAM From http://stackoverflow.com/questions/16779162/what-kind-of-virtual-machine-is-beam-the-erlang-vm The Erlang VM runs as one OS process. By default it runs one OS thread per core to achieve maximum utilisation of the machine. The number of threads and on which cores they run can be set when the VM is started.
  14. 14. Why BEAM From http://stackoverflow.com/questions/16779162/what-kind-of-virtual-machine-is-beam-the-erlang-vm Erlang processes are implemented entirely by the Erlang VM and have no connection to either OS processes or OS threads. So even if you are running an Erlang system of over one million processes it is still only one OS processes and one thread per core. So in this sense the Erlang VM is a "process virtual machine" while the Erlang system itself very much behaves like an OS and Erlang process have very similar properties to OS processes, for example isolation. There is actually an Erlang VM, based on the BEAM, which runs on the bare metal and is in fact an OS in its own right, see Erlang on Xen.
  15. 15. Why BEAM From http://stackoverflow.com/questions/16779162/what-kind-of-virtual-machine-is-beam-the-erlang-vm Btw it is perfectly possible to have systems running millions of Erlang processes and it is actually done in some products, for example WhatsApp. We were definitely thinking very much about OSes when we designed the basic Erlang environment. Robert Virding
  16. 16. DEMO
  17. 17. GenServer/Supervisor GenServer reacts to message it receives. Executes some actions and return to itself the new state. Supervisor monitors and is linked to its children and when detect their death it restart (using different policies).
  18. 18. OTP
  19. 19. OTP From http://www.erlang.org/ OTP is set of Erlang libraries and design principles providing middle-ware to develop these systems. It includes its own distributed database, applications to interface towards other languages, debugging and release handling tools.
  20. 20. Why OTP ● GenServer ● Supervisor ● A lot of other patterns ... ● Always think in async and distributed way (timeout) ● The community think about to increase (CRDT, GenStage, Broadway, etc…)
  21. 21. DEMO
  22. 22. Warning!!!!
  23. 23. Don’t try this at home
  24. 24. DEMO
  25. 25. What are the fields of application of Elixir?
  26. 26. Web Development
  27. 27. Machine Learning
  28. 28. Embed
  29. 29. Messaging
  30. 30. Who is using Elixir/Erlang?
  31. 31. Batteries Included Erlang and all OTP (gen_server, logger, mnesia, distribution, etc …) Tool to build and deploy your application (mix, eunit, etc …) Some libraries supported by “core team” (ecto, phoenix, telemetry, etc …)
  32. 32. Where to start https://elixir-lang.org/ https://beam-italia.slack.com/ http://www.italian-elixir.org/ https://www.meetup.com/it-IT/Elixir-Roma/
  33. 33. Thank you!!

×