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
《人脸识别与美颜算法实战》内容简介:本书从实战出发,介绍了大约60多个案例,脉络清晰,没有太多枯燥的理论讲解,而是以一位资深
21天学通C语言(第6版)(附光盘) 内容简介 本书译自《Teach Yourself C in 21 Days》第6版,该书的前五版都登上了畅销书排行榜,是初...
《王维诗选:四僧插图版》内容简介:王维诗选一书中精选王维文辞优美、通俗易懂的佳作100首,生僻的字词都作了注音和注释。同时又特
《程控交换与宽带交换》以程控交换、ATM交换到MPLS交换的技术发展为线索,对程控交换和宽带交换进行介绍。重点介绍程控交换技术和
Theworldofhealthcareisconstantlyevolving,everincreasingincomplexity,costs,andsta...
本书全面涵盖了并行软件和硬件的方方面面,深入浅出地介绍如何使用mpi(分布式内存编程)、pthreads和openmp(共享内存编程)编写
《一本书读懂经济新常态》内容简介:无论局势如何变幻莫测,经济形势都备受各界关注,经济工作依然是党的当前所有工作的重心,发展
《大规模数据分析和建模:基于Spark与R》内容简介:这本书的目的是帮助所有人通过R使用Apache Spark。第1章~第5章,简单地介绍了如
《复杂信息系统网络安全体系建设指南》内容简介:本书介绍复杂信息系统的网络安全体系建设,共分为7章,第一章为概述;第二章为安全
Thisgroundbreakingbookdefinestheemergingfieldofinformationvisualizationandoffers...
《Linux应用大全:服务器架设》内容简介:Linux是一个免费的多用户、多任务的操作系统,其稳定性、安全性与网络功能特别显著。目前
《嗨,夏威夷(图文版)》内容简介:夏威夷是人间的净土、浪漫的天堂、激情的乐园,也是冒险者与探险者的炼狱场。你可以试身火海,
《危机时刻:德国保守主义革命》内容简介:本辑为读者呈现的是1933年纳粹政权前后,德国思想界影响深远的思潮:保守主义革命。这股
TheHandbookofNaturalLanguageProcessing,SecondEditionpresentspracticaltoolsandtec...
多媒体技术及应用(第2版) 本书特色 执考用书,14年经验指导,全面覆盖大纲,补充超纲考点。多媒体技术及应用(第2版) 内容简介 本书根据教育部高等学校文科计算...
《社会主义核心价值观融入大学生思想政治教育的创新机制研究》内容简介:本书着眼于社会主义核心价值观和大学生思想政治教育的融合
《星野的呼唤》内容简介:本书详细介绍了星空摄影必备的天文常识,拍摄星空必备的器材知识,以及器材的使用方法,星空摄影必备的软
《2017年MBA、MPA、MPAcc管理类联考英语历年真题详解》内容简介:本书对MBA联考英语历年真题给予了系统分析和解答,并总结和归纳了
《智慧社会》内容简介:●如果要在大数据领域推举出一个代表性的科学家,阿莱克斯·彭特兰是一个无法令人忽略的名字。经过数年极具
《所罗门王的宝藏》内容简介:犹太民族的所罗门国王既是智慧的代表,又是财富的象征。他死后多少个世纪以来,人们一直在寻找这批古