SlideShare a Scribd company logo
1 of 43
Download to read offline
ERLANG
THE WORLD IS PARALLEL.




                 Picture: http://www.cs.purdue.edu/homes/jv/events/TiC06/pr.jpg
the world is parallel.
If we want to write programs that behave as
   other objects behave in the real world, then
   these programs will have a concurrent
   structure.
Use a language that was designed for writing
   concurrent applications, and development
   becomes a lot easier.
Erlang programs model how we think and
   interact.

                               Joe Armstrong
Agenda
    What we cover
    What we don’t cover
    You used Erlang to write what?
    History
    OTP
    The language
    Concurrency
    Distribution
    Hot code swapping
    Compile and run
    Development environments
    Various tidbits
Note and forgive that…
  This is an Erlang beginner trying to give you
   an overview
  I haven’t used Erlang for a while
What we cover
  What is it good for?
  Glance at functional programming

  Basic syntax and structure

  Erlang’s main features

  Basic tools to get you started

  Info on where to find more

   material
What we DON’T cover
  How to install Erlang
  A (blog) tutorial in 15 minutes

  Language reference

  How to write programs using a
   functional programming language
  How to parallelize programs

  How to distribute algorithms

  How to use the Open Telecom Platform

  Tons of example code
Therefore
    Read the book
You used Erlang to write what?




              http://www.cio.com/article/191000/You_Used_Ruby_to_Write_WHAT_
              http://www.zedshaw.com/
You used Erlang to write what?
    Systems/Applications that are:
       Concurrent

       Parallel (SMP)
       Distributed

       Fault tolerant

       Dynamically upgradable
History
  Created by the Computer Science Laboratory
   at Ellemtel (now Ericsson AB) around 1990
  Named after A. K. Erlang (not Ericsson
   Language)
  Licensed Version (Ericsson http://

   www.erlang.se)
  Released as open source in 1998 under EPL

   (http://www.erlang.org)


                                    Ref: wikipedia.org
Open Telecom Platform
  Middleware
  Similar to J2EE Container (JBoss, GlassFish,

   IBM WebSphere, BEA Weblogic)
  Coding standards

  Tools like web server, FTP server and CORBA

   ORB are included in OTP
  Licensed under Erlang Public License (EPL)
OTP




 Source: http://www.ericsson.com/technology/opensource/erlang/index.shtml
 Picture: http://www.ericsson.com/technology/opensource/images/erlang.gif
Erlang in use
  Ejabberd (http://www.ejabberd.im)
  Yaws (http://yaws.hyber.org/)

  CouchDB (
   http://incubator.apache.org/couchdb)
  Ericsson products AXD301 (ATM switch),

   SGSN, GGSN (GPRS nodes) according to
   http://www.erlang.se/productinfo/index.shtml
The language
    Functional programming language!
       (little)
              to no side effects
       Single assignment variables

       Pattern matching

       Higher-order functions

       Recursion

       No objects

       Haskell, Lisp, ML, F#, Scheme
So don’t think imperative!
    Don’t think
       Java

       C#

       C

       PHP

       Etc.
Think




Function
al!
Don’t think




Procedur
al
Think




 Recursi
 ve!
Don’t think




Loop
y
Let‘s get started




         Picture: http://www.wampower.com/images/wam%20pics/getting%20started/getting_started.jpg
Let’s get started
  Start interactive shell called erl and try things
   out (like irb in Ruby)
  ^G q to quit the shell

  % indicates a comment

  . terminates a statement
Files, modules and functions
    Example on next slide
    Module “geometry” would be defined in
     “geometry.erl”
    Export the functions you want to be public
    Don’t forget to specify the arity, number of params
     in function’s signature (e.g area/1)
    Compile modules within erl before using them
     c(module_name)
    Use : to access a module’s public functions =>
     lists:filter()
    erl –man module_name for man page => erl -man
     lists
Variables
    Start with an uppercase letter
    Single assignment like in Prolog so X = X + 1 is a
     no go
    Integers
       No limitation for integers e.g. faculty of 2000 returns
       valid result (Try that in Eiffel™)
    Floats
       A division always returns a float
       Limited in size (IEEE 754 64-bit)

    Strings: S = “world” (double quotes)
Atoms and Tuples
    Atoms
       Represent   non numerical constant values
       Start with lowercase letter

    Tuples
       Store a fixed number of items into a single entity
       F = {name , isabella}

       E = {woweffect, 10}

       Person = {person,{height,10},{gender,male}}

       Beauty = {beauty , F , E}
Lists
    Store variable numbers of things
    Head and tail syntax
    Define a list:
       Student_grades             = [{john,c},{michael,b},{lolita,aplus},
       {joe,b}].
    Extract into head and tail
       [Headval1,Headval2|Tailval]= Student_grades
       Where Headval1 matches with the 1st element,
        Headval2 with 2nd and Tailval with the rest
    See erl –man lists
                   http://images.apple.com/downloads/dashboard/travel/images/traveltodolist_20070724165034.jpg
Functions
-module(intro).
-export([main/0,factorial/1,some_other_function/0]).
% number in export statement defines arity of exported function
% only exported functions can be used from outside the module
main() -> io:format("The factorial of 5 is ~w ~n”,[factorial(5)]).
factorial(0) -> 1;
factorial(nonsense) -> "nonsense";                               
factorial(N) -> N*factorial(N-1).
% use comma to add statements together
some_other_function() ->                   
T = private_module_function(10,20),
 

     
       
T + 11.
% this function is not available from outside the module
private_module_function(X,Y) -> X * Y.



               Picture: http://casoilresource.lawr.ucdavis.edu/drupal/files/images/logistic-small.png
Anonymous functions (Funs)




           http://image.guardian.co.uk/sys-images/Arts/Arts_/Pictures/2007/08/10/laugh460.jpg
Anonymous functions (Funs)
    Like in JavaScript, delegates in C#
    Like regular functions but the word “end” defines the
     end of the function. Still use a period to indicate end of
     line.
    Cubic = fun(X) -> X*X*X end.
    Cubic(2) evaluates to 8.
    Funs can be useful as arguments eg. inline
       lists:filter(fun(X) -> X > 10 end, [1,2,3,445,28,203]).
       Returns [445,28,203]
    It is legal to pass a variable containing a Fun instead
     of defining it inline
    Funs can return Funs
List comprehensions
  Mostly shorter than funs, maps and filters
  To triple every element using funs we could

   write:
       Lists:map(fun(N)     -> 3*N end, L)
    Using list comprehensions
       [   3*N || N <- L]
    More complex forms are possible
       [{triple, 3*N} || N <- L]
       According to the rules of pattern matching
Stuff left out to save time
     Guards => Conditions
           f(X) when is_integer(X), X > 10 ->
            io:format(“X is greater than 10”).
           Predicates like is_integer()
           Built-in functions like length(X)
     Records (for large tuples)
     ETS / DTS
     case and if Expressions
     Exceptions (try catch syntax)
     Built-in Functions (BIFs)
           http://www.erlang.org/doc/man/erlang.html
     Macros


     Picture: http://www.ourappraisal.com/xsites/Appraisers/centralilappraisal/content/uploadedFiles/refi_clock_ticking.jpg
Concurrency
    Processes belong to Erlang and not the operating
     system (User, not kernel space)
    Creating and destroying processes is very fast
    Sending messages between processes is very
     fast
    Processes behave the same way on all operating
     systems
    We can have a large number of processes.
    Processes share no memory and are completely
     independent
    The only way for processes to interact is through
     message passing
Concurrency
    Concurrency primitives
       spawn
       Pid = spawn(Fun)
       send
       Pid ! Message
       receive
           receive
               Pattern 1
                 Expressions1;
               Pattern 2
                 Expressions 2;
               ...
           end



                                   Picture: http://www.spacecast.com/images/Shows/spawn_img1.jpg
Distribution
    Distributed Erlang
       Programs   are written to run on Erlang nodes
       Spawning processes on any node is very easy

       Message passing and error handling is the same as in
        a non distributed environment (one single node).
       The nodes run in a trusted environment (same LAN)

       Make sure, you run the same codebase and erlang
        version
    Socket-Based Distribution
       UsingTCP/IP Sockets
       The Applications can run in a untrusted environment
Hot Code Swapping




             Picture: http://www.firewebdesigns.com/images/fire_02.jpg
Hot Code Swapping
    Erlang supports change of code in a running
     system
       Very   cool for upgrading software
    Code for Module exist in two variants in the
     system
       State Current
       State Old

    OTP provides libraries for enhanced Code
     Swapping functionality
Multicore CPU’s
    Again, in Erlang, processes have no shared
     memory, so no mutexes, locks whatsoever
    Make sure, your program has a lot of processes
    Avoid side effects (those that the language and
     the runtime can’t prevent)
    In fact, Erlang has shared data structures
     (ETS,DETS). Better use Mnesia with transactions
     if you need a shared storage.
       Mnesia  is a distributed DBMS for Erlang
       http://www.erlang.org/documentation/doc-5.0.1/lib/
        mnesia-3.9.2/doc/index.html
Symmetric Muliprocessing
with SMP Erlang
    erl –smp +S N
       Where   N specifies the number of schedulers to
        use
       A Scheduler is a complete virtual machine

       Possibility to emulate a system with more CPU’s

    See previous slide for some requirements to
     parallelize a program
Compile and run
    Within erl shell
       c(module_name)

    Compiler
       erlc  module_name.erl
       erl –noshell –s module_name function_name –s
        init stop
    As an escript
     #!/usr/bin/env escript
     main(_) ->
        io:format("hello world~n").
    Automate things using build tools like make, ant
     etc.
Development environment
    http://www.erlang.org/download.html to install
     environment
    Erlang mode for emacs
         http://www.erlang.org/doc/apps/tools/
          erlang_mode_chapter.html
    Erlang bundle for TextMate
         http://macromates.com/svn/Bundles/trunk/Bundles/
          Erlang.tmbundle/
    Erlybird for Netbeans
         http://sourceforge.net/projects/erlybird/
    Erlide
         http://erlide.sourceforge.net/
Various tidbits
    Documentation generator called Edoc which is similar to Javadoc™
         http://www.erlang.org/doc/apps/edoc/index.html
    When things go wrong, consult the crash dump.
         webtool:start().
         Go to http://localhost:8888
    Unit testing framework called EUnit making heavy use of macros for
     the assertions
         http://svn.process-one.net/contribs/trunk/eunit/doc/overview-
          summary.html
    ErlyWeb, a web framework written in Erlang
         http://yarivsblog.com
    The Dialyzer, a static analysis tool to identify problems with program
     code
         http://www.it.uu.se/research/group/hipe/dialyzer/
Where to find help?
    Excellent documentation and examples on
     erlang.org
       http://www.erlang.org/starting.html
       http://www.erlang.org/doc.html
       http://www.erlang.org/doc/reference_manual/
        part_frame.html
       http://www.erlang.org/examples.html

    Joe Armstrongs home page
       http://www.sics.se/~joe/

    Consult erl –man module_name
Further reading
    Open Source Erlang
         http://www.erlang.org
    The High-Performance Erlang Project
         http://www.it.uu.se/research/group/hipe/
    Trapexit, an Erlang community site
         http://www.trapexit.org/
    Comprehensive Erlang Archive Network
         http://cean.process-one.net/
    Erlang style concurreny
       Article about concurrency explaining important topics using
        Java syntax to explain things
       http://www.defmacro.org/ramblings/concurrency.html
Further reading
  Programming Erlang, Software for a
   Concurrent World, Joe Armstrong (Pragmatic
   Bookshelf, 2007), ISBN 978-1-934356-00-5,
   Available in print and PDF
  Erlang: The Movie ;-)

       http://video.google.com/videoplay?
      docid=-5830318882717959520

More Related Content

What's hot

Python Foundation – A programmer's introduction to Python concepts & style
Python Foundation – A programmer's introduction to Python concepts & stylePython Foundation – A programmer's introduction to Python concepts & style
Python Foundation – A programmer's introduction to Python concepts & styleKevlin Henney
 
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 Winl xf
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to PythonNowell Strite
 
Erlang Developments: The Good, The Bad and The Ugly
Erlang Developments: The Good, The Bad and The UglyErlang Developments: The Good, The Bad and The Ugly
Erlang Developments: The Good, The Bad and The Uglyenriquepazperez
 
Python Programming - XII. File Processing
Python Programming - XII. File ProcessingPython Programming - XII. File Processing
Python Programming - XII. File ProcessingRanel Padon
 
introduction to python
 introduction to python introduction to python
introduction to pythonJincy Nelson
 
Python introduction towards data science
Python introduction towards data sciencePython introduction towards data science
Python introduction towards data sciencedeepak teja
 
Python Programming - I. Introduction
Python Programming - I. IntroductionPython Programming - I. Introduction
Python Programming - I. IntroductionRanel Padon
 
Python - Introduction
Python - IntroductionPython - Introduction
Python - Introductionstn_tkiller
 
Iterarators and generators in python
Iterarators and generators in pythonIterarators and generators in python
Iterarators and generators in pythonSarfaraz Ghanta
 
Intro to Functions Python
Intro to Functions PythonIntro to Functions Python
Intro to Functions Pythonprimeteacher32
 
name name2 n2.ppt
name name2 n2.pptname name2 n2.ppt
name name2 n2.pptcallroom
 

What's hot (20)

Python Foundation – A programmer's introduction to Python concepts & style
Python Foundation – A programmer's introduction to Python concepts & stylePython Foundation – A programmer's introduction to Python concepts & style
Python Foundation – A programmer's introduction to Python concepts & style
 
Cs3430 lecture 15
Cs3430 lecture 15Cs3430 lecture 15
Cs3430 lecture 15
 
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
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
 
Erlang Developments: The Good, The Bad and The Ugly
Erlang Developments: The Good, The Bad and The UglyErlang Developments: The Good, The Bad and The Ugly
Erlang Developments: The Good, The Bad and The Ugly
 
Python_in_Detail
Python_in_DetailPython_in_Detail
Python_in_Detail
 
Python and You Series
Python and You SeriesPython and You Series
Python and You Series
 
Python Programming - XII. File Processing
Python Programming - XII. File ProcessingPython Programming - XII. File Processing
Python Programming - XII. File Processing
 
introduction to python
 introduction to python introduction to python
introduction to python
 
Python introduction towards data science
Python introduction towards data sciencePython introduction towards data science
Python introduction towards data science
 
Theperlreview
TheperlreviewTheperlreview
Theperlreview
 
Python Programming - I. Introduction
Python Programming - I. IntroductionPython Programming - I. Introduction
Python Programming - I. Introduction
 
Python - Introduction
Python - IntroductionPython - Introduction
Python - Introduction
 
Python made easy
Python made easy Python made easy
Python made easy
 
Iterarators and generators in python
Iterarators and generators in pythonIterarators and generators in python
Iterarators and generators in python
 
Intro to Functions Python
Intro to Functions PythonIntro to Functions Python
Intro to Functions Python
 
Python programming
Python programmingPython programming
Python programming
 
name name2 n2.ppt
name name2 n2.pptname name2 n2.ppt
name name2 n2.ppt
 
ppt9
ppt9ppt9
ppt9
 
ppt18
ppt18ppt18
ppt18
 

Viewers also liked

Erlang Concurrency
Erlang ConcurrencyErlang Concurrency
Erlang ConcurrencyBarry Ezell
 
Lightning Talk: Erlang on Xen - Mikhail Bortnyk
Lightning Talk: Erlang on Xen - Mikhail BortnykLightning Talk: Erlang on Xen - Mikhail Bortnyk
Lightning Talk: Erlang on Xen - Mikhail BortnykElixir Club
 
The mystique of erlang
The mystique of erlangThe mystique of erlang
The mystique of erlangCarob Cherub
 
Introduction to Couchbase Server 2.0
Introduction to Couchbase Server 2.0Introduction to Couchbase Server 2.0
Introduction to Couchbase Server 2.0Dipti Borkar
 
Exception Handler, Controller Advice Of Spring
Exception Handler, Controller Advice Of SpringException Handler, Controller Advice Of Spring
Exception Handler, Controller Advice Of SpringHyun Dong Lee
 
Intro to Erlang
Intro to ErlangIntro to Erlang
Intro to ErlangKen Pratt
 
Erlang For Five Nines
Erlang For Five NinesErlang For Five Nines
Erlang For Five NinesBarcamp Cork
 
An introduction to erlang
An introduction to erlangAn introduction to erlang
An introduction to erlangMirko Bonadei
 
Erlang Practice
Erlang PracticeErlang Practice
Erlang Practicelitaocheng
 
learn you some erlang - chap 9 to chap10
learn you some erlang - chap 9 to chap10learn you some erlang - chap 9 to chap10
learn you some erlang - chap 9 to chap10경미 김
 
Intro To Erlang
Intro To ErlangIntro To Erlang
Intro To Erlangasceth
 
An Erlang Game Stack
An Erlang Game StackAn Erlang Game Stack
An Erlang Game StackEonblast
 
Introduction to Erlang
Introduction to ErlangIntroduction to Erlang
Introduction to ErlangKirinDave
 
Results presentation 1 q13
Results presentation 1 q13Results presentation 1 q13
Results presentation 1 q13TIM RI
 
2 Des Nas
2 Des Nas2 Des Nas
2 Des Nasepaper
 

Viewers also liked (20)

Erlang Concurrency
Erlang ConcurrencyErlang Concurrency
Erlang Concurrency
 
Lightning Talk: Erlang on Xen - Mikhail Bortnyk
Lightning Talk: Erlang on Xen - Mikhail BortnykLightning Talk: Erlang on Xen - Mikhail Bortnyk
Lightning Talk: Erlang on Xen - Mikhail Bortnyk
 
The mystique of erlang
The mystique of erlangThe mystique of erlang
The mystique of erlang
 
Introduction to Couchbase Server 2.0
Introduction to Couchbase Server 2.0Introduction to Couchbase Server 2.0
Introduction to Couchbase Server 2.0
 
Why erlang
Why erlangWhy erlang
Why erlang
 
Erlang on OSv
Erlang on OSvErlang on OSv
Erlang on OSv
 
Exception Handler, Controller Advice Of Spring
Exception Handler, Controller Advice Of SpringException Handler, Controller Advice Of Spring
Exception Handler, Controller Advice Of Spring
 
Intro to Erlang
Intro to ErlangIntro to Erlang
Intro to Erlang
 
Erlang For Five Nines
Erlang For Five NinesErlang For Five Nines
Erlang For Five Nines
 
An introduction to erlang
An introduction to erlangAn introduction to erlang
An introduction to erlang
 
Erlang Practice
Erlang PracticeErlang Practice
Erlang Practice
 
learn you some erlang - chap 9 to chap10
learn you some erlang - chap 9 to chap10learn you some erlang - chap 9 to chap10
learn you some erlang - chap 9 to chap10
 
Erlang OTP
Erlang OTPErlang OTP
Erlang OTP
 
Intro To Erlang
Intro To ErlangIntro To Erlang
Intro To Erlang
 
Actors in erlang
Actors in erlangActors in erlang
Actors in erlang
 
An Erlang Game Stack
An Erlang Game StackAn Erlang Game Stack
An Erlang Game Stack
 
Introduction to Erlang
Introduction to ErlangIntroduction to Erlang
Introduction to Erlang
 
10 010 waste pro (part 3)
10 010  waste pro (part 3)10 010  waste pro (part 3)
10 010 waste pro (part 3)
 
Results presentation 1 q13
Results presentation 1 q13Results presentation 1 q13
Results presentation 1 q13
 
2 Des Nas
2 Des Nas2 Des Nas
2 Des Nas
 

Similar to Erlang, an overview

Keynote joearmstrong
Keynote joearmstrongKeynote joearmstrong
Keynote joearmstrongSentifi
 
Introduction To Erlang Final
Introduction To Erlang   FinalIntroduction To Erlang   Final
Introduction To Erlang FinalSinarShebl
 
Erlang
ErlangErlang
ErlangESUG
 
Introduction to Erlang/(Elixir) at a Webilea Hands-On Session
Introduction to Erlang/(Elixir) at a Webilea Hands-On SessionIntroduction to Erlang/(Elixir) at a Webilea Hands-On Session
Introduction to Erlang/(Elixir) at a Webilea Hands-On SessionAndré Graf
 
Erlang kickstart
Erlang kickstartErlang kickstart
Erlang kickstartRyan Brown
 
Introduction to Erlang Part 1
Introduction to Erlang Part 1Introduction to Erlang Part 1
Introduction to Erlang Part 1Dmitry Zinoviev
 
A Survey of Concurrency Constructs
A Survey of Concurrency ConstructsA Survey of Concurrency Constructs
A Survey of Concurrency ConstructsTed Leung
 
Introduction to Erlang Programming Language
Introduction to Erlang Programming LanguageIntroduction to Erlang Programming Language
Introduction to Erlang Programming LanguageYasas Gunarathne
 
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go Wrong
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go WrongJDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go Wrong
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go WrongPROIDEA
 
Enrich Your Models With OCL
Enrich Your Models With OCLEnrich Your Models With OCL
Enrich Your Models With OCLEdward Willink
 
Basics java programing
Basics java programingBasics java programing
Basics java programingDarshan Gohel
 
Secure Programming Language Cs
Secure Programming Language CsSecure Programming Language Cs
Secure Programming Language CsIJRES Journal
 
Building scalable and language independent java services using apache thrift
Building scalable and language independent java services using apache thriftBuilding scalable and language independent java services using apache thrift
Building scalable and language independent java services using apache thriftTalentica Software
 
Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!olracoatalub
 

Similar to Erlang, an overview (20)

Erlang session1
Erlang session1Erlang session1
Erlang session1
 
IN4308 1
IN4308 1IN4308 1
IN4308 1
 
Keynote joearmstrong
Keynote joearmstrongKeynote joearmstrong
Keynote joearmstrong
 
Elixir
ElixirElixir
Elixir
 
Introduction To Erlang Final
Introduction To Erlang   FinalIntroduction To Erlang   Final
Introduction To Erlang Final
 
Erlang
ErlangErlang
Erlang
 
Introduction to Erlang/(Elixir) at a Webilea Hands-On Session
Introduction to Erlang/(Elixir) at a Webilea Hands-On SessionIntroduction to Erlang/(Elixir) at a Webilea Hands-On Session
Introduction to Erlang/(Elixir) at a Webilea Hands-On Session
 
Erlang kickstart
Erlang kickstartErlang kickstart
Erlang kickstart
 
Java
JavaJava
Java
 
Elixir introduction
Elixir introductionElixir introduction
Elixir introduction
 
Introduction to Erlang Part 1
Introduction to Erlang Part 1Introduction to Erlang Part 1
Introduction to Erlang Part 1
 
A Survey of Concurrency Constructs
A Survey of Concurrency ConstructsA Survey of Concurrency Constructs
A Survey of Concurrency Constructs
 
Introduction to Erlang Programming Language
Introduction to Erlang Programming LanguageIntroduction to Erlang Programming Language
Introduction to Erlang Programming Language
 
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go Wrong
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go WrongJDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go Wrong
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go Wrong
 
Introduction to F#
Introduction to F#Introduction to F#
Introduction to F#
 
Enrich Your Models With OCL
Enrich Your Models With OCLEnrich Your Models With OCL
Enrich Your Models With OCL
 
Basics java programing
Basics java programingBasics java programing
Basics java programing
 
Secure Programming Language Cs
Secure Programming Language CsSecure Programming Language Cs
Secure Programming Language Cs
 
Building scalable and language independent java services using apache thrift
Building scalable and language independent java services using apache thriftBuilding scalable and language independent java services using apache thrift
Building scalable and language independent java services using apache thrift
 
Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!
 

More from Patrick Huesler

Technical Challenges of Developing a Facebook Game
Technical Challenges of Developing a Facebook GameTechnical Challenges of Developing a Facebook Game
Technical Challenges of Developing a Facebook GamePatrick Huesler
 
Culerity and Headless Full Stack Integration Testing
Culerity and Headless Full Stack Integration TestingCulerity and Headless Full Stack Integration Testing
Culerity and Headless Full Stack Integration TestingPatrick Huesler
 
Client Side Optimization
Client Side OptimizationClient Side Optimization
Client Side OptimizationPatrick Huesler
 
Building and deploying Cocoa applications with ChocTop
Building and deploying Cocoa applications with ChocTopBuilding and deploying Cocoa applications with ChocTop
Building and deploying Cocoa applications with ChocTopPatrick Huesler
 
Choctop Lightning talk EuRuKo 2010
Choctop Lightning talk EuRuKo 2010Choctop Lightning talk EuRuKo 2010
Choctop Lightning talk EuRuKo 2010Patrick Huesler
 
Small Cocoa Apps with MacRuby
Small Cocoa Apps with MacRubySmall Cocoa Apps with MacRuby
Small Cocoa Apps with MacRubyPatrick Huesler
 

More from Patrick Huesler (9)

Technical Challenges of Developing a Facebook Game
Technical Challenges of Developing a Facebook GameTechnical Challenges of Developing a Facebook Game
Technical Challenges of Developing a Facebook Game
 
Culerity and Headless Full Stack Integration Testing
Culerity and Headless Full Stack Integration TestingCulerity and Headless Full Stack Integration Testing
Culerity and Headless Full Stack Integration Testing
 
Client Side Optimization
Client Side OptimizationClient Side Optimization
Client Side Optimization
 
Building and deploying Cocoa applications with ChocTop
Building and deploying Cocoa applications with ChocTopBuilding and deploying Cocoa applications with ChocTop
Building and deploying Cocoa applications with ChocTop
 
Choctop Lightning talk EuRuKo 2010
Choctop Lightning talk EuRuKo 2010Choctop Lightning talk EuRuKo 2010
Choctop Lightning talk EuRuKo 2010
 
Small Cocoa Apps with MacRuby
Small Cocoa Apps with MacRubySmall Cocoa Apps with MacRuby
Small Cocoa Apps with MacRuby
 
Fun with Ruby and Cocoa
Fun with Ruby and CocoaFun with Ruby and Cocoa
Fun with Ruby and Cocoa
 
Migrating legacy data
Migrating legacy dataMigrating legacy data
Migrating legacy data
 
Active Record No No's
Active Record No No'sActive Record No No's
Active Record No No's
 

Recently uploaded

DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 

Recently uploaded (20)

DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 

Erlang, an overview

  • 1. ERLANG THE WORLD IS PARALLEL. Picture: http://www.cs.purdue.edu/homes/jv/events/TiC06/pr.jpg
  • 2. the world is parallel. If we want to write programs that behave as other objects behave in the real world, then these programs will have a concurrent structure. Use a language that was designed for writing concurrent applications, and development becomes a lot easier. Erlang programs model how we think and interact. Joe Armstrong
  • 3. Agenda   What we cover   What we don’t cover   You used Erlang to write what?   History   OTP   The language   Concurrency   Distribution   Hot code swapping   Compile and run   Development environments   Various tidbits
  • 4. Note and forgive that…   This is an Erlang beginner trying to give you an overview   I haven’t used Erlang for a while
  • 5. What we cover   What is it good for?   Glance at functional programming   Basic syntax and structure   Erlang’s main features   Basic tools to get you started   Info on where to find more material
  • 6. What we DON’T cover   How to install Erlang   A (blog) tutorial in 15 minutes   Language reference   How to write programs using a functional programming language   How to parallelize programs   How to distribute algorithms   How to use the Open Telecom Platform   Tons of example code
  • 7. Therefore   Read the book
  • 8. You used Erlang to write what? http://www.cio.com/article/191000/You_Used_Ruby_to_Write_WHAT_ http://www.zedshaw.com/
  • 9. You used Erlang to write what?   Systems/Applications that are:   Concurrent   Parallel (SMP)   Distributed   Fault tolerant   Dynamically upgradable
  • 10. History   Created by the Computer Science Laboratory at Ellemtel (now Ericsson AB) around 1990   Named after A. K. Erlang (not Ericsson Language)   Licensed Version (Ericsson http:// www.erlang.se)   Released as open source in 1998 under EPL (http://www.erlang.org) Ref: wikipedia.org
  • 11. Open Telecom Platform   Middleware   Similar to J2EE Container (JBoss, GlassFish, IBM WebSphere, BEA Weblogic)   Coding standards   Tools like web server, FTP server and CORBA ORB are included in OTP   Licensed under Erlang Public License (EPL)
  • 12. OTP Source: http://www.ericsson.com/technology/opensource/erlang/index.shtml Picture: http://www.ericsson.com/technology/opensource/images/erlang.gif
  • 13. Erlang in use   Ejabberd (http://www.ejabberd.im)   Yaws (http://yaws.hyber.org/)   CouchDB ( http://incubator.apache.org/couchdb)   Ericsson products AXD301 (ATM switch), SGSN, GGSN (GPRS nodes) according to http://www.erlang.se/productinfo/index.shtml
  • 14. The language   Functional programming language!   (little) to no side effects   Single assignment variables   Pattern matching   Higher-order functions   Recursion   No objects   Haskell, Lisp, ML, F#, Scheme
  • 15. So don’t think imperative!   Don’t think   Java   C#   C   PHP   Etc.
  • 20. Let‘s get started Picture: http://www.wampower.com/images/wam%20pics/getting%20started/getting_started.jpg
  • 21. Let’s get started   Start interactive shell called erl and try things out (like irb in Ruby)   ^G q to quit the shell   % indicates a comment   . terminates a statement
  • 22. Files, modules and functions   Example on next slide   Module “geometry” would be defined in “geometry.erl”   Export the functions you want to be public   Don’t forget to specify the arity, number of params in function’s signature (e.g area/1)   Compile modules within erl before using them c(module_name)   Use : to access a module’s public functions => lists:filter()   erl –man module_name for man page => erl -man lists
  • 23. Variables   Start with an uppercase letter   Single assignment like in Prolog so X = X + 1 is a no go   Integers   No limitation for integers e.g. faculty of 2000 returns valid result (Try that in Eiffel™)   Floats   A division always returns a float   Limited in size (IEEE 754 64-bit)   Strings: S = “world” (double quotes)
  • 24. Atoms and Tuples   Atoms   Represent non numerical constant values   Start with lowercase letter   Tuples   Store a fixed number of items into a single entity   F = {name , isabella}   E = {woweffect, 10}   Person = {person,{height,10},{gender,male}}   Beauty = {beauty , F , E}
  • 25. Lists   Store variable numbers of things   Head and tail syntax   Define a list:   Student_grades = [{john,c},{michael,b},{lolita,aplus}, {joe,b}].   Extract into head and tail   [Headval1,Headval2|Tailval]= Student_grades   Where Headval1 matches with the 1st element, Headval2 with 2nd and Tailval with the rest   See erl –man lists http://images.apple.com/downloads/dashboard/travel/images/traveltodolist_20070724165034.jpg
  • 26. Functions -module(intro). -export([main/0,factorial/1,some_other_function/0]). % number in export statement defines arity of exported function % only exported functions can be used from outside the module main() -> io:format("The factorial of 5 is ~w ~n”,[factorial(5)]). factorial(0) -> 1; factorial(nonsense) -> "nonsense"; factorial(N) -> N*factorial(N-1). % use comma to add statements together some_other_function() -> T = private_module_function(10,20), T + 11. % this function is not available from outside the module private_module_function(X,Y) -> X * Y. Picture: http://casoilresource.lawr.ucdavis.edu/drupal/files/images/logistic-small.png
  • 27. Anonymous functions (Funs) http://image.guardian.co.uk/sys-images/Arts/Arts_/Pictures/2007/08/10/laugh460.jpg
  • 28. Anonymous functions (Funs)   Like in JavaScript, delegates in C#   Like regular functions but the word “end” defines the end of the function. Still use a period to indicate end of line.   Cubic = fun(X) -> X*X*X end.   Cubic(2) evaluates to 8.   Funs can be useful as arguments eg. inline   lists:filter(fun(X) -> X > 10 end, [1,2,3,445,28,203]).   Returns [445,28,203]   It is legal to pass a variable containing a Fun instead of defining it inline   Funs can return Funs
  • 29. List comprehensions   Mostly shorter than funs, maps and filters   To triple every element using funs we could write:   Lists:map(fun(N) -> 3*N end, L)   Using list comprehensions   [ 3*N || N <- L]   More complex forms are possible   [{triple, 3*N} || N <- L]   According to the rules of pattern matching
  • 30. Stuff left out to save time   Guards => Conditions   f(X) when is_integer(X), X > 10 -> io:format(“X is greater than 10”).   Predicates like is_integer()   Built-in functions like length(X)   Records (for large tuples)   ETS / DTS   case and if Expressions   Exceptions (try catch syntax)   Built-in Functions (BIFs)   http://www.erlang.org/doc/man/erlang.html   Macros Picture: http://www.ourappraisal.com/xsites/Appraisers/centralilappraisal/content/uploadedFiles/refi_clock_ticking.jpg
  • 31. Concurrency   Processes belong to Erlang and not the operating system (User, not kernel space)   Creating and destroying processes is very fast   Sending messages between processes is very fast   Processes behave the same way on all operating systems   We can have a large number of processes.   Processes share no memory and are completely independent   The only way for processes to interact is through message passing
  • 32. Concurrency   Concurrency primitives   spawn Pid = spawn(Fun)   send Pid ! Message   receive receive Pattern 1 Expressions1; Pattern 2 Expressions 2; ... end Picture: http://www.spacecast.com/images/Shows/spawn_img1.jpg
  • 33. Distribution   Distributed Erlang   Programs are written to run on Erlang nodes   Spawning processes on any node is very easy   Message passing and error handling is the same as in a non distributed environment (one single node).   The nodes run in a trusted environment (same LAN)   Make sure, you run the same codebase and erlang version   Socket-Based Distribution   UsingTCP/IP Sockets   The Applications can run in a untrusted environment
  • 34. Hot Code Swapping Picture: http://www.firewebdesigns.com/images/fire_02.jpg
  • 35. Hot Code Swapping   Erlang supports change of code in a running system   Very cool for upgrading software   Code for Module exist in two variants in the system   State Current   State Old   OTP provides libraries for enhanced Code Swapping functionality
  • 36. Multicore CPU’s   Again, in Erlang, processes have no shared memory, so no mutexes, locks whatsoever   Make sure, your program has a lot of processes   Avoid side effects (those that the language and the runtime can’t prevent)   In fact, Erlang has shared data structures (ETS,DETS). Better use Mnesia with transactions if you need a shared storage.   Mnesia is a distributed DBMS for Erlang   http://www.erlang.org/documentation/doc-5.0.1/lib/ mnesia-3.9.2/doc/index.html
  • 37. Symmetric Muliprocessing with SMP Erlang   erl –smp +S N   Where N specifies the number of schedulers to use   A Scheduler is a complete virtual machine   Possibility to emulate a system with more CPU’s   See previous slide for some requirements to parallelize a program
  • 38. Compile and run   Within erl shell   c(module_name)   Compiler   erlc module_name.erl   erl –noshell –s module_name function_name –s init stop   As an escript #!/usr/bin/env escript main(_) -> io:format("hello world~n").   Automate things using build tools like make, ant etc.
  • 39. Development environment   http://www.erlang.org/download.html to install environment   Erlang mode for emacs   http://www.erlang.org/doc/apps/tools/ erlang_mode_chapter.html   Erlang bundle for TextMate   http://macromates.com/svn/Bundles/trunk/Bundles/ Erlang.tmbundle/   Erlybird for Netbeans   http://sourceforge.net/projects/erlybird/   Erlide   http://erlide.sourceforge.net/
  • 40. Various tidbits   Documentation generator called Edoc which is similar to Javadoc™   http://www.erlang.org/doc/apps/edoc/index.html   When things go wrong, consult the crash dump.   webtool:start().   Go to http://localhost:8888   Unit testing framework called EUnit making heavy use of macros for the assertions   http://svn.process-one.net/contribs/trunk/eunit/doc/overview- summary.html   ErlyWeb, a web framework written in Erlang   http://yarivsblog.com   The Dialyzer, a static analysis tool to identify problems with program code   http://www.it.uu.se/research/group/hipe/dialyzer/
  • 41. Where to find help?   Excellent documentation and examples on erlang.org   http://www.erlang.org/starting.html   http://www.erlang.org/doc.html   http://www.erlang.org/doc/reference_manual/ part_frame.html   http://www.erlang.org/examples.html   Joe Armstrongs home page   http://www.sics.se/~joe/   Consult erl –man module_name
  • 42. Further reading   Open Source Erlang   http://www.erlang.org   The High-Performance Erlang Project   http://www.it.uu.se/research/group/hipe/   Trapexit, an Erlang community site   http://www.trapexit.org/   Comprehensive Erlang Archive Network   http://cean.process-one.net/   Erlang style concurreny   Article about concurrency explaining important topics using Java syntax to explain things   http://www.defmacro.org/ramblings/concurrency.html
  • 43. Further reading   Programming Erlang, Software for a Concurrent World, Joe Armstrong (Pragmatic Bookshelf, 2007), ISBN 978-1-934356-00-5, Available in print and PDF   Erlang: The Movie ;-)   http://video.google.com/videoplay? docid=-5830318882717959520