Slashdot is powered by your submissions, so send in your scoop

 



Forgot your password?
typodupeerror
×
Programming

Journal TrixX's Journal: Ramblings on Eiffel and Haskell

Desde que la gente de SmartEiffel se dedica a hacerle extensiones exóticas al lenguaje, en la lista de correo se han dado un par de discusiones interesantes.

A principios de febrero hubo una sobre la nueva forma de manejar tipos de constantes numéricas. En la última versión se agregaron tipos con tamaño explícito (INTEGER_8, INTEGER_16, INTEGER_32 e INTEGER_64, además del clásico INTEGER que es por definición equivalente a INTEGER_32). Y la gente de SE decidió darles a las constantes numéricas el tipo más chico en la que entren. Así, "100" tiene tipo INTEGER_8, "1000" es un INTEGER_16, y "-100000" es un INTEGER_32. Eso, entre otras cosas disparó un thread bastante extenso de como manejar esas cosas.

Alguien propuso usar un enfoque basado en Haskell, que en general hace muy bien esas cosas (me acuerdo que hubo un par de veces que no, pero no tengo el contraejemplo a mano). Yo mande un mensaje contando como era en Haskell, y que cosas le faltaban a Eiffel para poder hacer algo así (y aprovechar para decir que me gustan las funciones genéricas :) ).

La cosa es que esto disparó una discusión interesante (en privado) con Alexandre Ferrieux (uno de los usuales de la lista de SE). Es una discusión sobre lenguajes de las que me gustaría escribir y bloguear más. Cito:

From: Alexandre Ferrieux
To: dmoisset
Subject: Haskell and Eiffel
Date: Wed, 02 Feb 2005 15:48:47 +0100

Hello,

I know there are millions of "A vs. B" language comparisons, but your post on the SE list shows familiarity (to say the least) with both, while many comparison-writers have a strong bias...

Would you care to give your view of Eiffel and Haskell ? For example, considering the obvious concern for cleanliness in Haskell and the current state of uncertainty and ugliness Eiffel has fallen into, why would an experienced Haskell programmer want to spend time with Eiffel ? I was bred with C like anyone else, loved Prolog and Lisp as educational toys, was about to invest time with Eiffel, and am wondering about Haskell...

Thanks in advance,

-Alex

Le contesté:

From: Daniel F Moisset
To: Alexandre Ferrieux
Subject: Re: Haskell and Eiffel
Date: Wed, 02 Feb 2005 18:06:04 -0300

On Wed, 2005-02-02 at 11:48, Alexandre Ferrieux wrote:
> Hello,
>
> I know there are millions of "A vs. B" language comparisons, but your
> post on the SE list shows familiarity (to say the least) with both,
> while many comparison-writers have a strong bias...
>
> Would you care to give your view of Eiffel and Haskell ?

Disclaimer: I do not consider myself a serious Haskell programmer. I have studied it very deeply from a theoretical standpoint and from a programming language paradigms view. I haven't written large, real-life systems in Haskell, just some toy programs (some of them not-so small). OTOH I have coded a lot of Eiffel that works (and I need it to).

After that, I can give you my opinion and you can put a value on it :)

> For example, considering the obvious concern for cleanliness in
> Haskell and the current state of uncertainty and ugliness Eiffel has
> fallen into, why would an experienced Haskell programmer want to spend
> time with Eiffel ?

The cleanliness of Haskell is appealing, from a mathematical point of view. However, I have always felt some uncertainty about scaling that to bigger systems.

A lot of algorithms can be described beautifully in Haskell, in a form that is short, compact, non redundant, and clear at the same time. The same happens with a lot of data structures (but not any; the pure functional paradigm lends to some structures more than others). As I said in the mailing list, the typing system is a charm (as a programmer, and as a theoretical computer scientist). But I think it lacks several features for "programming in the large". It is hard to compare them one by one with Eiffel (given the different paradigm), but I feel Eiffel is much more of an "engineering" language instead of a "computer science" one.

Specially, is hard to profile algorithms and estimate running speed or memory usage given the "lazy evaluation" nature of Haskell (this is not a problem in some strict functional languages like Ocaml). And interaction with other systems and libraries (I/O, databases, etc.) is a little convoluted to program, even after understanding "monads", which are very useful to emulate aspects of imperative programming, but require some brain-bending to grasp.

A lot of people disagree with me and think Haskell is ready for big systems, and there is a lot of real software written in Haskell (a popular one today is the DARCS revision control system).

I think the ugliness in Eiffel is something that will go away, and more a matter of implementation. The language concept is by far the cleanest thing I've seen in imperative/OO programming, and probably will keep clean. Once ETL3 is released and ECMA sets the standard, I guess this crazy days of adding random features to Eiffel will go away. Or I hope, at least.

Some things I like in Eiffel and you wont find in Haskell (and perhaps nowhere else) are:

  • Design by Contract. I think this tool is invaluable. I even use it when programming C (with helper libraries)
  • Easy interfacing with other libraries (even external ones)
  • A language structure allowing clean, modular, systems
  • An OO typing system that does not suck. Specially, I still think Eiffel is the only language with multiple inheritance done right.

The typing system of Haskell is very clear and sound, completely static, with type inference, and with genericity everywhere (even more than Eiffel, which, anyway is the best I've seen for OO languages). But it's not OO (however, it has some kind of subtyping/inheritance that can help). The pattern matching mechanism is very useful, but there seems to be a conflict between them and modularity (you can't abstract patterns, and cannot use them without exposing your data structures), so part of the magic is lost.

OK, looking back this seems more of a pro-Eiffel mail, so your desire for an unbiased comparison may be lost :) Anyway, I think learning Haskell is an excellent educational exercise, and teachs you very different ways of programming and thinking problems.

> I was bred with C like anyone else, loved Prolog
> and Lisp as educational toys, was about to invest time with Eiffel,
> and am wondering about Haskell...

Both Eiffel and Haskell have a lot of interesting stuff in their design, that can help you even if you don't program in any of that languages afterward. I have read about Lisp (but not programmed much more than "hello world"), but it looks like a very primitive functional language compared to Haskell (like comparing assembly to C or Pascal).

I mentioned Haskell at the SE mailing list mainly because I think each language has it strengths, and the best solutions sometimes can be found mixing solutions found in different languages. And the Eiffel design could use a lot from the typing system of Haskell without conflicting its other features.

> Thanks in advance,

NP... btw, I sometimes blog this kind of stuff when I take the time to write it. Do you mind if i publish your email with my answer? (Omitting the name, if you want)

See you, Daniel

Parece que no le pareció tan pro Eiffel:

From: Alexandre Ferrieux
To: Daniel F Moisset
Subject: Re: Haskell and Eiffel
Date: Thu, 03 Feb 2005 14:13:40 +0100

Hello Daniel,

First, thanks for the precise and insightful answer. It is exactly what I needed ! And indeed, the principle of learning a language to export its spirit to another one is not alien to me: so far I've written very little in Eiffel (mainly by fear regarding the current uncertainty), but improved my C designs using those ideas...

So the immediate consequence of your message is that I'll rush to do the same with Haskell: good job for a "pro-Eiffel" view ;-)

(The idea of a 'thin imperative layer' isolating a 'functional core' from the hostile outside world is really exciting...)

> NP... btw, I sometimes blog this kind of stuff when I take the time to
> write it. Do you mind if i publish your email with my answer? (Omitting
> the name, if you want)

No problem to publish the message; and no need to hide my name.

Thanks again and best regards,

-Alex

Ahora nomás me falta autoconvencerme a mi de usar haskell :)

This discussion has been archived. No new comments can be posted.

Ramblings on Eiffel and Haskell

Comments Filter:

Disclaimer: "These opinions are my own, though for a small fee they be yours too." -- Dave Haynie

Working...