Synopses & Reviews
Erlang is the language of choice for programmers who want to write robust, concurrent applications, but its strange syntax and functional design can intimidate the uninitiated. Luckily, there's a new weapon in the battle against Erlang-phobia: Learn You Some Erlang for Great Good!
Erlang maestro Fred Hebert 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.
Learn You Some Erlang for Great Good! is a hilariously illustrated guide to the concurrent functional programming language you've heard so much about. You'll start out with the basics and learn all about the shell, tuples, list comprehensions, and bit syntax. Once you've got the easy stuff down, you'll work your way through tougher concepts like clients and servers, message passing, open telecom platform applications, and all of those other catchy Erlang phrases you'd love to brag to your friends about. As you laugh along with Hebert's brilliantly quirky drawings, you'll effortlessly pick up this complex language and have fun while you're at it.
About the Author
Fred Hebert is a self-taught programmer with experience in frontend web development, web services, and general backend programming in various languages. His online tutorial, "Learn You Some Erlang For Great Good!," is widely regarded as the best way to learn Erlang. He currently works at BLOOM Digital Platforms as an Erlang developer.
Table of Contents
Foreword; Preface; To the Foreigner; To the Erlang Regular; To the Person Who Has Read This Online; Acknowledgments; Introduction; So What's Erlang?; Don't Drink Too Much Kool-Aid; What You Need to Dive In; Where to Get Help; Chapter 1: Starting Out; 1.1 Using the Erlang Shell; 1.2 Some Erlang Basics; 1.3 Working with Binary Data; Chapter 2: Modules; 2.1 What Are Modules?; 2.2 Creating Modules; 2.3 Compiling Code; 2.4 Defining Macros; 2.5 More About Modules; Chapter 3: Syntax in Functions; 3.1 Pattern Matching; 3.2 Guards, Guards!; 3.3 What the If ?!; 3.4 In case ... of; 3.5 Which Should We Use?; Chapter 4: Types (or Lack Thereof); 4.1 Dynamite-Strong Typing; 4.2 Type Conversions; 4.3 To Guard a Data Type; 4.4 For Type Junkies; Chapter 5: Hello Recursion!; 5.1 How Recursion Works; 5.2 More Recursive Functions; 5.3 More Than Lists; 5.4 Thinking Recursively; Chapter 6: Higher-Order Functions; 6.1 Let's Get Functional; 6.2 Anonymous Functions; 6.3 Maps, Filters, Folds, and More; Chapter 7: Errors and Exceptions; 7.1 A Compilation of Errors; 7.2 Raising Exceptions; 7.3 Dealing with Exceptions; 7.4 Try a try in a Tree; Chapter 8: Functionally Solving Problems; 8.1 Reverse Polish Notation Calculator; 8.2 Heathrow to London; Chapter 9: A Short Visit to Common Data Structures; 9.1 Records; 9.2 Key/Value Stores; 9.3 A Set of Sets; 9.4 Directed Graphs; 9.5 Queues; 9.6 End of the Short Visit; Chapter 10: The Hitchhiker's Guide to Concurrency; 10.1 Don't Panic; 10.2 Concurrency Concepts; 10.3 Not Entirely Unlike Linear Scaling; 10.4 So Long and Thanks for All the Fish!; Chapter 11: More on Multiprocessing; 11.1 State Your State; 11.2 We Love Messages, But We Keep Them Secret; 11.3 Time Out; 11.4 Selective Receives; Chapter 12: Errors and Processes; 12.1 Links; 12.2 Monitors; 12.3 Naming Processes; Chapter 13: Designing a Concurrent Application; 13.1 Understanding the Problem; 13.2 Defining the Protocol; 13.3 Lay Them Foundations; 13.4 An Event Module; 13.5 The Event Server; 13.6 A Test Drive; 13.7 Adding Supervision; 13.8 Namespaces (or Lack Thereof); Chapter 14: An Introduction to OTP; 14.1 The Common Process, Abstracted; 14.2 The Basic Server; 14.3 Specific vs. Generic; 14.4 Callback to the Future; 14.5 .BEAM Me Up, Scotty!; Chapter 15: Rage Against the Finite-State Machines; 15.1 What Is a Finite-State Machine?; 15.2 Generic Finite-State Machines; 15.3 A Trading System Specification; 15.4 Game Trading Between Two Players; 15.5 That Was Really Something; 15.6 Fit for the Real World?; Chapter 16: Event Handlers; 16.1 Handle This! *pumps shotgun*; 16.2 Generic Event Handlers; 16.3 It's Curling Time!; Chapter 17: Who Supervises the Supervisors?; 17.1 Supervisor Concepts; 17.2 Using Supervisors; 17.3 Band Practice; 17.4 Dynamic Supervision; Chapter 18: Building an Application; 18.1 A Pool of Processes; 18.2 Implementing the Supervisors; 18.3 Working on the Workers; 18.4 Writing a Worker; 18.5 Run Pool Run; 18.6 Cleaning the Pool; Chapter 19: Building Applications the OTP Way; 19.1 My Other Car Is a Pool; 19.2 The Application Resource File; 19.3 Converting the Pool; 19.4 The Application Behavior; 19.5 From Chaos to Application; 19.6 Library Applications; Chapter 20: The Count of Applications; 20.1 From OTP Application to Real Application; 20.2 Run App Run; 20.3 Included Applications; 20.4 Complex Terminations; Chapter 21: Release Is the Word; 21.1 Fixing the Leaky Pipes; 21.2 Releases with systools; 21.3 Releases with Reltool; 21.4 Reltool Recipes; 21.5 Released from Releases; Chapter 22: Leveling Up in the Process Quest; 22.1 The Hiccups of Appups and Relups; 22.2 The Ninth Circle of Erl; 22.3 Process Quest; 22.4 Making Process Quest Better; 22.5 Relup Review; Chapter 23: Buckets of Sockets; 23.1 IO Lists; 23.2 UDP and TCP: Bro-tocols; 23.3 More Control with Inet; 23.4 Sockserv, Revisited; 23.5 Where to Go from Here?; Chapter 24: EUnited Nations Council; 24.1 EUnit--What's an EUnit?; 24.2 Test Generators; 24.3 Fixtures; 24.4 Testing Regis; 24.5 He Who Knits EUnits; Chapter 25: Bears, ETS, Beets: In-Memory NoSQL for Free!; 25.1 Why ETS; 25.2 The Concepts of ETS; 25.3 ETS Phone Home; 25.4 Meeting Your Match; 25.5 You Have Been Selected; 25.6 DETS; 25.7 A Little Less Conversation, a Little More Action, Please; Chapter 26: Distribunomicon; 26.1 This Is My Boomstick; 26.2 Fallacies of Distributed Computing; 26.3 Dead or Dead-Alive; 26.4 My Other Cap Is a Theorem; 26.5 Setting Up an Erlang Cluster; 26.6 Cookies; 26.7 Remote Shells; 26.8 Hidden Nodes; 26.9 The Walls Are Made of Fire, and the Goggles Do Nothing; 26.10 The Calls from Beyond; 26.11 Burying the Distribunomicon; Chapter 27: Distributed OTP Applications; 27.1 Adding More to OTP; 27.2 Taking and Failing Over; 27.3 The Magic 8 Ball; Chapter 28: Common Test for Uncommon Tests; 28.1 What Is Common Test?; 28.2 Common Test Structure; 28.3 Creating a Simple Test Suite; 28.4 Testing with State; 28.5 Test Groups; 28.6 Test Suites Redux; 28.7 Test Specifications; 28.8 Large-Scale Testing; 28.9 Integrating EUnit Within Common Test; 28.10 Is There More?; Chapter 29: Mnesia and the Art of Remembering; 29.1 What's Mnesia?; 29.2 What Should the Store Store?; 29.3 From Record to Table; 29.4 Of Mnesia Schemas and Tables; 29.5 Creating Tables; 29.6 Access and Context; 29.7 Reads, Writes, and More; 29.8 Implementing the First Requests; 29.9 Meet the Boss; 29.10 Deleting Stuff, Demonstrated; 29.11 Query List Comprehensions; 29.12 Remember Mnesia; Chapter 30: Type Specifications and Dialyzer; 30.1 PLTs Are the Best Sandwiches; 30.2 Success Typing; 30.3 Type Inference and Discrepancies; 30.4 Typing About Types of Types; 30.5 Typing Functions; 30.6 Typing Practice; 30.7 Exporting Types; 30.8 Typed Behaviors; 30.9 Polymorphic Types; 30.10 You're My Type; 30.11 That's All, Folks; Afterword; Other Erlang Applications; Community Libraries; Your Ideas Are Intriguing to Me and I Wish to Subscribe to Your Newsletter; Is That It?; On Erlang's Syntax; The Template; The English Sentence; And, Or, Done.; In Conclusion; Colophon; Updates;