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
“RubyonRails™3Tutorial:LearnRailsbyExamplebyMichaelHartlhasbecomeamustreadfordev...
《王安石诗歌研究史稿(两宋时期)》内容简介:本书从研究史的角度,对王安石诗歌在宋代的流传形式及诗文集的编刻整理、王诗注本的
《大树快跑》内容简介:“我”是一个童话作家,一天,一只八哥鸟来到了“我”的窗前,希望“我”帮它记录下来它的故事。纬四路上住
和谐家园保障性住房精选户型CAD图集 内容简介 本书依据国家的相关政策和规定,从特赖建筑网征集的住宅户型作品中精选而来。采用cad图集的形式,分为廉租房户型、经...
Java和Android开发学习指南-(第2版) 本书特色 本书是java语言学习指南,特别针对使用java进行android应用程序开发展开了详细介绍。全书共...
《中国生态文明新时代》内容简介:随着中国特色社会主义进入新时代,生态文明建设也进入了新时代。在新中国生态文明建设成就和经验
大多数记载个人电脑产业发展史的作品将个人电脑视为一种技术或者商业行为。但本书处处笔酣墨饱,深入探讨了催生第一台个人电脑的
本书内容完全站在网页制作技术的角度上,从网页必备元素开始,详细而完整地讲解了相关标记,并且用大量范例说明各元素的使用方法
"HereisthestorybehindoneofthemostremarkableInternetsuccessesofourtime.Basedonscr...
《教你读懂年报》内容简介:本书是解读上市公司年报的专著,涵盖了对上市公司年报所有12个章节的剖析。本书的所有案例都来自上市公
《即时记忆:快速记忆训练法》内容简介:在本书中,记忆大师迈克尔·蒂珀将通过久经考验的技巧来指导你,以提高你的记忆力和回忆力
《蒲褐山房诗话新编》内容简介:以诗话命名的著作始于欧阳修。它是一种以文学为内容的随笔。所以许颉说:『诗话者,辨句法,备古今
#NAME?
《2014年度全国会计专业技术资格考试真题详解及押题密卷:初级会计实务》内容简介:《2014年度全国会计专业技术资格考试真题详解及
内容简介本书是一部将模糊逻辑与神经网络进行结合研究的论著,介绍了作者近年来在模糊逻辑与神经网络的结合研究与探索中的部分研
关于算法分析的这多卷论著已经长期被公认为经典计算机科学的定义性描述。迄今已出版的完整的三卷组成了程序设计理论和实践的惟一
工业设计人机工程-第2版 本书特色 《工业设计人机工程(第2版)》:普通高等教育“十一五”国家级规划教材工业设计人机工程-第2版 内容简介 本书为普通高等教育“...
Long-awaitedrevisiontoauniqueguidethatcoversbothcompilersandinterpretersRevised,...
RoR(RubyonRails)是基于动态脚本语言——Ruby语言的Web开发框架,其主要应用领域是Web应用程序的开发。使用RoR开发优势在于简便
《纳兰词今译》内容简介:本书精选纳兰性德词作中的经典作品九十八首,每一首均由四个板块组成:1.相关背景、典故的简要介绍。2.诗