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
《人人可懂的数据科学》内容简介:数据科学的主要目标就是通过数据分析来改进决策,它与数据挖掘、机器学习等领域紧密相关,但范围
《中国历史的教训:精装版》内容简介:本书是一本以人物故事为主线、以廉政思想为内核的中国历史通俗读物,也是一本由纪检监察干部
《在远远的背后带领》内容简介:作为家庭教育领域内的标杆性人物之一,安心用十年的时间从不越界、不评判、负责任、无伤害等6个角度
《城和市的语言:城市规划图解辞典》以文字和图片中的每个单词、名称或概念的字母为顺序进行编撰,同时以简洁的传记体介绍城市场所
C语言程序设计 内容简介 《C语言程序设计(第4版)》以程序设计为主线,以编程应用为驱动,理论联系实际,通过丰富的实例分析详细地介绍了C程序设计的思想及方法。全...
《晚安妈妈,晚安宝贝:爱听故事的小猪卡尼》内容简介:本书含26个小故事,让孩子的睡前时光温暖甜蜜,治愈孩子小小的心灵。作者充
《爱书者说》内容简介:对世上某一类人而言,书可谓“身外之物”中最挤占斗室又最难以割舍者。这样的人,无论是读、是买,还是收藏
喧嚣商战,细数李彦宏与新浪、网易、搜狐、淘宝掌门人的恩怨纠葛!风云起伏,独创划分十年百度的“三大帝国”断代史!独门秘籍,
《Servlet与JSP核心编程》(第2版)叙述详尽,条理清晰。对于初学者来说是一本不可多得的入门书籍,经验丰富的Servelet和JSP开发人
这本书教你怎么用Bootstrap框架轻松设计出“杀手级”界面及响应式网站。从怎么用Bootstrap的HTML/CSS工具和现成模板构建页面开始
《中信国学大典:六祖坛经》内容简介:中信国学大典(50册)是中信出版社引进自香港中华书局的一套深具国际视野、贴近当代社会的中
AByteofPythonisabookonprogrammingusingthePythonlanguage.Itservesasatutorialorgui...
《万用英语口语张口就来:日常篇》内容简介:“万用英语口语张口就来”系列丛书在选材上既注重全面性又注重实用性,涵盖了社会及日
《网页艺术设计》将软件技术与艺术理论进行整合,注重知识性与研究性、实践性与理论性、系统性与逻辑性,全面介绍网页艺术设计的
专转本计算机应用基础考试核心密卷 内容简介 本书紧扣2005年计算及应用基础考试内容,分理论题和操作题两部分。本书前十套试卷是对计算机应用基础知识体系与操作实践...
「我們的使命是站立在科技與人文的交叉處,並以此為起點創造嶄新的事物!」史蒂夫賈伯斯(SteveJobs)◎市面上第一本將APPLE產品
《超级面试官》内容简介:面试是人才招聘过程中的重要一环,面试官的水平直接影响到所招人员的素质高低。那么,面试官该具备哪些基
《HTTP/2 in Action(中文版)》内容简介:本书以易于理解、方便上手的方式,使用贴近用户的实例来解释HTTP/2协议。本书首先介绍为
《从零开始构建深度前馈神经网络》内容简介:2016年,阿法狗(AlphaGo)为全世界打开了一条窄窄的门缝,通往未来之路就此展现。通过
从新手到高手Photoshop手绘从新手到高手 本书特色 零基础Photoshop手绘实战类图书。Photoshop手绘初学者从入门到精通s选。涵盖Photos...