Smalltalk


Smalltalk is a programming language object-oriented , reflexive and dynamically typed . It was one of the first programming languages ​​to have a fully graphical integrated development environment. It was established in 1972 . It is inspired by the Lisp and Simula languages . It was designed by Alan Kay , Dan Ingals , Ted Kaehler , Adele Goldberg atthe Xerox Palo Alto Research Center . The language has been formalized as Smalltalk-80 and has since been used by a large number of people.

Smalltalk was a great influence in the development of many programming languages, including: Objective-C , Actor  (in) , Java and Ruby .

Many of the software engineering innovations of the 1990s come from the Smalltalk programmer community, such as design patterns , extreme programming (XP), and refactoring . Ward Cunningham , the inventor of the wiki concept , is also a Smalltalk programmer.

History

There are many variants of Smalltalk, as is often the case with programming languages 1 . The word Smalltalk is often used to refer to Smalltalk-80, the first version to have been made public in 1980.

Smalltalk is the product of a group of researchers led by Alan Kay at Xerox’s Palo Alto Research Center (PARC) ; Alan Kay designed the first versions of Smalltalk that were implemented by Dan Ingalls . The first version, called Smalltalk-71, was created in a few mornings on the bet that a programming language based on the idea of ​​sending messages inspired by Simula could be realized in “a page of code”.

Concepts

The main concepts of Smalltalk are:

  • ” Everything is object “: strings , integers, booleans, class definitions , code blocks, stacks, and memory are represented as objects;
  • Everything is changeable. For example, the language allows you to change IDEs during use, without recompiling or restarting the application. Similarly, it is possible to create new control instructions in the language. Some implementations allow you to change the language syntax, or how the garbage collector works;
  • The typing is dynamic , thus giving a certain conciseness to the language;
  • A memory crumb collector is built-in and transparent to the developer;
  • An exceptions handling system with recovery is provided;
  • Smalltalk programs are usually compiled bytecode , executed by a virtual machine ;
  • The compilation is done on the fly : modern commercial virtual machines compile the bytecode to the native machine code in order to obtain better performance, a technique that Smalltalk-80 was the pioneer, developed by ParcPlace Systems in the mid- 1980s . This idea was adopted by the Java programming language some ten years later and renamed ” just-in-time compilation “, or JIT;
  • A class can inherit from a single other class ( simple inheritance ).

Description

Smalltalk implements, in addition to basic principles of objects ( class , object , inheritance , polymorphism ), original concepts ( metaclass ) and introduces the concept of persistent object, exception handling and the principle Model-View-Controller .

A surprising feature of Smalltalk is the complete absence of control commands built into the language: if-then-else, for, while, etc. All these instructions are implemented using objects. For example, decisions are made by sending an ifTrue message to a Boolean object, and passing a piece of code to execute if the Boolean is true. The only built-in appearance is the syntax for sending a message to an object.

The following example illustrates the Smalltalk programming style. The execution of this code makes it possible to find the vowels in a string. The | declare the variables : declare the parameters:

| AString vowels |
AString : = 'This is a string' .
Vowels : = aString select: [ : aCharacter | ACharacter isVowel ] .

At the last line, the aString string receives a select: message with a block of code as an argument. Here is the code of the super-class Collection that does the job:

Collection >> select: aBlock
| NewCollection |
NewCollection : = self species new .
Self do: [ : each |
 ( ABlock value: each )
 ifTrue: [ newCollection add: each ]] .
^ NewCollection

This code replies to the message by iterating through its members (it is the method do 🙂 in evaluating the aBlock code to each character; ABlock (aCharacter isVowel) once evaluated creates a boolean, which is then sent to ifTrue :. If the boolean is true, then the character is added to the string that will be returned. As select is defined in the abstract class Collection, it could also be used in this way:

| Rectangles aPoint |
rectangles : = OrderedCollection
 with: ( Rectangle left: 0 right: 10 top: 100 bottom: 200 )
 with: ( Rectangle left: 10 right: 10 top: 110 bottom: 210 ) .
APoint : = Point x: 20 y: 20 .
Collisions : = rectangles select: [ : aRect | ARect containsPoint: aPoint ] .

Notes and references

  1. ↑ ( in ) ” implementations of Smalltalk [ archive ] , The World of Smalltalk (accessed 24 April 2013 ) .

Bibliography

  • Clavel Gilles, Programming objects with Smalltalk ( ISBN  978-2-225-85157-5 )
  • Briffaut X. and Sabah G. , Smalltalk: Object-oriented programming and application development ,
  • Erard PJ and Déguénon P., Simulation by discrete events, Concept and realizations in Simula, Ada and Smalltalk, PPUR, coll. Computer Science, Lausanne, 1996
  • Goldberg, Adele (December 1983). Smalltalk-80: The Interactive Programming Environment . Addison-Wesley. ( ISBN  0-201-11372-4 ) .
  • Goldberg, Adele; Robson, David (May 1983). Smalltalk-80: The Language and its Implementation . Addison-Wesley. ( ISBN  0-201-11371-6 ) .