| Eiffel | Java |
|---|---|
Programming by Contract (assertions)
|
All popular web browsers comprehend
Java applet byte codes. (the "fun factor") |
| Parameterized Classes (generics) | Noticeably more popular in industry |
| More stable environment; the kernel
library and the language pretty much standardized in 1995 except for multithreading/distributed enablers. |
Library of universally available standard
classes is larger (640 vs 50), including a multithread framework; many other class libraries are widely available. |
| Very simple syntax | C-like syntax (the "familiarity factor") |
| Object attributes are read-only,
eliminating the need for accessor functions. |
|
| General feature visibity construct
instead of choices like protected and public. |
|
| renaming of inherited features allows
inheritance of classes that happen to have features whose names clash with something else |
|
| Eiffel | Java |
|---|---|
| Full support for multiple inheritance
of classes, with feature renaming to avoid name conflicts, and a simpler, less error-prone definition of how class features are merged than other languages like C++. This allows design of "mixin" style classes that contain an abstraction and a partial implementation. |
Multiple inheritance is limited to
interfaces. This prevents the programmer from employing almost all the ill- advised uses of multiple inheritance (Although nested classes undoes some of this restriction). If the effect of multiple inheritance is desired, it can be simulated through delegation with a slight bit of extra typing and as long as the parent class has an interface. |
| Program features can only be accessed
by inheriting or using, as a client, the class that contains that data. This reduces the chances of having hidden "pathological connections" between modules. |
Java allows access to static features via
just the class name. This simplifies the code in some cases, and eliminates one of the more confusing uses of inheritance. |
| Eiffel is largely unknown to incoming
students, thus helping to keep them from thinking in preconceived paradigms. It is also hard for them to find solutions to their assignments on the internet. |
Java is well-known by computer
afficionados, and generally has a positive reputation. This can be encouraging and motivating to students. |
| It is impossible to modify an object's
state from the outside. |
You are not forced to write a modifier
function for each attribute if you don't mind making it public. |
| Eiffel's exception policy is based at the
routine level. A routine is expected to have a single goal that it either achieves or it does not. If it does not, the caller is notified of that failure. The caller may not complete successfully without retrying. |
Java's exception policy, like C++'s, is to
have each function list possible exceptions that may be raised. When an exception is caught, it is considered handled (unless rethrown), and the program moves on. |
class HELLO creation main feature main is do io.put_string( "Hello, world!%N" ) end
end
class Hello {
public static void main( String args[] ) {
System.out.print( "Hello, world!\n" );
}
}