erlang by example

Upload: joshmuza

Post on 30-May-2018

213 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/14/2019 Erlang by Example

    1/3

    Erlang Training and Consulting Limited, Commercial in Confidence

    Erlang By ExampleCourse Contents

    Course: Erlang By ExampleTargeted Audience: Software DevelopersRequirements: Good programming skills.Objectives: Understanding of the basics of Erlang.

    Read/Write/Design Erlang Programs.Good knowledge of the development environment and tools.Understanding of the good and bad programming practices.Goal: Attend the OTP course and eventually pass the Erlang certification exam.Duration: Five days.

    Erlang By Example is a five day introductory course aimed at software engineers. Its objectives are to giveparticipants the knowledge to read, write and structure Erlang programs, providing all prerequisites to attendthe Advanced Erlang/OTP course. The course contains all the Erlang basics such as sequential andconcurrent programming, along side error handling and the latest language extensions. The Erlangdevelopment environment is presented, with a special emphasis on the Erlang mode for Emacs alongsidethe major debugging tools. Good and bad programming practices are discussed, as are tools used to profile

    the system. OTP design principles and concepts are sneaked into the material as well as the exercises.

    All material in these pages, including text, layout, presentation, logos, icons, photos, and all otherartwork is the Intellectual Property of Erlang Training & Consulting Ltd, unless otherwise stated, and

    subject to Erlang Training & Consulting Ltd copyright. No commercial use of any material is authorisedwithout the express permission of Erlang Training & Consulting Ltd. Information contained in, or derived

    from these pages must not be used for development, production, marketing or any other act, whichinfringes copyright. This document is for informational purposes only. Erlang Training & Consulting Ltdmakes no warranties, expressed or implied, in this document.

  • 8/14/2019 Erlang by Example

    2/3

    Erlang Training and Consulting Limited, Commercial in Confidence

    IntroductionWe start off with an introduction of the software needs of telecom control systems, followed by a history ofErlang, its features, and product and research examples within and outside Ericsson.

    Basic ErlangThis section deals with Erlang data types and pattern matching. Functions, modules, and BIFs arediscussed. Before the exercises, the Erlang shell, useful shell commands as well as Emacs and its Erlangmode are introduced.

    Sequential ProgrammingThe Sequential Programming section comprehends conditional evaluations, guards and scope of variables. Itthen introduces recursion, with a special emphasis on different recursive patterns, tail recursion, and spacesaving optimizations. Before the exercises, libraries and their manual pages, possible run time errors and thedebugger are demonstrated.

    Concurrent ProgrammingThis section describes the creation of processes and their life span. It looks at sending and receivingmessages, selective reception, and passing data in the messages. It continues with the various uses of timeouts and registering processes, and terminates by showing the generic process code structure. Before theexercises, a demonstration of the Process Manager tool is given.

    Process Design PatternsThis section introduces the concept of process patterns, preparing the students for the OTP behaviours. Itgives a detailed example of a client server system, looks at finite state machines and event handlers.Synchronous versus asynchronous message passing is discussed.

    Process Error HandlingThis section introduces the simple but powerful error handling mechanisms in processes. It looks at processlinks, exit signals and their propagation semantics. How robust systems are built in Erlang are discussed,and an example from the Process Design Patterns section is re-implemented, making it robust.

    Code UpdatingThe section introduces software upgrade during run time. The error handler, the code server, and codesearch paths are covered, as is the .erlang file.

    Records and FunsThe syntax and semantics of records is introduced, with a special emphasis on pattern matching. Funs arecovered, as are higher order functions. Plenty of examples are given for both constructs.

    ETS tablesAn introduction to the Erlang Term Storage is given, together with its different table options. Examples onwhen to use and not to use ETS tables are covered. A demonstration of the table visualizer is provided.

    Distributed ProgrammingAn introduction to the requirements of distributed systems is given, and how Erlang is able to fill theserequirements. The distribution syntax and semantics are covered, followed by the BIFs and the net kernel.

    Advanced ConstructsList comprehensions and their usage are explained. References are discussed. This is followed by Binaries,and the Bit syntax, where pattern matching can be applied directly to incoming structures. Lastly, bit wise

    and logical operators are described. This section also covers Macros, with examples on how they can beused for debugging purposes.

  • 8/14/2019 Erlang by Example

    3/3

    Erlang Training and Consulting Limited, Commercial in Confidence

    Ports and SocketsAn introduction of the mechanisms used to make Erlang more open are taken up in this section. Ports, forexternal communication within the same machine, and Sockets, for communication on IP networks arediscussed. The difference between TCP and UDP is described.

    Style and EfficiencyThis section gives an introduction to writing efficient Erlang Programs. The efficiency section describes howbinaries can be used to handle large amounts of data which have to be sent between processes, how tailrecursion can prevent bursts of memory usage, as well as other simple optimisations based on theimplementation of the virtual machine and its garbage collector. It then goes ahead with suggestions andguidelines on how to keep the code neat and readable and terminates with a few slides on coding strategy.