Erlang-China

erlang 中文社区

[荐]The Power of JavaScript


InfoQ 网站上发布了 Glenn Vanderburg 在 Jaoo 上做的一场有关 JavaScript 的展示。地址在[这里]。

在点上面的链接过去学习(或者是bypass掉)之前,顺便说一句:自 2000 年以来 JavaScript 从“最受人误解的编程语言”开始,又重新进入大家的视野,这股潜藏在地底的趋势一直不停的奔流,直到现在重新喷薄而出时,俨然已经初具“最具人气的编程语言”的明星气质。对于 Lisp 血统的 JavaScript 来说,这确实是它的幸运。

不可否认的一点是,作为程序员,对于 web 的发展,恐怕很难有人能够完全彻底的置身事外(专搞硬件编程的大拿除外)。多少了解一下曾被我们视作 toy 的 javascript 的真正实力,畅想一下 javascript 应用的 possibility ,或者仅仅是关注这一很有些 fp 语言编出来的代码的美感,恐怕只会无害有益。

另外一个很个人化的感想是:这些日子以来在 erlang/javascript (尤其是jQuery base的)之间频繁转换频道的编程,让我觉得这两者在某个地方其实高度相通。


starling,一个erlang的unicode字符串库


地址在这里:

http://12monkeys.co.uk/starling/

大体的介绍:

An OTP application, with a C pipe driver under the hood.

Based on ICU, the best implementation of Unicode.

Strings stored as binaries ⇒ big memory savings.

Backwards-compatible (mostly) with the standard string module.


CouchDB 的作者 Damien Katz 炮轰 Erlang 的语法


CouchDB 的作者,即知名的 Damien Katz ,虽说他用 Erlang 写出了名动江湖的 CouchDB ,但对于“他喜爱的 Erlang ”,还是发了 一满车的牢骚 来表达他对 Erlang 诡异语法的抱怨。

这一车牢骚主要集中于:

Basic Syntax
If Expressions
You Say String of Characters, I Say List of Integers
Functional Programming Mismatch
Records
Give me memory, or give me death!
Code Organization
Uneven Libraries and Documentation

具体来说,就是:

Basic Syntax,主要是抱怨在不同的上下文中 ; 和 . 都作为代码的分割符号来使用,这使得拷贝粘贴代码需要额外的小心处理这些符号。不过我倒没觉得别扭 ; 表示的是一个子句的结束,若要拷贝一个完整的函数(或者 case 的子句),确实是应该包括它的多个子句的。

If Expressions,主要在于 if 不能使用自定义的 函数 作为判断条件,而且还必须(包括 case)要有一个返回值。这一点在 erlang 文档中已经明确指出了原因 if 只能用无副作用的 bif 来作为判断条件。而 case 和 if 作为一个语句,都必须保证要有返回值(在 erlang 中所有的语句都要有值,比如说 undefined 这个 atom)。

You Say String of Characters, I Say List of Integers,主要是没有内置的 String 类型,而是作为 List 来对待引起的。Yariv 也倾向于赞同这一点,他提出的”将 regx 之类的函数扩展到 binary,以 binary 来处理 string”我谨慎赞同(如果能够妥善解决 utf8 的话)。

Functional Programming Mismatch,主要是抱怨“不可变的变量”带来的不适。看过 Joe thesis 的人能够理解为什么 Erlang 要搞“不可变的变量”,我觉得正是因为 Erlang 在这个问题上的决策才带来了它的优越性。用 Erlang 就必须要忍受它的“不可变的变量”,我觉得这是一个风格问题。

Records,怪异的 Record 语法。这个我赞同,改成任何一种简略一些的语法应该是可以的。

Give me memory, or give me death!,Erlang 在内存分配失败时的 exit(1) 处理让 Damien 相当不适应,但,这就是 Erlang 与众不同的异常处理策略。换句话说,也是它能量的一部分。照理说 VM 应该重启(如果配置了 Monitor),但 Damien 提到的 VM 没有成功重启,Klacke 在回帖中表示,这或许是一个 bug 。

Code Organization,只有 module 这一种代码组织方式让他不爽。无语,我只能说,这事风格冲突。

Uneven Libraries and Documentation,缺少库和文档,老问题了。确实该改进。

总结一下,对于 Damien 的抱怨,我赞同他对于 String, Records, Libraries and Documents 的看法。其余的,我认为大多出于设计决定,也是可以习惯的。如果理解了“不可变的变量”,“减少副作用”以及“速错”,这些异乎寻常的设计决定是如何做出的,那么看到这样诡异的代码,也许会更加容易认同。

另外,此前我和 dcaoyuan 也聊起过对 Erlang 语法和库的不适应。对于语法,我现在认为那是一个习惯问题,的确是与你之前所习惯的大不相同,但你总能适应。而对于库,我比较赞同他的话:“Erlang 过去太专注于自己狭窄的应用领域,用在其他的领域,你会发现它缺乏一些显而易见的支持库。但你选择了 Erlang 就要做好思想准备,要么等待 OpenSource 社区的贡献,要么就自己动手丰衣足食。”

再有,生命不就在于折腾么,折腾到 Erlang 必然有自己的理由,这些也许正是乐趣的一部分——这里拿 Yariv 的话作为结尾——“Like any language, Erlang has some warts. But if it were perfect, it would be boring, wouldn’t it? :)”


ErlyBird 0.16.0 Released - An Erlang IDE based on NetBeans


I’m pleased to announce ErlyBird 0.16.0, an Erlang IDE based on NetBeans. This is an important feature release in size of 25M. If you have latest NetBeans nightly build installed, you can also install ErlyBird modules via update center.

 

CHANGELOG:

 

    * Project metadata file is changed, please see Notes

    * Instant rename (put caret on variable or function name, press CTRL+R, when rename finished, press ENTER)

    * Go-To-Declaration to macros that are defined included header files

    * Fixed: Go-To-Declaration to -inlcudelib won’t work again after this include header file was opened in editor once

    * Fixed: syntax broken for packaged import attribute

    * Fixed: syntax broken for wild attribute

    * Completion suggestion will not search other projects

    * Track GSF changes, reindex performance was improved a lot; Can live with other GSF based language support now (Ruby, Groovy etc)

 

Java JRE 5.0+ is required.

 

To download, please go to: http://sourceforge.net/project/showfiles.php?group_id=192439

 

To install:

 

   1. Unzip erlybird-bin-0.16.0-ide.zip to somewhere.

   2. Make sure ‘erl.exe’ or ‘erl’ is under your environment path

   3. For Windows user, execute ‘bin/erlybird.exe’. For *nix user, ‘bin/erlybird’.

   4. Check/set your OTP path. From [Tools]->[Options], click on ‘Erlang’, then ‘Erlang Installation’ tab, fill in the full path of your ‘erl.exe’ or ‘erl’ file. For instance: “C:/erl/bin/erl.exe”

   5. The default -Xmx option for jvm is set to 256M, ErlyBird now works good with less memory, such as -Xmx128M. If you want to increase/decrease it, please open the config file that is located at etc/erlybird.conf, set -J-Xmx of ‘default_options’.

 

When run ErlyBird first time, the OTP libs will be indexed. The indexing time varies from 10 to 30 minutes deponding on your computer.

 

Notes:

 

   1. Since project metadata format is changed, to open old ErlyBird created project, you should modify project.xml which is located at your project folder: nbproject/project.xml, change line:

 

      <type>org.netbeans.modules.languages.erlang.project</type>

 

      to:

 

      <type>org.netbeans.modules.erlang.project</type>

 

   2. If you have previous version ErlyBird installed, you should delete the old cache files which are located at:

          * *nix: “${HOME}/.erlybird/dev”

          * mac os x: “${HOME}/Library/Application Support/erlybird/dev”

          * windows: “C:\Documents and Settings\yourusername\.erlybird\dev” or some where

 

The status of ErlyBird is still Alpha, feedbacks and bug reports are welcome. 


[转] InfoQ 对 CORBA Guru Steve Vinoski 的采访


Steve Vinoski InfoQ 上的[这篇]采访相当有价值。在这个采访中我们能了解到 CORBA 界的大牛 Steve Vinoski 对 CORBA, REST, C++ 的独到看法,很有营养价值。在采访的结尾, Steve 大牛还顺便说了一车 Erlang 的好话。

这一车话用“土磕啦转换器”翻译为大白话,大牛的意思就是“让他老人家在 CORBA 框架中绞尽脑汁试图解决的难题,在 Erlang 中根本就是小菜,浩叹浪费了许多青春云云。”以下内容来自 maillist (有删节):

Ulf Wiger 在推荐这篇访谈时提及:

“In terms of concurrency, if you’re writing middleware I think you owe it to yourself to look at Erlang. The language itself has the primitives, then there are libraries called the Open Telecom Platform that come with it, that build on those primitives to make reliable software almost simple. It’s never simple, but compared to what you have to do, jumping through hoops in other languages, it’s kind of a no-brainer.”

稍后 Steve Vinoski 大牛亲自现身,回复:

… I worked on CORBA starting in 1991 and still use it for certain integration tasks, and in total I helped write 6 or 7 different CORBA ORBs in C++ and Java over the years, including HP ORB Plus and IONA’s Orbix 2000 and its underlying Adaptive Runtime Technology (ART). I worked on other approaches over the years too, including J2EE stuff and WS-* stuff. Some of these systems have been, and in the IONA case still are, heavily used by a variety of large telco, finance, manufacturing, insurance, etc. companies.

Imagine all the issues I’ve encountered over all those years with scalability and performance, portability across operating systems, networking stacks, threads, and different language compilers, plus all the issues with concurrency, reliability, failover, replication, etc. for the distributed services we provided.

A little over year ago I began working for a startup (we’re in stealth mode so I can’t say what we’re working on), and we face many of the same hard distributed system issues. This time, though, I’m armed with Erlang. I started looking at it 2-3 years ago, but couldn’t convince my former company to use it, so I joined my current place instead.

Using Erlang continually makes me both smile and cry at the same time.

I smile because of the overall simplicity it brings to solving all those hard issues I mentioned above, but I also cry knowing how many hours, days, weeks, and months my former colleagues and I spent trying to solve all those really hard issues. We did reasonably well, but it wasn’t easy. If we had had Erlang, I know for certain we could have done so much better.

It all comes back to Robert Virding’s First Rule:

“Any sufficiently complicated concurrent program in another language contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Erlang.”

I now know based on hard-won experience that you could replace “concurrent program” with “distributed system” in Robert’s rule and it would still be just as accurate.

以上即另一位来自“长期战斗在另一条分布式战线”上的大拿对 Erlang 的只言片语,供参考。

另,知悉各位,在一个寒冷而糟糕的漫长春节休假之后,我幸存,并完整无缺的回来了。