—— Where exceptions happen.

显示标签为“OCaml”的博文。显示所有博文
显示标签为“OCaml”的博文。显示所有博文

2007年12月21日星期五

在并行计算领域JoCaml小规模小范围的成名了

不说废话,写这篇blog的原因是很高兴看见OCaml的一个分支JoCaml的优越性在一次并行计算优化竞赛中一举成名(在邮件列表和技术博客圈里),翻译老外的话是:一个JoCaml爱好者在一个下午写的JoCaml程序的性能超过了一群Erlang专家不断优化的结果(在我看来,Erlang已经不再是并行计算的第一选择了),而且更惊人的是当一个经过充分手工优化的C程序(其实是C++)出现的时候,JoCaml程序与之相比只有11%的性能差距,而当调整了5行代码之后,JoCaml程序又比C++程序快了1%,这点差别其实考虑到不同的编译器/平台/应用,已经可以忽略不计了。换言之,你完全可以把JoCaml并发程序的性能和经过手工优化过的C++并发程序的性能相提并论。更诱人的是,JoCaml在从多CPU平台扩展到多机平台时,只需要加一行代码(C++程序就麻烦了),而这是 JoCaml优越的并发抽象逻辑所保证的。

这系列并行优化的文章见:http://www.tbray.org/ongoing/When/200x/2007/09/20/Wide-Finder
JoCaml的性能优势:http://www.tbray.org/ongoing/When/200x/2007/10/30/WF-Results
一个被这次优化竞赛的发起人认可的性能总结:“Conclusions about Wide Finder, C++, OCaml, JoCaml, Erlang and friends “ (注意:我不知道为什么这个网站被河蟹咬到了,所以被GFW保护的人民请用标题在google搜索,然后设法穿墙看快照吧)
JoCaml的网站:http://jocaml.inria.fr/
文档:http://jocaml.inria.fr/manual/index.html (推荐这份东西,不过学过一点OCaml语言,看起来会更轻松)

ps. 我正在着手把我的OCaml语言写的神经网络仿真程序改写成JoCaml版,刚在一台4核至强的SUSE服务器上编译完了OCaml和JoCaml的3.10.0版本(both of them),看见这个消息真是振奋人心。最后再次赞美函数式语言在并行计算方面的潜力。

2007年6月8日星期五

比较OCaml和Haskell的开发效率

为了比较OCaml和Haskell,这位blogger在3个月内用这两种语言各自实现了一个编译器(从EasyLanguage到C#),结论是OCaml获胜,按作者的话:“OCaml is the practical Haskell.”
clipped from wagerlabs.com

Who let the dogs out?
May 26th, 2007

Why Ocaml? Why not Haskell? I'll list the pros and contras below, in no particular order. I'll write up a summary first, for those of you not interested in reading the whole post.

Tenerife Skunkworks


blog it

2007年6月7日星期四

Ocaml资源补遗:OCaml! My Caml!

一个介绍OCaml的Presentation,可能太短了,几个Ocaml资源站上都没有收这个的link。今天上午写了一个Eratosthenes筛法的OCaml程序,想搜索看看有没有更好的实现,结果看见了这个简介里的实现(关于筛法,它给了 Imperative approach和 Functional approach两种实现……但我还是比较喜欢我自己的两次尾递归方案,多出来的一次是因为没有用标准库的List.filter)
clipped from youngbloods.org
OCaml! my Caml!


A brief introduction to
Objective Categorical Abstract Machine Language


by Kats Rogo and Carl Youngblood


blog it

2007年5月16日星期三

How-to: Build OCaml native code with MSVC 2005

Most Ocaml books, tutorials and lectures would stress its performance. OCaml’s optimizing compiler generates high-performance native code, which I cost a whole afternoon to build.I installed Ocaml 3.09.3 release, and read the “Readme.windows.txt”. I found these evil lines:

" Visual C++ version 6 or later. We use Visual C++ 2003.
The free download Visual C++ 2005 Express Edition works under
Windows 2000, but not under Windows XP because of the "manifest"
annotations on DLLs, which are not yet supported by OCaml.
So, please stick with the 2003 edition for the time being. "
But... I've installed the free Visual C++ 2005 Express Edition. ╮(﹀_﹀")╭ One way is uninstalling the free MSVC 2005 Express edition, then emule/bt a pirate and out-of-date MSVC 2003. the other is trying to find some workaround. I chose the latter.
After a long try-err process, I successfully build OCaml into native win32 code with MSVC 2005 version. following is the detail step-by-step:

0. make sure you've installed Ocaml for the port based on the Microsoft toolchain. This guide isn't for Cygwin port.

1. get Visual C++ 2005 Express Edition from Microsoft.com, It's free. and get it's SP1 too.

2. get Microsoft Macro Assembler 8.0 (MASM) Package from Microsoft.com. It's free also.

3. get Microsoft Windows Server 2003 R2 Platform SDK from Microsoft.com. It's free but require you pass the "Windows Genuine Advantage" test.(if you hate this test. you can easily find the SDK ISO on emule...*\(▔▽▔)/*)

4. install 1,2.3.

5. set the PATH environment variable: add "C:\Program Files\Microsoft Visual Studio 8\Common7\IDE;C:\Program Files\Microsoft Visual Studio 8\VC\bin" into the PATH. you may need alter the path as your tools' real install directory.

6. set the LIB environment variable as "D:\Microsoft Platform SDK for Windows Server 2003 R2\Lib;C:\Program Files\Microsoft Visual Studio 8\VC\lib\" you may need alter the path too.

7. Thus you ocamlopt your .ml file, thus all of them. And on the seventh step you ended your work which you had made; and you rested on the seventh step from all your work which you had made. :-P

ps. this How-to guide is writen in an obviously imperative style. Let us rewrite it in functional style:
let PATH = "$Visual Studio$\VC\bin; $Visual Studio$\Common7\IDE"
let LIB = "$Platform SDK$\lib; $Visual Studio$\VC\lib"

Functional style is really short and clear. :-)

OCaml resources

Chosen OCaml for my neural network simulation, these days I greedily collected OCaml resources all the Web just as a spider. Wish the following links help other OCaml-rookies.

Intro:
Ocaml on Wikipedia ;
Ocaml Homepage

Manual:
The Objective Caml system release 3.09 (newest ref)

Lecture:
Using, Understanding, and Unraveling: The OCaml Language; (2000, 2001)

Tutorial:
http://www.ocaml-tutorial.org/ (this site is resourceful and updated)
"Ocaml for scientist" (Chapter 1) (recommend)

Code:
OCaml official codebase: The Caml Hump
Codecodex's OCaml Category
. (this site is very interesting for fans of many kinds of language , not including Haskell :-p )

IDE:
OCaml Development Tools (an Eclipse plug-in. released 1.0 at May 10, 2007)

Benchmark:
OCaml vs. Java.(Take it for fun!)

News rss:
Maybe I should use pipes to make one rss for OCaml News….Hmmm

中文论坛:
Ocaml china, 一个不错的中文Ocaml论坛,虽然草创,文章和人气都不是很多。但格局和讨论氛围很好:)希望能进一步壮大。