Your SlideShare is downloading. ×
Coding Dojo: Erlang
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.

Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Coding Dojo: Erlang


Published on

1 Like
  • Be the first to comment

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

No notes for slide


  • 1. Coding Dojo: Erlang Arkadi.Shishlov@gmail.comVladimir Tarasow
  • 2. Todays tools● Erlang/OTP● EUnit● Rebar● IntelliJ IDEA 11 CE + Erlang plugin● ERL shell● MochiWebs reloader.erl●
  • 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. Hows your Erlang homework?
  • 6. Kata: Grep1. Local file-system directory and its subdirectories contains large number of text files2. Extract unobfuscated e-mail addresses; together with people names, if possible3. Write the list of unique e-mails into specified output file
  • 7. Coding Dojo
  • 8. What is the Coding Dojo?Coding Dojo is a meeting where abunch of coders get together to workon a programming challenge.They are there to have fun and toengage in Deliberate Practice inorder to improve their skills.
  • 9. Roles● Sensei● Moderator● Pair: ○ Pilot ○ Navigator● Audience
  • 10. SenseiResponsible 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. ModeratorResponsible for:● facilitating attendees to obey the working agreements● conducting the retrospective
  • 12. PairPair of two developers working and talking atthe PC in order to complete the Kata.Pair consists of the pilot and the navigator.The pilot codes and the navigator helps thepilot to understand what has been done inthe previous iterations and what the pairshould do now.
  • 13. PrinciplesWorking on KataAt the Dojo one cant discuss a formwithout code, and one cant showcode without tests.
  • 14. PrinciplesTimeboxingPair works during a fixed period of time.SwitchingThe person who enters into the codingtimebox begins to act as a pilot. The personwho was the pilot during the previousiteration switches to the position of thenavigator.
  • 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.
  • 17. WorkingAgreement
  • 18. Working agreement ? Randori, Parisian, Pairs ?● Applicability of unit and functional tests● Randori round time● Switching: round-robin, by request
  • 19. Kata: Grep - Erlang cluster1. Join Erlang cluster2. Send grep module to peers and start grep worker there3. Send messages with files content4. Receive list of e-mail5. Aggregate results
  • 20. Join Erlang cluster1. Ping LAN bootstrap nodes - bootstrap@extensa - bootstrap@hal90112. Workes are: + nodes() - worker if name starts with "worker"*except coordinator local VM [node()] tosimplify programming and preventaggregator bottlenecks
  • 21. Send code to peers1. The functionality is implemented by module grep2. grep is also an (Erlang) application3. use code:get_object/1 to read the module beam4. use rpc:(multi)call/4, code:load_binary/1, erlang:spawn/4 to load beam and start application remotely
  • 22. Send work1. API signature: grep:grep(Dir) -> [ email1@domain, email2@domain2 ]2. Obtain list of workers by calling nodes/03. Scan directory recursively and create a tuple: Work = { self(), Content }4. Send message to next peer: { grep_worker, Node } ! { self(), Work }
  • 23. Receive result1. After all work units are sent - receive allreplies 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 OTP1. Use OTP gen_server and supervisor behaviour-s with simple_one_for_one strategy2. application:start/1 calls grep:init/13. 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
  • 25. CreditsVenueBook give-away
  • 26. Latvian Developers Network @LVDevNetArkadi Shislovarkadi.shishlov@gmail.com Tarasow
  • 27. This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. To view a copy of this license, visit