Erlang - a complete development environment for concurrent programming RTLab. Kim Tae-Hyon.

Slides:



Advertisements
Similar presentations
Practical Erlang Programming Process Error Handling.
Advertisements

OJ Reeves. Agenda  The Boring Stuff Basic syntax, expressions, funcs, records Atoms, BIFs, data types, bools, equality  The not so Boring Stuff Pattern.
COMMUNICATING SEQUENTIAL PROCESSES C. A. R. Hoare The Queen’s University Belfast, North Ireland.
Thomas Arts Industrial Use of a Functional Language Thomas Arts Ericsson Computer Science Laboratory Stockholm, Sweden
11/10/04 AIPP Lecture 6: Built-in Predicates1 Combining Lists & Built-in Predicates Artificial Intelligence Programming in Prolog Lecturer: Tim Smith Lecture.
Dialyzer – a DIscrepancy AnaLYZer of ERlang programs Tobias Lindahl and Kostis Sagonas Dept of Information Technology Uppsala University.
Erlang Paul Ang, Alex Quintero, Jessica Lombardi, Robin Adams.
Remote Procedure Call Design issues Implementation RPC programming
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 14 Web Database Programming Using PHP.
Registered Processes A perennial problem in client-server computing is “How do clients find the server?” Two possible answers:  Clients are told about.
Erlang concurrency. Where were we? Finished talking about sequential Erlang Left with two questions  retry – not an issue; I mis-read the statement in.
Macromedia Director 8 Advanced Level Course. Script Basics Lingo can be used to offer your users navigational control of the order of the scenes of your.
Linux+ Guide to Linux Certification, Second Edition
Lecture 19 Distributed Programming (Ch. 10) Other message-passing programming models  Channels vs mailboxes  Synchronous vs asynchronous.
Chapter 4 Processor Technology and Architecture. Chapter goals Describe CPU instruction and execution cycles Explain how primitive CPU instructions are.
CTEC 1863 – Operating Systems Shell Scripting. CTEC F2 Overview How shell works Command line parameters –Shift command Variables –Including.
1 Chapter 9 Spaces with LINDA. 2 Linda Linda is an experimental programming concept unlike ADA or Occam which are fully developed production-quality languages.
Javascript and the Web Whys and Hows of Javascript.
Advanced Software Tools Research Seminar Fall 07 Arik Nemtsov.
AIT 616 Fall 2002 PHP. AIT 616 Fall 2002 PHP  Special scripting language used to dynamically generate web documents  Open source – Free!!!  Performs.
Systèmes Distribués Eddy Caron Introduction to Erlang Eddy Caron 2013 M1. ENS-Lyon 1.
17-Sep-15 Erlang. Running Erlang Double-click on the Erlang icon, or type erl into a terminal (cmd) window You can try short pieces of code from here,
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 09/03/2010.
Week 7 Working with the BASH Shell. Objectives  Redirect the input and output of a command  Identify and manipulate common shell environment variables.
Keneequa Brown Chris Duzan Navaid Khalfay. Originally developed in 1986 by Joe Armstrong as a proprietary language within Ericsson Released as open source.
Rev PA Erlang Open Telecom Platform EAB/UPD/S Ulf Wiger.
Errors And How to Handle Them. GIGO There is a saying in computer science: “Garbage in, garbage out.” Is this true, or is it just an excuse for bad programming?
ERLANG Bruno Bourbon Gilberto Alves. Introdução Grades sistemas de telecomunicação são um grande desafio da programação: –Distribuidos –Concorretes –Tolerantes.
Shell Script Programming. 2 Using UNIX Shell Scripts Unlike high-level language programs, shell scripts do not have to be converted into machine language.
Supported by ELTE IKKK, Ericsson Hungary, in cooperation with University of Kent Erlang refactoring with relational database Anikó Víg and Tamás Nagy Supervisors:
1 Exception Handling, Modules, Names Per Brand. 2 Exception Handling An exception is any expression E. To raise the exception, one executes the following.
1 © 2001 John Urrutia. All rights reserved. Chapter 10 using the Bourne Again Shell.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
Supported by ELTE IKKK, Ericsson Hungary, in cooperation with University of Kent Erlang refactoring with relational database Anikó Víg and Tamás Nagy Supervisors:
PHP PHP: Hypertext Preprocesor Personal Home Page Tools.
Just a Little PHP Programming PHP on the Server. Common Programming Language Features Comments Data Types Variable Declarations Expressions Flow of Control.
Fall 2004CSI University of Ottawa Introduction to PHP Basic principles and syntax.
Overview of the Haskell 98 Programming Language
The Complexity of Distributed Algorithms. Common measures Space complexity How much space is needed per process to run an algorithm? (measured in terms.
Practical Erlang Programming Basic Erlang. © Erlang Training and Consulting Ltd2Basic Erlang Practical Erlang Programming.
ICAPRG301A Week 2 Strings and things Charles Babbage Developed the design for the first computer which he called a difference engine, though.
©Colin Jamison 2004 Shell scripting in Linux Colin Jamison.
1 © 2000 John Urrutia. All rights reserved. Session 5 The Bourne Shell.
Erlang Noah Dietrich Chris Ruffalo.
Just a Little PHP Programming PHP on the Server. Common Programming Language Features Comments Data Types Variable Declarations Expressions Flow of Control.
Introduction to JavaScript CSc 2320 Fall 2014 Disclaimer: All words, pictures are adopted from “Simple JavaScript”by Kevin Yank and Cameron Adams and also.
Fall 2004CSI University of Ottawa Introduction to PHP Basic principles and syntax.
CSED101 INTRODUCTION TO COMPUTING SUM TYPE 유환조 Hwanjo Yu.
8 th Semester, Batch 2009 Department Of Computer Science SSUET.
Practical Erlang Programming OSCON Tutorial July 21 st 2009, San Jose Francesco Cesarini Erlang Training and Consulting Ltd
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Erlang Erricsson and Ellemtel Computer Science Laboratories
Unit – 3 Control structures. Condition Statements 1.If.…..else :- Has someone ever told you, "if you work hard, then you will succeed"? And what happens.
Message Passing, Concurrency, And Parallelism with Erlang Presented By: Craig R. Kuehn Department of Computer Science and Software Engineering University.
Linux Administration Working with the BASH Shell.
Quiz 1 A sample quiz 1 is linked to the grading page on the course web site. Everything up to and including this Friday’s lecture except that conditionals.
Scaling For (Almost) Free
Web Database Programming Using PHP
Principles of programming languages 12: Functional programming
Section 15.4, 15.6 plus other materials
Model and complexity Many measures Space complexity Time complexity
Web Database Programming Using PHP
An Introduction to Java – Part I
Erlang 15-Nov-18.
Erlang 3 Concurrency 8-Dec-18.
Basic Syntax and Semantics
C Programming Getting started Variables Basic C operators Conditionals
Industrial Use of a Functional Language
COS 151 Bootcamp – Week 4 Department of Computer Science
Computer Science 312 Concurrent Programming II
Presentation transcript:

Erlang - a complete development environment for concurrent programming RTLab. Kim Tae-Hyon

Contents  What is Erlang?  Erlang features  Sequential Programming  Concurrent Programming  Distribute Programming

What is Erlang?  Erlang is a general-purpose programming language and runtime environment  Erlang has built-in support for concurrency, distribution and fault tolerance  Erlang is used in several large telecommunication systems from EricssonEricsson

Erlang features  Concurrency  Distribution  Robustness  Soft real-time  Hot code upgrade  Incremental code loading  External Interface

Data Types  Term  A piece of data of any data type is called a term  Numbers  Integer (10, -234, 16#AB10F, $A)  Floats (17.368, , 12.34E-10)  Atoms  abcdef, start_with_a_lower_case, ‘Blanks can be quoted’  Tuples  {123, bcd}, {123, def, abc}, {abc, {def, 123}, jkl}, {}  Lists  [123, xyz], [123, def, abc], [{person, ‘Kim’, ‘Tae Hyon’}, {person, …}]  Variables  Abc, A_long_variable_name, AnObjectName

Data Types (Cont)  String  Not a data type in erlang  Bit string and Binaries  Red=2, Green=61, Blue=20.  Mem = >  >  > = Mem.  R1 = 2, G1 = 61, B1 = 20  Fun  Functional object  Fun1 = fun(x) -> X+1 end.  Fun1(2).  3

Data Types (Cont)  Pid  A Process Identifier  Record  -record(person, {name, age}).  new(Name, Age) ->  #person{name=Name, age=Age}.  1> person:new(ernie, 44).  {person,ernie,44}  Boolean  True, false

Sequential Programming  Pattern Matching  A = 10 (succeeds)  {B, C, D} = {10, foo, bar} (succeeds)  {A, A, B} = {abc, abc, foo} (succeeds)  {A, A, B} = {abc, def, foo} (fails)  [A, B, C] = [1, 2, 3] (succeeds)  [A, B, C, D] = [1, 2, 3] (fails)  [A, B|C] = [1,2,3,4,5,6,7] (succeeds)  [H|T] = [1,2,3,4] (succeeds)  [H|T] = [abc] (succeeds)  [H|T] = [] (fails)  {A, _, [B|_], {B}} = {abc, 23, [22, x], {22}} (succeeds)

Sequential Programming (Cont)

 Function Calls  module:func(Arg1, Arg2, …, Argn)  func(Arg1, Arg2, …, Argn)  Module System  -module(seminar_demo).  -export([double/1]).  double(X) ->times(X,2).  times(X, N) ->X * N.

Sequential Programming (Cont)

 Built In Functions(BIF)  date()  time()  length([1,2,3,4,5])  atom_to_list(an_atom)  list_to_tuple([1,2,3,4])  integer_to_list(2234)  tuple_to_list({})

Sequential Programming (Cont)  Function Syntax  func(Pattern1, Pattern2,...) ->... ;  func(Pattern1, Pattern2,...) ->... ; func(Pattern1, Pattern2,...) ->....  Function Example  area({square, Side}) ->  Side * Side;  area({circle, Radius}) ->  3 * Radius * Radius;  area({triangle, A, B, C}) ->  S = (A + B + C)/2,  math:sqrt(S*(S-A)*(S-B)*(S-C));  area(Other) ->  {invalid_object, Other}.

Sequential Programming (Cont)  Guarded Function Clauses  factorial(N) when N > 0 ->  N * factorial(N - 1);  factorial(0) -> 1.  Examples of Guards  is_atom(X)  is_binary(X)  Is_constant(X)  Is_function(X)  X == Y (equal)  X =:= Y (exactly equal -> 1==1.0 succeds, 1=:=1.0 fails) ...

Concurrent Programming  Creating a Process  Pid2 = spawn(Mod, Func, Args)  Simple Message Passing

Concurrent Programming (Cont)  An Echo Process

Concurrent Programming (Cont)  Selective Message Reception  Selection of Any Message

Concurrent Programming (Cont)  Pid Can Be Sent in Message  Registered Process  start() ->  Pid = spawn(num_anal, server, [])  register(analyser, Pid).  analyse(Seq) ->  analyser ! {self(),{analyse,Seq}},  receive  {analysis_result,R} ->  R  end.

Concurrent Programming (Cont)  Timeouts

Concurrent Programming (Cont)  Primitives For Exit Signal Handling  link(Pid) - Set a bi-directional link between the current process and the process Pid  process_flag(trap_exit, true) - Set the current process to convert exit signals to exit messages, these messages can then be received in a normal receive statement.  exit(Reason) - Terminates the process and generates an exit signal where the process termination information is Reason.

Concurrent Programming (Cont)  Exit Signal are Sent when Processes Crash  Exit Signals Propagate through Links

Concurrent Programming (Cont)  Processes can trap exit signals  receive  {'EXIT', P1, Why} -> ... exit signals...  {P3, Msg} -> ... normal messages...  end

Concurrent Programming (Cont)  Robust system made by layering

Distribute Programming  Nodes  A node is an executing erlang runtime system which has been given a name, using the command line flag -name or –sname  Node connections  spawn(Node, Module, Function, Arguments)  net_adm:ping(Node)

Distribute Programming (Cont) doris $ erl –name gandalf –setcookie abc 1>kvs:start(). true george $ erl –name bilbo –setcookie abc kvs, store, [weather, kvs true kvs, lookup, kvs {ok, cold}