As a developer, you’ve probably heard that functional programming techniques help manage the complexities of today’s real-world, concurrent systems. You’re also investigating designs that help you maximize uptime and manage security.
This book is your guide to Elixir, a modern, functional, and concurrent programming language. Because Elixir runs on the Erlang VM, and uses the underlying Erlang/OTP architecture, it benefits from almost 20 years of research into high performance, highly parallel, and seriously robust applications. Elixir brings a lot that’s new: a modern, Ruby-like, extendable syntax, compile and runtime evaluation, a hygienic macro system, and more.
But, just as importantly, Elixir brings a sense of enjoyment to parallel, functional programming. Your applications become fun to work with, and the language encourages you to experiment.
Part 1 covers the basics of writing sequential Elixir programs. We’ll look at the language, the tools, and the conventions.
Part 2 uses these skills to start writing concurrent code—applications that use all the cores on your machine, or all the machines on your network! And we do it both with and without OTP.
And Part 3 looks at the more advanced features of the language, from DSLs and code generation to extending the syntax.
By the end of this book, you’ll understand Elixir, and know how to apply it to solve your complex, modern problems.
Contents and Extracts
This book is currently in beta, so the contents and extracts will change as the book is developed.
Preface/Introduction
Conventional Programming
Pattern Matching
Assignment: I do not think it means what you think it means
More Complex Matches
Ignoring a Value With _
Variables Bind Once (Per Match)
Another way of looking at the equals sign
Immutability
You Already Have (Some) Immutable Data
Immutable Data Is Known Data
Performance Implications of Immutability
Coding With Immutable Data
Elixir Basics excerpt
Value Types
System Types
Collection Types
Names, Source Files, Conventions, Operators, and So On
End of the Basics
Anonymous Functions
Functions and Pattern Matching
One Function, Multiple Bodies
Functions Can Return Functions
Passing Functions as Arguments
Functions Are The Core
Modules and Named Functions
The Body of the Function is a Block
Function Calls and Pattern Matching
Guard Clauses
Default Parameters
|> — The Amazing Pipe Operator
Modules
Module Attributes
Module Names: Elixir, Erlang, and Atoms
Lists and Recursion
Heads and Tails
Using Head and Tail to Process a List
Using Head and Tail to Build a List
Creation of a Map Function
Keeping Track of Values During Recursion
More Complex List Patterns
List Comprehensions
Using the Built-in Libraries
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
Records
Defining Records: defrecord
Records and Pattern Matching
Advanced Records
Control Flow
if and unless
cond
case
Raising Exceptions
Designing With Exceptions
What we’ve seen
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 External Libraries
Transformation: Convert Response
Transformation: Take First N Items
Transformation: Format the Table
Task: Make a command line executable (#sec.cmd-line}
Task: Test The Comments
Task: Create Project Documentation
What We’ve Just Seen
Concurrent Programming
Working With Multiple Processes
A Simple Process
Process Overhead
When Processes Die
Parallel Map—The Hello World of Erlang
A Fibonacci Server
What’s Next
Nodes—The Key To Distributing Services excerpt
Naming Nodes
Naming Your Processes
I/O, PIDs, and Nodes
What’s Next
OTP: Servers
Some OTP Definitions
An OTP Server
GenServer Callbacks
Naming A Process
Tidying Up The Interface
What We Learned
OTP: Supervisors
Supervisors And Workers
Supervisors Are The Heart of Reliability
OTP: Applications
Application: I do not think it means what you think it means
The Application Specification File
Turning Our Sequence Program into an OTP Application
Tell Mix About The Application
Create the application OTP entry point
Hot Code Swapping
OTP is Big. Unbelievably Big
Web Applications with Dynamo
More Advanced Elixir
Protocols
Use and Using
Macros
【董龙飞】毕业于北京航空航天大学,自动控制系硕士。为人热诚、执著、正直和幽默。现供职于Adobe系统软件(北京)有限公司,是A
本书不仅描述了IMS域的体系结构,而且通过实例深入浅出地对IMS的关键概念、主要过程以及典型业务进行了剖析。本书内容远远超越了
《怎样成为一名设计师》内容简介:头脑独立的设计师需要自己发现合理建议,也需要当代设计师面对的道德与实践问题的指南。《怎样
《数据结构》(C语言版)针对采用ANSIC实现数据结构进行了全面的描述和深入的讨论。书中详细讨论了栈、队列、链表以及查找结构、高
Designersanddevelopers,createsmashingappsforAndroiddevicesIfyouredevelopingappli...
《知行合一:悦读《传习录》》内容简介:《传习录》是明朝著名的哲学家、政治家、教育家和军事家王阳明的一部语录体哲学著作,内容
《粗糙食堂2:一个人的幸福餐》内容简介:为什么一个人的生活总是被外卖或随便吃填满?因为一个人做饭太难了!不知道吃什么。不知道
信息处理技术员2014至2019年试题分析与解答 本书特色 历年试题分析与解答是理解考试大纲有效、具体的途径。本书由全国计算机专业技术资格考试办公室汇集了信息处...
我要学office2007高效办公三合一 内容简介 本书分为4篇,共12章。前三篇详细介绍了Word、Excel和PowerPoint的基础操作,第四篇以综合实...
《Node即学即用》由休斯-克劳奇、威尔逊编著,《Node即学即用》讲解如何用Node构建可扩展因特网应用,是全面的实用指南,除了详
本书是由国内资深网页设计师凝聚8年设计配色经验精心编著而成的。全分为网页界面设计、网页版式布局、网页色彩搭配、网页版式与色
《新手易学:中文版Photoshop CS5图像处理》内容简介:《新手易学:中文版Photoshop CS5图像处理》是为帮助Photoshop初级用户掌握Ph
《全能鼓手实战教程——648句技巧训练》内容简介:本书是一本鼓手必备的练习宝典。涵盖了爵士鼓、小军鼓等各类鼓乐学习过程中初级、
2015,中国以“一带一路”为纽带,选择和平与共享的方式,重新缔造与世界的关系;抗战胜利日大阅兵,对应的是70年前中国以血肉之
《HTML+CSS+JavaScript网页设计与布局实用教程》紧密围绕网页设计师在制作网页过程中实际需要掌握的技术,全面介绍了使用html、c
《刚好遇见你》内容简介:本书从改编理论出发,囊括了影视改编理论、影视改编案例到改编实践理论,分三编,共十个章节。影视改编理
中文版PremierePro CS6完全自学教程 本书特色 这是一本精心设计的Premiere学习教程,图书结合平常学习、工作的需求,精心挑选案例,结合应用,力...
《LED照明驱动电源模块化设计技术》内容简介:随着LED照明技术的迅速发展和LED灯具的规模化应用,对LED驱动电源的要求也越来越高。
本书比较全面地介绍了网页设计应注意的相关问题,在网页设计基础方面着重讲解了网页框架、页面元素、色彩设计,分析了一些人们容
《区块链与智慧物流》内容简介:本书以区块链技术与智慧物流的融合应用为核心,通过剖析智慧物流的发展演进及区块链影响物流系统与