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
《拉通》内容简介:怎样加快项目或订单的获取和交付,实现高效增长?怎样提高部门之间、员工之间的协作效率或人效?怎样判断并从根
jaybryant:横跨两个不同的领域:写作和编程。在过去的20年中,他一直致力于帮助ge(通用电气)、motorola(摩托罗拉)、dell(戴
Galadinner:SalvadorDalí’ssurrealistcookbook“LesdinersdeGalaisuniquelydevotedtoth...
《独坐》内容简介:阅读的过程,从一开始的“围坐”渐渐变成“独坐”的时候,你也许已经能够在那书本知识的五彩斑斓里遨游了,或许
《控制阀设计及先进制造技术》内容简介:控制阀是过程自动化装置中极为重要的设备之一,是流程工业自动控制系统的执行器,流程控制
《无线局域网设计与优化》内容简介:《无线局域网设计与优化》从WLAN的起源和演进出发,简洁而又直观地描述了基于IEEE 802.11 协议
《中国舞蹈通史:宋 辽 西夏 金 元卷》内容简介:中国舞蹈史学研究的意义和任务是什么呢?无非是为了“考古以证今”,“以史明鉴”
《全球价值链、中国经济增长与碳排放》内容简介:本书将全球价值链研究的前沿成果与环境经济学、国际贸易理论的学术洞见整合在一起
《敏捷软件开发(珍藏版)》内容简介:本书作为敏捷软件开发的里程碑之作,重点介绍了敏捷软件开发的原则、模式和实践。全书共6部分
《MATLAB计算机视觉实战》内容简介:本书以MATLAB8.X汉化版为工具,深入浅出地介绍了基于计算机视觉系统工具箱(ComputerVisionSys
本书作为有关VisualC++Debugger的专著,是一本非常难得的好书。书中深入地分析了开发不包含逻辑和语法错误的代码技巧以及调试程
《村落效应》内容简介:面对面的接触是作为社会性动物的人类古老、深刻的需求。在互联网时代,社交媒体已经成为人际沟通的主体,人
《下一代移动网络应用:在Web2.0和Mobile2.0环境中创建移动应用(第2版)》为无线移动领域的从业人员提供一种思考以及应对日益复杂的
《时尚圣经》内容涵盖时装、妆容、珠宝、明星四大部分,向中国及世界展示一百年来时装艺术的终极美学价值,表现高级时装精神,坚
《写给数据产品经理新人的工作笔记》内容简介:本书的目标在于,为数据产品从业新人或准备转行做数据产品的读者提供一个本领域的通
The3GIPMultimediaSubsystem(IMS):MergingtheInternetandtheCellularWorlds,SecondEdi...
这不是一本常规意义上Python的入门书。这本书中没有Python关键字和for循环的使用,也没有细致入微的标准库介绍,而是完全从实战的
《阿里铁军销售课》内容简介:什么是销售? 我们每天都在销售和被销售,销售已经成为一种意识,是一种思维。本书作者“阿里军校”首
Asthefirstbooktosharethenecessaryalgorithmsforcreatingcodetoexperimentwithdesign...
Iftheusualpatchworkofwebdevelopmenttoolsandlanguagesjustisntcuttingitforyou,youn...