Erlang: Let’s talk to java
试了一下传说中的 JInterface ,使用 OtpErlang.jar 的整个过程其实非常简单,似乎比 JMS 的程序都简单。
首先,我们要用 java 实现的原始 erlang 程序如下,没错,就是巨简单的 echo ,我们的目标是要把它用 java 来改写,不仅写服务端,也要写客户端。
Read more…
试了一下传说中的 JInterface ,使用 OtpErlang.jar 的整个过程其实非常简单,似乎比 JMS 的程序都简单。
首先,我们要用 java 实现的原始 erlang 程序如下,没错,就是巨简单的 echo ,我们的目标是要把它用 java 来改写,不仅写服务端,也要写客户端。
Read more…
原文网址:erlang网络编程的几个性能调优和注意点
原文作者:coderplay
前些天给echo_server写了个非常简单的连接压力测试程序,
一开始我的这个stress_test客户端运行在windows上面, echo_server服务器端运行在linux上面。结果接受了1016个连接就停止了. 于是我用ulimit -n 改了服务器端的文件描述符数量为10240. 接着还是如此,折腾了几天,最终还是没有搞明白。
于是就求助于公司的linux编程牛人,结果让我一倒… 客户端没有修改文件描述符个数. windows上得在注册表里面改. Read more…
Arbow 的 blog 提到他发现了 Programming Erlang 实例代码中的一个 bug。
拿到了Programming Erlang的电子书,研究一下Potian先前跟俺说的“Socket Base Distribution”部分代码,结果发现chat_client.erl(对应书上的Chapter 11 IRC Lite),运行出错……。
而在 Maillist 里 Joe Armstrong 本人也确认了这个bug。
There *was* a bug after all – there was a patch by Kazuya Sakakihara
on the errata list for the book.I missed this since I when I retested the version I distributed it seemed to work (very strange). I’ve now fixed the code and the changes should make it into the next printing of the book.
The corrected versions of code/socket_dist/chat_client.erl and code/socket_dist/chat_group.erl are attached to this mail.
Joe Armstrong 给出的正确代码是: Read more…
从 maillist 得知 GoF 的 Ralph Johnson 最近对 Erlang 给出一些评价。原文在【这里】。
应该说,这是一个大师对 Erlang 相当高的评价,当然,不能排除 Ralph 大师本人对 Lisp/Prolog 系的偏爱,或与 Joe Armstrong 私交甚笃的因素。大师煽情的写下了:
Erlang is going to be a very important language. It could be the next Java. Its main problem is that there is no big company behind it. Instead, it is being pushed as an open source project. Its main advantage is that it is perfectly suited for the multi-core, web services future. In fact, it is the ONLY mature, rock-solid language that is suitable for writing highly scalable systems to run on multicore machines.
而作为 OO 领域,设计模式的大师,关于 Erlang 和 OO 有这么一段精彩的表达:
Processes in Erlang are objects. At the beginning of my course on OO design, I explain three views of OO programming. The Scandinavian view is that an OO system is one whose creators realize that programming is modeling. The mystical view is that an OO system is one that is built out of objects that communicate by sending messages to each other, and computation is the messages flying from object to object. The software engineering view is that an OO system is one that supports data abstraction, polymorphism by late-binding of function calls, and inheritance.
Erlang is a perfect example of the actor model, which is an example of the mystical view. Processes certainly support data abstraction and polymorphism. An Erlang process is a function that reads from the incoming message queue, pattern matches to find a particular message, and then responds to it. A function structured in this particular way is similar to a class in Smalltalk. Moreover, given several kinds of processes that have a common protocol and that share some things in common, it is easy to factor out the commonality into a function that they can both call. This is similar to class inheritance. So, you could even say that Erlang supports inheritance, though it does it very differently than in Java or Smalltalk. I imagine that many Erlang programmers think about programming as modeling. So, Erlang fits all the characteristics of an OO system, even though sequential Erlang is a functional language, not an OO language.
和其他语言相比,大师认为 Erlang 的特别之处在于:
Joe makes too much of functional programming because he says that lack of mutable state implies no locks. However, it is really lack of SHARED state that implies no locks. You could write processes in Basic, perl, or C. I’m sure that lots of people will look at Erlang and say “we can add that to our language”. In my opinion, it is the concurrent programming aspects of Erlang that make it special, along with its mature implementation and powerful library designed for concurrency and reliability.
I do not believe that other languages can catch up with Erlang anytime soon. It will be easy for them to add language features to be like Erlang. It will take a long time for them to build such a high-quality VM and the mature libraries for concurrency and reliability. So, Erlang is poised for success. If you want to build a multicore application in the next few years, you should look at Erlang.
我这么理解这篇充满溢美之词的文章—— Erlang 是一种强大的语言,但是不是会成为下一个 Java ,恐怕大师一个人说了还不算。也许这更象是一场博弈,正如大师开头就提到的——Its main problem is that there is no big company behind it ——想一想,如果离开了 SUN ,今天的 Java 会是怎样?
anyway, impossible is nothing. 且让我们拭目以待。
rabbitMQ 是 AMQP 用 Erlang 实现的 MQ 。之前不是很理解,为什么要用 Erlang 来“又实现一个中间件”呢?这么做能发挥 Erlang 的优势么?机缘巧合,最近了解了一下 AMQP ,有了一点新的认识。
Read more…
Recent Comments