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
Acommitmenttousabilityinuserinterfacedesignanddevelopmentoffersenormousbenefits,...
MATLAB GUI设计学习手记-(第3版) 本书特色《matlab gui设计学习手记》(第3版)在《matlab gui设计学习手记》(第2版)的基础上,结...
《典藏——印象派作品高清图集》内容简介:印象派是西方绘画史上划时代的艺术流派,兴起于法国,在19世纪末达到鼎盛,其影响遍及欧
计算机网络安全教程-(修订本) 本书特色 《计算机网络安全教程》(修订本)在原书基础上做了大量修整和扩充,使之更加适合高校教学和自学的需要。利用大量的实例讲解知...
ThisbookisaboutthenextgenerationoftheGoogleMapsAPI.Itwillprovidethereaderwiththe...
博客(blog),这个由“网络日志”(weblog)派生出来的词,早已跳脱了“日志”的范畴,担当起信息传播、情感交流、产品宣传等等职责
内容简介:作为唯一所有主流浏览器都支持的脚本语言,JavaScript俨然已成为Web开发领域最具号召力的语言,但它的种种语言怪癖以及
《最新日本设计模板:版面设计》着重对海报、DH、POP、书籍等印刷品的设计和运用进行解说,因为“版面设计”存在于人们生活的方方
《目标跟踪中的群智能优化方法》内容简介:全书内容分为9章,系统地介绍了群智能优化方法的发展及其在目标跟踪中的应用,包括基于标
计算机审计数据采集与处理技术研究报告 内容简介 我国改革开放以来的经济发展和科技进步,推进了国家审计的信息步伐。金审工程的启动,使计算机审计从现场审计方式发展到...
《Python人脸识别:从入门到工程实践》内容简介:本书讲解了人脸识别模型的实现原理和特点,更重要的是强调了工程上的实践能力,对
《公司法学(下)》内容简介:本书通过浅显的文字说明,配以具体案例,对董事的注意义务和忠诚义务、派生诉讼、征集投票代理权等国
因為無法「保留」,所以美。因為「留白」,所以更豐盈。因為「看不見」,所以想像無限。日本擁有獨特的美意識和自然觀,自古傳承
《译前译后》内容简介:《译前译后》主要涉及到笔者多年来翻译并出版过的作品。译前,系译者对原著的认识。译后,这里包括译著的成
《明德学校史话》内容简介:本书依据宏富的史料,记述了明德学校艰苦卓绝的办学历程及其辉煌的办学业绩,展示了胡元倓等一批明德人
单片机实验与实践教程-(二)(第2版) 内容简介 本书为《单片机系列教程》之一,较之第1版,增删了部分内容。保留了第1版中循序渐进、汇编语言与高级语言并重、串并...
交通流时间序列的分析与应用 本书特色 本书针对交通流时间序列所涉及的预测、优化和控制问题,系统地给出了作者在非线性动力学领域的*研究成果,已期为研究人员在非线性...
《口水民国:民国名人的笔墨官司》内容简介:本书主要围绕民国时期的口水公案、笔墨官司,详细叙述了民国时期学界、政界、工商界等
《李国文散文》内容简介:李国文散文,无论抒写对现实人生的思考,还是关注历史上文人的生存状态,字里行间都透出真性情,具有洞明
《服装设计师创业指南》就是要摘下时装界的光环,在呈现其艰辛一面的同时奉上有用的知识和有效的方法以战胜困难,这是一本关于时