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
《Puppet实战》内容简介:Puppet领域的经典之作,资深运维专家多年一线经验结晶,51cto技术社区强烈推荐,新浪研发中心平台架构部高
三维人脸建模方法研究与应用 本书特色真实感三维人脸建模技术是计算机视觉领域一个备受关注的研究热点,基于形变模型的三维人脸建模方法是目前建模效果*好的方法之一。《...
书中作者探讨了技术如何重塑人们对阅读的定义。数字阅读越来越受欢迎,更便利、节约成本、并把免费书籍提供给全世界的读者。但是
本书是一本经典的人工智能教材。全面系统地阐述了人工智能的基础理论,有效结合了求解智能问题的数据结构以及实现的算法,把人工
《Excel数据分析可视化必备技能案例视频精讲》内容简介:数据分析的目的是快速发现问题,进而分析问题并解决问题。因此,通过制作可
《国外计算机科学教材系列·用TCP/TP进行网际互联(第3卷):客户-服务器编程与应用(Linux.POSIX套接字版)》是一部关于计算机网络的
《零基础学C语言(第3版)》内容简介:单片机C51语言是目前最流行的单片机程序设计语言。本书由浅入深,循序渐进地讲解了C51语言的
AppropriateforcoursestitledComputerNetworkingorIntroductiontoNetworkingatboththe...
《TRIZ:产品创新设计》内容简介:开发出有竞争力的产品,是制造业企业提高自身竞争优势的重要保障因素。在模糊前端和新产品开发、
当今社会技术体系面临变革,巨大的社会需求和挑战不断涌现,毫不夸张地说,这是一个人人参与设计的时代。在此背景下,无论是设计
在《首饰的秘密》中,女人们向我们讲述她们的首饰——她们何时并如何得到,怎么佩戴,而它们又代表着什么——我们事实上在邀请她
《Python深度强化学习:基于Chainer和OpenAI Gym》内容简介:近年来,机器学习受到了人们的广泛关注。本书面向普通大众,指导读者在
本书介绍了Python应用在各个领域中的一些使用技巧和方法,从最基本的字符、文件序列、字典和排序,到进阶的面向对象编程、数据库
Visual C#.NET程序设计教程(第2版) 本书特色 《Visual C#.NET程序设计教程(第2版普通高等学校计算机教育十二五规划教材)》(作者罗福强...
《软件测试的艺术》(原书第2版)成功、有效地进行软件测试的实用策略和技术:基本的测试原理和策略 验收测试程序检查和走查 安装
Theintroductoryprogrammingcourseisdifficult.Manystudentsfailtosucceedorhavetroub...
《Presto实战》内容简介:作为高性能分布式SQL查询引擎,Presto能够针对不同的数据源高效、快速地执行交互式分析。大数据的兴起使得
《AIoT系统开发》内容简介:本书融合了人工智能和物联网两大热点技术,将人工智能中的优越方法应用到物联网的构建中,以形成更加智
由胡翔骏编著的《电路分析》是面向21世纪课程教材——《电路分析》(胡翔骏编)的修订版,也是普通高等教育“十一五”国家级规划
别样诠释——一个VisualC++老鸟10年学习与开发心得 本书特色 《别样诠释:一个visual c++老鸟10年学习与开发心得》着眼于实际应用,循序渐进地介...