Object Pascal

Object Pascal is a collective name for several programming languages ​​derivatives, Pascal extend to object -oriented programming. The most common variant is the programming language of Embarcadero Delphi development environment, which was developed by company Borland Delphi language and at times was called.

Development

1986 Advanced Borland Turbo Pascal their development environment for the Apple Macintosh to first object-oriented language features. With Turbo Pascal 5.5 followed in 1989 a version for DOS. 1993 Borland began with the development of Delphi as the successor of Turbo Pascal for Windows. Published in 1995, Borland Delphi 1.0, which introduced new language extensions as a new object model. The old object model of Turbo Pascal was still supported.

Over time, the language has grown and evolved and, inter alia, to include features such as Generics and Anonymous extended functions.

In addition to the popular Delphi there are many other compiler for Object Pascal as, inter alia, the open source projects Free Pascal and GNU Pascal. They strive partly of compatibility with Delphi, but maintain their own language definition using extensions.

Properties

Features of Object Pascal is comparable to that of C , where the syntax is very different. Variables must be declared and assigned a data type. There are classes with constructors and destructors, methods, and properties. Methods may be virtual. The inheritance supports only one base class; Interfaces allow multiple inheritance. For the memory management of objects, the programmer is responsible. Strings are not affected because they are supported as elementary data type.

Until Delphi 2005 objects were always created on the heap. This makes it possible in Delphi to any object as a return to the caller. In other programming languages ​​, such as C objects can be created both in the heap and the stack. Objects in the stack can not be passed as a return value, as they will be deleted when you exit the function along with the rest of the stack frame of the function. Thus here is a design decision was made that decreases the decision between the heap / stack the Delphi programmer and always chooses the flexible solution. A disadvantage of this technique it is immediately evident that the programmer its objects created itself must remove it from memory. For objects in the stack, this is not necessary. Since Delphi 2006 Records are supported by methods, which can stack objects create similar to C .

Program Example

( For Delphi and Free Pascal )

Program ObjectPascalExample;   grade    THelloWorld = class    public      procedure Greet;    end;   procedure THelloWorld.Greet; begin    Writeln ('Hello, World! '); end;   var    Hello World: THelloWorld; { Implicit pointer } begin    Hello World: = THelloWorld.Create; { Constructor returns a pointer to an instance of the class THelloWorld }    try      HelloWorld.Greet;    finally      HelloWorld.Free; { Share the instance }    end; end. implementations

Compiler or interpreter who support Object Pascal, inter alia:

  • Turbo Pascal ( commercial)
  • Embarcadero Delphi ( formerly Borland Delphi, commercial, Windows)
  • Borland Kylix (commercial, Linux)
  • Free Pascal ( open source, multi-platform )
  • GNU Pascal (Open Source)
  • Virtual Pascal (Open Source)
  • Oxygene
  • DWScript (Open Source)

Class libraries

For Object Pascal multiple class libraries exist. Under Delphi form the runtime library (RTL) and the Visual Component Library (VCL) traditionally the basis for the development. While the former basic functionalities such as string processing functions contains, the latter is a class library, especially for visual components (buttons, etc.). At times, there was next to the VCL or the Component Library for Cross Platform ( CLX ). However, this was discontinued. Delphi XE2 FireMonkey was introduced in contrast to VCL platform-independent, vector-based component library.

Most of the functionality is based on class libraries, other functions very frequently used but are directly implemented by the compiler, such as the seamless integration of COM technology in Microsoft Windows. The direct access to the Windows API is possible. By other providers, there is a plurality of components for different applications. So also some open source libraries and components collections have been established. In particular, the JEDI Class Library ( JCL ), JEDI Visual Component Library ( JVCL ) and Internet Direct ( Indy ).

For Free Pascal / Lazarus exist equivalent libraries to RTL and VCL, which differ in the handling only in the detail and there hot Free Component Library FCL and LCL Lazarus Component Library.

Influence on other programming languages

Some of the elements and ideas of Object Pascal were taken in the C # programming language from Microsoft. One of the reasons is that many co-developers of Delphi at Borland have been poached by Microsoft and were instrumental in the development of C #. These included, among others, the Delphi project manager Anders Hejlsberg, where the change to Microsoft has been made ​​palatable with a bonus in the millions, as well as Chuck Jazdzewski (Delphi Chief Architect), Corbin Dunn ( developer of the Delphi IDE), Danny Thorpe (Delphi, Borland Chief Scientist ), Eddie Churchill and Ramin Halviatti. Hejlsberg was to describe Microsoft software architecture boss, co-inventor of. NET and chief developer of C #.

226669
de