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
《嵌入式系统开发之道:菜鸟成长日志与项目经理的私房菜》用平易朴实的语言,以一个完整的嵌入式系统的开发流程为架构,通过一位“
SolidWorks2007零件设计与案例精粹-(含1CD) 本书特色 本书是SolidWorks三维设计与案例精粹丛书之一,是一部关于SolidWorks20...
《数据与计算机通信(第7版)(影印版)》的宗旨是向读者完整地介绍数据与计算机通信这一广阔领域。作者通过书中的章节,将庞大的论题
中文版CorelDRAW X6完全自学教程-(附光盘) 本书特色 这是一本全面介绍中文版coreldraw x6基本功能及实际运用的书。《中文版coreldra...
《王学研究(第六辑)》内容简介:《王学研究》由贵阳学院阳明学与黔学研究院主办,围绕阳明学研究,征集国内外学者的论文,汇集阳
《市场研究与应用》收集、整理、归纳和丰富了市场研究的最新成果,内容涉及市场细分与定位、产品测试、营销渠道及其管理研究体系
《精进:极简论语》内容简介:王蒙写给年轻人的中国智慧读本,凝聚数十年读书心得与人生经验,直达《论语》精华内核。在本书中,王
WhilethereareseveralbooksonprogrammingforMacOSX,AdvancedMacOSXProgramming:TheBig...
《企业重组的税会处理与筹划》内容简介:本书内容涵盖了企业重组的所有主要形式,包括债务重组、股权收购、资产收购、企业合并、企
《世界遗产·中国》内容简介:人类生存于这个星球之上算是一个侥幸。两万年前,我们还是个濒危物种,熬过了冰河期,人类日益壮大。
作者简介:JohnResigjQuery之父,世界级Web开发大师。2007年加入Mozilla公司,现为可汗学院开发人员。RussFerguson资深开发人员...
《轨道交通软件功能安全标准解析与实践》内容简介:本书面向航空航天、轨道交通、机器人、汽车电子、智能家电等与安全相关领域,围
DustyPhillips是一名加拿大自由软件开发人员、教师、武术家以及开源爱好者。他和ArchLinux社区以及其他开源社区有着紧密联系。他
《大话西方艺术史》内容简介:本书用浅白风趣的语言和逻辑清晰的脉络,梳理了30000多年西方艺术史的精髓,帮助你迅速构建完整的艺术
《交易员的自我修养:中国顶级交易员访谈实录(陈侃迪)》内容简介:本书是“中国顶级交易员访谈丛书”之一,丛书致力于通过十数年
《Photoshop电商设计与装修从新手到高手》内容简介:本书是一本系统讲解Photoshop电商设计与装修的教程。主要讲述了Photoshop电商设
《企业应用架构模式经典重读》内容简介:本书作者是当今面向对象软件开发的权威,他在一组专家级合作者的帮助下,将40多种经常出现
中文版AutoCAD2004经典实例158例 内容简介 Autocad2004是美国Autodesk公司开发的通用计算机辅助绘图与设计系列软件,是当今工程设计领...
Acommitmenttousabilityinuserinterfacedesignanddevelopmentoffersenormousbenefits,...
《移动互联网商规28条》内容简介:如果说《22 条商规》是工业经济时代最重要的著作之一,那么本书则有可能成为移动互联网时代最具价