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
京东高速的增长、闪电响应的供应链、庞大的团队规模等背后内幕,对于业界一直像谜一样神秘。随着成为中国B2C领导厂商以及在纳斯达
《图说西方绘画艺术》内容简介:西方绘画始于古希腊、古罗马时期,是与其他艺术如雕塑、音乐、舞蹈等等一起发展起来的,与人类的生
《阅读理解高分6法:文体法》内容简介:阅读理解想要拿高分,文章读不透,学习再多答题技巧也是事倍功半!本书聚焦“文章如何读”“
《Qt高级编程》是一本阐述Qt高级编程技术的书籍。《Qt高级编程》以工程实践为主旨,是对Qt现有的700多个类和上百万字参考文档中部
本书内容上覆盖了用Android开发的大部分场景,从Android基础介绍、环境搭建、SDK介绍、Market使用,到应用剖析、组件介绍、实例演
《本草通串证图(纯手绘版)》内容简介:《本草通串证图》是一部从未在国内出版过的本草图册,原作成书于日本江户时代末期,由日本
《Odoo快速入门与实战:Python开发ERP指南》内容简介:本书包括基础篇、研发技术篇和实战篇,按照由基础到进阶,再到实战的顺序讲解
《数据中台产品经理》内容简介:随着移动互联网的快速发展,“中台”纷纷在国内大小互联网企业快速落地。前有阿里云智能事业群对外
Whatdoesittaketobecomeadoctor,andhowdotheykeepushealthy?Learnhowlongdoctorshavet...
本书从最基本的光纤、光发射和光接收机讲起,随后按章节分别讨论了系统设计、光纤损耗和色散管理所涉及的先进技术、光网络中的波
Thisbookpresentsanintegratedcollectionofrepresentativeapproachesforscalingupmach...
《游戏架构:核心技术与面试精粹》内容简介:本书从架构与封装、艺术资源、底层核心、自定义扩展和独立游戏五个方向组织内容,每一
《贫困的复杂图景与反贫困的多元路径》内容简介:本书在实地田野调研的基础上,通过宏观、微观考察民族地区农村贫困的复杂图景及致
本书紧紧围绕下一代(XC)移动网络发展前沿的热点问题,依据XC移动网络的最新标准,以XC移动网络技术与应用为核心,比较全面和系统
《人生的每日忠告》内容简介:既然你热爱生活,就要爱它的。当满天的繁星落定,远处的歌声清灵地绽放,你询问手中的红莲,哪一朵光
《游戏编程中的人工智能技术》是人工智能游戏编程的一本指南性读物,介绍在游戏开发中怎样应用遗传算法和人工神经网络来创建电脑
如今的网站和内联网已经变得比以前越来越大,越来越有价值,而且越来越复杂,同时其用户也变得更忙,也更加不能容忍错误的发生。
LukeWilliamsisaleadingspeaker,educator,andconsultantoninnovationstrategy.Hehaswo...
《真幌站前狂骚曲》内容简介:《真幌站前狂骚曲》中,多田与行天在彼此嫌弃与互相扶持中,又迎来了新的一年。“真幌站前”系列大结
《一小时漫画基金实战法》内容简介:基金投资是非常适合普通人的一种投资方式,但在投资之前,我们先要搞懂基金是什么、基金是怎么