Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Foreword
A Vain Attempt at a Justification
Acknowledgments
1. Take the Red Pill
Programming Should Be About Transforming Data
Installing Elixir
Running Elixir
Suggestions for Reading the Book
Exercises
Think Different(ly)
Part I. Conventional Programming
2. Pattern Matching
Assignment: I Do Not Think It Means What You Think It Means.
More Complex Matches
Ignoring a Value with _ (Underscore)
Variables Bind Once (per Match)
Another Way of Looking at the Equals Sign
3. Immutability
You Already Have (Some) Immutable Data
Immutable Data Is Known Data
Performance Implications of Immutability
Coding with Immutable Data
4. Elixir Basics
Built-in Types
Value Types
System Types
Collection Types
Maps
Binaries
Dates and Times
Names, Source Files, Conventions, Operators, and So On
Variable Scope
End of the Basics
5. Anonymous Functions
Functions and Pattern Matching
One Function, Multiple Bodies
Functions Can Return Functions
Passing Functions As Arguments
Functions Are the Core
6. Modules and Named Functions
Compiling a Module
The Function’s Body Is a Block
Function Calls and Pattern Matching
Guard Clauses
Default Parameters
Private Functions
The Amazing Pipe Operator: |>
Modules
Module Attributes
Module Names: Elixir, Erlang, and Atoms
Calling a Function in an Erlang Library
Finding Libraries
7. Lists and Recursion
Heads and Tails
Using Head and Tail to Process a List
Using Head and Tail to Build a List
Creating a Map Function
Keeping Track of Values During Recursion
More Complex List Patterns
The List Module in Action
Get Friendly with Lists
8. Maps, Keyword Lists, Sets, and Structs
How to Choose Between Maps and Keyword Lists
Keyword Lists
Maps
Pattern Matching and Updating Maps
Updating a Map
Structs
Nested Dictionary Structures
Sets
With Great Power Comes Great Temptation
9. An Aside—What Are Types?
10. Processing Collections—Enum and Stream
Enum—Processing Collections
Streams—Lazy Enumerables
The Collectable Protocol
Comprehensions
Moving Past Divinity
11. Strings and Binaries
String Literals
The Name “strings”
Single-Quoted Strings—Lists of Character Codes
Binaries
Double-Quoted Strings Are Binaries
Binaries and Pattern Matching
Familiar Yet Strange
12. Control Flow
if and unless
cond
case
Raising Exceptions
Designing with Exceptions
Doing More with Less
13. Organizing a Project
The Project: Fetch Issues from GitHub
Task: Use Mix to Create Our New Project
Transformation: Parse the Command Line
Step: Write Some Basic Tests
Transformation: Fetch from GitHub
Task: Use Libraries
Transformation: Convert Response
Transformation: Sort Data
Transformation: Take First n Items
Transformation: Format the Table
Task: Make a Command-Line Executable
Task: Add Some Logging
Task: Create Project Documentation
Coding by Transforming Data
14. Tooling
Testing
Code Dependencies
Server Monitoring
Inevitably, There’s More
Part II. Concurrent Programming
15. Working with Multiple Processes
A Simple Process
Process Overhead
When Processes Die
Parallel Map—The “Hello, World” of Erlang
A Fibonacci Server
Agents—A Teaser
Thinking in Processes
16. Nodes—The Key to Distributing Services
Naming Nodes
Naming Your Processes
I/O, PIDs, and Nodes
Nodes Are the Basis of Distribution
17. OTP: Servers
Some OTP Definitions
An OTP Server
GenServer Callbacks
Naming a Process
Tidying Up the Interface
18. OTP: Supervisors
Supervisors and Workers
Supervisors Are the Heart of Reliability
19. OTP: Applications
This Is Not Your Father’s Application
The Application Specification File
Turning Our Sequence Program into an OTP Application
Supervision Is the Basis of Reliability
Releasing Your Code
EXRM—The Elixir Release Manager
OTP Is Big—Unbelievably Big
20. Tasks and Agents
Tasks
Agents
A Bigger Example
Agents and Tasks, or GenServer?
Part III. More Advanced Elixir
21. Macros and Code Evaluation
Implementing an if Statement
Macros Inject Code
Using the Representation As Code
Using Bindings to Inject Values
Macros Are Hygienic
Other Ways to Run Code Fragments
Macros and Operators
Digging Deeper
Digging Ridiculously Deep
22. Linking Modules: Behavio(u)rs and Use
Behaviours
use and using
Putting It Together—Tracing Method Calls
Use use
23. Protocols—Polymorphic Functions
Defining a Protocol
Implementing a Protocol
The Available Types
Protocols and Structs
Built-In Protocols
Protocols Are Polymorphism
24. More Cool Stuff
Writing Your Own Sigils
Multi-app Umbrella Projects
But Wait! There’s More!
A1. Exceptions: raise and try, catch and throw
Raising an Exception
catch, exit, and throw
Defining Your Own Exceptions
Now Ignore This Appendix
A2. Type Specifications and Type Checking
When Specifications Are Used
Specifying a Type
Defining New Types
Specs for Functions and Callbacks
Using Dialyzer
Bibliography
← Prev
Back
Next →
← Prev
Back
Next →