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
AutoCAD 2016中文版建筑设计师——装潢施工设计篇 本书特色 本书以敏锐的视角、简练的语言,并结合室内装潢业的特点,运用大量的室内装潢施工设计实例,对A...
电脑实用技巧大全 内容简介 本书针对电脑新手的学习需求,从零起步,详细讲解了新手学习电脑需要熟知和掌握的大量实用操作技巧。全书共分为三大篇,其中:**篇(1~2...
《大写的历史:被忽略的历史文化》内容简介:霸王别姬的故事感动了一代又一代的人,然而虞姬、项羽以及他的亲信没有一人存活,那么
"HereisthestorybehindoneofthemostremarkableInternetsuccessesofourtime.Basedonscr...
PHP经典实例(第2版)能够为您节省宝贵的Web开发时间。有了这些针对真实问题的解决方案放在手边,大多数编程难题都会迎刃而解。《
《上街》内容简介:《上街》收录了作者夏佑至近百幅摄影作品,以及众多关于社会、城市、历史、文化的小文章。这本书中有你熟悉的日
《认知心理学》内容简介:中国心理学家对认知心理学的兴趣,主要表现在两个方面。在理论方面,认知心理学有助于揭示人的认识过程
《清华法治论衡(第27辑)》内容简介:马克斯·韦伯是19世纪到20世纪最杰出的社会学家与法学家,其研究涉及法学、社会学、政治学、
非常网管——网络基础 内容简介 本书使用通俗易懂的语言,并通过大量的示例,全面系统地介绍了计算机网络的相关知识。本书的主要内容包括:计算机网络基础知识、OSI和...
Mostcompanieshavemassiveamountsofdataattheirdisposal,yetfailtoutilizeitinanymean...
“你不是个玩意儿。”这句话当然不是骂人,这是一个宣言。人当然不是玩意儿,不是机器,而是人。在网络化程度越来越高的今天,我
《区块链实战》内容简介:本书重点向大家展示了区块链在金融和国际贸易两个领域的落地案例,是一本实际业务落地案例与区块链技术相
书由国内资深前端工程师撰写,是目前内容最为全面和深入的Bootstrap专著。它不仅系统讲解了Bootstrap的各项功能和使用方法,详细
压缩感知理论的工程应用方法 内容简介 在传输带宽有限和数据量激增的数字化时代,压缩感知理论为低速有效获取信息提供了一种新的思路,成为近十年来信号信息处理领域中一...
HeadFirstC#isacompletelearningexperienceforobject-orientedprogramming,C#,andtheV...
在游戏开发中,应用正确的物理定律可以逼真地模拟游戏中任何弹跳、飞行、翻滚、滑行或非静止的物体,以建立令人注目且真实的游戏
《赛雷三分钟漫画三国演义3》内容简介:电影式全场景,爆笑还原三国演义!超立体,超生动,超涨知识!《三国演义》可以说是中国较为
《通信类毕业生求职宝典》找一份让自己满意且适合自身发展的工作对于即将走向社会的同学们而言尤为重要。通信类专业毕业生知识覆
《图解室内设计(第2版)》由程大锦教授与科基·宾格利共同编写的,现已修订、扩充升级至第二版。通过兼具实用性与艺术美感的插图,
《现代通信工程设计》较为全面地阐述了现代通信网络及其系统有关工程设计方面的理论与方法,分别介绍了工程设计内容主要涵盖的网