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
Java成为世界上编程语言之一是有其优势的。熟悉JavaSE的程序员可以轻松地进入到JavaEE开发中,构建出安全、可靠和具有扩展性的企
機器人端咖啡,電腦當醫生,數據分析愈來愈便利精準,我們以為科技將創造新一波繁榮,卻低估了它推動世界變遷的速度!機器開始全
《宋代家礼》内容简介:《宋代家礼》一书将宋代家礼作为一种集体写作规范的历史场景来观察,探讨了这一时期书写者在家礼文本中的自
《JavaWeb开发实战宝典》从初学者的角度出发,通过通俗易懂的语言、丰富实用的实例,详细介绍了使用Java语言和开源框架进行Web程
龚正/惠普公司高级顾问拥有十多年的IT从业经验,具备丰富的云计算、大数据分析和大型企业级应用的架构设计和实施经验,是电信、金
《铅笔素描绘制详解——质感表现技法》内容简介:质,是指物体的物质属性。不同的物质给人以不同的视觉感知,这就是质感。素描绘画
《移动设计》内容简介:移动应用的交互设计对于移动产品的体验来说有着决定性的作用。作者首先从人-机-环的角度出发来阐述移动应用
1714新概念PhotoshopCS教程 本书特色 本书是职业教育院校和电脑培训学校的理想教材,是十一五期间重点计算机多媒体教学出版物规划项目。活泼生动的多媒体...
《活着,就要无声炸裂》内容简介:这是一本让年轻人小宇宙爆发的力量之书。人气博主南顾用自己的亲身经历写下颠沛流离的青春、肆意
《吉狄马加的诗》内容简介:本书汇集作者自创作以来诗歌作品的精华,充分展现了迄今作者诗歌创作的全貌,同时因其代表性位置,展现
数字逻辑基础与Verilog设计(原书第2版)(附光盘) 内容简介 本书系统介绍数字逻辑基本概念与实际应用。主要内容包括:逻辑电路、组合逻辑、算术运算电路、存储...
各位,下一個最好的投資機會,不在於股票、債券或房地產,而是原物料,也就是我們日常生活基本所需的大宗物資。聰明的投資人已經
《Go语言学习指南:惯例模式与编程实践》内容简介:本书Go语言正在迅速成为构建Web服务的优选语言。本书很好地阐述了Go语言的特性,
计算机审计数据采集与处理技术研究报告 内容简介 我国改革开放以来的经济发展和科技进步,推进了国家审计的信息步伐。金审工程的启动,使计算机审计从现场审计方式发展到...
卷1 协议-TCP/IP详解-(英文版.第2版) 本书特色 ·w. richard stevens传奇般的tcp/ip指南,现在被顶级网络专家kevin r.f...
本书由资深Python专家亲自执笔,Python语言的核心开发人员作序推荐,权威性毋庸置疑。对于程序员而言,标准库与语言本身同样重要
《世界经典步枪TOP10》内容简介:步枪是世界上产量最高、应用最广泛的单兵轻武器。本书以轻武器发展的重要节点划分历史时期,纵向回
《别让心态毁了你》内容简介:保持什么样的心态就会有什么样的行为方式,而行为方式决定着一个人的生人走向。心态能够成就一个人,
CorelDRAW X4基础运用与设计实例 本书特色 《CorelDRAW X4基础运用与设计实例》:艺术与设计类规划教材。CorelDRAW X4基础运用与设...
《英国陶艺设计基础教程》是一本陶艺设计的完全指导手册,融合了理论、实践、技术三方面的重点,你可以通过《英国陶艺设计基础教