Programming Erlang Software for a Concurrent World (2nd Edition) - Joe Armstrong.pdf

(4983 KB) Pobierz
Prepared exclusively for John Chukwuma
ß
Under Construction:
The book you’re reading is still under
development. As part of our Beta book program, we’re releasing
this copy well before a normal book would be released. That
way you’re able to get this content a couple of months before
it’s available in finished form, and we’ll get feedback to make
the book even better. The idea is that everyone wins!
Be warned:
The book has not had a full technical edit, so it will contain errors.
It has not been copyedited, so it will be full of typos, spelling mistakes, and the
occasional creative piece of grammar. And there’s been no effort spent doing
layout, so you’ll find bad page breaks, over-long code lines, incorrect hyphen-
ation, and all the other ugly things that you wouldn’t expect to see in a finished
book. It also doesn't have an index. We can’t be held liable if you use this book
to try to create a spiffy application and you somehow end up with a strangely
shaped farm implement instead. Despite all this, we think you’ll enjoy it!
Download Updates:
Throughout this process you’ll be able to get updated
ebooks from your account at
pragprog.com/my_account
. When the book is com-
plete, you’ll get the final version (and subsequent updates) from the same ad-
dress.
Send us your feedback:
In the meantime, we’d appreciate you sending us your
feedback on this book at
pragprog.com/titles/jaerlang2/errata
, or by using the links
at the bottom of each page.
Thank you for being part of the Pragmatic community!
Dave & Andy
Prepared exclusively for John Chukwuma
Programming Erlang,
Second Edition
Software for a Concurrent World
Joe Armstrong
The Pragmatic Bookshelf
Dallas, Texas • Raleigh, North Carolina
Prepared exclusively for John Chukwuma
Many of the designations used by manufacturers and sellers to distinguish their products
are claimed as trademarks. Where those designations appear in this book, and The Pragmatic
Programmers, LLC was aware of a trademark claim, the designations have been printed in
initial capital letters or in all capitals. The Pragmatic Starter Kit, The Pragmatic Programmer,
Pragmatic Programming, Pragmatic Bookshelf, PragProg and the linking
g
device are trade-
marks of The Pragmatic Programmers, LLC.
Every precaution was taken in the preparation of this book. However, the publisher assumes
no responsibility for errors or omissions, or for damages that may result from the use of
information (including program listings) contained herein.
Our Pragmatic courses, workshops, and other products can help you and your team create
better software and have more fun. For more information, as well as the latest Pragmatic
titles, please visit us at
http://pragprog.com
.
Copyright © 2013 Pragmatic Programmers, LLC.
All rights reserved.
No part of this publication may be reproduced, stored in a retrieval system, or
transmitted, in any form, or by any means, electronic, mechanical, photocopying,
recording, or otherwise, without the prior consent of the publisher.
Printed in the United States of America.
ISBN-13: 978-1-937785-53-6
Encoded using the finest acid-free high-entropy binary digits.
Book version: B6.0—July 26, 2013
Prepared exclusively for John Chukwuma
Contents
Changes in the Beta Releases
Introduction
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
xi
xiii
Part I — Why Erlang?
1.
Introducing Concurrency
.
.
.
.
.
.
.
.
1.1
Modeling Concurrency
1.2
Benefits of Concurrency
1.3
Concurrent Programs and Parallel Computers
1.4
Sequential vs. Concurrent Programming Languages
A Whirlwind Tour of Erlang
.
.
.
.
2.1
The Shell
2.2
Processes, Modules, and Compilation
2.3
Hello, Concurrency
.
.
.
.
.
.
3
3
6
8
9
11
11
13
15
2.
.
Part II — Sequential Programming
3.
Basic Concepts
.
.
.
.
.
.
.
.
3.1
Starting and Stopping the Erlang Shell
3.2
Simple Integer Arithmetic
3.3
Variables
3.4
Floating-Point Numbers
3.5
Atoms
3.6
Tuples
3.7
Lists
3.8
Strings
3.9
Pattern Matching Again
.
.
.
.
23
23
26
26
30
31
32
35
37
39
Prepared exclusively for John Chukwuma
Zgłoś jeśli naruszono regulamin