Coding Dojo: Erlang
Upcoming SlideShare
Loading in...5
×
 

Coding Dojo: Erlang

on

  • 1,198 views

http://meetu.ps/hxHVz

http://meetu.ps/hxHVz

Statistics

Views

Total Views
1,198
Views on SlideShare
1,194
Embed Views
4

Actions

Likes
1
Downloads
5
Comments
0

2 Embeds 4

https://twitter.com 3
https://si0.twimg.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Coding Dojo: Erlang Coding Dojo: Erlang Presentation Transcript

  • Coding Dojo: Erlang Arkadi.Shishlov@gmail.comVladimir Tarasow netrat@netrat.eu
  • Todays tools● Erlang/OTP● EUnit● Rebar● IntelliJ IDEA 11 CE + Erlang plugin● ERL shell● MochiWebs 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
  • Hows your Erlang homework?
  • 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
  • Coding Dojo
  • 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.
  • Roles● Sensei● Moderator● Pair: ○ Pilot ○ Navigator● Audience
  • 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.
  • ModeratorResponsible for:● facilitating attendees to obey the working agreements● conducting the retrospective
  • 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.
  • PrinciplesWorking on KataAt the Dojo one cant discuss a formwithout code, and one cant showcode without tests.
  • 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.
  • 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.
  • WorkingAgreement
  • Working agreement ? Randori, Parisian, Pairs ?● Applicability of unit and functional tests● Randori round time● Switching: round-robin, by request
  • 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
  • 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
  • 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
  • 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 }
  • 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
  • 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
  • CreditsVenueBook give-away
  • Latvian Developers Networkhttp://www.ldn.lv http://fb.me/LatvianDevelopersNetwork @LVDevNetArkadi Shislovarkadi.shishlov@gmail.comhttp://bitbucket.org/arkadiVladimir Tarasowhttp://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/