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
《20世纪物理学(第3卷)》内容简介:20世纪是物理学的世纪,物理学在20世纪取得了突破性的进展,改变了世界以及世界和人们对世界的
《四库全书总目发微》内容简介:本书为作者近年发表《四库全书总目》领域论文之合集,分为“文献编”与“经学思想编”两部分。文献
矿山水害空间数据挖掘与知识发现的支持向量机理论与方法 内容简介 本书分为理论与应用两大部分, 在理论部分对支持向量机的训练参数、核函数及核参数的选择进行了探讨,...
《Python安全攻防》内容简介:随着近几年互联网的发展,Python在各行各业发挥着举足轻重的作用。除应用在科学计算、大数据处理等人
TED百萬人觀賞的視覺時代革命概念!幫助全美企業界「用畫的」解放創意、促進團隊思考的「塗鴉博士」力作!“身為一個職業頭銜裡有
本书并不具体地描述某一技术的细节,而是尽量从宏观上、从历史的角度来描述通信产业的发展和变迁,描述在一个通信基础设施中使用
《群体的思维:如何利用群体智慧解决工作、生活难题》无论我们是要做金融方面的决策、换个工作还是找到我们的另一半,众包都不失
《大学的改革(第五卷·学子篇·研究生)》内容简介:1. 经管学院院长倾力打造,与国际接轨的本土教育圣典;所有家长之枕边书,所以
《《外国文学史》学习辅导与习题集》内容简介:本教材为外国文学史的配套教辅,既适合于学生自学,更可作为考研复习资料。本书由外
《MySQL必知必会》MySQL是世界上最受欢迎的数据库管理系统之一。书中从介绍简单的数据检索开始,逐步深入一些复杂的内容,包括联
《儿童心理问题全攻略(家庭教育)》内容简介:每一个孩子的内心都是一个充满奥秘的世界。如何走进孩子的内心? 如何了解孩子莫名举
就科学传播领域而言,《新闻、科学与社会:新闻和公共关系中的科学传播》的基本思路是把科学新闻报道和科研机构中公关部门的工作并
现代操作系统(英文版.第3版) 本书特色 在本书中作者深入讨论了许多主题,包括:进程、线程、存储管理、文件系统、i/o、死锁、接口设计、多媒体、性能权衡,以及有...
Excel 2007公式.函数与图表宝典-(含光盘一张) 内容简介 Excel2007是微软推出的*新电子表格处理软件,界面有了很大变化,在实用性方面有了很大提...
数据结构-C++版-(第四版)-(英文影印版) 本书特色 《数据结构:C++版(第4版)(影印版)》以C++语言作为实现语言,利用面向对象的方法,从规格说明出发...
EXCEL图表实战技巧精粹 本书特色 《EXCEL图表实战技巧精粹》内容丰富、图文并茂,内容由浅入深,适合于各个学习阶段的读者阅读,能有效地帮助读者提高Exce...
陶国荣编著的《HTML5实战》是一本系统而全面的HTML5教程,根据HTML5标准的最新草案,系统地对HTML5的所有重要知识点进行了全面的
本书每章为一个主题,实验内容安排紧扣大学算法和数学的教学,用程序设计竞赛中的算法和数学试题作为实验试题,将算法和数学的教
何为好设计?答案在于你如何定义“Good”,它是关于形式、功能、花费、价值,还是可持续性?Good是一个主观的词汇,本书介绍了许
《汽车标志大全.德国、法国、俄罗斯篇》内容简介:汽车品牌和它的标志是一个不可分割的整体,汽车品牌对应着标志。品牌名即是可以读