Programming Erlang
查看:819 | 下载:338 | 评论:1 | 创建:2008-05-02 00:20:16
SPAN (江南石斑) 
注册: 2008-04-24
积分: 12244 分
等级:


尘世如潮人如水 只叹江湖几人回
Oh no! Not another programming language! Do I have to learn yet another
one? Aren’t there enough already?
I can understand your reaction. There are loads of programming languages,
so why should you learn another?
Here are five reasons why you should learn Erlang:
• You want to write programs that run faster when you run them on
a multicore computer.
• You want to write fault-tolerant applications that can be modified
without taking them out of service.
• You’ve heard about “functional programming” and you’re wondering
whether the techniques really work.
• You want to use a language that has been battle tested in real
large-scale industrial products that has great libraries and an
active user community.
• You don’t want to wear your fingers out by typing lots of lines of
code.
Can we do these things? In Section 20.3, Running SMP Erlang, on
page 376, we’ll look at some programs that have linear speed-ups when
we run them on a thirty-two-core computer. In Chapter 18, Making a
System with OTP, we’ll look at how to make highly reliable systems that
have been in round-the-clock operation for years. In Section 16.1, The
Road to the Generic Server, on page 292, we’ll talk about techniques for
writing servers where the software can be upgraded without taking the
server out of service.
ROAD MAP 13
In many places we’ll be extolling the virtues of functional programming.
Functional programming forbids code with side effects. Side effects and
concurrency don’t mix. You can have sequential code with side effects,
or you can have code and concurrency that is free from side effects.
You have to choose. There is no middle way.
Erlang is a language where concurrency belongs to the programming
language and not the operating system. Erlang makes parallel programming
easy by modeling the world as sets of parallel processes that can
interact only by exchanging messages. In the Erlang world, there are
parallel processes but no locks, no synchronized methods, and no possibility
of shared memory corruption, since there is no shared memory.
Erlang programs can be made from thousands to millions of extremely
lightweight processes that can run on a single processor, can run on a
multicore processor, or can run on a network of processors.
1.1 Road Map
• Chapter 2, Getting Started, on page 18 is a quick “jump in and
swim around” chapter.
• Chapter 3, Sequential Programming, on page 43 is the first of two
chapters on sequential programming. It introduces the ideas of
pattern matching and of nondestructive assignments.
• Chapter 4, Exceptions, on page 76 is about exception handling. No
program is error free. This chapter is about detecting and handling
errors in sequential Erlang programs.
• Chapter 5, Advanced Sequential Programming, on page 86 is the
second chapter on sequential Erlang programming. It takes up
some advanced topics and fills in the remaining details of sequential
programming.
• Chapter 6, Compiling and Running Your Program, on page 118
talks about the different ways of compiling and running your program.
• In Chapter 7, Concurrency, on page 137, we change gears. This
is a nontechnical chapter. What are the ideas behind our way of
programming? How do we view the world?
• Chapter 8, Concurrent Programming, on page 141 is about concurrency.
How do we create parallel processes in Erlang? How do processes
communicate? How fast can we create parallel processes?
ROAD MAP 14
• Chapter 9, Errors in Concurrent Programs, on page 159 talks about
errors in parallel programs. What happens when a process fails?
How can we detect process failure, and what can we do about it?
• Chapter 10, Distributed Programming, on page 175 takes up distributed
programming. Here we’ll write several small distributed
programs and show how to run them on a cluster of Erlang nodes
or on free-standing hosts using a form of socket-based distribution.
• Chapter 11, IRC Lite, on page 191 is a pure application chapter.
We tie together the themes of concurrency and socket-based distribution
with our first nontrivial application: a mini IRC-like client
and server program.
• Chapter 12, Interfacing Techniques, on page 212 is all about interfacing
Erlang to foreign-language code.
• Chapter 13, Programming with Files, on page 226 has numerous
examples of programming with files.
• Chapter 14, Programming with Sockets, on page 245 shows you
how to program with sockets. We’ll look at how to build sequential
and parallel servers in Erlang. We finish this chapter with the second
sizable application: a SHOUTcast server. This is a streaming
media server, which can be used to stream MP3 data using the
SHOUTcast protocol.
• Chapter 15, ETS and DETS: Large Data Storage Mechanisms, on
page 273 describes the low-level modules ets and dets. ets is a
module for very fast, destructive, in-memory hash table operations,
and dets is designed for low-level disk storage.
• Chapter 16, OTP Introduction, on page 291 is an introduction to
OTP. OTP is a set of Erlang libraries and operating procedures
for building industrial-scale applications in Erlang. This chapter
introduces the idea of a behavior (a central concept in OTP).
Using behaviors, we can concentrate on the functional behavior
of a component, while allowing the behavior framework to solve
the nonfunctional aspects of the problem. The framework might,
for example, take care of making the application fault tolerant or
scalable, whereas the behavioral callback concentrates on the specific
aspects of the problem. The chapter starts with a general discussion
on how to build your own behaviors and then moves to
describing the gen_server behavior that is part of the Erlang standard
libraries.
ROAD MAP 15
• Chapter 17, Mnesia: The Erlang Database, on page 313 talks about
the Erlang database management system (DBMS) Mnesia. Mnesia
is an integrated DBMS with extremely fast, soft, real-time
response times. It can be configured to replicate its data over several
physically separated nodes to provide fault-tolerant operation.
• Chapter 18, Making a System with OTP, on page 335 is the second
of the OTP chapters. It deals with the practical aspects of sewing
together an OTP application. Real applications have a lot of small
messy details. They must be started and stopped in a consistent
manner. If they crash or if subcomponents crash, they must be
restarted. We need error logs so that if they do crash, we can figure
out what happened after the event. This chapter has all the nittygritty
details of making a fully blown OTP application.
• Chapter 19, Multicore Prelude, on page 365 is a short introduction
to why Erlang is suited for programming multicore computers. We
talk in general terms about shared memory and message passing
concurrency and why we strongly believe that languages with no
mutable state and concurrency are ideally suited to programming
multicore computers.
• Chapter 20, Programming Multicore CPUs, on page 367 is about
programming multicore computers. We talk about the techniques
for ensuring that an Erlang program will run efficiently on multicore
computers. We introduce a number of abstractions for speeding
up sequential programs on multicore computers. Finally we
perform some measurements and develop our third major program,
a full-text search engine. To write this, we first implement
a function called mapreduce—this is a higher-order function for
parallelizing a computation over a set of processing elements.
• Appendix A, on page 390, describes the type system used to document
Erlang functions.
• Appendix B, on page 396, describes how to set up Erlang on the
Windows operating system (and how to configure emacs on all
operating systems).
• Appendix C, on page 399, has a catalog of Erlang resources.
• Appendix D, on page 403, describes lib_chan, which is a library for
programming socket-based distribution.
BEGIN AGAIN 16
• Appendix E, on page 419, looks at techniques for analyzing, pro-
filing, debugging, and tracing your code.
• Appendix F, on page 439, has one-line summaries of the most
used modules in the Erlang standard libraries.
| 下载次数 |
文件大小 |
56K下载 |
512K下载 |
1M下载 |
| 338次 |
2.65 MB |
小于49秒 |
小于6秒 |
小于3秒 |
所有资源只对本网注册用户开放,新注册账号,2天以后才能下载资源。

最近下载

相关资源