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
基于贝叶斯网络的结构系统可靠性评估方法 内容简介 本书是在作者近几年的研究成果上著作而成的,着眼于VA族元素形成的二维材料体系,采用基于密度泛函理论的性原理研究...
GooglebuilttheGolanguagefromthegrounduptosimplifythechallengesofmodernapplicatio...
《jQuery风暴:完美用户体验》全面讲解了jQuery的各种技术,包括基础特性、各类函数的介绍、使用jQuery进行AJAX调用、jQuery插件的
Ruby for Rails-(中文版) 本书特色 本书是一部专门为Rails实践而写的经典Ruby著作,由四部分组成,共17章。**部分讲述Ruby和Rail...
二级Visual Basic-全国计算机等级考试无纸化专用题库-(2013年9月考试专用)-(1CD) 本书特色 《虎奔教育·全国计算机等级考试无纸化专用题库:...
本书是根据2003年的ISO/ANSIC++标准编写的,通过大量短小精悍的范例程序详细而全面地阐述了C十+的基本概念和技术,包括控制输入
《网站入侵与脚本攻防修炼》从“攻”、“防”两个角度,通过现实中的入侵实例,并结合原理性的分析,图文并茂地展现网站入侵与防
云计算已经不仅仅是一项技术,或一个产品,或一种商业模式,它已经代表了IT产业的一个新的浪潮和时代。深受传统知识、思维、利益
老兵新传Visual Basic核心编程及通用模块开发 本书特色 编程“高手”的功力体现在对语言的彻底掌握和丰富的实践经验书稿内容由作者原创编写,直接面向实际应...
Humansperceivethethree-dimensionalstructureoftheworldwithapparentease.However,de...
高级数据结构 本书特色 《高级数据结构》在基本数据结构的基础上,围绕一些常用的高级数据结构,结合大量实战例题,深入分析“数据结构是如何服务于算法的”。内容包括:...
《美国经典时装画技法》(基础篇)内容由浅显处入手,易学易懂,读后可基本掌握时装画技法要领,可操作性操,且画风具现代感。主要
CrossSiteScriptingAttacksstartsbydefiningthetermsandlayingoutthegroundwork.Itass...
《销售冠军是如何炼成的》内容简介:销售既是一份充满挑战的工作, 更是一项伟大而光荣的事业! 茫茫人海,你要寻找的精准客户在哪
《人人能懂的相对论》内容简介:这一次,你将真正理解相对论,跟上爱因斯坦的脚步,吃透现代物理学基础! 两位作者在书中完整解释时
逻辑与计算机科学哲学 内容简介 本书是作者自2000年以来在科学技术哲学领域研究的一些成果集,分为逻辑与思维和计算机科学哲学两编,主要包括归纳思维、逻辑真探讨、...
《多云和混合云:云原生多集群和应用管理》内容简介:这是一本讲解如何在多云/混合云的环境下进行多集群管理、多集群应用编排以及应
《帆船、海盗与世界》内容简介:轮子、马镫、弓箭、火药和帆船,在历史的时间线上,每一个器物都有它值得诉说的故事,它们引发国家
《穿透式学习》内容简介:在数字时代,随着知识更迭速度的加快,学习变成了每一个职场人士必须终身面对的首要事情。高效工作的前提
我要学office2007高效办公三合一 内容简介 本书分为4篇,共12章。前三篇详细介绍了Word、Excel和PowerPoint的基础操作,第四篇以综合实...