[英]Joe Armstrong:關於Erlang,有很多東西我想改變(圖靈訪談)

盼盼姐發表於2014-07-08

Joe Armstrong,Erlang最初的設計者和實現者,他也是Erlang OTP系統專案的首席架構師。他擁有瑞典皇家理工學院博士學位,是容錯系統開發領域的世界級專家。Armstrong起初是一名物理工作者,在攻讀物理學博士學位時因為用完積蓄而轉向了電腦科學,找到一份研究員的工作,為英國人工智慧領域奠基人之一的Donald Michie工作。在此期間,他成為英國機器人學會的創始成員並撰寫了一些有關機器人視覺的論文。人工智慧的資金來源枯竭,Armstrong又回到了物理學領域。開始時他在歐洲非相干散射科學協會工作,後來又到了瑞典空間研究中心,最後加入了愛立信電腦科學實驗室,Erlang就是在那裡發明的。

在現代語言的版圖中,Erlang有點另類。同很多流行的語言相比,它既老又新。早在1986年,也就是Perl出現的前一年,Armstrong就已經開始了Erlang的工作,當時它只作為商用產品出售並且主要在愛立信公司內部使用。這種情況直到1998年Erlang作為開源專案釋出後才發生變化,那時Java和Ruby已經問世3年了。當時Erlang設計初衷也相當明確,它針對的軟體是類似於電話交換機那樣的高可用性、高可靠性系統。

iTuring: There are hundreds of programming languages in the world, some of them are highly efficient and concise, but they have never been widely used. In your opinion, what does it take to make a successful language?

A: A new language has to be extremely good for solving some particular class of problem. The type of problem must be one that people want to solve, and the alternative languages should be bad at solving this problem. For commercial success somebody must be able to earn money by using the language. Use of the language should give some competitive advantage over the use of other languages.

iTuring: What have been the crucial factors that have made Erlang as it is today?

A: Erlang's first opportunity came due to the failure of a large project programmed in a different programming language. We were able to save the project by reprogramming the hardware in Erlang.

The second significant factor was when Erlang was briefly banned by Ericsson in 1998. This led to a sequence of events where Erlang became open source and a number of companies were formed that chose Erlang as their principle technology.

More recently WhatsApp was purchased by Facebook for $19B USD - making this the largest ever software acquisition. WhatsApp was programmed in Erlang, and this fact has attracted a lot of interest.

iTuring: You have commented highly about Elixir. Do you think Erlang will be influenced by Elixir in the future?

A: Yes - but not only by Elixir, also by developments in other languages.

iTuring: How Erlang is going to evolve? Are there any key points?

A: Erlang was developed when machine memories were of the order of a few Megabytes, so we decided to only allow two versions of the same module to co-exist. Now we have Gigabyte memories, so we could have thousands of versions and let the garbage collector remove unused versions.

In the original Erlang implementation, message passing times between processes on the same machine was constant. On multi-core computers this is no longer true, so we have to consider the physical placement of processors on multi-cores.

In the very near future we will see the emergence of massively multi-cores with thousands of CPUs per chip, some of the cores will be broken due to manufacturing problems and so we need to learn how to map Erlang processes onto the available cores.

We also need to understand energy use. For environmental reasons it is important to understand how to maximize performance and simultaneously minimize energy consumption. Massive multi-cores running at low voltages and clock rates can be used to minimize energy consumption, but we still need to do a lot of work to understand how to program these.

iTuring: Do you think Erlang and Scala are rivalries to each other? What are their unique advantages?

A: They are rivals - but Scala is closely tied to the JVM. Scala provides a migration path for Java programmers, but Scala has completely different run-time characteristics to Erlang. There are many problems for which Erlang is good and Scala bad and the other way around.

iTuring: Among concurrent, parallel and distributed programming, which area Erlang does best? And which area it does worst? Why is that?

A: Erlang is best at co-ordinating parallel activities and handling faults, Erlang programs also scale well when run on multi-cores.

Erlang is not good at memory intensive numerical computations. The reason for this has to do with fault-tolerance and memory management. To make things fault-tolerant we have to keep copies of data in different places so if one process crashes we can restart it somewhere else. All this copying takes time. Efficient numerical computations can be done in-memory and without much copying, but this is at the expense of fault-tolerance.

Making things fault-tolerant costs CPU time and memory, so if you don't want fault-tolerant and distribution you would be better off not using Erlang.

iTuring: If you can start again, is there anything you would like to change in Erlang?

A: Yes - many things. But the language is slowly changing. There are several things I'd like to see. Everything should be first class. Modules, for example, are not first class, we can't easily turn a module into a list of functions, or a list of functions into a module. We should be able to construct and deconstruct any Erlang object. Things like protocols, which are implicit, should be made explicit.

The Erlang programming model for distributed programming needs to be extended for "planetary scale distribution". Right now we can register a process on an individual Erlang node, or on a cluster of nodes, but not in away that would allow every computer in the world to access it.

iTuring: XML language doesn't’t seem to fit in today’s environment of big data. What feature the new language ML9 should have to keep up XML’s advantages while eliminating its defects?

A: ML9 was an experiment which I'm no longer maintaining. XML is fine but should never be used for long-term storage or transmission of large volumes of data. XML is great for small configuration files and so on, but not large data volumes.

iTuring: There are many programmers of Ruby, Java, or Python who would like of learn Erlang, do you have some learning suggestions for them?

A: Read my book!

iTuring: You have mentioned that Dave Thomas had advised you a lot about writing, what have you learned from your writing experience? And what advices would you like to give to other new authors?

A: I've really learned to enjoy writing, and to keep on revising and re-writing the text to improve it. I also get a set of mixed readers to read the text and tell me if they understand it. I really appreciate lots of feedback, so if people don't understand what I have written then I can write more explanation. Without feedback I don't know which parts people find easy to understand and which parts are difficult.

For many years I found writing very difficult, at school I was good at math but bad at writing, but I worked at it and Dave Thomas gave me lot's of great advice so now it's the other way around.

The most difficult part of being an author is trying to put yourself in the position of somebody who does not know what you know, so you have to imagine the problems they will have and try and solve them before the have them.


更多精彩,加入圖靈訪談微信!

相關文章