Self (programming language)
|developer||David Ungar, Randall Smith|
|Current version||2017.1 ("Mandarin")
(May 24, 2017)
|operating system||Linux , macOS , etc. a.|
|programming language||dynamic, strictly typed|
|category||Object-oriented programming language ( prototype-based programming ), IDE|
Self [ sɛlf ] is a programming language that was designed by Randall B. Smith and David Ungar with a focus on expressiveness and malleability . To achieve these goals, a purely prototype- based object model was developed with uniform access to the state and behavior of the objects, i.e. to their attributes and methods. In contrast to other programming languages, it is possible in Self to inherit the state of objects and to dynamically adapt the inheritance at runtime.
The last version 4.3 released by Sun was released in June 2006. It runs on Intel and PowerPC- based Apple computers and on Sun SPARC , but not on Linux or Microsoft Windows . The further development will then no longer be operated by Sun and is currently happening independently.
Ideas and concepts that have their original origin in the programming language Self have been incorporated into the Squeak Smalltalk system over the years and continued in programming languages such as Slate or io .
The outstanding self property is probably the self universe , a kind of graphical user interface ( GUI ) within which the self runtime system can be interacted with. An interaction usually takes place via the mouse and / or the keyboard. The self-universe is visualized using the GUI framework Morphic . When a person enters the self-universe, this always happens through the lobby, an allusion to the reception hall of a hotel. It contains all objects, modules, namespaces and traits in the system . The concept of the (programming) universe and the Morphic concept were implemented almost identically in the Squeak Smalltalk system .
Despite the various ports, one should keep in mind that the Self programming language is a rather academically motivated undertaking. Nevertheless, the innovations tested in Self had and still have an impact on newer object-oriented programming languages.
Self was originally designed in 1986 by David Ungar and Randall B. Smith while working at the Xerox Parc Institute. After Smalltalk-80 was released, their goal was to advance software technology. They moved to Stanford University and released the first working compiler the following year . The first complete self-system was published in 1990; the following year, the group moved to Sun Microsystems , where the self-system was used as an experimental field for development. This was where Urs Hölzle came in, who developed new compiler and VM technologies and was involved in the development of the Strongtalk programming language . In 1995, development at Sun Microsystems was officially discontinued: “Self 4.0 is, in a certain sense, the culmination of the Self project, but it is not officially continued at Sun.” However, there was still the developer group at Stanford University and various others other initiatives. Despite the official stop, version 4.1.6 was released in September 2002. Version 4.2 was released in April 2004 and version 4.3 in June 2006. Version 4.4 has been available since July 2010. In February 2011 an experimental snapshot of a version 4.5 was released. However, it took until January 2014 for a finished version to be published under the name "Mallard".
The development environment
The self-system can be understood as a prototype-based small talk variant. The developers call the language the Smalltalk dialect, meaning that the syntax of the language and the object library are largely based on Smalltalk. Smalltalk's class browser has been replaced by an object browser.
Like Smalltalk , Self is based on a runtime environment and a virtual machine . Like other systems based on virtual machines, self-programs always need the associated storage environment in order to be able to run. As a result, applications are often delivered as an image of memory. This memory image is also called a snapshot .
An alternative to the delivery of snapshots are text files into which changes to the system or even entire modules can be exported and imported via the so-called transporter. These text files can be edited with any editor. They are comparable to a C source code, but much more powerful. The entire system can be controlled with it. Since these text files can also be read in automatically when the system is started, Self can be used as a scripting language just like Perl .
The typical size of a snapshot is approx. 13 MB for a complete system with JIT compiler , interpreter and the development environment . The advantage inherited from Smalltalk is that work on the system can be interrupted at any time, even in the middle of a calculation, and saved in snapshots. All changes, i.e. what corresponds to programming, a drawing or any kind of work with the system in classic systems, can be available again the next time you restart. The system wakes up where it was left. Self is persistent .
The self-development environment enables source code, objects, inheritance, the object hierarchy or individual values to be changed at runtime. This is made possible by the ability to multitask and a debugger that is seamlessly integrated into the system . This leads to an incremental kind of "on the fly" development. Some modern methods of software development, such as agile software development or adaptive software development , propagate something similar.
The development environment is tailored to the rapid and continuous modification of individual objects. The refactoring of the "object" design is almost as simple as removing a method via drag and drop , in order to assign as a new object. Simpler tasks such as creating test methods can be handled by a copy. The corresponding method is then dragged into the object copy so that it can be changed. Compared to traditional systems, only the newly created object also has new source code. As a result, there is no need to recompile any code to test it. As soon as it has been ensured that the test method works according to the specification, it can be copied back to the original object.
The following is only intended to give a first impression of this programming language. For more information, see The Self Language and Teaching Self and Prototype-Based Programming .
Self is an object-oriented, prototype-based programming language. A few simple constructs form the basis: prototypes, slots and behavior. Unlike the concepts of Smalltalk and many other programming languages, there are no classes or variables. The programming model is essentially based on communicating objects and a simple form of inheritance.
In Self , programs are not actually written - instead, the "Self-Universe" is described. Here there are only objects that communicate with each other by sending messages. This sending of a message corresponds to a procedure call in classic programming. New objects are created by cloning existing objects.
The prototype concept enables interactive programming: the programmer interacts with the objects in the self-universe.
Self does not distinguish between the state of an object and its behavior. The state of an object results from its properties, i.e. the values of its attributes. The behavior of an object is described in its methods. The fact that there is no difference between the state and the behavior reduces the gap that exists in other programming languages between objects, procedures and variables. Everything is one in Self.
For example, calling up a property - provided the object or one of its ancestors has this property - provides its value:
In this statement, the property name of the object aPerson is called or queried. The following statement assigns a value to the same property:
Objects consist of (theoretically) any number of slots . A slot has a name and can contain an attribute (value) or a method (procedure). In any case, it is an object that he picks up. An object therefore consists of one or more slots for objects that can be accessed using the name.
A method object contains one or more statements that are executed when the method object is called. An attribute object returns itself when it is called like a method object .
New objects are created by cloning. For this purpose, a suitable object is used as a prototype, so to speak as a master copy. Every object can be used as a prototype.
A short program
Here is the classic Hello World program :
'Hello, World!' print.
The period at the end of the statement means that the return of the value - which actually occurs with all messages - is suppressed or avoided. Here again in a more elaborate form:
(desktop activeWindow) draw: (labelWidget copy label: 'Hello, World!').
Explanation: The first thing the desktop object is asked for is the active window. The desktop object sees this in his list of the current window by and returns the corresponding object. A previously created copy of the labelWidget object is entered for this object in the slot named draw . Before that happens, the labelWidget copy was sent a message that it should create a slot with the name label and the value Hello, World! should drop.
Theoretically, each self-object is an independent entity. There are no classes, no meta-classes, etc. to specify the properties and behavior of an object. Changes to the object itself do not affect the behavior of other objects. In individual cases, however, this would make sense. Basically, an object only understands the messages that can also be clearly assigned to one of its slots. However, if one or more slots refer to a parent object, the object is able to delegate messages to these parent objects if it is unable to interpret them itself. In this way, Self manages tasks that would have required the vehicle of inheritance in traditional object-oriented languages. This procedure is also used to implement namespaces.
In order to be able to better illustrate the connection between inheritance, an object called BankAccount should be assumed at this point . This should be used in a simple accounting application. It makes sense to equip the object bank account with the methods deposit and withdraw . Additional slots for simple data are also required. The object just specified is a prototype, but already represents a fully functional bank account.
If you create a clone of the BankAccount object for “Bob's Account”, you get a copy that is identical to the original prototype. However, a more effective approach is to create a simple object called a traits object that contains all of the elements one would normally associate with a class.
As in the current example, the BankAccount object would, as a logical consequence, have neither a deposit nor a withdraw method. Rather, it now has a parent object that contains these methods. In this way it is possible to create innumerable copies of the bank account object, the behavior of which can be changed by a single change to the parent object.
How does the situation described differ from the traditional classes of an OO language? What does the following construct mean:
myObject parent: someOtherObject.
This construct changes the "class" of myObject at runtime by changing the value associated with the slot parent * (the asterisk is part of the slot name and therefore does not belong to the message that this slot receives).
At this point, the question arises of how copies of a Self object must be modified so that they contain new slots. If you use the graphical self-programming environment, this is pretty easy. From a programmatic point of view, it makes the most sense to create what is known as a mirror object of the object and then modify it. To do this, you send corresponding messages to this mirror object.
One way that leads to the goal faster is to use the primitive _AddSlots : . A primitive has the same syntax as a normal keyword message. However, its name begins with an underscore. The _AddSlots primitive is now considered obsolete; because of its brevity it is used here anyway.
One of the first examples involved refactoring a simple class called a vehicle. Refactoring became necessary in order to be able to differentiate between passenger and heavy goods vehicles. If you try to implement the refactoring in Self, it looks something like this:
_AddSlots: (| vehicle <- (|parent* = traits clonable|) |).
Since the recipient of the _AddSlots: primitive was not specified, this is automatically "self". If an expression is entered and executed within the shell prompt of the development environment, the object that receives the resulting messages is always the lobby object. The argument passed to _AddSlots: is the object that will be copied into the recipient object. In this case it is an object literal with exactly one slot. The name of the slot is vehicle , and its value is another object literal. The notation "
<-" implies another slot called vehicle: which is necessary to change the value of the first slot.
=" indicates a slot with a constant value. For this reason there is no corresponding parent: slot. The object literal, which represents the initial value vehicle , has a slot in order to be able to react to messages from the cloning. An object that is actually empty is represented by
(). Such an object is not able to receive messages.
vehicle _AddSlots: (| name <- 'automobile'|).
In this example, the message recipient is the previous object which, in addition to the parent * slot, contains both a name and a name: slot.
_AddSlots: (| sportsCar <- vehicle copy |). sportsCar _AddSlots: (| driveToWork = (''some code, this is a method'') |).
Despite the fact that the objects vehicle and sportsCar were previously identical objects, the current object now contains a slot that is assigned a method that did not previously exist. Methods can only be contained in slots with a constant value.
_AddSlots: (| porsche911 <- sportsCar copy |). porsche911 name:'Bobs Porsche'.
- 4.0: runs on SPARC-based Sun workstations with SunOS 4.1.x, Solaris 2.3, or Solaris 2.4 as the operating system
- 4.1.6: also runs as an application under Mac OS X. Support for Mac OS 9 has been discontinued
- 4.2.1: also runs on G3 Macs
- 4.3: also runs on Intel- based Macs
- 4.4: runs on Mac OS X and Linux (x86)
- 4.5: runs on Mac OS X and Linux
- A Self Bibliography (English, literature list at Sun's former Self-Group)
List of some self-implementations
- The original self-implementation from Sun
- Self-implementation for x86 - Linux and - Cygwin
- Current further development and documentation
- release 4.3 ( Memento of the original from June 28, 2008 in the Internet Archive ) Info: The archive link was inserted automatically and not yet checked. Please check the original and archive link according to the instructions and then remove this notice. at sun.com
- release 4.0 ( Memento of the original dated May 31, 2008 in the Internet Archive ) Info: The archive link was inserted automatically and has not yet been checked. Please check the original and archive link according to the instructions and then remove this notice. at sun.com
- release 4.1 ( Memento of the original dated May 31, 2008 in the Internet Archive ) Info: The archive link was inserted automatically and has not yet been checked. Please check the original and archive link according to the instructions and then remove this notice. at sun.com
- Version 4.4
- Version 4.5 (formerly Snapshot) on blog.selflanguage.org
- Version 4.5 (Release "Mallard") on blog.selflanguage.org
- language ( Memento of the original from June 20, 2008 in the Internet Archive ) Info: The archive link was inserted automatically and not yet checked. Please check the original and archive link according to the instructions and then remove this notice. at research.sun.com
- teaching ( Memento of the original from June 4, 2008 in the Internet Archive ) Info: The archive link was inserted automatically and not yet checked. Please check the original and archive link according to the instructions and then remove this notice. at research.sun.com