Re: [linux-audio-dev] [ot] [rant] gcc, you let me down one time too many

From: Erik de Castro Lopo <erikd-lad@email-addr-hidden-nerd.com>
Date: Sun Jun 05 2005 - 05:18:10 EEST

Tim Goetze wrote:

> To be honest, I don't know if it's undefined behaviour; I don't read
> ISO compiler ABI standards (if they exist in the first place). I was
> simply trusting that common sense would always allow this
> cross-language subclassing, apparently I was wrong.

Trusting that unspecified/undocumented characteristics will remain
the same across versions is asking for trouble.

>
> > Can I sell you an Ocaml:
> >
> > http://www.ocaml.org/
>
> Does it give me inline assembly, realtime-safeness and the performance
> of C/C++?

Well I really like to separate the C and C++. C is unashamedly a
low level language. C++ OTOH tries to be both low level and high
level. In comparison to C, C++ is a poor low level language.
Compared to Python or Ocaml, C++ is a poor high level language.

So to answer your question, Ocaml will not give you the low level
stuff that is available in C (inline asm etc), but it is a much
better high level language than C++.

I also find Ocaml a better high level language than Python because
it is strictly and statically typed as well as compiling to native
binaries which come close to the speed of C. The (very flawed IMO)
language shootout puts Ocaml compiled to native binaries as faster
than C++ but slower than C.

Linking low level C code to Ocmal is about the same complexity as
doing the same for Python.

> Browsing the site, the tutorial shows code lines ending with two
> semicola and assignments using a 'let' operator; first bitter pills
> to swallow for a friend of code brevity to be sure.

The syntax does have a few warts, but IMO no more than C++.

However, you should look at the big picture instead of the minor
details. Ocaml's bevity comes from it being a true high level
language like Python, not some psuedo high level constructs grafted
onto a low level language like C++.

I've done quite a bit of Ocaml over the last 9 months or so and
I find that for the tasks I was working on I can get a job done
in less lines of Ocaml code than it would take to get the same
task done in Python. That is brevity.

In adition, unlike Python my chances of getting run time errors
are reduced to almost zero because of Ocaml's strict, static
type checking. Errors that are runtime errors in Python are almost
always compile time errors in Ocaml.

> It does look like it has its sweet spots after some more tutorial
> browsing, however I'm afraid my ideal it is not.

I have done some seriously difficult code in Ocaml; tasks that in
C or C++ would a nightmare of complexity and/or endless futzing
about with trivial minor details. It is not the ideal programming
language, but for some kinds of tasks it beats every other
programming language I've ever seen.

You might also find that Ocaml combined with C is a better option
than C++.

Erik

-- 
+-----------------------------------------------------------+
  Erik de Castro Lopo  nospam@email-addr-hidden-nerd.com (Yes it's valid)
+-----------------------------------------------------------+
"The growing and dangerous intrusion of this new technology,
threatens an entire industry's economic vitality and future
security." -- Jack Valenti (MPAA president) on the video
cassette recorder, 1982.
Received on Sun Jun 5 08:15:06 2005

This archive was generated by hypermail 2.1.8 : Sun Jun 05 2005 - 08:15:06 EEST