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
无线接入技术 本书特色 本书全面、系统地阐述无线接入网领域的基本原理、基本技术,较充分地反映了当代无线接入领域的*新技术。全书共五章,**章介绍接入网技术概述、...
《唐朝定居指南》内容简介:《唐朝定居指南》是《唐朝穿越指南》的姊妹篇。以浅显风趣的笔调,介绍唐人衣、食、住、行、语言、娱乐
《商业美食摄影必修课》内容简介:本书结合作者多年美食摄影的工作经验,用大量的作品和实际案例,由浅及深地向读者描绘了一条美食
体现日本民艺大师柳宗理“实用之美”的白瓷酱油壶;传承两百年的小久慈烧煎茶碗;当代最受欢迎的工业设计大师马克·纽森充满未来
Itsthelittlethingsthatturnagooddigitalproductintoagreatone.Withthispracticalbook...
《鸽群中的猫》内容简介:著名女子学院“芳草地”迎来了新的学期。新入学的女孩里有一位谢斯塔公主,她的表哥刚刚在一场政变中被害
数控编程技术228例 本书特色 本书对228个数控机床编程与造型实例进行了分析和讲解,每个编程实例的主要内容有零件分析、工艺分析、工件坐标系的设定、编制加工程序...
《信息存储与IT管理》内容简介:本书由华为技术有限公司与上海交通大学计算机科学与工程系联合编写,融合了上海交通大学在计算机领
《计算机科学概论》由两位知名的计算机科学教育家编写,全面而细致地介绍了计算机科学的各个方面。书中,计算系统的每个分层都以
《大数据实践之路》内容简介:《大数据实践之路:数据中台+数据分析+产品应用》共13章,汇集了7位作者(来自多个大型互联网企业)的
LATEX 入门 本书特色 LATEX肇始于20世纪80年代初,也是LeslieLamport博士为了编写他自己的一部书籍而设计的。LATEX实际上就是用TEX...
《Hadoop实战》作为云计算所青睐的分布式架构,Hadoop是一个用Java语言实现的软件框架,在由大量计算机组成的集群中运行海量数据
《母婴健康照护棘手问题解答:预防出生缺陷 孕育健康宝宝》内容简介:随着预产期临近,准妈妈们最担心的是能否顺利生下宝宝,有什么
《混沌工程:复杂系统韧性实现之道》内容简介:混沌工程已然腾飞。在各个垂直领域,成千上万的各种类型和规模的公司都将混沌工程作
蜜蜂病虫害防治 内容简介 本书由中国农业科学陆军蜜蜂研究所冯峰研究员等编著。内容包括:蜜蜂的种类、形态、发育阶段和生物学特性,蜜蜂疾病的发生、诊断和防治,蜜蜂的...
TheSeriesinCommunicationTechnologyandSocietyisanintegratedseriescenteringontheso...
Python程序设计 本书特色 本书以Python程序设计语言为主要内容,重点强调程序设计概念的理解和计算思维的实践。内容包括:Python语言的介绍和快速入门...
Visual C#.NET程序设计教程(第2版) 本书特色 《Visual C#.NET程序设计教程(第2版普通高等学校计算机教育十二五规划教材)》(作者罗福强...
《十指意气 数行好书》内容简介:新碑帖的发现和出土,不仅改变书法史的阐述方式与角度,使得每一个时代的书法史图谱更为详实而可靠
《卡通IP时代:品牌卡通形象设计揭秘(第3版·修订版)》内容简介:大IP时代就要来临了,那么到底什么是设计行业的大IP?本书就IP设