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
本书主要讲解如何将集成开发环境、设计模式、极限编程、测试驱动开发、重构、持续集成这些现代编程方法应用到C语言的嵌入式开发中
《Docker从入门到实战》内容简介:本书从Docker的相关概念与基础知识讲起,结合实际应用,通过不同开发环境的实战例子,详细介绍了
《xHTML+CSS+DreamweaverCS3标准网站构建实例详解》特别适合网站美工、网站前端架构师、网页设计爱好者、Wap页面设计师作为学习W
《大中东行纪(修订版)》内容简介:恐怖主义为何主要在大中东猖獗? 突尼斯小贩自焚何以点燃北非局势的燎原之火? 巴勒斯坦、黎巴
该丛书从我国移动通信技术应用现状与发展情况出发,以系统与技术为中心,全面系统地介绍了当今移动通信领域涉及的有关关键技术与
《色彩心理探析》为那些有志于从事色彩学习的人士以及色彩专业人士提供专业指导,使他们懂得在实际工作中如何应用色彩形象体系,
笨办法学Ruby-(第3版) 本书特色 本书是一本ruby入门书籍,是《“笨办法”学python》的姊妹篇。本书适合对计算机了解不多,没有学过编程,但对编程感兴...
《化学会呼吸》内容简介:本书基于全国重点中学资深化学老师多年累积的经验和研究成果,以活泼又不失严谨的写作风格,用身边可触摸
《CMOS集成电路后端设计与实战》内容简介:本书详细介绍整个后端设计流程,分为概述、全定制设计、半定制设计、时序分析四大部分。
《美国留学移民全攻略》内容简介:《海外留学指南系列:美国留学移民全攻略》的主要目标读者定位于留学方面,以国内接受过中等教育、
Perl语言编程-(上下册)-第四版-影印版 本书特色 div>Perl语言编程-(上下册)-第四版-影印版 内容简介 本书有哪些新的内容呢?老实说几...
《锦笺记》内容简介:笺纸是古代文人用于书写的小幅花色纸张,其起源可以追溯到南北朝时期。历经唐宋之发展,至明代,笺纸追求精致
《一千零一夜(新版)》内容简介:《一千零一夜》又名《天方夜谭》。相传一国王因王后与人私通,心中愤恨,将王后处死之后,便每夜
Ittakesmorethanjustadesignschooleducationandakillerportfoliotosucceedinacreative...
Linux 驱动程序开发实例-第2版 本书特色 Linux设备驱动程序是高级应用程序与硬件设备之间的桥梁。驱动程序开发是软硬件相互结合的技术。本书是一本专门介绍...
《蜂鸟摄影学院新手学摄影(后期篇)》内容简介:本书是蜂鸟网根据摄影初学者的要求和实际学习情况特意编写的一套学习教程中的后期
本书作者利用丰富的时尚类杂志设计和宝贵的数字出版方面(iPad交互杂志)的经验为我们展示了不需要编程的知识,如何使用平面软件
机器人几何代数模型与控制 内容简介 本书以作者的研究成果为依托,讲述了向量空间、李代数以及对偶数环上的旋量理论等数学工具在机器人运动学中的应用。全书包含了...
《IP电话技术与软交换(第2版)》较全面地介绍了与IP电话和软交换有关的技术。主要包括IP电话的基本概念,IP电话网的一般结构和IP电
《人间修炼指南》内容简介:为什么看了那么多鸡汤,依然过不好这一生?面对疯狂的世界,在被无力感击溃之后,我们怎么做? 人间到处