Eiffel (programming language)
Eiffel is an object-oriented programming language designed by Bertrand Meyer and Eiffel Software. Meyer conceived the language in 1985 with the goal of increasing the reliability of commercial software development. The first version was released in 1986. In 2005, the International Organization for Standardization released a technical standard for Eiffel.
The design of the language is closely connected with the Eiffel programming method. Both are based on a set of principles, including design by contract, command–query separation, the uniform-access principle, the single-choice principle, the open–closed principle, and option–operand separation.
Many concepts initially introduced by Eiffel were later added into Java, C#, and other languages. New language design ideas, particularly through the Ecma/ISO standardization process, continue to be incorporated into the Eiffel language.
Characteristics
The key characteristics of the Eiffel language include:- An object-oriented program structure in which a class serves as the basic unit of decomposition.
- Design by contract tightly integrated with other language constructs.
- Automatic memory management, typically implemented by garbage collection.
- Inheritance, including multiple inheritance, renaming, redefinition, "select", , and other mechanisms intended to make inheritance safe.
- Constrained and unconstrained generic programming
- A uniform type system handling both value and reference semantics in which all types, including basic types such as INTEGER, are class-based.
- Static typing
- Void safety, or static protection against calls on null references, through the attached-types mechanism.
- Agents, or objects that wrap computations, closely connected with closures and lambda calculus.
- Once routines, or routines evaluated only once, for object sharing and decentralized initialization.
- Keyword-based syntax in the ALGOL/Pascal tradition but separator-free, insofar as semicolons are optional, with operator syntax available for routines.
- Case insensitivity
- Simple Concurrent Object-Oriented Programming facilitates creation of multiple, concurrently active execution vehicles at a level of abstraction above the specific details of these vehicles.
Design goals
Eiffel shuns coding tricks or techniques intended as program optimization hints to a compiler. The goals are to make the code more readable, and to facilitate concentrating on the important aspects of a program without getting bogged down in implementation details. Eiffel's simplicity is intended to promote simple, extensible, reusable, and reliable answers to computing problems. Compilers for computer programs written in Eiffel provide extensive optimizing techniques, such as automatic inline expansion, that eliminate part of the optimizing burden.
Background
Eiffel was originally developed by Eiffel Software, a company founded by Bertrand Meyer. Object-Oriented Software Construction contains a detailed treatment of the concepts and theory of the object technology that led to Eiffel's design.The design goal behind the Eiffel language, libraries, and programming methods is to enable programmers to create reliable, reusable software modules. Eiffel supports multiple inheritance, genericity, polymorphism, encapsulation, type-safe conversions, and parameter covariance. Eiffel's most important contribution to software engineering is design by contract, in which assertions, preconditions, postconditions, and class invariants are employed to help ensure program correctness without sacrificing efficiency.
Eiffel's design is based on object-oriented programming theory, with only minor influence of other programming paradigms or concern for support of legacy code. Eiffel formally supports abstract data types. Under Eiffel's design, a software text should be able to reproduce its design documentation from the text itself, using a formalized implementation of the "Abstract Data Type".
Implementations and environments
is an integrated development environment available under either an open source or a commercial license. It offers an object-oriented environment for software engineering. EiffelEnvision is a plug-in for Microsoft Visual Studio that allows users to edit, compile, and debug Eiffel projects from within the Microsoft Visual Studio IDE. Five other open source implementations are available: "The Eiffel Compiler" tecomp; Gobo Eiffel; SmartEiffel, the GNU implementation, based on an older version of the language; LibertyEiffel, based on the SmartEiffel compiler; and Visual Eiffel.Several other programming languages incorporate elements first introduced in Eiffel. Sather, for example, was originally based on Eiffel but has since diverged, and now includes several functional programming features. The interactive-teaching language Blue, forerunner of BlueJ, is also Eiffel-based. The Apple Media Tool includes an Eiffel-based Apple Media Language.
Specifications and standards
The Eiffel language definition is an international standard of the ISO. The standard was developed by ECMA International, which first approved the standard on 21 June 2005 as Standard ECMA-367, Eiffel: Analysis, Design and Programming Language. In June 2006, ECMA and ISO adopted the second version. In November 2006, ISO first published that version. The standard can be found and used free of charge on the ECMA site. The ISO version is identical in all respects except formatting.Eiffel Software, "The Eiffel Compiler" tecomp and Eiffel-library-developer Gobo have committed to implementing the standard; Eiffel Software's EiffelStudio 6.1 and "The Eiffel Compiler" tecomp implement some of the major new mechanisms—in particular, inline agents, assigner commands, bracket notation, non-conforming inheritance, and attached types. The SmartEiffel team has turned away from this standard to create its own version of the language, which they believe to be closer to the original style of Eiffel. Object Tools has not disclosed whether future versions of its Eiffel compiler will comply with the standard. LibertyEiffel implements a dialect somewhere in between the SmartEiffel language and the standard.
The standard cites the following, predecessor Eiffel-language specifications:
- Bertrand Meyer: Eiffel: The Language, Prentice Hall, second printing, 1992
- Bertrand Meyer: Standard Eiffel, ongoing, 1997–present, at Bertrand Meyer's ETL3 page, and
- Bertrand Meyer: Object-Oriented Software Construction, Prentice Hall: first edition, 1988; second edition, 1997.
- Bertrand Meyer: Touch of Class: Learning to Program Well with Objects and Contracts, Springer-Verlag, 2009 lxiv + 876 pages Full-color printing, numerous color photographs
Syntax and semantics
Overall structure
An Eiffel "system" or "program" is a collection of classes. Above the level of classes, Eiffel defines cluster, which is essentially a group of classes, and possibly of subclusters. Clusters are not a syntactic language construct, but rather a standard organizational convention. Typically an Eiffel program will be organized with each class in a separate file, and each cluster in a directory containing class files. In this organization, subclusters are subdirectories. For example, under standard organizational and casing conventions,x.e might be the name of a file that defines a class called X.A class contains features, which are similar to "routines", "members", "attributes" or "methods" in other object-oriented programming languages. A class also defines its invariants, and contains other properties, such as a "notes" section for documentation and metadata. Eiffel's standard data types, such as
INTEGER, STRING and ARRAY, are all themselves classes.Every system must have a class designated as "root", with one of its creation procedures designated as "root procedure". Executing a system consists of creating an instance of the root class and executing its root procedure. Generally, doing so creates new objects, calls new features, and so on.
Eiffel has five basic executable instructions: assignment, object creation, routine call, condition, and iteration. Eiffel's control structures are strict in enforcing structured programming: every block has exactly one entry and exactly one exit.
Scoping
Unlike many object-oriented languages, but like Smalltalk, Eiffel does not permit any assignment into attributes of objects, except within the features of an object, which is the practical application of the principle of information hiding or data abstraction, requiring formal interfaces for data mutation. To put it in the language of other object-oriented programming languages, all Eiffel attributes are "protected", and "setters" are needed for client objects to modify values. An upshot of this is that "setters" can and normally do, implement the invariants for which Eiffel provides syntax.While Eiffel does not allow direct access to the features of a class by a client of the class, it does allow for the definition of an "assigner command", such as:
some_attribute: SOME_TYPE assign set_some_attribute
set_some_attribute
-- Set value of some_attribute to `v'.
do
some_attribute := v
end
While a slight bow to the overall developer community to allow something looking like direct access, the practice is dangerous as it hides or obfuscates the reality of a "setter" being used. In practice, it is better to redirect the call to a setter rather than implying a direct access to a feature like
some_attribute as in the example code above.Unlike other languages, having notions of "public", "protected", "private" and so on, Eiffel uses an exporting technology to more precisely control the scoping between client and supplier classes. Feature visibility is checked statically at compile-time. For example,, the "" is similar to "protected" in other languages. Scope applied this way to a "feature set" can be changed in descendant classes using the "export" keyword.
feature -- Initialization
default_create
-- Initialize a new `zero' decimal instance.
do
make_zero
end
Alternatively, the lack of a export declaration implies and is similar to the "public" scoping of other languages.
feature -- Constants
Finally, scoping can be selectively and precisely controlled to any class in the Eiffel project universe, such as:
feature -- Access
Here, the compiler will allow only the classes listed between the curly braces to access the features within the feature group.