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
GPS卫星导航定位原理与方法 本书特色 本书是我国**本GPS教科书《全球定位系统原理及其应用》(刘基余主编, 北京测绘出版社于1993年10月**次出版发行)...
Thishands-onguidedemonstrateshowtheflexibilityofthecommandlinecanhelpyoubecomeam...
《进步的回退》内容简介:本书分为演讲、对话、记谈录三部分。主要内容包括:进步的回退;冷战后:文学写作新的处境;现代汉语再认
《大盘时代:中国泛地产革命》内容简介:1999年,一条从广州南直通番禺的华南快速干线将普通的岭南小镇南村,变成了中国房地产史上
《Kubernetes实战:构建生产级应用平台》内容简介:本书探讨了通往Kubernetes生产环境成功道路中所涉及的多种技术、模式和抽象方面
samuelp.harbisoniii于卡内基—梅隆大学获得计算机科学博士学位,现任carlow学院的计算机科学系副教授。他曾就职于德州仪器和ta
《百年战争》内容简介:1417年,英格兰军队在诺曼底登陆,百年战争的战火重燃,法军节节败退,在接下来充满戏剧性的30年中,英国人
《Spark GraphX 实战》内容简介:本书是一本Spark GraphX入门书籍。前5章为基础内容,即使读者对Spark、GraphX、Scala不熟悉,...
《作家榜名著:你一定爱读的中国近代史》内容简介:◆忠实原著:以民国二十七年艺文研究会的初始定版为底本,全新精校典藏。◆精美
《张力与限界:中央苏区的革命(1933~1934)》内容简介:中央苏区史,在中共党史中是一段“别样的经历”。中共在1927年国共分裂后
《JavaTCP/IPSocket编程(原书第2版)》基于TCP/IPSocket相关原理,对如何在Java中进行Socket编程作了深入浅出的介绍。《Java...
《战后世界进程与外国文学进程研究(第三卷):全球化视域下的当代外国文学研究》内容简介:20世纪80年代以来,全球化与反全球化两
《给孩子讲历史》内容简介:本书一是丰富孩子的知识。历史是一个知识的宝藏,文学、政治、科学等人类所有的文明成果尽在其中,通过
《成年人居家科学健身方法指导》内容简介:《成年人居家科学健身方法指导》由国家体育总局体育科学研究所的健身专家倾力打造,书中
《OpenCV 4.5计算机视觉开发实战:基于Python》内容简介:OpenCV是一个跨平台计算机视觉和机器学习软件库,也是计算机视觉领域的开
《专业嵌入式软件开发:全面走向高质高效编程》分为6篇。硬件篇就嵌入式软件开发所需掌握的处理器概念进行了介绍。工具篇对make、
《未来机器人畅想》内容简介:经过几十年的努力、实验和改进,工程师已经优化了复杂的人机协作关系,使商业航空运输系统为我们带来
《时与光》内容简介:这是一部像推理小说一样“烧脑”的科学史话。跟随书中的一个个智者,你将从古典力学走向经典体系,最终跨入理
《Android应用测试与调试实战》内容简介:本书是Android应用测试与调试领域最为系统、深入且极具实践指导意义的著作,由拥有近10年
《钢琴基础必修教程(第五册)》内容简介:本书由上海音乐学院附中青年教师倾情呈现,全套教材共六册,每册十二课,内容编排从入门