Chapter 1 of Programming Erlang:begin

来源:互联网 发布:哈工大数据结构与算法 编辑:程序博客网 时间:2024/06/09 16:08

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 ot 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 and that has great libraries and an 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 writting servers where the software can be upgraded without taking the server out of  service.

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 exhanging messages.In the Erlang world,there are parallel processes but no locks,no synchronized methods,and no posibility of shared memory corruption,there is no shared memory.

Erlang programs can be made from thousans 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.