SlideShare a Scribd company logo
1 of 26
Learning Erlang


                   Ivan Yatskevich
    Lead Software Engineer, EPAM
Learn at least one new language
           every year.
     Tip 8: Invest Regularly in Your
          Knowledge Portfolio
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

What's hot

Full Python in 20 slides
Full Python in 20 slidesFull Python in 20 slides
Full Python in 20 slides
rfojdar
 

What's hot (20)

Basic Concepts in Python
Basic Concepts in PythonBasic Concepts in Python
Basic Concepts in Python
 
Programming
ProgrammingProgramming
Programming
 
Python programming
Python programmingPython programming
Python programming
 
Full Python in 20 slides
Full Python in 20 slidesFull Python in 20 slides
Full Python in 20 slides
 
introduction to python
 introduction to python introduction to python
introduction to python
 
Python ppt
Python pptPython ppt
Python ppt
 
Python Seminar PPT
Python Seminar PPTPython Seminar PPT
Python Seminar PPT
 
Python introduction towards data science
Python introduction towards data sciencePython introduction towards data science
Python introduction towards data science
 
Python
PythonPython
Python
 
Python Book/Notes For Python Book/Notes For S.Y.B.Sc. I.T.
Python Book/Notes For Python Book/Notes For S.Y.B.Sc. I.T.Python Book/Notes For Python Book/Notes For S.Y.B.Sc. I.T.
Python Book/Notes For Python Book/Notes For S.Y.B.Sc. I.T.
 
Python Basics
Python BasicsPython Basics
Python Basics
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Python Session - 2
Python Session - 2Python Session - 2
Python Session - 2
 
Python 3 Programming Language
Python 3 Programming LanguagePython 3 Programming Language
Python 3 Programming Language
 
Python Data Types
Python Data TypesPython Data Types
Python Data Types
 
1.Role lexical Analyzer
1.Role lexical Analyzer1.Role lexical Analyzer
1.Role lexical Analyzer
 
The Ring programming language version 1.10 book - Part 7 of 212
The Ring programming language version 1.10 book - Part 7 of 212The Ring programming language version 1.10 book - Part 7 of 212
The Ring programming language version 1.10 book - Part 7 of 212
 
Lex
LexLex
Lex
 
Python basics
Python basicsPython basics
Python basics
 
Python training
Python trainingPython training
Python training
 

Viewers also liked (7)

Mid Year Survey Results PMI SOC 2012 Mentoring Program
Mid Year Survey Results PMI SOC 2012 Mentoring ProgramMid Year Survey Results PMI SOC 2012 Mentoring Program
Mid Year Survey Results PMI SOC 2012 Mentoring Program
 
賞蝶去
賞蝶去賞蝶去
賞蝶去
 
Tecnologia
TecnologiaTecnologia
Tecnologia
 
SLIDESHARE
SLIDESHARESLIDESHARE
SLIDESHARE
 
Corporate changeagentsoverview
Corporate changeagentsoverviewCorporate changeagentsoverview
Corporate changeagentsoverview
 
How to get thin legs
How to get thin legsHow to get thin legs
How to get thin legs
 
Cambio apariencia a menu joomla con css
Cambio apariencia a menu joomla con cssCambio apariencia a menu joomla con css
Cambio apariencia a menu joomla con css
 

Similar to Erlang intro

Erlang Message Passing Concurrency, For The Win
Erlang  Message  Passing  Concurrency,  For  The  WinErlang  Message  Passing  Concurrency,  For  The  Win
Erlang Message Passing Concurrency, For The Win
l xf
 
Introduction To Erlang Final
Introduction To Erlang   FinalIntroduction To Erlang   Final
Introduction To Erlang Final
SinarShebl
 
Keynote joearmstrong
Keynote joearmstrongKeynote joearmstrong
Keynote joearmstrong
Sentifi
 
Unmanaged Parallelization via P/Invoke
Unmanaged Parallelization via P/InvokeUnmanaged Parallelization via P/Invoke
Unmanaged Parallelization via P/Invoke
Dmitri Nesteruk
 
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
DRVaibhavmeshram1
 
Migrating from matlab to python
Migrating from matlab to pythonMigrating from matlab to python
Migrating from matlab to python
ActiveState
 
Python and Pytorch tutorial and walkthrough
Python and Pytorch tutorial and walkthroughPython and Pytorch tutorial and walkthrough
Python and Pytorch tutorial and walkthrough
gabriellekuruvilla
 
Tutorial on-python-programming
Tutorial on-python-programmingTutorial on-python-programming
Tutorial on-python-programming
Chetan Giridhar
 

Similar to Erlang intro (20)

Python programming
Python programmingPython programming
Python programming
 
Erlang Message Passing Concurrency, For The Win
Erlang  Message  Passing  Concurrency,  For  The  WinErlang  Message  Passing  Concurrency,  For  The  Win
Erlang Message Passing Concurrency, For The Win
 
01-Python-Basics.ppt
01-Python-Basics.ppt01-Python-Basics.ppt
01-Python-Basics.ppt
 
Erlang/OTP for Rubyists
Erlang/OTP for RubyistsErlang/OTP for Rubyists
Erlang/OTP for Rubyists
 
Introduction To Erlang Final
Introduction To Erlang   FinalIntroduction To Erlang   Final
Introduction To Erlang Final
 
Basics of Python Programming in one PDF File.pdf
Basics of Python Programming in one PDF File.pdfBasics of Python Programming in one PDF File.pdf
Basics of Python Programming in one PDF File.pdf
 
Sioux Hot-or-Not: Functional programming: unlocking the real power of multi-c...
Sioux Hot-or-Not: Functional programming: unlocking the real power of multi-c...Sioux Hot-or-Not: Functional programming: unlocking the real power of multi-c...
Sioux Hot-or-Not: Functional programming: unlocking the real power of multi-c...
 
GE3151_PSPP_UNIT_5_Notes
GE3151_PSPP_UNIT_5_NotesGE3151_PSPP_UNIT_5_Notes
GE3151_PSPP_UNIT_5_Notes
 
Erlang is not a city in Germany
Erlang is not a city in GermanyErlang is not a city in Germany
Erlang is not a city in Germany
 
Python (3).pdf
Python (3).pdfPython (3).pdf
Python (3).pdf
 
Erlang
ErlangErlang
Erlang
 
Keynote joearmstrong
Keynote joearmstrongKeynote joearmstrong
Keynote joearmstrong
 
Unmanaged Parallelization via P/Invoke
Unmanaged Parallelization via P/InvokeUnmanaged Parallelization via P/Invoke
Unmanaged Parallelization via P/Invoke
 
R tech introcomputer
R tech introcomputerR tech introcomputer
R tech introcomputer
 
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
 
1B-Introduction_to_python.ppt
1B-Introduction_to_python.ppt1B-Introduction_to_python.ppt
1B-Introduction_to_python.ppt
 
Migrating from matlab to python
Migrating from matlab to pythonMigrating from matlab to python
Migrating from matlab to python
 
Python and Pytorch tutorial and walkthrough
Python and Pytorch tutorial and walkthroughPython and Pytorch tutorial and walkthrough
Python and Pytorch tutorial and walkthrough
 
Tutorial on-python-programming
Tutorial on-python-programmingTutorial on-python-programming
Tutorial on-python-programming
 
JavaOne 2012 - CON11234 - Multi device Content Display and a Smart Use of Ann...
JavaOne 2012 - CON11234 - Multi device Content Display and a Smart Use of Ann...JavaOne 2012 - CON11234 - Multi device Content Display and a Smart Use of Ann...
JavaOne 2012 - CON11234 - Multi device Content Display and a Smart Use of Ann...
 

Recently uploaded

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Recently uploaded (20)

Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 

Erlang intro

Editor's Notes

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