A multi-user game, web site, cloud application, or networked database can have thousands of users all interacting at the same time. You need a powerful, industrial-strength tool to handle the really hard problems inherent in parallel, concurrent environments. You need Erlang. In this second edition of the bestselling Programming Erlang, you’ll learn how to write parallel programs that scale effortlessly on multicore systems.
Using Erlang, you’ll be surprised at how easy it becomes to deal with parallel problems, and how much faster and more efficiently your programs run. That’s because Erlang uses sets of parallel processes-not a single sequential process, as found in most programming languages.
Joe Armstrong, creator of Erlang, introduces this powerful language in small steps, giving you a complete overview of Erlang and how to use it in common scenarios. You’ll start with sequential programming, move to parallel programming and handling errors in parallel programs, and learn to work confidently with distributed programming and the standard Erlang/Open Telecom Platform (OTP) frameworks.
You need no previous knowledge of functional or parallel programming. The chapters are packed with hands-on, real-world tutorial examples and insider tips and advice, and finish with exercises for both beginning and advanced users.
The second edition has been extensively rewritten. New to this edition are seven chapters covering the latest Erlang features: maps, the type system and the Dialyzer, WebSockets, programming idioms, and a new stand-alone execution environment. You’ll write programs that dynamically detect and correct errors, and that can be upgraded without stopping the system. There’s also coverage of rebar (the de facto Erlang build system), and information on how to share and use Erlang projects on github, illustrated with examples from cowboy and bitcask.
Erlang will change your view of the world, and of how you program.
What You Need
The Erlang/OTP system. Download it from erlang.org.
Author(s): Joe Armstrong
If you’re new to Erlang, its functional style can seem difficult, but with help from this hands-on introduction, you’ll scale the learning curve and discover how enjoyable, powerful, and fun this language can be.
In this updated second edition, author Simon St.Laurent shows you how to write simple Erlang programs by teaching you one skill at a time. You’ll learn about pattern matching, recursion, message passing, process-oriented programming, and establishing pathways for data rather than telling it where to go. By the end of your journey, you’ll understand why Erlang is ideal for concurrency and resilience.
- Get cozy with Erlang’s shell, its command line interface
- Define functions, using the fun tool, to represent repeated calculations
- Discover atoms, pattern matching, and guards: the foundations of your program structure
- Delve into the heart of Erlang processing with recursion, strings, lists, and higher-order functions
- Create processes, send messages among them, and apply pattern matching to incoming messages
- Store and manipulate structured data with Erlang Term Storage and the Mnesia database
- Learn about Open Telecom Platform, Erlang’s open source libraries and tools
Author(s): Simon St. Laurent
If you need to build a scalable, fault tolerant system with requirements for high availability, discover why the Erlang/OTP platform stands out for the breadth, depth, and consistency of its features. This hands-on guide demonstrates how to use the Erlang programming language and its OTP framework of reusable libraries, tools, and design principles to develop complex commercial-grade systems that simply cannot fail.
In the first part of the book, you’ll learn how to design and implement process behaviors and supervision trees with Erlang/OTP, and bundle them into standalone nodes. The second part addresses reliability, scalability, and high availability in your overall system design. If you’re familiar with Erlang, this book will help you understand the design choices and trade-offs necessary to keep your system running.
- Explore OTP’s building blocks: the Erlang language, tools and libraries collection, and its abstract principles and design rules
- Dive into the fundamentals of OTP reusable frameworks: the Erlang process structures OTP uses for behaviors
- Understand how OTP behaviors support client-server structures, finite state machine patterns, event handling, and runtime/code integration
- Write your own behaviors and special processes
- Use OTP’s tools, techniques, and architectures to handle deployment, monitoring, and operations
Author(s): Francesco Cesarini, Steve Vinoski
Erlang maestro Fred Hébert starts slow and eases you into the basics: You’ll learn about Erlang’s unorthodox syntax, its data structures, its type system (or lack thereof!), and basic functional programming techniques. Once you’ve wrapped your head around the simple stuff, you’ll tackle the real meat-and-potatoes of the language: concurrency, distributed computing, hot code loading, and all the other dark magic that makes Erlang such a hot topic among today’s savvy developers.
As you dive into Erlang’s functional fantasy world, you’ll learn about:
–Testing your applications with EUnit and Common Test
–Building and releasing your applications with the OTP framework
–Passing messages, raising errors, and starting/stopping processes over many nodes
–Storing and retrieving data using Mnesia and ETS
–Network programming with TCP, UDP, and the inet module
–The simple joys and potential pitfalls of writing distributed, concurrent applications
Packed with lighthearted illustrations and just the right mix of offbeat and practical example programs, Learn You Some Erlang for Great Good! is the perfect entry point into the sometimes-crazy, always-thrilling world of Erlang.
Author(s): Fred Hebert
This book is an in-depth introduction to Erlang, a programming language ideal for any situation where concurrency, fault tolerance, and fast response is essential. Erlang is gaining widespread adoption with the advent of multi-core processors and their new scalable approach to concurrency. With this guide you’ll learn how to write complex concurrent programs in Erlang, regardless of your programming background or experience.
Written by leaders of the international Erlang community — and based on their training material — Erlang Programming focuses on the language’s syntax and semantics, and explains pattern matching, proper lists, recursion, debugging, networking, and concurrency.
This book helps you:
- Understand the strengths of Erlang and why its designers included specific features
- Learn the concepts behind concurrency and Erlang’s way of handling it
- Write efficient Erlang programs while keeping code neat and readable
- Discover how Erlang fills the requirements for distributed systems
- Add simple graphical user interfaces with little effort
- Learn Erlang’s tracing mechanisms for debugging concurrent and distributed systems
- Use the built-in Mnesia database and other table storage features
Erlang Programming provides exercises at the end of each chapter and simple examples throughout the book.
Author(s): Francesco Cesarini, Simon Thompson
6. Erlang and OTP in Action (2010)
Concurrent programming has become a required discipline for all programmers. Multi-core processors and the increasing demand for maximum performance and scalability in mission-critical applications have renewed interest in functional languages like Erlang that are designed to handle concurrent programming. Erlang, and the OTP platform, make it possible to deliver more robust applications that satisfy rigorous uptime and performance requirements.
Erlang and OTP in Action teaches you to apply Erlang’s message passing model for concurrent programming–a completely different way of tackling the problem of parallel programming from the more common multi-threaded approach. This book walks you through the practical considerations and steps of building systems in Erlang and integrating them with real-world C/C++, Java, and .NET applications. Unlike other books on the market, Erlang and OTP in Action offers a comprehensive view of how concurrency relates to SOA and web technologies.
This hands-on guide is perfect for readers just learning Erlang or for those who want to apply their theoretical knowledge of this powerful language. You’ll delve into the Erlang language and OTP runtime by building several progressively more interesting real-world distributed applications. Once you are competent in the fundamentals of Erlang, the book takes you on a deep dive into the process of designing complex software systems in Erlang.
Purchase of the print book comes with an offer of a free PDF, ePub, and Kindle eBook from Manning. Also available is all code from the book.
Author(s): Martin Logan, Eric Merritt
Don’t accept the compromise between fast and beautiful: you can have it all. Phoenix creator Chris McCord, Elixir creator Jose Valim, and award-winning author Bruce Tate walk you through building an application that’s fast and reliable. At every step, you’ll learn from the Phoenix creators not just what to do, but why. Packed with insider insights, this definitive guide will be your constant companion in your journey from Phoenix novice to expert, as you build the next generation of web applications.
Phoenix is the long-awaited web framework based on Elixir, the highly concurrent language that combines a beautiful syntax with rich metaprogramming. The authors, who developed the earliest production Phoenix applications, will show you how to create code that’s easier to write, test, understand, and maintain.
The best way to learn Phoenix is to code, and you’ll get to attack some interesting problems. Start working with controllers, views, and templates within the first few pages. Build an in-memory repository, and then back it with an Ecto database layer. Learn to use change sets and constraints that keep readers informed and your database integrity intact. Craft your own interactive application based on the channels API for the real-time, high-performance applications that this ecosystem made famous. Write your own authentication components called plugs, and even learn to use the OTP layer for monitored, reliable services. Organize your code with umbrella projects so you can keep your applications modular and easy to maintain.
This is a book by developers and for developers, and we know how to help you ramp up quickly. Any book can tell you what to do. When you’ve finished this one, you’ll also know why to do it.
What You Need:
To work through this book, you will need a computer capable of running Erlang 17 or better, Elixir 1.1, or better, Phoenix 1.0 or better, and Ecto 1.0 or better. A rudimentary knowledge of Elixir is also highly recommended.
Author(s): Chris McCord, Bruce Tate
Why choose Erlang for web applications? Discover the answer hands-on by building a simple web service with this book. If you’re an experienced web developer who knows basic Erlang, you’ll learn how to work with REST, dynamic content, web sockets, and concurrency through several examples. In the process, you’ll see first-hand that Erlang is ideal for building business-critical services.
Erlang was designed for fault-tolerant, non-stop telecom systems, and building applications with it requires a large set of skills. By the end of the book, you’ll have the information you need to build a basic web service and get it running.
- Explore the power of Erlang and REST for building web services
- Serve static and dynamic content with the Yaws web server
- Use different methods for outputting data to user, such as encoding Erlang data structures into JSON or XML
- Build an application to listen for HTTP requests, process them, store data, and return useful data
- Go beyond the request-response model—push data to clients with web sockets
- Use Erlang and Yaws to stream data from the server to a client
“A book which is truly needed and will help get Erlang to the next level.”
—Francesco Cesarini, CEO of Erlang Solutions, author of Erlang Programming.
Author(s): Zachary Kessin
9. The Little Elixir & OTP Guidebook (2016)
The Little Elixir & OTP Guidebook gets you started programming applications with Elixir and OTP. You begin with a quick overview of the Elixir language syntax, along with just enough functional programming to use it effectively. Then, you’ll dive straight into OTP and learn how it helps you build scalable, fault-tolerant and distributed applications through several fun examples.
Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications.
About the Technology
Elixir is an elegant programming language that combines the expressiveness of Ruby with the concurrency and fault-tolerance of Erlang. It makes full use of Erlang’s BEAM VM and OTP library, so you get two decades’ worth of maturity and reliability right out of the gate. Elixir’s support for functional programming makes it perfect for modern event-driven applications.
About the Book
The Little Elixir & OTP Guidebook gets you started writing applications with Elixir and OTP. You’ll begin with the immediately comfortable Elixir language syntax, along with just enough functional programming to use it effectively. Then, you’ll dive straight into several lighthearted examples that teach you to take advantage of the incredible functionality built into the OTP library.
- Covers Elixir 1.2 and 1.3
- Introduction to functional concurrency with actors
- Experience the awesome power of Erlang and OTP
About the Reader
Written for readers comfortable with a standard programming language like Ruby, Java, or Python. FP experience is helpful but not required.
About the Author
Benjamin Tan Wei Hao is a software engineer at Pivotal Labs, Singapore. He is also an author, a speaker, and an early adopter of Elixir.
Table of Contents
- A whirlwind tour
- Processes 101
- Writing server applications with GenServer
- Concurrent error-handling and fault tolerance with links, monitors, and processes
- Fault tolerance with Supervisors
- Completing the worker-pool application
- Distribution and load balancing
- Distribution and fault tolerance
- Dialyzer and type specifications
- Property-based and concurrency testing
GETTING STARTED WITH ELIXIR AND OTP
FAULT TOLERANCE, SUPERVISION, AND DISTRIBUTION
Author(s): Benjamin Tan Wei Hao
Write code that writes code with Elixir macros. Macros make metaprogramming possible and define the language itself. In this book, you’ll learn how to use macros to extend the language with fast, maintainable code and share functionality in ways you never thought possible. You’ll discover how to extend Elixir with your own first-class features, optimize performance, and create domain-specific languages.
Metaprogramming is one of Elixir’s greatest features. Maybe you’ve played with the basics or written a few macros. Now you want to take it to the next level. This book is a guided series of metaprogramming tutorials that take you step by step to metaprogramming mastery. You’ll extend Elixir with powerful features and write faster, more maintainable programs in ways unmatched by other languages.
You’ll start with the basics of Elixir’s metaprogramming system and find out how macros interact with Elixir’s abstract format. Then you’ll extend Elixir with your own first-class features, write a testing framework, and discover how Elixir treats source code as building blocks, rather than rote lines of instructions. You’ll continue your journey by using advanced code generation to create essential libraries in strikingly few lines of code. Finally, you’ll create domain-specific languages and learn when and where to apply your skills effectively.
When you’re done, you will have mastered metaprogramming, gained insights into Elixir’s internals, and have the confidence to leverage macros to their full potential in your own projects.
Author(s): Chris McCord
11. The Erlang Run-Time System (2015)
Erlang’s process-oriented approach has given it a very different runtime environment. As Erlang and tools built on Erlang, like CouchDB, Riak, and EjabberD spread, understanding those underpinnings becomes much more important for people building and maintaining applications. This book will explore Erlang’s unique approach to building a virtual machine, demonstrating how to take advantage of its power and tune it to fit your needs.
Author(s): Erik Stenman
Erlang solves one of the most pressing problems facing developers today: how to write reliable, concurrent, high-performance systems. It’s used worldwide by companies who need to produce reliable, efficient, and scalable applications. Invest in learning Erlang now.
Moore’s Law is the observation that the amount you can do on a single chip doubles every two years. But Moore’s Law is taking a detour. Rather than producing faster and faster processors, companies such as Intel and AMD are producing multi-core devices: single chips containing two, four, or more processors. If your programs aren’t concurrent, they’ll only run on a single processor at a time. Your users will think that your code is slow.
Erlang is a programming language designed for building highly parallel, distributed, fault-tolerant systems. It has been used commercially for many years to build massive fault-tolerated systems that run for years with minimal failures.
Erlang programs run seamlessly on multi-core computers: this means your Erlang program should run a lot faster on a 4 core processor than on a single core processor, all without you having to change a line of code.
Erlang combines ideas from the world of functional programming with techniques for building fault-tolerant systems to make a powerful language for building the massively parallel, networked applications of the future.
This book presents Erlang and functional programming in the familiar Pragmatic style. And it’s written by Joe Armstrong, one of the creators of Erlang.
It includes example code you’ll be able to build upon. In addition, the book contains the full source code for two interesting applications:
Learn how to write programs that run on dozens or even hundreds of local and remote processors. See how to write robust applications that run even in the face of network and hardware failure, using the Erlang programming language.
Author(s): Joe Armstrong