User:Doug Pardee/Working

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

Eiffel is an object-oriented (OO) programming language which emphasizes the production of robust software. Many find its syntax to be reminiscent of Pascal. Eiffel is a compiled language, strongly statically typed, with automatic memory management (typically implemented by garbage collection).

Created in 1987, Eiffel is a mature OO language with development systems available from four different suppliers. Despite this maturity and a generally excellent reputation among those who are familiar with the language, Eiffel has failed to gain much interest from software developers. The reasons for this lack of interest are unclear, and are a topic of frequent discussion within the Eiffel community.

Hello World in Eiffel[edit]

creation make
   make is
         print ("Hello, world!%N")

Notable features and characteristics[edit]

At first glance, Eiffel appears to be quite ordinary. Aside from the statements and declarations associated with Design by Contract™, there is little that is remarkable in the Eiffel syntax. Nevertheless, Eiffel has a number of unusual aspects, many of which are reflected by what is absent from the Eiffel syntax.

Guiding principles[edit]

Analysis, design, and implementation language: Eiffel is not just an implementation language. Eiffel can be used to specify an analysis-level object model, which can be elaborated into a design-level object model, to which implementation code can be added to achieve a running program. In recent years, graphical analysis and design systems such as UML have overshadowed the analysis and design specification aspects of Eiffel, despite the graphical languages' requirement for translation between the design language and the implementation language and vice versa.

Reliance on development systems: Eiffel attempts to move as much work as possible from the programmer to the development system and automated tools. The effects of this principle are most obvious when compared against the C++ language. C++ has restrictions on forward references to save the compiler from the effort of making one additional pass over the source code; Eiffel makes the extra pass. C++ requires the programmer to provide a separate header file; Eiffel extracts the header information directly from the main class file. C++ puts the programmer in charge of releasing memory allocations when they are no longer needed; Eiffel has automatic memory management (typically garbage collection). The Java language is very similar to Eiffel in these respects.

Preference for declarative rather than imperative: Eiffel code tends to have more declarative statements and fewer imperative instructions than code in most other languages. To some extent, this stems from the expression of analysis and design concepts within the code, and the reliance upon the development system rather than the programmer.

Exactly one way to do anything: in stark contrast to Perl's philosophy of there is more than one way to do it, Eiffel follows Bertrand Meyer's Principle of Uniqueness: "The language design should provide one good way to express every operation of interest; it should avoid providing two." This philosophy eases the strain on the automated tools which Eiffel relies upon. However, many programmers dislike the restraint on stylistic expression that results from Eiffel's lack of syntactic sugar; some have described Eiffel programming as "bondage and discipline".

Problem solution only: an Eiffel program contains only that coding which is necessary to solve the problem at hand. Bookkeeping code, optimization hints to the compiler, and system assembly instructions (include, import, etc.) are not present in Eiffel.

Only one compile-time warning message: a program either is correct or it is not. In theory, Eiffel has only one warning message at compile-time, generated when the class is referencing code which has been declared obsolete by its author. In practice, however, most Eiffel implementations do have a few other warning messages.

Lexical and syntax[edit]

Case insensitive: like Ada, Eiffel is not case-sensitive. Keywords and identifiers can be written in any combination of upper and lower case. The tokens MaKe and make and MAKE all refer to the same identifier. Coding style standards, however, generally prescribe the use of all-capitals for class names, all lower-case for variables and method names, and initial capitals for constants. Keywords are normally written in all lower-case except for the reserved identifiers—True, False, Void, Current, Precursor, and Result—which are conventionally written with initial capitals. The style standards generally discourage the use of CamelCase, recommending instead the use of underscores between the words in an identifier.

Optional semicolons: Eiffel's syntax can be parsed without requiring end-of-statement markers. The use of semicolons as statement terminators or as statement separators is left to the discretion of the programmer. Putting a semicolon in or leaving one out will make no difference except in the unusual case where the following statement starts with a left parenthesis. Most Eiffel programmers choose to omit semicolons except when putting multiple statements on a line.

Proportional font: Unlike most programming languages, Eiffel is not normally displayed in a monospaced typeface. The recommended display style is to use a proportional typeface. Keywords are displayed in bold, user-defined identifiers and constants are displayed in italics. Standard upright (roman) style is used for comments, operators, and punctuation marks. This is essentially the same concept as syntax coloring which has become very popular in IDEs for many languages, except that Eiffel's recommendations also extend to print media.

Strict ordering of syntactical elements: Eiffel generally requires that sections and clauses appear in a specific order. Some programmers find the very notion to be onerous, but it does not seem to be at all controversial among the actual users of the language.

Type system[edit]

Strong static typing: like most compiled programming languages, Eiffel is statically typed. In contrast to some statically typed programming languages which permit indiscriminate casting, Eiffel provides no way to circumvent the typing.

Value types with value semantics: the question of whether value types should be implemented with value semantics or with immutables is a subject of considerable debate. Smalltalk uses immutables; Java uses immutables for non-primitive value types but value semantics for primitives. Eiffel uses value semantics for all value types, as does the more recent C# language.

Eiffel performs automatic conversion to and from references when needed; C# calls these operations boxing and unboxing. C# does not permit direct operations on boxed value objects—they can only be unboxed—but Eiffel allows full access to the reference object. This is an important distinction—the boxed objects in C# are immutable and thus continue to be value objects, where Eiffel converts them to sharable, mutable reference objects. Theoretical arguments would favor the C# approach, while Eiffel's approach provides some practical advantages.

Unified type system: Eiffel does not distinguish between primitive types and other types, as C++ and Java do. All types in Eiffel are classes. All Eiffel types are descendants of the base type ANY, with the exception of GENERAL which is the parent type of ANY.

Enumerations: Eiffel provides a simple form of enumerations based on the INTEGER type. Because all enumerations in Eiffel are fundamentally of type INTEGER, these do not have even the relatively primitive type-safety of the enum types in C and C++. This lack of type-safety is unusual considering the strict type-safety that Eiffel enforces elsewhere.

Generic types: one of the problems that a statically typed OO language encounters is that of providing general-purpose container classes that are type-safe relative to the values that they store. Genericity is an elegant solution to the problem. It can also be used in other situations where an object must hold a reference to an object of a type known only to the client, and then return that reference to the client. The most well-known form of genericity is the template in C++; Java will be getting genericity in version 1.5. Many C++ programmers find the template syntax to be verbose and clumsy; in contrast, Eiffel's syntax for genericity is quite simple (as is Java's).

Eiffel's genericity is restricted to the ability to parameterize a class based on types; C++ and Java also allow individual functions to be parameterized, but Eiffel has no functions which are not object methods. C++ allows parameterization on values as well as types, primarily used for setting sizes of statically allocated arrays; Eiffel does not have statically allocated arrays and does not provide this kind of genericity (neither will Java). Eiffel allows the actual generic parameter type to be a value type, as does C++, but Java will not.

Eiffel allows a formal generic parameter to be specified to be of a particular class, or a subclass thereof. This constrained genericity allows the generic class to access the methods and features of objects of a generic type. Constrained genericity is not available in C++ but will be available in in Java.

Arrays: there is no special syntax for defining arrays nor for accessing elements of an array. An array is simply an instance of the generic collection class ARRAY[G], and access is made through ordinary method calls. This is similar to the ArrayList class in Java, if ArrayList could hold primitives such as "int". Some Eiffel compilers provide specialized optimizations for array access. Many programmers who are new to Eiffel find the absence of a special array syntax to be almost unthinkable, but in practice arrays are not used as much as lists and other collection types.

Pure object orientation[edit]

All data is contained in objects: Perhaps uniquely among the OO languages, Eiffel requires that all data be associated with an object. There are no "static" data items in Eiffel. Objects that need to be shared among all instances of a class (and its subclasses) can be created as once functions, which return the same value on the second and subsequent calls as they did on the first call.

All methods are associated with objects: As with data items, Eiffel requires that all methods be associated with an object. There are no "static" methods in Eiffel.

No main method: there is no special syntax for a "main program" in Eiffel. When compiling a system, the developer specifies which class, and which constructor of that class, will initially be executed.

C is used for non-OO operations: any non-OO coding—especially code that must be "close to the machine"—is expected to be done in C, and Eiffel provides a straightforward interface to the C routines through external methods. Eiffel tends to be quite closely connected to C in any event; three of the four Eiffel compilers translate the Eiffel source into C code rather than into object code.


Operator overloading: Eiffel allows classes to define implementations for operators. In addition, new operators (called free operators in Eiffel) can be defined. However, this is not full operator overloading because each defined operator can take only a single operand type.

No method overloading: methods cannot be overloaded by the declared argument types, as they can in C++ and Java. Each method must have a unique name.


Constructors are explicitly named: constructors in Eiffel are ordinary methods that have been designated as creation features. They have standard method name.

Constructors can also be used as ordinary methods

Visibility (access) control[edit]

Explicit exporting: access control in Eiffel is accomplished by listing the specific classes which are permitted to use a method, attribute, or constructor—this is referred to as exporting. All subclasses of the named classes are also granted access. The default export is to {ANY} which is public access. Exporting to the current class gives the same effect as "protected" access in C++. Since there is no equivalent of Java packages in Eiffel, there is no equivalent of Java's default access.

Private access is different: although it might appear that exporting a method or variable to "{NONE}" would be the same as private access in C++ or Java, it is quite different. The private access modifier indicates that the method or variable can be accessed by any object of the same class, but not of a subclass. The Eiffel export to "{NONE}" indicates that the method or variable can be accessed only by the current object, either in the current class or a subclass, but not by any other object even if of the same class.

Exporting of constructors: access control can be different for construction and ordinary use of the method.

Statements vs. expressions[edit]

Statements and expressions are different: In contrast to most members of the curly brace family of programming languages, Eiffel does not permit expressions to be used as statements, nor statements to be used as expressions.

Routines and functions are different: Accordingly, a method which returns a value can only be used in expressions, while a method which does not return a value can only be invoked by method call statements.

Command/Query Separation: The philosophy that expressions and statements are fundamentally different in nature is expanded into the concept of Command-Query Separation (CQS). Under CQS, a query method (a function which returns a value) must not change the state of the object, while a command method will change the state of the object but will not return a value. CQS is strongly recommended for Eiffel programming, but is not actually enforced by the Eiffel system.

Universal access: a function with no arguments is not written with the empty parentheses that are characteristic of the curly brace family. On the surface this seems like a minor syntax point, but by eliminating the parentheses it no longer matters to the client if the value is provided by a variable or by a function with no arguments, because the syntax is identical. This provides an important bit of implementation hiding.

Publicly accessible attributes and information hiding

Imperative statements[edit]

Six imperative statements: Eiffel has only six basic executable statements: assignment, object creation, method call, conditional, iteration, and choice (case).

Left side of assignment restricted: Perhaps uniquely among the OO languages, Eiffel does not permit storing into member variables of other objects. The assignment statement can only change the value of a member variable of the current object, or a local variable of the current method. All changes to other objects must be accomplished by calls to methods of that object. Direct access to member variables of other objects is "read only" in Eiffel.

Only one type of loop: the only iteration statement in Eiffel is the from...until statement, which evaluates the termination condition at the beginning of the loop. There is no "while" statement, no "do...until" nor "do...while", and no "for" loop.

Loop statement does not include step instruction: the iteration (loop) statement in Eiffel is unusual in that it does not provide a field or clause which will step the loop. The programmer must explicitly code the appropriate stepping statement within the loop. For example:
   from i := 0 until i >= 10 loop
      my_array.put (0, i)
      i := i + 1

Strictly structured coding: Eiffel's procedural coding is strictly structured. There are no Eiffel statements for terminating a loop early, nor for exiting a method early.

Design by Contract™[edit]

Disciplined exceptions


Implementation inheritance

Multiple inheritance

Anchored types and covariance

Eiffel genesis[edit]

Eiffel was originally developed by Bertrand Meyer and his company Interactive Software Engineering (ISE). It closely follows Dr. Meyer's work in Object Oriented Software Construction, Second Edition. Eiffel differs from most popular languages in several ways.

The goal of the language, libraries, and programing methods is to create reliable, reusable software modules. It supports multiple inheritance, genericity, polymorphism, and encapsulation. Its most important contribution to software engineering is Design by Contract, in which assertions, preconditions, postconditions, and class invariants are used to assist in assuring program correctness without sacrificing efficiency.

Eiffel also offers multiple class inheritance. Many people (such as the designers of Java) have objections to multiple inheritance. The Eiffel implementation of multiple inheritance, in the opinion of its supporters, successfully meets these objections.

Eiffel's design is closely based on OOP theory, with less influence from other paradigms or support for legacy code. The language has formal support for abstract data types. In accordance with Self Documentation, a software text should be able to reproduce its design documentation from the text itself. Eiffel accomplishes this by using a formalized implementation of the Abstract Data Type.

Eiffel Studio, an integrated development environment for Eiffel, offers an object-oriented interface for software engineering. However, many programmers disliked it because it was very different from user interfaces for other integrated development environments.

Specifications and standards[edit]

The official language specification for Eiffel is Eiffel: The Language, first edition, second printing (ETL2), but that book is reportedly out of print. Bertrand Meyer is working on a new version of the Eiffel language specification, but no completion date is available (as of early 2003). In the interim, ISE has made a significant subset of ETL2 available online.

The specifications for the Eiffel language and its basic libraries are nominally under the control of the Nonprofit International Consortium for Eiffel (NICE). Although NICE has sporadically worked on improving the specifications for the basic library classes, it has done little with the language itself aside from ratifying ETL2 and a few changes which already had appeared in the available development systems. In June 2002 ISE submitted the Eiffel language to the European Computer Manufacturers Association (ECMA) for standardization, a move which effectively deposed NICE as the standards body for the language proper.

External links[edit]