Smalltalk
Smalltalk is a reflexive, object-oriented, dynamically typed programming language. Due to its characteristics, Smalltalk can also be considered as an object environment, where even the system itself is an object. Metaphorically, it can be considered that a Smalltalk is a virtual world where objects live that communicate with each other, by sending messages.
A Smalltalk system is made up of:
- A virtual machine
- A file called "Imagen", which contains all the objects of the system.
- A programming language (also known as Smalltalk).
- A huge library of "reusable objects".
- And generally, a development environment that can also function as a system in execution time.
Smalltalk took second place for "most loved programming language" in Stack Overflow Developer Surveys in 2017.
History
Smalltalk's origins lie in research conducted by Alan Kay, Dan Ingalls, Ted Kaehler, Adele Goldberg and others during the 1970s at Xerox's Palo Alto Research Center (known as Xerox PARC), for the creation of a computer system oriented to education. The objective was to create a system that would allow the creativity of its users to expand, providing an environment for experimentation, creation and research.
Terminology
A Smalltalk program consists solely of objects, a concept that is universally used within any Smalltalk system. Just about everything from a natural number like 4 to a web server is an object. Smalltalk objects have common characteristics:
- They have their own memory.
- They can communicate with other objects.
- They possess the ability to inherit characteristics of ancestors.
- They have processing capacity.
Objects communicate with each other by sending messages. Also, one object can provide many operations (currently this is determined by each implementation).
The definitions of these operations on objects are called methods. A method specifies the reaction of an object when it receives a message that is addressed to that method. The resolution, in the binding sense, of a message to a method is dynamic. The entire collection of methods of an object is called the messaging protocol or messaging interface of the object. The messages can be parameterized, these parameters will be objects, and the result or response of the same will also be an object.
The common characteristics of objects are captured under the notion of class, in such a way that objects grouped under a class are called instances of it. Instances are created during the execution of a program for some purpose and are automatically cleaned up when they are no longer needed by the garbage collector. Except for some special objects like very simple ones, called literals (numbers, strings, etc), each object has its own local state and represents a different instance of its class.
Features
Smalltalk is considered the first of the object-oriented languages, although in reality the first to implement object-oriented programming was Simula. In Smalltalk everything is an object, including real numbers or the Smalltalk environment itself.
As a language it has the following characteristics:
- Object orientation
- Dynamic dye
- Interaction between objects by sending messages
- Simple and common root
- Complete computational Reflection
- Waste collection
- Compilation in execution or Interpreting time (depending on the distribution or supplier)
- Multiple Implementations
Smalltalk has had a great influence on other languages such as Java or Ruby, and many of the development practices and tools currently promulgated by agile methodologies have emerged from its environment. (refactoring, incremental development, test-driven development, etc.).
The Smalltalk environment
The heavier Smalltalk implementations (VisualWorks, Squeak, VisualSmalltalk, VisualAge, Dolphin, Pharo Smalltalk, Smalltalk X) have a very different interaction environment than the typical development environment of other technologies such as Microsoft Visual Studio.Net or Eclipse. The Smalltalk environment is primarily graphical and functions as a runtime system that integrates various programming tools (Smalltalk), multimedia utilities, interfaces for executing non-native Smalltalk code, and operating system services. These capabilities, which have Influenced in the work methodology and conception of programming, translate into the tendency to consider Smalltalk more than a simple programming language. The way of developing software in Smalltalk does not consist of the typical cycle of traditional technologies: Start a text editor, compile and run and finish the application. In Smalltalk the environment itself is manipulated, commonly through the System Browser.
Syntax
Traditionally, Smalltalk does not have an explicit notation to describe an entire program. An explicit syntax is used to define certain elements of a program, such as methods, but the way such elements are structured within an entire program is generally defined by multiple implementations. The standard itself does not promote any other direction, so it defines an abstract Smalltalk program syntax, which defines all the elements that constitute a Smalltalk program and the way in which those elements are logically composed of other elements, however each implementation is free. to define and use the many possible syntaxes that conform to the standard abstract syntax. An example of a concrete syntax is the Smalltalk Interchange Format (or SIF) defined in the same standard.
Smalltalk-80 syntax tends to be minimalist. This means that there are a small number of reserved words and declarations in existence compared to most popular languages. Smalltalk has a set of 6 reserved words: self, super, nil, true false and thisContext.
Garbage Collection
Smalltalk does not need to explicitly evict objects, so it does not provide mechanisms for doing so. Implementations use garbage collection techniques to detect and reclaim memory space associated with objects that will no longer be used on the system. In Smalltalk garbage collection is built-in configurable. The way the garbage collector runs is in background, that is, as a non-interactive low-priority process, although in some implementations it is possible to run it on demand, and it is possible to define special memory configurations for each system through policies (for example in VisualWorks). The frequency and characteristics of the collection depend on the technique used by the implementation. Additionally, some Smalltalk implementations provide support for completion mechanisms such as the use of ephemerons.
Computational Reflection
Smalltalk-80 provides computational and structural reflection, as it is a self-implemented system. Structural reflection manifests itself in that the classes and methods that the system defines are themselves objects as well and are part of the system itself. Most Smalltalk implementations tend to expose the Smalltalk compiler to the programming environment, allowing (textual) source code to be compiled within the system, transforming itself into method objects, which are commonly instances of the CompiledMethod class. >. The system generally embeds these methods in classes, storing them in the method dictionary of the class to which you want to add the behavior that performs the method. This, as well as the incorporation of new classes to the system, is done within the system itself; although most implementations have visual tools that hide the complexity of interacting with the class that usually handles such tasks, the ClassBuilder.
The computational reflection of Smalltalk-80 manifests itself in the possibility of observing the computational state of the system. In the languages derived from the original Smalltalk-80, during the sending of messages between objects, each object receiving a message consults its class to access the methods it defines. If the method is found in the class, it is said to be "activated" the method. This activation of a currently executing method is accessible via a keyword called thisContext. By sending messages to thisContext you can query questions such as "who sent me this message?". These facilities make it possible to implement Prolog-style coroutines, continuations, or back-tracking without the need to modify the virtual machine. One of the most interesting uses of this facility is in Avi Bryant's Seaside web framework.
Smalltalk Examples
In Smalltalk everything is an object, and messages are sent to an object. For example:
1 + 1
It means that the object "1" we send you the message "+" with the external collaborator, another object, "1". This example then results in the object "2".
Transcript show: 'Hello, world!'
In the typical Hello World, the object is Transcript, which receives the show message with the external collaborator 'Hello World!'.
To instantiate an object, simply send a new message to a class:
Class of the Object new
To get the vowels of a text string:
'This is a text' select: [chuckles]:aCharacter 日本語 aCharacter isVowel].
Contenido relacionado
Protocol for Simple Mail Transfer
Help: FAQ
Help:How to edit a page