| Erlang語言 | |
|---|---|
| 編程范型: | 多種范型:函數式、併發式 |
| 面市時間: | 1987年 |
| 設計者: | 愛立信 |
| 實作者: | 愛立信 |
| 最近釋出日期: | R12B-2/ 2008年4月 |
| 啟發語言: | Prolog、LISP |
| 影響語言: | Scala |
| 作業系統: | Solaris、SUSE、Microsoft Windows、VxWorks |
Erlang是一種通用的面向併發的程式語言,它由瑞典電信設備製造商愛立信所轄的CS-Lab開發,目的是創造一種可以應對大規模併發活動的程式語言和運行環境。Erlang問世于1987年,經過十年的發展,于1998年發布開源版本。Erlang是運行於虛擬機的解釋性語言,但是現在也包含有烏普薩拉大學高性能Erlang計劃(HiPE)[1]開發的本地代碼編譯器,自R11B-4版本開始,Erlang也開始支持腳本式解釋器。在編程范型上,Erlang屬於多重范型程式語言,涵蓋函數式、併發式及分散式。
目錄 |
Erlang得名于丹麥數學家及統計學家Agner Krarup Erlang,同時Erlang還可以表示Ericsson Language。
1998年起,Erlang發布開源版本,採用修改過的Mozilla公共許可證協議進行發放,同時愛立信仍然提供商業版本的技術支持。目前,Erlang最大的商業用戶是愛立信,其他知名用戶有北電網路、Amazon.com以及T-Mobile等[2]。
Ering函數大致寫法如下,以一個求整數階乘的模塊為例:
-module(fact). -export([fac/1]). fac(0) -> 1; fac(N) when N > 0 -> N * fac(N-1).
下面是快速排序演算法的一個Erlang實現:
%% quicksort:qsort(List)
%% Sort a list of items
-module(quicksort).
-export([qsort/1]).
qsort([]) -> [];
qsort([Pivot|Rest]) ->
qsort([ X || X <- Rest, X <= Pivot]) ++ [Pivot] ++ qsort([ Y || Y <- Rest, Y > Pivot]).
代碼示例如下:
% create process and call the function web:start_server(Port, MaxConnections)
ServerProcess = spawn (web, start_server, [Port, MaxConnections]),
% create a remote process and call the function web:start_server(Port, MaxConnections) on machine RemoteNode
RemoteProcess = spawn(RemoteNode, web, start_server, [Port, MaxConnections]),
% send the {pause, 10} message (a tuple with an atom "pause" and a number "10") to ServerProcess (asynchronously)
ServerProcess ! {pause, 10},
% receive messages sent to this process
receive
a_message -> do_something;
{data, DataContent} -> handle(DataContent);
{hello, Text} -> io:format("Got hello message: ~s", [Text]);
{goodbye, Text} -> io:format("Got goodbye message: ~s", [Text])
end.
|
檢 • 論 • 編 • 歷
|
|
|---|---|
| 工業程式語言 | A+ - ActionScript - Ada - 組合語言 - B - Brainfuck - COBOL - Curl - D - Eiffel - Erlang - FORTRAN - IronPython - Java - JavaScript - JScript - Jython - LISP - Lua - SCILAB - MATLAB - MATHEMATICA - Nuva - Oberon - OCaml - Perl - PHP - PostScript - Powerbuilder - Python - R - REXX - Ruby - Self - Smalltalk - Tcl/Tk - C# - F# - J# - Microsoft Visual C# |
| C/C++語言 | C - C++ - Turbo C++ - Borland C++ - C++ Builder- C++/CLI - Objective-C - Microsoft Visual C++ |
| BASIC語言 | BASIC - BASICA - GW-BASIC - QBASIC - QuickBASIC - True BASIC - Turbo BASIC - PowerBASIC - DarkBASIC -ETBASIC Visual Basic .NET - Visual Basic - VBScript - VBA |
| Pascal/Delphi語言 | Pascal語法:(Pascal - Turbo Pascal - Object Pascal - Free Pascal) Pascal+Delphi語法:(Delphi) |
| GPU用著色器語言 | Cg - GLSL - HLSL |
| 學術程式語言 | APL/J - Clean - Haskell - Logo - ML - Prolog - Scheme - SAC |
| 資料庫相關程式語言 | Clipper - Visual FoxPro - SQL - SQL預存程序 |
| 其他程式語言 | ALGOL - Forth - Modula-2/Modula-3 - MUMPS - PL/I - Simula |
Why are we here?
All text is available under the terms of the GNU Free Documentation License
This page is cache of Wikipedia. History