跳到主要內容

發表文章

目前顯示的是有「erlang」標籤的文章

Concurrent Programming II

1.Concurrency is easy…? ( http://armstrongonsoftware.blogspot.com/2006/08/concurrency-is-easy.html ) 2.Sequential Programming -module(factorial). -export([factoriala/1, factorialb/1, factorialc/1, factoriald/1]). %Simplest: factoriala(0) -> 1; factoriala(N) -> N * factoriala(N - 1). %Using function guards: factorialb(0) -> 1; factorialb(N) when N > 0 -> N * factorialb(N - 1). %Using if: factorialc(N) -> if N == 0 -> 1; N > 0 -> N * factorialc(N - 1) end. %Using case: factoriald(N) -> case N of 0 -> 1; N when N > 0 -> N * factoriald(N - 1) end. -module(set). -export([new/0, add_element/2, del_element/2,is_element/2, is_empty/1, union/2, intersection/2]). new() -> []. is_element(H, [H|_]) -> true; is_element(H, [_|Set]) -> is_element(H, Set); is_element(_, []) -> false. is_empty([]) -> true; is_empty(_) -> false add_element(X, Set) -> case is_element(X, Set) o...

Erlang/OTP R12B released

Major relese : otp_src_R12B-0 Build date : 2007-12-04 R12B-0 is a major new release of Erlang/OTP. You can download the full source distribution from http://www.erlang.org/download/otp_src_R12B-0.tar.gz http://www.erlang.org/download/otp_src_R12B-0.readme (this file) Note: To unpack the TAR archive you need a GNU TAR compatible program. For installation instructions please read the README that is part of the distribution. The Windows binary distribution can be downloaded from http://www.erlang.org/download/otp_win32_R12B-0.exe On-line documentation can be found at http://www.erlang.org/doc/ . You can also download the complete HTML documentation or the Unix manual files http://www.erlang.org/download/otp_doc_html_R12B-0.tar.gz http://www.erlang.org/download/otp_doc_man_R12B-0.tar.gz We also want to thank those that sent us patches, suggestions and bug reports,

RFID智慧型護送系統建置計畫

昨天接獲資訊: 微程式資訊 以專業技術與成功建置經驗獲得經濟部大型示範性計畫 『RFID智慧型護送系統建置計畫』 的支持,為醫療領域結合IT科技再跨出一步。 這可是一個將近兩千萬的專案阿,不過這事實上是一個XMPP 的應用,我們在XMPP 建置了一些訊息的交換邏輯,讓訊息在XMPP 上交易所產生的應用,業界這幾年對 concurrent programming 需求殷切,主要是因為資訊系統跳了一個層次在看訊息傳遞這回事,當大量資訊需要即時 精確的被傳遞時,過去的那種multiprocess mutithread 不敷使用,一個動輒上萬的長時間連線交易,更需要像erlang 這類以 concurrent programming 為觀點出發的語言,而這也同時是我會接觸functional language的主要原因 計畫相關聯結: http://www.program.com.tw/news/news_071129.htm http://blog.sina.com.tw/sandychang/article.php?pbgid=40436&entryid=575124

erlang 相關paper

http://www.it.uu.se/research/group/hipe/publications.shtml 內有相關於erlang 的論文 期刊 或是相關會議裡 提出的文章,其中這兩篇恰好是談到昨天提到的erlang bit syntax http://user.it.uu.se/~kostis/Papers/JFP_06.pdf Per Gustafsson and Konstantinos Sagonas Efficient manipulation of binary data using pattern matching In the Journal of Functional Programming, 16(1):35-74, January 2006 http://www.it.uu.se/research/group/hipe/papers/padl07.pdf Per Gustafsson and Konstantinos Sagonas Applications, Implementation and Performance Evaluation of Bit Stream Programming in Erlang In Proceedings of the Ninth International Symposium on Practical Aspects of Declarative Languages (PADL'07). To appear.

Erlang Bit Syntax

Erlang Bit Syntax 看起來蠻強悍的,在erlang programming 裡提到一個 16-bit Colors 的例子: << 這例子來自 erlang programming >> 1> Red = 2. 2 2> Green = 61. 61 3> Blue = 20. 20 4> Mem = <<Red:5, Green:6, Blue:5>>. 用在pattern matching也很直觀,比如: <<Header2:8/binary,$\ ,Rest2/binary>> = <<"HTTP/1.1 200 OK\r\n">>. 不過;他目前還不支援regexp , 用起來有時會綁手綁腳,可能是還不太熟析? Bit Syntax 可以用在網路的封包解析,或是encode/decode某種檔案格式...目前;關於封包分析部分我也還在努力搞懂中 http://community.livejournal.com/en_dmitriid/5806.html http://www.erlang.se/euc/07/papers/1700Gustafsson.pdf 這裡也有相關Erlang Bit Syntax的文章可參考

Quicksort in Erlang

-module(sort). -export([sort/1]). sort([]) -> []; sort([PivotRest]) -> {Smaller, Bigger} = split(Pivot, Rest), lists:append(sort(Smaller), [Pivotsort(Bigger)]). split(Pivot, L) -> split(Pivot, L, [], []). split(Pivot, [], Smaller, Bigger) -> {Smaller, Bigger}; split(Pivot, [HdTl], Smaller, Bigger) when Hd split(Pivot, Tl, [HdSmaller], Bigger); split(Pivot, [HdTl], Smaller, Bigger) when Hd >= Pivot -> split(Pivot, T, Smaller, [HdBigger]).

Concurrent Programming 相關報告

一. 我會接觸Erlang的緣由 1.RFID Middleware 2.jabber (xml::stream http://zh.wikipedia.org/wiki/Jabber) 3.ejabber (http://www.process-one.net/en/ ) 二. 現在的商業環境(web server)所面臨的問題 1.連線的數量不斷的攀升 2.連線的時間很長 傳統上httpd 使用Prefork的方式來解決,短時間時密集連線的問題,在現在的環境愈到了嚴重的挑戰,比如: HTTP_Streaming、Server Push、COMET 這些需要長時間連線的架構,使得httpd 能夠服務的連線變少了,而fork process 最大的問題是,他所需要佔用記憶體的空間過於龐大,於是其他的伺服器架構崛起(lighthttpd ghttpd …) The C10K problem( http://www.kegel.com/c10k.html ) It's time for web servers to handle ten thousand clients simultaneously, don't you think? After all, the web is a big place now. And computers are big, too. You can buy a 1000MHz machine with 2 gigabytes of RAM and an 1000Mbit/sec Ethernet card for $1200 or so. Let's see - at 20000 clients, that's 50KHz, 100Kbytes, and 50Kbits/sec per client. It shouldn't take any more horsepower than that to take four kilobytes from the disk and send them to the network once a second for each of twenty thousand clients. (That works out to $0.08 per client,...

遊戲開發人員眼中下一代的程式語言

這文章原是我的恩師在討論過程提到的一篇文章,文章裡提到一些目前c++ 遇到的問題,並且使用haskell去討論一些可能的解決方法 The Next Mainstream Programming Language: A Game Developer's Perspective by Tim Sweeny (from Epic Games, Unreal) http://www.st.cs.uni-sb.de/edu/seminare/2005/advanced-fp/docs/sweeny.pdf 這讓我想起另一篇介紹concurrency programming/erlang的文章 http://mirror.linux.org.au/pub/linux.conf.au/2007/video/talks/ 252.pdf 後來我才意會過來;原來之前看的這篇文章有一小段是由上面的文章片段 另一個不錯的連結(介紹相關問題) http://www.algorithm.com.au/talks/concurrency-erlang/

ejabberd 使用 Erlang 開發IM Server

最近在思考 message center 所使用的 jabber server要自己寫還是用現成 的server,自己寫不是不可能只是可能要花的時間可能會比較久,於是參考了 ejabberd 他的網站提到 ejabberd is a free and open source instant messaging server written in Erlang. 從來沒聽過語言,查了一下 Erlang is a programming language designed at the Ericsson Computer Science Laboratory. Open-source Erlang is being released to help encourage the spread of Erlang outside Ericsson. 看來是一種非oo 非程序 的functional programming language,有點類似 Haskell,最有趣的是他是跨平台的語言,而讓我驚奇佩服的是,ejabberd 居然可 以把功能做的這麼完善,真是高手中的高手