January 2008

Having used different kinds of language (C++, python, ruby, ocaml, erlang), I still can’t choose what kind of typing I prefer as far as static vs dynamic typing is concerned (I will not discuss the strong vs duck typing).

I’m not convince that a static type system is a useful “bug avoidance system” (for my kind of development habits at least!). Not that it cannot prevent some bugs, but those are probably the “easy bugs” that would have show-up in unit-tests … and this is exactly the point: unit-tests are anyway necessary to test the functional aspect, so type kind of bug will be found in either kind of development environment.

Having written lot of code in python and C++, I sure better love python: I will not repeat here why language like python or ruby are more easy to read, more concise and so on …

However in team environment, a type is a first documentation feature! In a clear API, the type information is nearly enough to use the API (most python API documentation define all types of the parameters …).

Also with my last experiences with ocaml, I discover that having to define the type oblige to think more about what is the data. When thinking of the type of a data, you end-up asking you question like: what is it that I want to manipulate? if it should have this and that method, is it an application object? is it a subcomponent of my current object? is it a facet/interface of my object? can I abstract this “thing”? … all that is a good point in favor of strongly typed language at compile time as it help to concentrate on defining data!


Tip I enjoyed today: python in vim, how cool is that!?

For those who like vim but not the vim script language, try :help python.

:py import vim
:py [vim.current.buffer.append(str(e)) for e in xrange(10)]

Managed to have some time to play with ocamerl: ocaml node is now able to receive data from erlang node, and also send data to pid on connected nodes.

I begin to understand what I’m doing, so that I will be able to clean the code and refactor some parts very soon.

As example, an ocaml process which multiply integer by 2! wow! What’ an interesting example!

bash> cd trunk/lib/ocamerl
bash> ./ex/node_double >/dev/null 2>&1 &
bash> erl -setcookie cookie  -sname erl
erl@devhost 1> net_adm:ping(ocaml@devhost).
erl@devhost 2> {bytwo, ocaml@devhost} ! {self(), 8}.
erl@devhost 3>  receive I -> io:format("Got: ~w~n", [I]) after 0 -> ko end.
Got: 16

Note: the ping was optional and the answer seems correct: 8 * 2 = 16!

It’s kind of surprising how people can like such a simple game as pong. Isn’t it even more odd to find programmer which enjoy their program to play?

All that to say: ocaml node (using the ocamerl lib of erlocaml) can now reply pong to a ping request from erlang node 😉 … and that’s all it can do!

Next step: receive data 🙂