The Differences Between Sather and Eiffel
Total Page:16
File Type:pdf, Size:1020Kb
The Differences Between Sather and Eiffel CLOS showed it to be far too within some class. Class names are inefficient for the desired purposes. in a global namespace and elass Eiffel was chosen as the language of feature names are interpreted relative choice and a system with about 150 to the elass in which they appear. classes was developed over a period These two levels of namespace of 18 months. This experience hierarchy appear exactly right for demonstrated the power of many projects with several hundred classes Eiffel concepts, but also exposed and several tens of features within many weaknesses in the design and each class. Aspects of Eiffel's clean Sather is a new object oriented implementation for our purposes. syntax have been retained. Each language derived primarily from The primary shortcomings from our construct is self bracketed by Eiffel. Many design decisions must perspective were the inefficiency of keywords and there is no need for be made in the design of a language the generated code and growing "begin/end" constructs. The and different priorities give rise to semantic complexity of the grammar is LALR(I) and easily fits different decisions. Every language language. We were also beginning on a page. is a compromised response to a large the design of object oriented number of conflicting goals. This constructs for parallel computers and Added Features article focuses on the priorities needed a non-proprietary compiler Several features not found in which informed the design of Sather. base on which to build. For these Eiffel were added. Shared and Eiffel reflects a different set of reasons, we undertook the design of constant features in Sather are priorities than those described here a more efficient, simplified language and may well be more appropriate variables that are allocated per class which still retained the desirable and may be directly accessed by any for certain users. features of Eiffel. The design went object from the class. Sather arrays The International Computer through many iterations and many are a part of the language rather than Science Institute is involved in a people made suggestions and being merely a special class as in variety of projects that require the refinements. Eiffel. The memory for objects may construction of complex software. The fundamental language have a variable sized array portion Some examples include a general features were retained from Eiffel. after the storage for features. purpose connectionist simulator; a The two primary forms of reuse in Standard syntax is used to access high-level vision system based on Sather are based on parameterized and assign to array elements ( ego intricate geometric data structures; classes and object oriented dispatch. "a[5]:=3", "e:=b[17,c+d]", the support software for a high-speed Sather is garbage collected and "f[7,2,3].foo"). The code generated parallel computing engine for speech supports multiple inheritance. for Sather array access often avoids recognition; and CAD tools for Classes provide modularity and a double indirection needed for an integrated circuit design. Each of encapsulation and all code is defined equivalent Eiffel array access. these applications requires both complex data structures and very high efficiency. The complexity of these projects suggested that the benefit of switching from C to an object oriented language would far outweigh the startup costs. Sather was initially developed in response to the needs of the vision project. Preliminary work with C++ and Objective C showed them to be insufficiently elean and modular for the needed tasks. The lack of garbage collection, parameterized types, and at the time, multiple inheritance prevented the development of software modules with the desired level of 12 encapsulation and reuse. Work with by Stephen Omohundro Arrays are used extensively in "RECTANGLE". As long as statement list and "assert" for a the library code. Local variables in "add_vertex" is not applied to a conditionally compiled boolean test. Sather may be declared at the point "$POLYGON"variable, this causes The inheritance rules are much of use (as in C++) rather than in a no problems in Sather. special"local" section at the simpler in Sather than in Eiffel. Sather uses the more natural There is no "rename" construct to beginning of a routine. Class "contravariant" rule for constraining access ancestor features under a features may be declared "private" at the types of function arguments in different name. Eiffel has complex the point of definition (instead of not inherited classes, while Eiffel uses a rules for multiple inheritance paths appearing in an "export" list at the "covariant" rule. This means that in to the same ancestor class in the beginning of a class definition). A Sather the arguments of routines inheritance DAG. In Sather, the "break" statement to exit from loops which are used in a dispatched effect of inheritance is exactly as if and a "retumHstatement to exit from fashion must have a type in a the parent class were textually routines were added. The "switch II descendent which is a super-type of copied into the descendent class at statement (analogous to the Eiffel the type in the parent rather than a the point at which the parent is "inspect" statement) allows arbitrary sub-type. This ensures that any code inherited. The definitions of later expressions in the target clauses. which has valid types on the parent Conditionally compiled assertions attributes override the definitions of will still have valid types on the earlier attributes with the same and debug statements are named in child. Eiffel cannot make this natural name. In Eiffel, "Create" and Sather and an arbitrary subset of choice because it would prevent "Clone" are different from every names may be activated on any many common uses of inheritance. other function in that they change given compilation. As in C++, Because Sather makes the distinction the value of a variable they are Sather allows direct access to class between dispatched and applied to. In Sather the only way to routines, shareds and constants using non-dispatched type declarations, change the value of a variable is to the syntax "FOO::routine(S,6y. and only applies the type constraints assign to it. Sather adds the "type" The Sather type system has a to dispatched usage, these common feature that returns the tag ofan major addition to that of Eiffel. In uses are still available in a object and is necessary to do Eiffel, a variable may hold an object contravariant framework. old-style switch-based dispatch. of any descendent class of its Sather is much smaller than declared class. In Sather, the Simplifications Eiffel. Eiffel keywords which were declaration "a:FOO" means that the Several Eiffel features were eliminated in Sather include: variable "a" will hold an object eliminated or simplified. Expanded "as", "BITS", "CloneH, HCreaten, whose type is "FOO", while classes and binary operator H deferred", "define", H div", "do", "a:$POO" means that "a" may hold overloading were viewed as creating "ensure", "expanded", "export", any descendent of "POO". This often more complexity than they "external", "feature", " Porget" , allows the compiler to do better type elim:inated. Sather provides library "from", "implies", "inherit","infixlI, checking and to generate far more classes to support exception "invariant", "is" , "language", "like", efficient code than it otherwise handling rather than building it into "localII , "mod", "name", could. It also introduces an extra the language. The complex liNochange", "obsolete", "old", level of specification which can exception handling in Eiffel is a Honce", "prefix", "redefine", clarify the semantics in situations major source of inefficiency. Eiffel "rename", "repeat", "require", with complex inheritance. In Sather, IIonce" functions were eliminated "rescue", "retry", "unique", a descendent class need not define because the "shared" attributes in A "variant", "Void". "xor".and II ". all of the features that its ancestors Sather are simpler and may be used In several cases features have been define. Such a requirement only to perform the same function. The moved from the language into an holds for those features which are Nlike" construct was eliminated. The appropriate library class. applied to "$" variables. Thus if main use for this in our code was to IIFOO" defines the routine declare something to have the type The Sather Environment Hfoo_rout", it's descendents need of the current class. A special The Sather implementation and only define it if a dispatched access declarator "SELF TYPE" is used in programming environment is Ha.fooJout" appears applied to a Sather to declare ;uch variables. The somewhat different from Eiffel's. variable declared as "a:$FOO". This conditionally compiled statements in More than one class may be defined solves a problem that has recently Eiffel ("check", "ensure", in a file and the file name need have received much discussion. The class "invariant", "require", "variant", and nothing to do with the class name. "POLYGON" might define a routine "debug" ) were reduced to just Class names may be of any length "add vertex", which is inappropriate "debug" for a conditionally compiled 13 and are not restricted to file names ~~o~r~th~-e~d~e~sc~en~d~en~t~cl~a~ss~_________________________________________________________________ Sather Differences (continued from page 13) problems, including Towers of An extensive library of Sather Hanoi, Eight Queens, etc. The allowed by the operating system. classes is being developed. As with special features of RIse machines Many times a natural conceptual unit the compiler, the design of the (register windows, etc.) may consists of many small classes and library focuses on efficiency and exacerbate the efficiency problem it's convenient to put them in the extensively uses the efficiency with the generated Eiffel code. same file. It's also convenient for enhancing features of Sather.