Programming ERLANG: Software for a Concurrent World

Free Download

Authors:

Edition: 1

ISBN: 9781934356005, 193435600X

Size: 3 MB (2783822 bytes)

Pages: 519/519

File format:

Language:

Publishing Year:

Category: Tags: , ,

Joe Armstrong9781934356005, 193435600X

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: ASHOUTcastserver which you can use to stream music to every computer in your house, and a full-text indexing and search engine that can index gigabytes of data. 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.

Table of contents :
Programming Erlang……Page 1
Begin……Page 12
Road Map……Page 13
Begin Again……Page 16
Acknowledgments……Page 17
Overview……Page 18
Installing Erlang……Page 21
The Code in This Book……Page 23
Starting the Shell……Page 24
Simple Integer Arithmetic……Page 25
Variables……Page 27
Floating-Point Numbers……Page 32
Atoms……Page 33
Tuples……Page 35
Lists……Page 38
Strings……Page 40
Pattern Matching Again……Page 41
Modules……Page 43
Back to Shopping……Page 49
Funs……Page 52
Simple List Processing……Page 58
List Comprehensions……Page 61
Arithmetic Expressions……Page 64
Guards……Page 65
Records……Page 69
case and if Expressions……Page 72
Building Lists in Natural Order……Page 73
Accumulators……Page 74
Exceptions……Page 76
Raising an Exception……Page 77
try…catch……Page 78
catch……Page 81
Programming Style with try…catch……Page 82
Catching Every Possible Exception……Page 83
Stack Traces……Page 84
Advanced Sequential Programming……Page 86
Binaries……Page 87
The Bit Syntax……Page 89
Miscellaneous Short Topics……Page 98
Starting and Stopping the Erlang Shell……Page 118
Modifying the Development Environment……Page 119
Different Ways to Run Your Program……Page 122
Automating Compilation with Makefiles……Page 127
Command Editing in the Erlang Shell……Page 130
When Things Go Wrong……Page 131
Getting Help……Page 134
Tweaking the Environment……Page 135
The Crash Dump……Page 136
Concurrency……Page 137
Concurrent Programming……Page 141
The Concurrency Primitives……Page 142
A Simple Example……Page 143
Client-Server—An Introduction……Page 144
How Long Does It Take to Create a Process?……Page 148
Receive with a Timeout……Page 150
Selective Receive……Page 153
Registered Processes……Page 154
A Word About Tail Recursion……Page 156
Spawning with MFAs……Page 157
Problems……Page 158
Linking Processes……Page 159
An on_exit Handler……Page 160
The Details of Error Handling……Page 162
Error Handling Primitives……Page 170
Monitors……Page 172
A Keep-Alive Process……Page 173
Distributed Programming……Page 175
The Name Server……Page 177
The Distribution Primitives……Page 182
Libraries for Distributed Programming……Page 185
The Cookie Protection System……Page 186
Socket-Based Distribution……Page 187
IRC Lite……Page 191
Message Sequence Diagrams……Page 193
The User Interface……Page 194
Client-Side Software……Page 195
Server-Side Software……Page 199
Running the Application……Page 203
The Chat Program Source Code……Page 204
Exercises……Page 211
Interfacing Techniques……Page 212
Ports……Page 213
Interfacing an External C Program……Page 214
open_port……Page 220
Linked-in Drivers……Page 221
Notes……Page 225
Organization of the Libraries……Page 226
The Different Ways of Reading a File……Page 227
The Different Ways of Writing to a File……Page 235
Directory Operations……Page 239
Finding Information About a File……Page 240
Bits and Pieces……Page 241
A Find Utility……Page 242
Programming with Sockets……Page 245
Using TCP……Page 246
Control Issues……Page 255
Where Did That Connection Come From?……Page 258
Error Handling with Sockets……Page 259
UDP……Page 260
Broadcasting to Multiple Machines……Page 263
A SHOUTcast Server……Page 265
Digging Deeper……Page 272
ETS and DETS: Large Data Storage Mechanisms……Page 273
Basic Operations on Tables……Page 274
Types of Table……Page 275
ETS Table Efficiency Considerations……Page 276
Creating an ETS Table……Page 277
Example Programs with ETS……Page 279
DETS……Page 284
What Haven’t We Talked About?……Page 287
Code Listings……Page 288
OTP Introduction……Page 291
The Road to the Generic Server……Page 292
Getting Started with gen_server……Page 301
The gen_server Callback Structure……Page 305
Code and Templates……Page 309
Digging Deeper……Page 312
Database Queries……Page 313
Adding and Removing Data in the Database……Page 317
Mnesia Transactions……Page 319
Storing Complex Data in Tables……Page 323
Table Types and Location……Page 325
Creating the Initial Database……Page 328
Digging Deeper……Page 329
Listings……Page 331
Making a System with OTP……Page 335
Generic Event Handling……Page 336
The Error Logger……Page 339
Alarm Management……Page 346
The Application Servers……Page 348
The Supervision Tree……Page 351
Starting the System……Page 354
The Application……Page 358
File System Organization……Page 360
Digging Deeper……Page 361
How Did We Make That Prime?……Page 363
Multicore Prelude……Page 365
Programming Multicore CPUs……Page 367
How to Make Programs Run Efficiently on a Multicore CPU……Page 368
Parallelizing Sequential Code……Page 372
Small Messages, Big Computations……Page 375
mapreduce and Indexing Our Disk……Page 379
Growing Into the Future……Page 389
Documenting Our Program……Page 390
Erlang Type Notation……Page 391
Tools That Use Types……Page 394
Fetch and Install MinGW……Page 396
Emacs……Page 397
Online Documentation……Page 399
Blogs……Page 400
Projects……Page 401
Bibliography……Page 402
An Example……Page 403
How lib_chan Works……Page 406
The lib_chan Code……Page 409
Analysis and Profiling Tools……Page 419
Debugging……Page 422
Tracing……Page 431
Dynamic Code Loading……Page 435
Module: application……Page 439
Module: base64……Page 440
Module: c……Page 441
Module: calendar……Page 443
Module: code……Page 444
Module: dets……Page 445
Module: dict……Page 448
Module: digraph……Page 449
Module: digraph_utils……Page 450
Module: disk_log……Page 451
Module: epp……Page 452
Module: erl_parse……Page 453
Module: erl_tar……Page 454
Module: erlang……Page 455
Module: error_logger……Page 464
Module: ets……Page 465
Module: file……Page 468
Module: file_sorter……Page 470
Module: filename……Page 471
Module: gb_sets……Page 472
Module: gb_trees……Page 474
Module: gen_event……Page 475
Module: gen_fsm……Page 476
Module: gen_sctp……Page 477
Module: gen_tcp……Page 478
Module: global……Page 479
Module: inet……Page 480
Module: io……Page 481
Module: io_lib……Page 482
Module: lists……Page 483
Module: net_adm……Page 487
Module: os……Page 488
Module: qlc……Page 489
Module: queue……Page 490
Module: random……Page 491
Module: rpc……Page 492
Module: sets……Page 494
Module: slave……Page 495
Module: sofs……Page 496
Module: string……Page 500
Module: sys……Page 501
Module: timer……Page 502
Module: win32reg……Page 503
Module: zlib……Page 504
B……Page 507
C……Page 508
E……Page 509
G……Page 511
J……Page 512
M……Page 513
O……Page 514
Q……Page 515
S……Page 516
V……Page 518
Y……Page 519

Reviews

There are no reviews yet.

Be the first to review “Programming ERLANG: Software for a Concurrent World”
Shopping Cart
Scroll to Top