SlideShare ist ein Scribd-Unternehmen logo
1 von 27
Downloaden Sie, um offline zu lesen
Coding Dojo:
     Erlang
   Arkadi.Shishlov@gmail.com
Vladimir Tarasow netrat@netrat.eu
Today's tools


●   Erlang/OTP
●   EUnit
●   Rebar
●   IntelliJ IDEA 11 CE + Erlang plugin
●   ERL shell
●   MochiWeb's reloader.erl
    https://github.com/mochi/mochiweb/blob/master/src/reloader.erl

● erldocs.com
Some other day tools


●   Agner
●   Sublime Text 2 + SublimErl
●   Eclipse + ErlIDE
●   Emacs
●   Elixir
Erlang in nutshell


● Functional language
● Unusual syntax
● Forces into concurrent
  programming paradigm
● Robust VM
● Patterns for scalable services
● OTP
How's your Erlang homework?
Kata: Grep

1. Local file-system directory and its
   subdirectories contains large
   number of text files
2. Extract unobfuscated e-mail
   addresses; together with people
   names, if possible
3. Write the list of unique e-mails into
   specified output file
Coding Dojo
What is the Coding Dojo?


Coding Dojo is a meeting where a
bunch of coders get together to work
on a programming challenge.

They are there to have fun and to
engage in Deliberate Practice in
order to improve their skills.
Roles


●   Sensei
●   Moderator
●   Pair:
    ○   Pilot
    ○   Navigator
●   Audience
Sensei


Responsible for:
● No long discussions without the code.
● Working code by the end of the iteration.
● Tests are written during the iteration.
● Green tests by the end of the iteration,
  otherwise the next iteration begins by
  making tests green.
● Progress on fulfilling the Kata.
Moderator




Responsible for:
● facilitating attendees to obey the
  working agreements
● conducting the retrospective
Pair

Pair of two developers working and talking at
the PC in order to complete the Kata.

Pair consists of the pilot and the navigator.

The pilot codes and the navigator helps the
pilot to understand what has been done in
the previous iterations and what the pair
should do now.
Principles




Working on Kata
At the Dojo one can't discuss a form
without code, and one can't show
code without tests.
Principles

Timeboxing
Pair works during a fixed period of time.

Switching
The person who enters into the coding
timebox begins to act as a pilot. The person
who was the pilot during the previous
iteration switches to the position of the
navigator.
Respect



●   Ringtones of mobile phones are off. A
    person can answer a call, but he or she
    must leave the room to do it.
●   Only the pair at the PC can talk loud.
●   Sensei can interfere and talk loud by his or
    her own decision.
Respect


●   All discussions away from the PC must be
    made in the way not to spoil the pair’s
    deep diving into the Kata.
●   If a person wants to ask or suggest smth
    to the pair, he or she should raise the
    hand and wait for the moderator for
    permit.
●   Only one person from the observers can
    talk at a time.
Working
Agreement
Working agreement


       ? Randori, Parisian, Pairs ?

● Applicability of unit and functional
  tests
● Randori round time
● Switching: round-robin, by request
Kata: Grep - Erlang cluster


1. Join Erlang cluster
2. Send grep module to peers and
   start grep worker there
3. Send messages with files content
4. Receive list of e-mail
5. Aggregate results
Join Erlang cluster
1. Ping LAN bootstrap nodes
   - bootstrap@extensa
   - bootstrap@hal9011
2. Workes are:
   + nodes()
   - worker if name starts with "worker"

*except coordinator local VM [node()] to
simplify programming and prevent
aggregator bottlenecks
Send code to peers
1. The functionality is implemented by
   module 'grep'
2. 'grep' is also an (Erlang) application
3. use code:get_object/1 to read the module
   beam
4. use rpc:(multi)call/4, code:load_binary/1,
   erlang:spawn/4 to load beam and start
   application remotely
Send work
1. API signature:
   grep:grep(Dir) ->
      [ email1@domain, email2@domain2 ]
2. Obtain list of workers by calling nodes/0
3. Scan directory recursively and create a
   tuple:
   Work = { self(), Content }
4. Send message to next peer:
   { grep_worker, Node } ! { self(), Work }
Receive result
1. After all work units are sent - receive all
replies or timeout occur:
  recv(N) -> c:flush(), recv([], N).
  recv(A, 0) -> A.
  recv(A, N) ->
     receive
         {emails, Mails} -> recv([Mails | A], N-1)
     after 1000 -> A
     end.
2. Flatten, sort, uniq results
Worker workflow with OTP
1. Use OTP gen_server and supervisor
   behaviour-s with simple_one_for_one
   strategy
2. application:start/1 calls grep:init/1
3. grep:init/1 spawns a number of workers
   that is equal to core count as returned by
   erlang:system_info(schedulers)
4. grep:init/1 registers all workers with global:
   register_name/2
Credits

Venue




Book give-away
Latvian Developers Network
http://www.ldn.lv
    http://fb.me/LatvianDevelopersNetwork
    @LVDevNet



Arkadi Shislov
arkadi.shishlov@gmail.com
http://bitbucket.org/arkadi



Vladimir Tarasow
http://about.me/NetRat
This work is licensed under the Creative Commons Attribution-
NonCommercial-ShareAlike 3.0 Unported License. To view a copy of this
    license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/

Weitere ähnliche Inhalte

Was ist angesagt?

Comparing Cpp And Erlang For Motorola Telecoms Software
Comparing Cpp And Erlang For Motorola Telecoms SoftwareComparing Cpp And Erlang For Motorola Telecoms Software
Comparing Cpp And Erlang For Motorola Telecoms Software
l xf
 
Pré Descobrimento Do Brasil
Pré Descobrimento Do BrasilPré Descobrimento Do Brasil
Pré Descobrimento Do Brasil
ecsette
 

Was ist angesagt? (19)

NTUT Information Security Homework 1
NTUT Information Security Homework 1 NTUT Information Security Homework 1
NTUT Information Security Homework 1
 
Parallel program design
Parallel program designParallel program design
Parallel program design
 
Decision Making & Loops
Decision Making & LoopsDecision Making & Loops
Decision Making & Loops
 
Intro to Data Structure & Algorithms
Intro to Data Structure & AlgorithmsIntro to Data Structure & Algorithms
Intro to Data Structure & Algorithms
 
Python Interview Questions For Freshers
Python Interview Questions For FreshersPython Interview Questions For Freshers
Python Interview Questions For Freshers
 
Socket Programming In Python
Socket Programming In PythonSocket Programming In Python
Socket Programming In Python
 
Python final ppt
Python final pptPython final ppt
Python final ppt
 
Runtime Bytecode Transformation for Smalltalk
Runtime Bytecode Transformation for SmalltalkRuntime Bytecode Transformation for Smalltalk
Runtime Bytecode Transformation for Smalltalk
 
An Introduction to ANTLR
An Introduction to ANTLRAn Introduction to ANTLR
An Introduction to ANTLR
 
Comparing Cpp And Erlang For Motorola Telecoms Software
Comparing Cpp And Erlang For Motorola Telecoms SoftwareComparing Cpp And Erlang For Motorola Telecoms Software
Comparing Cpp And Erlang For Motorola Telecoms Software
 
Python week 7 8 2019-2020 for g10 by eng.osama ghandour
Python week 7 8 2019-2020 for g10 by eng.osama ghandourPython week 7 8 2019-2020 for g10 by eng.osama ghandour
Python week 7 8 2019-2020 for g10 by eng.osama ghandour
 
Python Interview Questions For Experienced
Python Interview Questions For ExperiencedPython Interview Questions For Experienced
Python Interview Questions For Experienced
 
Erlang For Five Nines
Erlang For Five NinesErlang For Five Nines
Erlang For Five Nines
 
Cutting edge android stack. One year later
Cutting edge android stack. One year laterCutting edge android stack. One year later
Cutting edge android stack. One year later
 
Lecture 10
Lecture 10Lecture 10
Lecture 10
 
Pré Descobrimento Do Brasil
Pré Descobrimento Do BrasilPré Descobrimento Do Brasil
Pré Descobrimento Do Brasil
 
Erlang - Concurrent Language for Concurrent World
Erlang - Concurrent Language for Concurrent WorldErlang - Concurrent Language for Concurrent World
Erlang - Concurrent Language for Concurrent World
 
Intro to Erlang
Intro to ErlangIntro to Erlang
Intro to Erlang
 
MPI message passing interface
MPI message passing interfaceMPI message passing interface
MPI message passing interface
 

Ähnlich wie Coding Dojo: Erlang

Python and Pytorch tutorial and walkthrough
Python and Pytorch tutorial and walkthroughPython and Pytorch tutorial and walkthrough
Python and Pytorch tutorial and walkthrough
gabriellekuruvilla
 
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdfHashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
ssuser705051
 
Linux multiplexing
Linux multiplexingLinux multiplexing
Linux multiplexing
Mark Veltzer
 
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
goccy
 

Ähnlich wie Coding Dojo: Erlang (20)

Multithreaded_Programming_in_Python.pdf
Multithreaded_Programming_in_Python.pdfMultithreaded_Programming_in_Python.pdf
Multithreaded_Programming_in_Python.pdf
 
Algoritmi e Calcolo Parallelo 2012/2013 - OpenMP
Algoritmi e Calcolo Parallelo 2012/2013 - OpenMPAlgoritmi e Calcolo Parallelo 2012/2013 - OpenMP
Algoritmi e Calcolo Parallelo 2012/2013 - OpenMP
 
Python week 6 2019 2020 for grade 10
Python week 6 2019 2020 for grade 10 Python week 6 2019 2020 for grade 10
Python week 6 2019 2020 for grade 10
 
Introduction to multicore .ppt
Introduction to multicore .pptIntroduction to multicore .ppt
Introduction to multicore .ppt
 
Distributed Elixir
Distributed ElixirDistributed Elixir
Distributed Elixir
 
GooglePropsal
GooglePropsalGooglePropsal
GooglePropsal
 
25-MPI-OpenMP.pptx
25-MPI-OpenMP.pptx25-MPI-OpenMP.pptx
25-MPI-OpenMP.pptx
 
Python and Pytorch tutorial and walkthrough
Python and Pytorch tutorial and walkthroughPython and Pytorch tutorial and walkthrough
Python and Pytorch tutorial and walkthrough
 
Intel open mp
Intel open mpIntel open mp
Intel open mp
 
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdfHashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
 
Terraform-2.pdf
Terraform-2.pdfTerraform-2.pdf
Terraform-2.pdf
 
Linux multiplexing
Linux multiplexingLinux multiplexing
Linux multiplexing
 
EKON 25 Python4Delphi_mX4
EKON 25 Python4Delphi_mX4EKON 25 Python4Delphi_mX4
EKON 25 Python4Delphi_mX4
 
DDD with Behat
DDD with BehatDDD with Behat
DDD with Behat
 
Concurrent Programming with Ruby and Tuple Spaces
Concurrent Programming with Ruby and Tuple SpacesConcurrent Programming with Ruby and Tuple Spaces
Concurrent Programming with Ruby and Tuple Spaces
 
Golang
GolangGolang
Golang
 
Golang
GolangGolang
Golang
 
Software Craftmanship - Cours Polytech
Software Craftmanship - Cours PolytechSoftware Craftmanship - Cours Polytech
Software Craftmanship - Cours Polytech
 
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
 
distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...
distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...
distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...
 

Coding Dojo: Erlang

  • 1. Coding Dojo: Erlang Arkadi.Shishlov@gmail.com Vladimir Tarasow netrat@netrat.eu
  • 2. Today's tools ● Erlang/OTP ● EUnit ● Rebar ● IntelliJ IDEA 11 CE + Erlang plugin ● ERL shell ● MochiWeb's reloader.erl https://github.com/mochi/mochiweb/blob/master/src/reloader.erl ● erldocs.com
  • 3. Some other day tools ● Agner ● Sublime Text 2 + SublimErl ● Eclipse + ErlIDE ● Emacs ● Elixir
  • 4. Erlang in nutshell ● Functional language ● Unusual syntax ● Forces into concurrent programming paradigm ● Robust VM ● Patterns for scalable services ● OTP
  • 5. How's your Erlang homework?
  • 6. Kata: Grep 1. Local file-system directory and its subdirectories contains large number of text files 2. Extract unobfuscated e-mail addresses; together with people names, if possible 3. Write the list of unique e-mails into specified output file
  • 8. What is the Coding Dojo? Coding Dojo is a meeting where a bunch of coders get together to work on a programming challenge. They are there to have fun and to engage in Deliberate Practice in order to improve their skills.
  • 9. Roles ● Sensei ● Moderator ● Pair: ○ Pilot ○ Navigator ● Audience
  • 10. Sensei Responsible for: ● No long discussions without the code. ● Working code by the end of the iteration. ● Tests are written during the iteration. ● Green tests by the end of the iteration, otherwise the next iteration begins by making tests green. ● Progress on fulfilling the Kata.
  • 11. Moderator Responsible for: ● facilitating attendees to obey the working agreements ● conducting the retrospective
  • 12. Pair Pair of two developers working and talking at the PC in order to complete the Kata. Pair consists of the pilot and the navigator. The pilot codes and the navigator helps the pilot to understand what has been done in the previous iterations and what the pair should do now.
  • 13. Principles Working on Kata At the Dojo one can't discuss a form without code, and one can't show code without tests.
  • 14. Principles Timeboxing Pair works during a fixed period of time. Switching The person who enters into the coding timebox begins to act as a pilot. The person who was the pilot during the previous iteration switches to the position of the navigator.
  • 15. Respect ● Ringtones of mobile phones are off. A person can answer a call, but he or she must leave the room to do it. ● Only the pair at the PC can talk loud. ● Sensei can interfere and talk loud by his or her own decision.
  • 16. Respect ● All discussions away from the PC must be made in the way not to spoil the pair’s deep diving into the Kata. ● If a person wants to ask or suggest smth to the pair, he or she should raise the hand and wait for the moderator for permit. ● Only one person from the observers can talk at a time.
  • 18. Working agreement ? Randori, Parisian, Pairs ? ● Applicability of unit and functional tests ● Randori round time ● Switching: round-robin, by request
  • 19. Kata: Grep - Erlang cluster 1. Join Erlang cluster 2. Send grep module to peers and start grep worker there 3. Send messages with files content 4. Receive list of e-mail 5. Aggregate results
  • 20. Join Erlang cluster 1. Ping LAN bootstrap nodes - bootstrap@extensa - bootstrap@hal9011 2. Workes are: + nodes() - worker if name starts with "worker" *except coordinator local VM [node()] to simplify programming and prevent aggregator bottlenecks
  • 21. Send code to peers 1. The functionality is implemented by module 'grep' 2. 'grep' is also an (Erlang) application 3. use code:get_object/1 to read the module beam 4. use rpc:(multi)call/4, code:load_binary/1, erlang:spawn/4 to load beam and start application remotely
  • 22. Send work 1. API signature: grep:grep(Dir) -> [ email1@domain, email2@domain2 ] 2. Obtain list of workers by calling nodes/0 3. Scan directory recursively and create a tuple: Work = { self(), Content } 4. Send message to next peer: { grep_worker, Node } ! { self(), Work }
  • 23. Receive result 1. After all work units are sent - receive all replies or timeout occur: recv(N) -> c:flush(), recv([], N). recv(A, 0) -> A. recv(A, N) -> receive {emails, Mails} -> recv([Mails | A], N-1) after 1000 -> A end. 2. Flatten, sort, uniq results
  • 24. Worker workflow with OTP 1. Use OTP gen_server and supervisor behaviour-s with simple_one_for_one strategy 2. application:start/1 calls grep:init/1 3. grep:init/1 spawns a number of workers that is equal to core count as returned by erlang:system_info(schedulers) 4. grep:init/1 registers all workers with global: register_name/2
  • 26. Latvian Developers Network http://www.ldn.lv http://fb.me/LatvianDevelopersNetwork @LVDevNet Arkadi Shislov arkadi.shishlov@gmail.com http://bitbucket.org/arkadi Vladimir Tarasow http://about.me/NetRat
  • 27. This work is licensed under the Creative Commons Attribution- NonCommercial-ShareAlike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/