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
全国数据库技术水平考试一级学员教材 本书特色 本书按照教学大纲中规定的内容,系统、全面地介绍了数据库水平考试所涵概的内容。既重视基本理论、基础知识的阐述,又指导...
Thisbookprovidesandin-depthexaminationofthecoreconceptsandgeneralprinciplesofweb...
《黑客攻防从入门到精通:黑客与反黑客工具篇(第2版)》内容简介:本书从“攻”“防”两个不同的角度出发,在讲解黑客攻击手段的同
《餐饮中的设计》有别于家庭和工作场所,餐厅就犹如一个第三空间,是个人的避难所,更是社交聚会的好去处。在高速公路看到餐馆标
《SQL反模式》是一本广受好评的SQL图书。它介绍了如何避免在SQL的使用和开发中陷入一些常见却经常被忽略的误区。它通过讲述各种具
《住宅精细化设计》为作者针对住宅设计要点的长期研究的总结。书中就住宅精细化设计过程中的方法、意义和建议等问题,围绕我国住
《精通正则表达式:基于.NET/ASP/PHP/JSP/JavaScript》从正则表达式的基本概念、基本语法入手,着重介绍了正则表达式在数字验证、
《精益企业之现场管理实战(图解版)》内容简介:随着工业4.0时代的到来,以及“中国制造2025”行动计划的不断推进,许多企业开始更
《基石:伟大企业的协同哲学》内容简介:本书融合了具有前瞻性和战略性的世界级的企业管理模式和实践,用多元的视角深入剖析典型借
《错觉》内容简介:在人工智能异常火热的今天,很多人认为我们生活在一个不可思议的历史时期,人工智能和大数据可能比工业革命更能
《陈子涛传》内容简介:本书为雨花台烈士传丛书之一,记叙了陈子涛烈士的一生。陈子涛1920年出生于广西玉林。1938年,初中毕业的陈
《佛学思想与佛教文化研究(全2册)》内容简介:2015年7月,“禅与人类文明研究中心”与中国佛教学会合作,举办“第十届青年佛教学
Rails是业界领先的新一代Web2.0应用程序开发框架,而这本《RailsCookbook》里充满了为了让你成为Rails开发专家而准备的各种解决方
本书作者利用丰富的时尚类杂志设计和宝贵的数字出版方面(iPad交互杂志)的经验为我们展示了不需要编程的知识,如何使用平面软件
Ifyouveusedamoretraditionalobject-orientedlanguage,suchasC++orJava,JavaScriptpro...
ForreaderswhowanttodesignWebpagesthatloadquickly,areeasytoupdate,accessibletoall...
Mozillaisnotjustabrowser.Mozillaisalsoaframeworkthatallowsdeveloperstocreatecros...
《细菌为什么看不见》内容简介:细菌是地球上最古老的生物,是大自然物质循环的主要参与者。它们无法用肉眼观察到,却无时无刻不在
Whateveryourprogramminglanguage,whateveryourplatform,youprobablytapintolinkerand...
本书是讲述Intel微处理器的国外经典教材,已经多次再版,经过长期教学使用,吐故纳新,不断完善,内容丰富,体系完整。第6版中包