Eiffel's syntax can be parsed without requiring end-of-instruction markers. The use of semicolons as instruction terminators or as instruction separators is left to the discretion of the programmer. Putting a semicolon in or leaving one out makes no difference, except in the unusual case of an instruction starting with a left parenthesis. Most Eiffel programmers choose to omit semicolons except when putting multiple statements on a line.
Eiffel requires that sections and clauses appear in a specific order.
In contrast to most curly bracket programming languages, Eiffel does not let expressions be used as instructions, nor instructions be used as expressions. Thus, a routine which returns a value can only be used in expressions, while a routine which does not return a value can only be invoked as an instruction.
This philosophy - that expressions and statements are fundamentally different in nature - is expanded into the concept of Command-Query Separation (CQS). Under CQS, a query routine (a function which returns a value) must not change the state of the object, while a command routine 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.
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 shown in bold, user-defined identifiers and constants are shown in italics. Standard upright (roman) style is used for comments, operators, and punctuation marks.
Eiffel has only six basic executable instructions:
Unlike many object-oriented languages, but similar to Smalltalk, Eiffel does not permit storing into fields of other objects. The assignment instruction can only change the value of a field of the current object, or a local variable of the current routine. All changes to other objects must be accomplished by calls to methods of that object. Direct access to fields of other objects is "read only" in Eiffel.
The iteration (loop) instruction in Eiffel does not provide a field or clause which will step the loop. The programmer must express the stepping as part of the loop. For example:
from i := 0 until i >= 10 loop my_array.put (0, i) i := i + 1 end
The example above also illustrates that Eiffel treats arrays simply as instances of the class ARRAY, providing access in the form of routine calls, in line with object-oriented ideas. Eiffel compilers optimize this access.
Eiffel's procedural coding is strictly structured. There are no instructions for exiting a loop or routine early.
Eiffel is a purely object-oriented language. Any coding which must be "close to the machine" is expected to be done in C. Eiffel provides a straightforward interface to C routines, including allowing for straight C calls within Eiffel code. Eiffel is generally closely connected to C: three of the four Eiffel compilers output no object or machine code, but only C source code as an intermediate language, to submit to a C compiler, for optimizing and portability.
Background of Eiffel
Eiffel was originally developed by Bertrand Meyer and his company Interactive Software Engineering (ISE), since renamed Eiffel Software, Inc. Eiffel 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, encapsulation, and parameter covariance. Its most important contribution to software engineering is Design by contract (DbC), 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 Object-Oriented Programming (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.
EiffelStudio, an integrated development environment for Eiffel that has recently become open source software, offers an object-oriented interface for software engineering. However, many programmers dislike it because its user interface is very different from other integrated development environments. There are two alternative, also open source implementations, SmartEiffel - the GNU implementation, and Visual Eiffel, which provides a more "traditional" interface. So does EiffelEnvision, a plugin for Microsoft Visual Studio which allows users to edit, compile, and debug Eiffel apps from within the Microsoft Visual Studio IDE. EiffelStudio and EiffelEnvision are only free for non-commercial use, though.
Specifications and standards
On the 21 June 2005 the European Computer Manufacturers Association (ECMA) approved the first international standard for Eiffel ECMA standard 367, Eiffel Analysis, Design and Implementation Language. The standard is currently (March 2006) up for acceptance as an International Standards Organization (ISO) standard.
This standard is not accepted by the SmartEiffel team, which has decided to create its own version of the language, because they think the ECMA standard throws away important principles of the original language. Eiffel Software and Gobo have committed to implementing the standard. Object Tools has not to date expressed a position.
The standard cites the following as earlier Eiffel Language specifications:
The ETL3 page requires a password for access which can be found at Bertrand Meyer's Home Page under Work in progress Differences between SmartEiffel and other implementations SmartEiffel is currently unable to compile the open-source EiffelBase library from Eiffel Software.
A "Hello World" program in Eiffel
class HELLO_WORLD create make feature make is do io.put_string ("Hello, world!%N") end end