occasionally useful ruby, ubuntu, etc

11Jul/100

Grandparent of Ruby and Java: Eiffel and friends

I'm curious about the effort involved in writing a new programming language, and hence have been doing a little research (including watching Guy Steele's now-famous and amusing Growing a Language lecture). I know I want to target the NekoVM (primarily one of the targets of haxe, for now), but what languages should I base it on? One of the languages I've heard a good deal about about, mainly based on its design-by-contract principles, is Eiffel.

(even if you're not interested in building a new language, learning about programming languages and their design decisions increases our understanding of them and, hopefully, our proficiency with them)

What is Eiffel? Is it another language that lives solely in academia? Is there anything particularly interesting about it?

It's a static, strongly typed language, and...the rest of its characteristics you can read about on Wikipedia.

From a historical perspective, it's interesting to see some of the key features in Eiffel make their way into Java and Ruby, and to see which features didn't.

For example, Eiffel has a notion of abstract classes, except they're called "deferred" classes and use the deferred keyword. Ruby has no abstract classes, though you could simply make the constructor throw an exception, I suppose.

More interestingly, Eiffel supports multiple inheritance, but neither Ruby nor Java do (though Scala supports something similar). How does it evade the diamond inheritance problem? Eiffel doesn't support argument overloading, like Java does; so if two parent classes have the same method, it won't compile. Instead, you have to resolve the name conflict by renaming one or both of the conflicting parent methods in your subclass.

Like Java (1.5 and later, at least), you can't override a parent method without explicitly stating it, except instead of with an @Override annotation at the site of the override, you declare the override at the start of the class with redefine.

Like Scala, Eiffel holds the Uniform Access Principle close -- Eiffel lets you redefine an argument-less method in an ancestor as an attribute in the current class.

Like Scala, Eiffel has a void type, and it is a descendant of ALL reference types, which allows you to pass void into any function expecting a reference type.

Unlike Ruby, Java, and Scala, the only structuring tool is a class -- no interfaces, mixins, traits, interfaces, or modules.

Like Java, Eiffel has a notion of a once routine. Java's equivalent is the static initializer block (static {}). Ruby has a similar pattern, using ||=, to initialize a value once. (Scala also has a notion of lazily evaluated methods/attributes)

Unlike Java, Eiffel does not allow you to cast an object to another type (though you can always try to assign one object to a variable of a type and it will 'cast' it).

And so on. If this piqued your interest in the ancestor of two big languages of today, check out the tutorial. The first 2-3 chapters are a bit dry and apparently a little self-absorbed in places (it's not just a language, it's a process! they say), but still a good read/skim.

Empire Avenue codez: EAVB_HZQKANROTY (my symbol is GFY)

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.