Sather

From Wikipedia, the free encyclopedia

(Redirected from Sather programming language)
Jump to: navigation, search
Sather
Paradigm object-oriented, functional
Appeared in 1990
Designed by Steve Omohundro
Developer Free Software Foundation, University of Karlsruhe, University of Waikato
Typing discipline static, strong
Major implementations GNU Sather, Sather-K, Sather-W
Influenced by Eiffel

Sather is an object-oriented programming language. It originated circa 1990 at the International Computer Science Institute at the University of California, Berkeley, developed by an international team led by Steve Omohundro. It supports garbage collection and generics by subtypes.

Originally, it was based on Eiffel, but it has diverged, and now includes several functional programming features. It is probably best to view it as an object-oriented language, with many ideas borrowed from Eiffel. Even the name is inspired by Eiffel; the Sather Tower is a recognizable landmark at Berkeley. Sather also takes inspiration from other programming languages and paradigms: iterators, design by contract, abstract classes, multiple inheritance, anonymous functions, operator overloading, contravariant type system. Some of these features are normally only found in functional programming languages.

The original Berkeley implementation is now maintained by many people, not all at Berkeley, and has been adopted by the Free Software Foundation therefore becoming GNU Sather. There are at least two other implementations: Sather-K from the University of Karlsruhe, and Sather-W from the University of Waikato.

The former ICSI sather compiler (now GNU Sather) is implemented as a compiler to C, i.e., the compiler does not output object or machine code, but takes Sather source code and generates C source code as an intermediate language. Optimizing is by the C compiler, Sather code often performs better than the corresponding C++ code, and the generated C code can always be optimized by hand.

The GNU Sather compiler, written in Sather itself, is dual licensed under the GNU GPL & LGPL.

class HELLO_WORLD is
 main is 
  #OUT+"Hello World\n"; 
 end; 
end;

A few remarks:

  • Class names are ALL CAPS; this is not only a convention but is enforced by the compiler.
  • The method called main is the entry point for execution. It may belong to any class, but if this is different from MAIN, it must be specified as a compiler option.
  • # is the constructor symbol, calling method create of the corresponding class; here it is used for instantiating the OUT class, which is actually stdout.
  • The + operator has been overloaded here to stand for stream append.
  • Operators such as + are syntactic sugar for conventionally-named method calls: a + b stands for a.plus(b). The usual arithmetic precedence conventions are used to resolve the calling order of methods in complex formulae.
  • The program layout, reminiscent of Sather's Eiffel lineage, allows for pre- and post-conditions, not shown here.

class MAIN is
  main is
    loop
     i := 1.upto!(10);
     #OUT + i + "\n";
    end;
  end;
end;

This program prints numbers from 1 to 10.

The loop ... end construct is the preferred means of defining loops (although while and repeat-until are also available). Within the construct, one or more iterators may be used. Iterator names always end with an exclamation mark (this convention is enforced by the compiler). upto! is a method of the integer class INT accepting one once argument, meaning its value will not change as the iterator yields. upto! could be implemented in the INT class like this:

 upto!(once m:INT):SAME is
   i: INT := self; -- initialise i to the value of self, that is the integer of which this method is called
   loop
     if i>m then 
       quit -- leave the loop when i goes beyond m
     end;
     yield i; -- else use i as return value and stay in the loop
     i := i + 1; -- and increment
   end;
 end;

Type information for variables is denoted by a postfix syntax variable:CLASS. The type can often be inferred and thus the typing information is optional, like in anInteger::=1. SAME is a convenience pseudo-class referring to the current class.

Advanced Search
Included Web Search Engines


Safe Search

close

Top Matching Results

Occasionally Search.com will highlight specialized results that are based on the context of your query. Examples of specialized results include specific links to news, images, or video.

Top Matching Results may highlight information from other Search.com pages, content from the CNET Network of sites, or third party content. The listings are based purely on relevance. Search.com does not receive payment for listings in this section but our partners that provide this data may get paid for listing these products.

Sponsored Links

This section contains paid listings which have been purchased by companies that want to have their sites appear for specific search terms and related content. These listings are administered, sorted and maintained by a third party and are not endorsed by Search.com.

Search Results

Search.com sends your search query to several search engines at one time and integrates the results into one list which has been sorted by relevance using Search.com's proprietary algorithm. You can customize the list of search engines included in your metasearch from the preferences.

The search engines that are used in your metasearch may allow companies to pay to have their Web sites included within the results. To view the Paid Inclusion policy for a specific search engine, please visit their Web site. Search.com does not accept payment or share revenue with any search engine partner for listings in this section.