Chapter 2. Erlang language essentials

 

This chapter covers

  • Working interactively in the Erlang shell
  • Data types, modules, functions, and compiling your code
  • Single-assignment variables and pattern matching
  • Erlang language survival guide
  • How to program with recursion

In the previous chapter, we talked about the underlying platform for Erlang and OTP, but not much about the Erlang programming language. The focus of this book isn’t on Erlang in itself; but before can you move on to programming with Erlang/OTP design patterns, we want to go through the language basics to make sure everyone is on the same page. This chapter will also serve as a reference as you work your way through the book.

This is a long chapter. If you already know Erlang, you can skim this chapter, but we try to make sure there are some useful nuggets for you too. These are the things we think every Erlang programmer should be aware of, and we know it’s possible for even the most experienced old-timers to have missed some useful detail.

2.1. The Erlang shell

2.2. Data types in Erlang

2.3. Modules and functions

2.4. Variables and pattern matching

2.5. Functions and clauses

2.6. Case and if expressions

2.7. Funs

2.8. Exceptions, try, and catch

2.9. List comprehensions

2.10. Bit syntax and bitstring comprehensions

2.11. Record syntax

2.12. Preprocessing and include files

2.13. Processes

2.14. ETS tables

2.15. Recursion: it’s how you loop

2.16. Erlang programming resources

2.17. Summary