erlang initial experiences
Tue Apr 18 08:35:00 CEST 2000
I've posted my first two Erlang programs at
The latter prints how many 1's there are in the binary expansion of a
positive integer; the former does Fibonacci search for maximum of a
function on a finite interval. They were done with the otp_src_R6B-0
release running on a pre-release snapshot of OpenBSD-2.7.
I'd be interested in knowing how to improve them and in following
current Erlang usage as closely as possible.
My impressions while writing them:
1. Building OTP aborted on every directory with .java files. This was
due to the Makefiles trying to make .classes one at a time when there
were complex and sometimes circular dependencies. With both kjc-1.4C
on OpenBSD and Sun's native Java compiler (when I copied files to a
SparcStation for testing), it was necessary to feed all .java files at
once in a single command line to javac. With this workaround the build
2. I see there's a bsr but no logical shift right. A minor annoyance.
3. Support for parsing of command line arguments passed from the UNIX
shell seems limited. No getopt() (or did I miss it?), and numbers
are passed in as atoms so must go through the dual conversion of
atom_to_list and list_to_integer.
4. The second program has perfectly legal balanced exports of
variables from both branches of an if structure. This leads to a slew
of inappropriate warnings - and I don't see any way to turn them off
without rebuilding the compiler. There is a compiler switch to enable
warning reports, on by default, but no apparent way to turn it off.
Am I off base on any of these items? Erlang is fun, but there seem to
be some rough edges. I plan to stay with it at least long enough to
write more than toy programs.
More information about the erlang-questions