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
《生命3.0》内容简介:在人工智能崛起的当下,你希望看到一个什么样的未来?当超越人类智慧的人工智能出现时,人类将何去何从?你是
《创业就是构建美好关系》内容简介:创业就是一场修行,谋生又谋爱,爱就是一种美好链接,创业者和周遭的关系,将影响企业发展和人
遥感数据质量改善之信息重建 本书特色 基于航空航天遥感技术,人们可以感知地球陆表信息,从而认识和理解各种现象和规律。其中,传感器观测影像是遥感信息的载体,其数据...
《香料在丝绸的路上浮香》内容简介:尚书郎在朝堂上含的“口香糖”鸡舌香,故乡远在太平洋中央的热带火山岛;印度佛教仪式中熏燃的
《市场研究与应用》收集、整理、归纳和丰富了市场研究的最新成果,内容涉及市场细分与定位、产品测试、营销渠道及其管理研究体系
《南京理工大学史话》内容简介:南京理工大学是隶属于中华人民共和国工业和信息化部的全国重点大学,由创建于1953年的新中国军工科
如今,我们要面对和使用的数据正在变得越来越庞大和复杂。如果说数据是新的石油。那么数据库就是油田、炼油厂、钻井和油泵。作为
《简明版面设计》通过大量的实际图例分析,介绍如何应用3种格调和5种要素来设计各种各样的版面。《简明版面设计》分学习编、分析
《做自己的保险规划师》内容简介:本书分为八章,每章围绕一个主题,以通俗易懂的写作方式,为读者提供了实用且清晰的保险规划建议
《Maya 2013完全学习手册》内容简介:本书是“完全学习手册”系列图书中的一本。《Maya 2013完全学习手册》遵循人们的学习规律和方
《Web2.0高级编程》首先通过一个Web2.0应用演示了服务器和浏览器之间的交互过程,让读者对《Web2.0高级编程》中介绍的技术在Web2
《商业银行操作风险量化分析》内容简介:本书以信度理论和贝叶斯网络为主要工具,研究了操作风险的高级计量法与预警机制,并针对中
TheSeriesinCommunicationTechnologyandSocietyisanintegratedseriescenteringontheso...
本书介绍了行为科学(重点是心理学)中用到的基本统计知识:描述性统计、简单的假设验证和最简单的多元统计。全书共分4个部分:第一部
主板维修技能实训(芯片级) 内容简介 本书结合大量图解与实例,循序渐进地讲解了主板的结构和电路组成,常用维修工具,元器件好坏的判定方法,总线插槽和测试点,以及接...
AUTODESK INVENTOR产品设计实例精解-2013版-(附2DVD) 本书特色 零件建模与设计是产品设计的基础和关键,要熟练掌握应用Inventor设...
学习OpenCV(中文版),ISBN:9787302209935,作者:(美)布拉德斯基(Bradski,G.),(美)克勒(Kaehler,A.)著,于仕琪,...
《块数据5.0:数据社会学的理论与方法》内容简介:块数据是贵阳发展大数据的理论创新和实践探索的产物,是大数据时代的解决方案。《
《国家干预经济与中日近代化(修订本)》内容简介:本书以19世纪中后期中日两国两个典型企业的发展历程为例,从纵向和横向两个角度
《电子技术基础:模拟部分(第4版)》是“九五”国家级重点教材,前版获国家级优秀教材特等奖及国家科技进步二等奖。为适应电子信息