SlideShare a Scribd company logo
Learning Erlang


                   Ivan Yatskevich
    Lead Software Engineer, EPAM
Erlang intro
Learn at least one new language
           every year.
     Tip 8: Invest Regularly in Your
          Knowledge Portfolio
Erlang intro
Erlang intro
Erlang intro
Erlang intro
OTP
                                      Framework
                           Parallel
                           Erlang
             Distributed
             Erlang

Sequential
Erlang
Part I: Sequential Erlang
Data types, modules, functions, variables and pattern matching
Data types

• Numbers
 12, 2#10, 16#FF, 2.76
• Atoms
 ok, false, summer, „Wednesday‟
• Bit strings and binaries
 <<“Are you sure?”>>, <<45, 19, 4>>
Data types (cont’d)

• Containers (Lists, Tuples)
 List = [1, true, “Erlang”]
 Tuple = {io, format, [“~p~n”]}
• Functions
 Tripler = fun(N) -> N*3 end
• Identifiers (Refs, Pids, Ports)
(Fake) Data types

• Boolean
 true, false
• String
 “ABC” = [65, 66, 67]
• Record (≈tuple)
Building blocks

• Modules
• Functions
  •   Clauses
  •   Guards
  •   MFA
  •   BIFs
• Control structures
  • Case, If
  • Catch
Variables and Matching



Index ≠ Index + 1
{ "data":
  { "translations": [
     { "translatedText": "Hallo Welt" }
    ]
  }
}
Variables and Pattern Matching
Translation =
{data,
  {translations, [
     {translatedText, "Hallo Welt"}
    ]
  }
}.
{data,
  {translations, [
     {translatedText, Text}|Tail
    ]
  }
} = Translation.
Variables and Pattern Matching
Translation =
{data,
  {translations, [
     {translatedText, "Hallo Welt"}
    ]
  }
}.

{_, {_, [{_, Text}|_]}} = Translation.
LAN




Part II: Distributed Erlang
Nodes, net_adm module, a lot of fun
Distributed Erlang

• Nodes
 $ erl –name nyan_cat@127.0.0.1
• Cookies
 $ erl –sname nyan_cat –setcookie secret
• net_adm:ping
 erl> net_adm:ping(tom_cat@192.168.32.4).
Part III: Parallel Erlang
Processes, Pids, message passing
Parallel Erlang
• Processes
 Pid = spawn(fun() -> hi end).
• Sending message
 Pid ! {any_message, [“with”, list]}.
• Receiving message
 receive
    Pattern1 -> action1;
    Pattern2 -> action2
 after
    TimeInMs ->
         action_after_timeout
 end.
Parallel Erlang (cont’d)
• self()
• make_ref()
• System process and linking
• Named process
 register(name_as_atom, Pid).
Part IV: OTP Framework
Overview
OTP Framework



http://learnyousomeerlang.com/what-is-otp
Resources
• http://www.erlang.org
• http://www.tryerlang.org
• http://learnyousomeerlang.com
• http://www.trapexit.org/
• Programming Erlang, by Joe Armstrong
• Erlang Programming, by Francesco Cesarini and
  Simon Thompson
• Erlang and OTP in Action, by Martin Logan, Eric
  Merritt, and Richard Carlsson
• http://nyan.cat
Thank you!




Q&A

More Related Content

PPTX
Python programming introduction
PPT
Python Programming Language
PPTX
Python basics
PDF
Introduction to python programming
PDF
What is Python?
PPTX
Python Tutorial Part 1
PPTX
Introduction to Python Programming
DOCX
PYTHON NOTES
 
Python programming introduction
Python Programming Language
Python basics
Introduction to python programming
What is Python?
Python Tutorial Part 1
Introduction to Python Programming
PYTHON NOTES
 

What's hot (20)

PDF
Basic Concepts in Python
PPTX
Programming
PDF
Python programming
PPTX
Full Python in 20 slides
PPTX
introduction to python
PPT
Python ppt
PPTX
Python Seminar PPT
PPTX
Python introduction towards data science
PPTX
Python
PDF
Python Book/Notes For Python Book/Notes For S.Y.B.Sc. I.T.
PPTX
Python Basics
PPTX
Introduction to python
PPTX
Python Session - 2
PPTX
Python 3 Programming Language
PDF
Python Data Types
PPT
1.Role lexical Analyzer
PDF
The Ring programming language version 1.10 book - Part 7 of 212
PPTX
Python basics
PPTX
Python training
Basic Concepts in Python
Programming
Python programming
Full Python in 20 slides
introduction to python
Python ppt
Python Seminar PPT
Python introduction towards data science
Python
Python Book/Notes For Python Book/Notes For S.Y.B.Sc. I.T.
Python Basics
Introduction to python
Python Session - 2
Python 3 Programming Language
Python Data Types
1.Role lexical Analyzer
The Ring programming language version 1.10 book - Part 7 of 212
Python basics
Python training
Ad

Viewers also liked (7)

PDF
Mid Year Survey Results PMI SOC 2012 Mentoring Program
PPSX
賞蝶去
PPTX
Tecnologia
PPTX
SLIDESHARE
PPTX
Corporate changeagentsoverview
PPT
How to get thin legs
PPTX
Cambio apariencia a menu joomla con css
Mid Year Survey Results PMI SOC 2012 Mentoring Program
賞蝶去
Tecnologia
SLIDESHARE
Corporate changeagentsoverview
How to get thin legs
Cambio apariencia a menu joomla con css
Ad

Similar to Erlang intro (20)

PDF
Erlang, an overview
PDF
Erlang Message Passing Concurrency, For The Win
PDF
Introduction To Erlang Final
PDF
Erlang session1
PDF
Erlang intro
KEY
Erlang bootstrap course
PDF
Erlang session2
PDF
Introduction to Erlang Part 1
ODP
An introduction to erlang
PDF
Erlang is not a city in Germany
PPT
Reliable and Concurrent Software - Erlang
PDF
Introduction to Erlang for Python Programmers
PDF
Erlang - Concurrent Language for Concurrent World
PDF
Programming Erlang Software for a Concurrent World Second Edition Joe Armstrong
PDF
Erlang Lightning Talk
PPTX
Erlang os
PPTX
Introduction to Erlang Programming Language
PPTX
Erlang kickstart
PDF
Intro To Erlang
PPTX
Erlang, an overview
Erlang Message Passing Concurrency, For The Win
Introduction To Erlang Final
Erlang session1
Erlang intro
Erlang bootstrap course
Erlang session2
Introduction to Erlang Part 1
An introduction to erlang
Erlang is not a city in Germany
Reliable and Concurrent Software - Erlang
Introduction to Erlang for Python Programmers
Erlang - Concurrent Language for Concurrent World
Programming Erlang Software for a Concurrent World Second Edition Joe Armstrong
Erlang Lightning Talk
Erlang os
Introduction to Erlang Programming Language
Erlang kickstart
Intro To Erlang

Recently uploaded (20)

PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPT
Teaching material agriculture food technology
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
1. Introduction to Computer Programming.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Electronic commerce courselecture one. Pdf
PPTX
Spectroscopy.pptx food analysis technology
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Machine learning based COVID-19 study performance prediction
Programs and apps: productivity, graphics, security and other tools
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Teaching material agriculture food technology
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
MYSQL Presentation for SQL database connectivity
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Encapsulation_ Review paper, used for researhc scholars
Reach Out and Touch Someone: Haptics and Empathic Computing
1. Introduction to Computer Programming.pptx
Unlocking AI with Model Context Protocol (MCP)
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Building Integrated photovoltaic BIPV_UPV.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Mobile App Security Testing_ A Comprehensive Guide.pdf
Electronic commerce courselecture one. Pdf
Spectroscopy.pptx food analysis technology
Spectral efficient network and resource selection model in 5G networks
MIND Revenue Release Quarter 2 2025 Press Release
“AI and Expert System Decision Support & Business Intelligence Systems”
Machine learning based COVID-19 study performance prediction

Erlang intro

Editor's Notes

  • #4: Это не означает, что нужно овладеть языком на профессиональном уровне. Новый язык = новые идеи, подходы, иной способ мышления...
  • #8: Это был знак. Без долгих раздумий я приступил к изучению нового для меня языка. Сегодня я вам расскажу занимательную историю о том, как Erlang оказал существенное влияние на успех NyanCat’a.
  • #9: Сегодня мы узнаем, что пришлось сделать Нян Кэту на пути к успеху и параллельно изучим основные концепции языка Erlang. Начнем с типов данных и основных конструкций языкаи закончим обзором OTP фреймворка.
  • #12: Вот за что мне нравится Эрланг – в нем так мало встроенных типов!!! Но тут возникает – а достачно ли их?! Может каких-то типов нам не хватает?
  • #13: Показать, как создать запись. Запись ~= tuple. Теперь у нас есть всё (ну или почти всё), для того, чтобы создать Nyan Cat’а. Конечно же реальные приложения не пишутся в шеле Эрланга.
  • #14: Большое демо – создаем модуль nyan, функцию sing с проверкой, что тип – это atom, функцию eat, которая принимает только запись типа food (food, {content}). Case на примере реакции кота на определенную еду.MFA на примере apply, использование MFA можно встретить во многих модулях из stdlibBIFs – невозможно реализовать в Erlang, либо реализация будет неоптимальной: date(), time().Try..catch – есть, но не будем его сегодня рассматривать.А теперь более подробно поговорим о переменных... Мы уже видели, что переменные в Эрланге начинаются с большой буквы.ЭЭ, а где циклы?
  • #15: С большой буквыПоказать ошибку, когда I = I + 1Bound &amp; unbound
  • #16: Пример Саши Колоницкого
  • #18: Variable placeholder =&gt; “_”Unused variable = starts with “_” – “_Tail”Паттерн слева, выражение справа вычисляется и потом сравнивается с паттерном.Нет никакой связи с паттернами в смысле регулярных выражений.В какой-то момент Нян Кэт понял, что сидя на одном компьютере сильно популярным не станешь (да и не безопасно это. А вдруг комп сломается?)И поэтому решил узнать, как работает Distributed Erlang.