74189

Object-oriented programming languages and tools. Evolution of Smalltalk

Лекция

Информатика, кибернетика и программирование

The lnguge ws first generlly relesed s Smlltlk80. Smlltlklike lnguges re in continuing ctive development nd hve gthered loyl communities of users round them. NSI Smlltlk ws rtified in 1998 nd represents the stndrd version of Smlltlk.

Английский

2015-01-22

41 KB

0 чел.

Lecture 8. Object-oriented programming languages and tools. Part 2.

8.1 Evolution of Smalltalk1

Smalltalk is an object-oriented, dynamically typed, reflective programming language. The language was first generally released as Smalltalk-80. Smalltalk-like languages are in continuing active development, and have gathered loyal communities of users around them. ANSI Smalltalk was ratified in 1998 and represents the standard version of Smalltalk.

Smalltalk was the product of research led by Alan Kay at Xerox Palo Alto Research Center (PARC); Alan Kay designed most of the early Smalltalk versions, which Dan Ingalls implemented.

Smalltalk-80 was the first language variant made available outside of PARC, first as Smalltalk-80 Version 1, given to a small number of firms (Hewlett-Packard, Apple Computer, Tektronix, and DEC) and universities (UC Berkeley) for “peer review” and implementation on their platforms. Later (in 1983) a general availability implementation, known as Smalltalk-80 Version 2, was released as an image (platform-independent file with object definitions) and a virtual machine specification. ANSI Smalltalk has been the standard language reference since 1998.

Two of the currently popular Smalltalk implementation variants are descendants of those original Smalltalk-80 images. Squeak is an open source implementation derived from Smalltalk-80 Version 1 by way of Apple Smalltalk. VisualWorks is derived from Smalltalk-80 version 2 by way of Smalltalk-80 2.5 and ObjectWorks (both products of ParcPlace Systems, a Xerox PARC spin-off company formed to bring Smalltalk to the market). As an interesting link between generations, in 2001 Vassili Bykov implemented Hobbes, a virtual machine running Smalltalk-80 inside VisualWorks. (Dan Ingalls later ported Hobbes to Squeak.)

Object-oriented programming with Smalltalk.

As in other object-oriented languages, the central concept in Smalltalk-80 is that of an object. An object is always an instance of a class. Classes are “blueprints” that describe the properties and behavior of their instances. For example, a GUI’s window class might declare that windows have properties such as the label, the position and whether the window is visible or not. The class might also declare that instances support operations such as opening, closing, moving and hiding. Each particular window object would have its own values of those properties, and each of them would be able to perform operations defined by its class.

A Smalltalk object can do exactly three things:

  •  Hold state (references to other objects).
  •  Receive a message from itself or another object.
  •  In the course of processing a message, send messages to itself or another object.

The state an object holds is always private to that object. Other objects can query or change that state only by sending requests (messages) to the object to do so. Any message can be sent to any object: when a message is received, the receiver determines whether that message is appropriate. Alan Kay has commented that despite the attention given to objects, messaging is the most important concept in Smalltalk.

Smalltalk is a “pure” object-oriented programming language, meaning that, unlike Java and C++, there is no difference between values which are objects and values which are primitive types. In Smalltalk, primitive values such as integers, booleans and characters are also objects, in the sense that they are instances of corresponding classes, and operations on them are invoked by sending messages. A programmer can change or extend (through subclassing) the classes that implement primitive values, so that new behavior can be defined for their instances—for example, to implement new control structures—or even so that their existing behavior will be changed. This fact is summarized in the commonly heard phrase “In Smalltalk everything is an object”, which may be more accurately expressed as “all values are objects”, as variables are not.

Since all values are objects, classes themselves are also objects. Each class is an instance of the metaclass of that class. Metaclasses in turn are also objects, and are all instances of a class called Metaclass. Code blocks—Smalltalk’s way of expressing anonymous functions—are also objects

Influences.

Smalltalk was one of many object-oriented programming languages based on Simula. Smalltalk was also one of the most influential programming languages. Virtually all of the object-oriented languages that came after—Flavors, CLOS, Objective-C, Java, Python, Ruby, and many others—were all influenced by Smalltalk. Smalltalk was also one of the most popular languages with the Agile Methods, Rapid Prototyping, and Software Patterns communities. The highly productive environment provided by Smalltalk platforms made them ideal for rapid, iterative development.

Smalltalk emerged from a larger program of ARPA funded research that in many ways defined the modern world of computing. In addition to Smalltalk working prototypes of things such as hypertext, GUIs, multimedia, the mouse, telepresence, and the Internet were developed by ARPA researchers in the 1960s. Alan Kay (one of the inventors of Smalltalk) also described a tablet computer he called the Dynabook which was essentially a design for an iPad.

Smalltalk environments were often the first to develop what are now common object-oriented software design patterns. One of the most popular is the Model–view–controller pattern for User Interface design. The MVC pattern enables developers to have multiple consistent views of the same underlying data. It's ideal for software development environments, where there are various views (e.g., entity-relation, dataflow, object model, etc.) of the same underlying specification. Also, for simulations or games where the underlying model may be viewed from various angles and levels of abstraction.

In addition to the MVC pattern the Smalltalk language and environment were tremendously influential in the history of the Graphical User Interface (GUI) and the What You See Is What You Get (WYSIWYG) user interface, font editors, and desktop metaphors for UI design. The powerful built-in debugging and object inspection tools that came with Smalltalk environments set the standard for all the Integrated Development Environments, starting with Lisp Machine environments, that came after.

8.2 C++2

C++ was developed by Bjarne Stroustrup of AT&T Bell Laboratories in the early 1980's, and is based on the C language. The name is a pun – “+” is a syntactic construct used in C (to increment a variable), and C++ is intended as an incremental improvement of C. Most of C is a subset of C++, so that most C programs can be compiled (i.e. converted into a series of low-level instructions that the computer can execute directly) using a C++ compiler.

C is in many ways hard to categorise. Compared to assembly language it is high-level, but it nevertheless includes many low-level facilities to directly manipulate the computer's memory. It is therefore an excellent language for writing efficient “systems” programs. But for other types of programs, C code can be hard to understand, and C programs can therefore be particularly prone to certain types of error. The extra object-oriented facilities in C++ are partly included to overcome these shortcomings.

ANSI/ISO C++.

The American National Standards Institution (ANSI) and the International Standards Organisation (ISO) provide “official” and generally accepted standard definitions of many programming languages, including C and C++. Such standards are important. A program written only in ANSI/ISO C++ is guaranteed to run on any computer whose supporting software conforms to the standard. In other words, the standard guarantees that standard-compliant C++ programs are portable. In practice most versions of C++ include ANSI/ISO C++ as a core language, but also include extra machine-dependent features to allow smooth interaction with different computers' operating systems. These machine dependent features should be used sparingly. Moreover, when parts of a C++ program use non-compliant components of the language, these should be clearly marked, and as far a possible separated from the rest of the program, so as to make modification of the program for different machines and operating systems as easy as possible. The four most significant revisions of the C++ standard are C++98 (1998), C++03 (2003) and C++11 (2011) and C++14 (2014). The next iteration is currently expected in 2017.

There are several editors available for UNIX-based systems. Two of the most popular editors are emacs and vi. For the compiler and linker, there is the GNU g++ compiler/linker, and for the debugger  the GNU debugger gdb. For those that prefer an integrated development environment (IDE) that combines an editor, a compiler, a linking program and a debugger in a single programming environment (in a similar way to Microsoft Developer Studio under Windows NT), there are also IDEs available for UNIX (e.g. Eclipse, xcode, kdevelop etc.).

Example. “Hello world” program.

//-- Hello world C++

#include <iostream.h>

#include <conio.h>

using namespace std;

int main ()

{

cout << "Hello, world!";

_getch();

return 0;

}

8.3 Java

History.

Before Java emerged as a programming language, C++ was the dominant player in the trade. The primary goals that the creators of Java was to create a language that could tackle most of the things that C++ offered while getting rid of some of the more tedious tasks that came with the earlier languages.

James Gosling, Mike Sheridan, and Patrick Naughton initiated the Java language project in June 1991. Java was originally designed for interactive television, but it was too advanced for the digital cable television industry at the time. The language was initially called Oak after an oak tree that stood outside Gosling's office. Later the project went by the name Green and was finally renamed Java, from Java coffee, said to be consumed in large quantities by the language’s creators. Gosling designed Java with a C/C++-style syntax that system and application programmers would find familiar.

\Sun Microsystems released the first public implementation as Java 1.0 in 1995. It promised “Write Once, Run Anywhere” (WORA), providing no-cost run-times on popular platforms. Fairly secure and featuring configurable security, it allowed network- and file-access restrictions. Major web browsers soon incorporated the ability to run Java applets within web pages, and Java quickly became popular. The Java 1.0 compiler was re-written in Java by Arthur van Hoff to comply strictly with the Java 1.0 language specification. With the advent of Java 2 (released initially as J2SE 1.2 in December 1998 – 1999), new versions had multiple configurations built for different types of platforms. J2EE included technologies and APIs for enterprise applications typically run in server environments, while J2ME featured APIs optimized for mobile applications. The desktop version was renamed J2SE. In 2006, for marketing purposes, Sun renamed new J2 versions as Java EE, Java ME, and Java SE, respectively.

In 1997, Sun Microsystems approached the ISO/IEC JTC 1 standards body and later the Ecma International to formalize Java, but it soon withdrew from the process. Java remains a de facto standard, controlled through the Java Community Process. At one time, Sun made most of its Java implementations available without charge, despite their proprietary software status. Sun generated revenue from Java through the selling of licenses for specialized products such as the Java Enterprise System.

On November 13, 2006, Sun released much of Java as free and open-source software, (FOSS), under the terms of the GNU General Public License (GPL). On May 8, 2007, Sun finished the process, making all of Java's core code available under free software/open-source distribution terms, aside from a small portion of code to which Sun did not hold the copyright.

Oracle Corporation acquired Sun Microsystems in 2009–2010. Java software runs on everything from laptops to data centers, game consoles to scientific supercomputers. There are 930 million Java Runtime Environment downloads each year and 3 billion mobile phones run Java.

Principles. There were five primary goals in the creation of the Java language:

  •  It must be “simple, object-oriented and familiar”
  •  It must be “robust and secure”
  •  It must be “architecture-neutral and portable”
  •  It must execute with “high performance”
  •  It must be “interpreted, threaded, and dynamic”

Versions. Major release versions of Java, along with their release dates:

  •  JDK 1.0 (January 21, 1996)
  •  JDK 1.1 (February 19, 1997)
  •  J2SE 1.2 (December 8, 1998)
  •  J2SE 1.3 (May 8, 2000)
  •  J2SE 1.4 (February 6, 2002)
  •  J2SE 5.0 (September 30, 2004)
  •  Java SE 6 (December 11, 2006)
  •  Java SE 7 (July 28, 2011)
  •  Java SE 8 (March 18, 2014)

Java platform.

One design goal of Java is portability, which means that programs written for the Java platform must run similarly on any combination of hardware and operating system with adequate runtime support. This is achieved by compiling the Java language code to an intermediate representation called Java bytecode, instead of directly to architecture-specific machine code. Java bytecode instructions are analogous to machine code, but they are intended to be executed by a virtual machine (VM) written specifically for the host hardware. End users commonly use a Java Runtime Environment (JRE) installed on their own machine for standalone Java applications, or in a web browser for Java applets.

Standardized libraries provide a generic way to access host-specific features such as graphics, threading, and networking.

A major benefit of using bytecode is porting. However, the overhead of interpretation means that interpreted programs almost always run more slowly than programs compiled to native executables would. Just-in-Time (JIT) compilers were introduced from an early stage that compile bytecodes to machine code during runtime.

Syntax.

The syntax of Java is largely derived from C++. Unlike C++, which combines the syntax for structured, generic, and object-oriented programming, Java was built almost exclusively as an object-oriented language. All code is written inside a class, and everything is an object, with the exception of the primitive data types, i.e., integers, floating-point numbers, boolean values, and characters, which are not classes for performance reasons.

Unlike C++, Java does not support operator overloading or multiple inheritance for classes. This simplifies the language and aids in preventing potential errors and anti-pattern design.

Java uses similar commenting methods to C++. There are three different styles of comments: a single line style marked with two slashes (//), a multiple line style opened with /* and closed with */, and the Javadoc commenting style opened with /** and closed with */. The Javadoc style of commenting allows the user to run the Javadoc executable to compile documentation for the program.

Example.

The traditional “Hello, world!” program can be written in Java as:

class HelloWorldApp {

   public static void main(String[] args) {

       System.out.println("Hello World!"); // Print the string to the console.

   }

}

1 http://en.wikipedia.org/wiki/Smalltalk

2 http://www.doc.ic.ac.uk/~wjk/C++Intro/RobMillerL1.html


 

А также другие работы, которые могут Вас заинтересовать

41759. Работа менеджера с электронной записной книжкой Microsoft OneNote 2010 73.27 KB
  В отличие от бумажных систем текстовых редакторов приложений электронной почты и других офисных программ OneNote позволяет собирать и упорядочивать текстовые заметки рисунки цифровой рукописный текст аудио и видеозаписи и другие материалы в одной цифровой записной книжке на компьютере. OneNote может повысить эффективность работы поскольку вся нужная информация находится под рукой а время которое приходится тратить на поиск сведений в сообщениях электронной почты бумажных записных книжках папках и распечатках сокращается. OneNote...
41760. ОПРЕДЕЛЕНИЕ РЕЖИМА НАПРЯЖЕНИЯ СЕЛЬСКОЙ РАДИАЛЬНОЙ СЕТИ И ВЫБОР НАДБАВОК У ТРАНСФОРМАТОРОВ 65.17 KB
  Замкнутой называют электрическую сеть магистральные линии которой получают питание не менее чем с двух сторон. Расчетная схема линии с двухсторонним питанием Рис. Схема трёхфазной распределительной линии с двухсторонним питанием а и её однофазная модель переменного тока б Рис. Результаты опыта при номинальном режиме работы линии Условия опыта 1.
41761. Исследование протокола FTP (File Transfer Protocol) 272.9 KB
  Получить практические навыки в использовании протокола FTP File Trnsfer Protocol. Провести сеансы работы с FTPсервером в активном и пассивном режимах используя Windows Commnder. Провести сеансы работы с FTPсервером в активном и пассивном режимах с помощью стандартного FTPклиента Windows.
41762. ИОННООБМЕННАЯ АДСОРБЦИЯ 63.35 KB
  В каждой порции определите кислотность для этого пипеткой отберите 10 мл элюата перенесите в стакан и титруйте 02 М NOH в присутствии фенолфталеина. Постройте кривую зависимости концентрации кислоты от объема вышедшего элюата.1 Результаты зависимости концентрации кислоты от объема элюата прошедшего через колонку № опыта Объем 02 М NOH V мл Концентрация элюата с г мл 1 n Часть 2.2 Результаты зависимости рН от объема элюата прошедшего через колонку № опыта Объем элюата V мл рН 1 n 5.
41763. Программирование на языках Техno ST и Техno FBD 1.37 MB
  Добавьте каналы хранящие значение стоимости продукта расхода продукта периода генерации рисунок 3. Рисунок 3. Для этого задайте противоположные углы кнопок щелчком левой кнопки мыши рисунок 3. Выделите строку mousePressed и вызовите контекстное меню рисунок 3.
41764. Изучение и анализ конструкций систем охлаждения транспортных двигателей 77.95 KB
  Ознакомиться с устройством систем охлаждения различных двигателей, уметь анализировать их конструктивные особенности.
41765. Работа с таблицами в MS ACCESS 52.72 KB
  Работа с таблицами в MS ACCESS. Цель работы: изучение принципов создания запросов в СУБД MS Acces. Создание запроса на выборку товара не позднее определённой даты.
41766. Использования вспомогательных средств трансформирования простых объектов в Corel Drаw 2.11 MB
  Цели занятия: Сформировать умения использовать средства привязки выравнивания и распределения объектов инструментов изменения формы объектов. Учащиеся должны научиться: Осуществляет привязку объектов к сетке направляющим; выполняет выравнивание и распределение объектов. Применять инструменты изменения формы объектов.
41767. Настройка фрезерного станка и делительной головки на нарезание зубчатого колеса с винтовым зубом 946.84 KB
  Задание: Изучить устройство станка и делительной головки. Рассчитать настройку делительной головки и настроить её на работу. Поэтому необходимо усвоить следующее: Устройство механизмов отсчёта делительной головки и методику их наладки.