售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
Learning Elixir
Table of Contents
Learning Elixir
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Introducing Elixir – Thinking Functionally
Why functional?
Installing Elixir
GNU/Linux
Apple Mac OS X
Windows
Manual installation – binary
Manual installation – source
Hello, World!
Using the IO.puts/2 function
Using the inspect/2 function
Exercises
Summary
2. Elixir Basics – Foundational Steps toward Functional Programming
Everything is an expression
A short introduction to types
Numerical types
Memory usage
Binary, hexadecimal, and octal numbers
Atoms
Atom memory usage
Booleans
Strings
(Linked) Lists
A little more about strings
Ranges
Tuples
Tuples or lists
Binaries
Even more about Strings
Some more built-in types
Functions
Process IDs
Invariable variables and pattern matching
Using the underscore
More pattern matching
IEEE-754
Elixir structure
Elixir files
Exercises
Summary
3. Modules and Functions – Creating Functional Building Blocks
Modules
Anonymous functions
Pattern matching
Named functions
Private functions
Calling functions
When to use .
Grabbing functions
When patterns aren't enough for matching
Functional algorithms for everyday problems
Iteration versus recursion
Performance considerations
Reverse
Sorting
Mix – the ladle of Elixir
Structure of Elixir projects
mix.exs
.gitignore
config
README.md
lib
test
Compiling a project
Testing a project
Running interactively
Files
Mix and beyond
Building functional projects
Flatten
A small introduction to testing
More to do about modules
Testing with comments
Exercises
Summary
4. Collections and Stream Processing
Keywords, maps, and dictionaries
Keywords
Maps
Dictionaries
More pattern matching
Modifying dictionaries
Performance considerations
Structures and Hash dicts
Yet another dictionary type
Flow-based programming
Stream processing and Elixir
Processing with the Enum module
Processing with the Stream module
Greedy versus lazy
Stream examples
Koolaid
Graphs
A small introduction to graphs
Node ancestors
Exercises
Summary
5. Control Flow – Occasionally You Need to Branch
Branching with Elixir
if and unless
The new else if
Elixir case expressions
Examples using branching
FizzBuzz
Mergesort
Writing tests
Implementing the sort
Exception handling
Raising exceptions
Error, exit, and throw
Handling exceptions
The try-rescue blocks
The try-catch blocks
Using exceptions
Opening files
Exceptions recap
Determinism
References
Exercises
Summary
6. Concurrent Programming – Using Processes to Conquer Concurrency
Parallel computation and concurrent computation
Erlang processes and OS processes
Parallel map
Basics of Elixir process
Self
Sending messages
Receiving messages
Spawn
Process links
Spawning with links
Process monitor
Storing state inside processes
Naming processes
Process module
Applications
Ping pong
Work pool
Summary
7. OTP – A Poor Name for a Rich Framework
Applications
Gen(eric) behaviours
Gen(eric) servers
Asynchronous messaging
Gen(eric) events
Special OTP processes
Variable scope in the Gen* processes
Back-pressure and load shedding
Supervisors
Fail fast(er)
Designing with supervisors
Assumptions of the OTP process initialization
Exercises
Summary
8. Distributed Elixir – Taking Concurrency to the Next Node
Obligatory discussion about distributed computing
Fallacies of distributed computing
The network is reliable
There is no latency
Bandwidth is infinite
The network is secure
Topology doesn't change
There is only one administrator
Transport cost is zero
The network is homogeneous
Fighting dragons blindfolded, equipped with a butter knife
CAP – choose two, and one will be partition tolerance
Why you must choose partition tolerance
Relaxing definitions
Another short discussion about networks
Topologies
Distributed computing with Elixir
OTP nodes
Node names
Connecting nodes
Cookies and node security
Node ping pong
Group leader
Globally registered names
Summary
9. Metaprogramming – Doing More with Less
Behaviours and protocols
Behaviours
Defining behaviours
A short introduction to typespecs
Using – implementing – behaviours
Protocols
Built-in protocols
Abstract syntax trees
Our first macros
Context and macro hygiene
Unhygienic macros – overriding context
Macro examples
Debugging and tracing
Static data to functions
Testing macros
Domain-specific languages
Creating a DSL
State of the macro
With great power...
Exercises
Summary
Going forward
Index
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜