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
本书介绍了微波中继通信系统、短波通信系统、卫星通信系统、移动通信系统和光纤通信系统。内容包括系统的组成、相关的新技术、系
《管理故事与哲理》内容简介:这是一本用故事+剖析的形式来传授管理哲学的大众经管图书。将管理的原理、策略、方法、技巧融入短小精
《背影(2019)》内容简介:时光匆匆,背影长存 2019未删节新版 一九二八年开明书店初版散文集《背影》完整呈现 《背影》《荷塘月色
《学习脑:像训练肌肉一样训练大脑》内容简介:你知道吗:做总结、做标记、图形记忆、重复阅读—这些我们从小就在使用的学习方法都
Inordertounderstandtheframeworkinthecontextofareal-worldapplication,weneedtobuil...
精通COBOL:大型机商业编程技术详解(修订版 本书特色 目前市面上有关COBOL书籍多为外文书籍,中文书籍较少。虽然在网上有少数几个关于COBOL方面知识的网...
《PVCBOT零基础机器人制作(第3版)》内容简介:“PVCBOT”是“PVC-Robot”的缩写,既是指以PVC为主要材料来制作的机器人,也是指定
《网站开发专家·Google成功背后的技术:Ajax网页程序设计》详细介绍了Google背后的技术——Ajax,主要内容包括:Ajax简介、Ajax基
《新能源系统储能原理与技术》内容简介:随着可再生能源的不断发展,催生了对于储能设备的需求,新一代储能电池、超级电容器等储能
《从文字到影像》内容简介:本书在梳理洛特曼艺术符号学基本理论和阐释洛特曼艺术模式化思想的基础上,对艺术文本的意义与符号结构
Machinelearningisoneofthefastestgrowingareasofcomputerscience,withfar-reachingap...
开放式知识网络与高技术服务模式创新-构建体系.动态耦合及网络效应 本书特色 本书既为高技术开放式知识网络体竞争优势的完善、强化与发展提供有力的理论支撑与战略依据...
《城堡的故事》内容简介:城堡是欧洲中世纪的产物,在战争频繁时期常作军事防御之用,如今还有了很好的观赏价值。关于城堡都有哪些
《如果舌尖能思考》内容简介:人工智能AlphaGo能把人类的九段围棋手们打得遍地找牙,但是没法跟人比赛吃喝。吃喝,也许是最后能给人
《民事诉讼程序研究》共分为诉讼程式;扩散利益、分散利益和集体利益的保护;程式样式;当事人与法官;对判決的救济;程式改革。
通过使用Dojo这个工业强度的JavaScript工具箱,我们可以比使用其他任何Ajax框架更高效、更容易地创建JavaScript或Ajax驱动的应用
《思维风暴:22种黄金思维+700道世界思维名题(超值白金版)》内容简介:爱因斯坦说过:人们解决世界的问题,靠的是大脑思维和智慧。
《鸽群中的猫》内容简介:著名女子学院“芳草地”迎来了新的学期。新入学的女孩里有一位谢斯塔公主,她的表哥刚刚在一场政变中被害
《Oracle程序开发范例宝典》内容简介:本书紧密围绕编程人员在编程中遇到的实际问题和开发中应该掌握的技术,全面介绍了使用Oracle
《肖星的财务思维课》内容简介:懂财务不只是会计的事儿。财务,不只是管钱,最重要的是让你透过数据,洞察经营的本质、管理的真相