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
Thisexuberantselectionoftypographicfontsandstylestracesthemodernevolutionofthepr...
《区块链实战》内容简介:本书重点向大家展示了区块链在金融和国际贸易两个领域的落地案例,是一本实际业务落地案例与区块链技术相
《西方文明东进战略与中国应对》内容简介:本书结合西方文明向东方国家扩散的历史与现实,深刻揭示与剖析西方文明东进战略,全书从
Fromreviewsofthefirstedition:"wellorganized...Recommendedasanintroductorytextfor...
这本书从整体的写作风格来说,会以介绍Go语言特性为主,示例则尽量采用作者平常的实践,而不是一个没有太大实际意义的语法示范样
《贾伯斯傅》这本贾伯斯生前唯一授权的传记,完整记载他的一生。但这本书谈的不只是贾伯斯。人人都知道贾伯斯不遗余力捍卫隐私,
[内容简介] 洞察社交网络必读之作,本书深度剖析社交网络引发的三大现象,全面解读社交网络给我们生活、工作和世界带来的伟大变
《乾隆帝及其时代》内容简介:本书立足于世界史的视野,以乾隆帝八十多年的生命之旅为切入点,广泛搜罗中外各种文献与档案,向人们
本书分为两大部分。第一部分结合精心挑选的实例,系统地讨论了黑客代码分析技术,包括调试器于反汇编器等典型分析工具的使用、代码
It’sthelittlethingsthatturnagooddigitalproductintoagreatone.Withthisfullcolorpra...
本书精选了近1000个国外不同风格的网页,按色彩分成十个色系。每个色系先简要介绍该色系的特点与意义,列出该色系的常用搭配关系
作为Web2.0的新生事物的博客,如今已蓬勃发展,呈燎原之势,业已成为许多人的一种生活方式。中国从事博客写作的人数已达千万级,
Listenup,designers,andwipethosegrinsoffyourfaces!Itstimetogetseriousaboutyourdes...
《大学:平民的修养》内容简介:《重读经典·大学:平民的修养》作者从一位普通百姓的视角,重新注析解读了《大学》。全书由经、传两
多媒体应用技术 内容简介 本书从多媒体的构成要素入手,全面系统地介绍了各种素材的采集、编辑和应用,主要介绍了当前比较流行的多媒体应用软件,如C00L 3D、 P...
《自由的人》内容简介:本书是以梁实秋、林语堂为代表的众多亲历者,对中国近现代史上四位极具争议性的文人——徐志摩、郁达夫、闻
《为什么精英都有超强专注力》内容简介:精英都在践行的专注力提升术! 多任务、分心时代,专注力是掌控自我、带来高绩效的关键解方
《现代C:概念剖析和编程实践》内容简介:这本书按级别组织,编号从0到3。初始级别0,名为“邂逅”,它将总结使用C进行编程的基础知
《零起点Python大数据与量化交易》内容简介:本书是国内较早关于Python大数据与量化交易的原创图书,配合zwPython开发平台和zwQuan
《毛泽东周恩来与长征》内容简介:《王朝柱精选文集:毛泽东周恩来与长征》内容简介::长征堪称人类战争史上的奇迹,它不仅在中国人民