1 / 26

CONCURRENT PROGRAMMING USING ERLANG

CONCURRENT PROGRAMMING USING ERLANG. SHASHANK KADAVERU. The History. 1995 PC Week Study of software projects: 16% successful 53% operational (but less than successful) 31% cancelled Butler Group 1997 on large software projects 5 out of 6 large projects fail

dinh
Télécharger la présentation

CONCURRENT PROGRAMMING USING ERLANG

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CONCURRENT PROGRAMMING USING ERLANG SHASHANK KADAVERU

  2. The History • 1995 PC Week Study of software projects: • 16% successful • 53% operational (but less than successful) • 31% cancelled • Butler Group 1997 on large software projects • 5 out of 6 large projects fail • In >$300M companies, 9 out of 10 large projects fail • How to approach this? • Use high-level modeling tools & generate code? • Raise the level of programming language? • We should Fight all causes for project failure!

  3. ERLANG • Erlang is a programming language which was designed for programming concurrent, real-time, distributed fault-tolerant systems. • Developed By Ericsson and hence the name. • ‘ER’icsson ‘LANG’uage.

  4. Applications of ERLANG • Telecom industry • Location based mobile services • Electronic payment systems • Messaging and Interactive Voice Response services • Data acquisition and real-time monitoring

  5. The Telecom Industry The Telecom industry consists of: • Switches, routers, • base-stations • Networks • Mobile telephones

  6. What they Need.. • Massive concurrency • Soft real-time • Distribution • Interaction with hardware • Very large software systems • Complex functionality • Continuous operation for many years • Software maintenance without stopping the system • Stringent quality and reliability requirements • Fault tolerance errors

  7. How ERLANG Prog started Concurrent systems programming languages like Ada, Modula or Chill Functional programming languages like ML or Miranda Concurrent functional programming language Erlang

  8. A Simple Example of ERLANG -module(math2). -export([double/1]). double(X) -> times(X, 2). times(X, N) -> X * N. The function double/12 can be evaluated from outside the module, whereas times/2 is purely local, for example: > math2:double(10). 20 > math2:times(5, 2). ** undefined function: math2:times(5,2) **

  9. Another Example Pattern Matching -module(math3). -export([area/1]). area({square, Side}) -> Side * Side; area({rectangle, X, Y}) -> X * Y; area({circle, Radius}) -> 3.14159 * Radius * Radius; area({triangle, A, B, C}) -> S = (A + B + C)/2, math:sqrt(S*(S-A)*(S-B)*(S-C)).

  10. activity(Joe,75,1024) Creating a new process using spawn Syntax: Pid= spawn(Module, FunctionName, ArgumentList) Example Program: -module(ex3). -export([activity/3]). activity(Name,Pos,Size) -> ………… Pid = spawn(ex3,activity,[Joe,75,1024])

  11. Concurrency in ERLANG ringing_a(A, B) -> receive {A, on_hook} -> back_to_idle(A, B); {B, answered} -> A ! {stop_tone, ring}, switch ! {connect, A, B}, conversation_a(A, B) after 30000 -> back_to_idle(A, B) end. back_to_idle(A, B) -> A ! {stop_tone, ring}, B ! terminate, idle(A). Selective receive Asynchronous send Optional timeout

  12. Cooperating processes may be linked together using spawn_link(…,…,…) or link(Pid)

  13. Layering in ERLANG Robust systems can be built by layering “Supervisors” “Workers”

  14. Connectivity Ports can be used to link to External processes. These ports will behave like Erlang processes. External process Port Port ! {PidC, {command, Data}} Port ! {PidC, {connect, Pid1}} Port ! {PidC, close}

  15. ERLANG v/s OTHER PROG LANG’S Applications written in Erlang Applications written in C, C++ or Java OTP Components Standard Libraries Erlang Run-Time System Hardware and Operating System

  16. Using Erlang in Complex Systems • Fits very well with the incremental design method • High programmer satisfaction • Outstanding support for robustness and concurrency • Easier to add/change single components • Small directed teams can achieve impressive results

  17. Productivity Estimates • Similar line/hour programmer productivity • 4-10 fewer lines of source code (compared to C/C++, Java) • 4-10x higher programmer productivity • Similar number of faults per 1000 lines of source code • 4-10x higher quality

  18. Efficient Program Development Requirements • Interaction with the real environment • Powerful and appropriate abstraction mechanisms • Efficient implementation • Useful tools Ideas Prototyping Productification

  19. Erlang {‘home.page’, [{title, “My Home Page”}], [{title, “Welcome to My Home Page”}, {text, [{para, “Sorry, this home page is still under ” “construction. Please come back soon!”} ]} ]}. A Simple Erlang-XML Document XML <?xml version=“1.0”?> <home.page title=“My Home Page”> <title> Welcome to My Home Page </title> <text> <para> Sorry, this home page is still under construction. Please come back soon! </para> </text> </home.page>

  20. EARLANG HIGHLIGHTS • Concurrency • Either transparent or explicit concurrency • Light-weight processes • Highly scalable • Declarative • Functional programming language • High abstraction level • Pattern matching

  21. EARLANG HIGHLIGHTS • Soft Real-time • Response times in the order of milliseconds • Per-process garbage collection • Robustness • Simple and consistent error recovery • Supervision hierarchies • "Program for the correct case"

  22. EARLANG HIGHLIGHTS • Distribution • Explicit or transparent distribution • Network-aware runtime system • Hot Code loading • Easily change code in a running system • Enables non-stop operation • Simplifies testing • External Interfacing • "Ports" to the outside world behave as Erlang processes

  23. EARLANG HIGHLIGHTS • Portability • Erlang runs on any UNIX, Windows, ... • Supports heterogeneous networks

  24. THE RESEARCH CONTINUES • HiPE - High Performance Erlang (Uppsala, Astec) • ETOS - Erlang to Scheme (Montréal) • Erlang Verification (SICS, Astec) • Type System (Glasgow) • “Safe” Erlang (Canberra) • Specification Techniques (Aachen) • Erlang Processor (Ericsson CADLab) • ...

  25. References • http://www.ibm.com/developerworks/opensource/library/os-erlang1/ • http://www.erlang.org • http://en.wikipedia.org/wiki/Erlang_(programming_language)

  26. Any Questions? Thank You

More Related