Chapter 9. More Data Types and High-Level Constructs

At this stage of the book, we have covered all the fundamentals: sequential programming, concurrency, fault tolerance, and error recovery. The Erlang language—and in particular, its many libraries—offer more to help the programmer be as effective as possible. The various language features covered in this chapter, many of them derived from functional programming languages, are tools that will improve the productivity of a working Erlang programmer.

Functional Programming for Real

Erlang is a functional programming language—among other things—but what does that really mean? Prominent in Erlang are function definitions, but that’s also the case in Pascal, C, and many other languages. What makes a true functional programming language is the fact that functions can be handled just like any other sort of data. Functional data types in Erlang are called funs. They can be passed as arguments to other functions and they can be stored in data structures like tuples and records or sent as messages to other processes. Most of all, they can be the results of other functions so that the functions passed around as data can be created dynamically within the program, and are not just pointers to statically defined functions. This, in turn, lets you write concise, abstract, reusable functions that are parameterized over particular behaviors, “wrapped up” as function arguments. As a result, your code becomes not only more compact, but also easier ...

Get Erlang Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.