Programming Elixir

Programming Elixir

Dave Thomas

Language: English

Pages: 620

ISBN: 168050200X

Format: PDF / Kindle (mobi) / ePub


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.

The Well-Grounded Rubyist

Mobile ASP.NET MVC 5

RasPi Magazine, Issue 21

Beginning XML (4th Edition)

Cassandra: The Definitive Guide (2nd Edition)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

is effectively a linked data structure. A list may either be empty or consist of a head and a tail. The head contains a value and the tail is itself a list. (If you’ve used the language Lisp, then this will all seem very familiar.) As we’ll discuss in Chapter 7, ​Lists and Recursion​, this recursive definition of a list is the core of much Elixir programming. Because of their implementation, lists are easy to traverse linearly, but they are expensive to access in random order (to get to the nth

node_two --cookie cookie-two iex(node_two@light-boy)> =ERROR REPORT==== 27-Apr-2013::21:27:43 === ** Connection attempt from disallowed node 'node_one@light-boy' ** The node that attempts to connect receives false, indicating the connection was not made. And the node that it tried to connect to logs an error describing the attempt. But why does it succeed when we don’t specify a cookie? When Erlang starts, it looks for an .erlang.cookie file in your home directory. If that file doesn’t

You can also load a file as if you’d typed each line into iex using import_file. In this case, local variables set in the file are available in the iex session. As some folks fret over such things, the Elixir convention is to use two-column indentation and spaces (not tabs). Suggestions for Reading the Book This book is not a top-to-bottom reference guide to Elixir. Instead, it is intended to give you enough information to know what questions to ask and when to ask them. So approach what

_ (underscore) lets you ignore a match We started the previous chapter by saying Elixir engenders a different way of thinking about programming. To illustrate this and to lay the foundation for a lot of Elixir programming, let’s start reprogramming your brain by looking at something that’s one of the cornerstones of all programming languages—assignment. Assignment: I Do Not Think It Means What You Think It Means. Let’s use the interactive Elixir shell, iex, to look at a really simple

PatternMatching-2 Which of the following will match?[ a, b, a ] = [ 1, 2, 3 ] [ a, b, a ] = [ 1, 1, 2 ] [ a, b, a ] = [ 1, 2, 1 ] Exercise: PatternMatching-3 If you assume the variable a initially contains the value 2, which of the following will match?[ a, b, a ] = [ 1, 2, 3 ] [ a, b, a ] = [ 1, 1, 2 ] a = 1 ^a = 2 ^a = 1 ^a = 2 - a Another Way of Looking at the Equals Sign Elixir’s pattern matching is similar to Erlang’s (the main difference being that Elixir allows a match

Download sample

Download

About admin