Object Pascal
Object Pascal is an extension to the programming language Pascal that provides object-oriented programming features such as classes and methods.
The language was originally developed by Apple Computer as Clascal for the Lisa Workshop development system. As Lisa gave way to Macintosh, Apple collaborated with Niklaus Wirth, the author of Pascal, to develop an officially standardized version of Clascal. This was renamed Object Pascal. Through the mid-1980s, Object Pascal was the main programming language for early versions of the MacApp application framework. The language lost its place as the main development language on the Mac in 1991 with the release of the C++-based MacApp 3.0. Official support ended in 1996.
Symantec also developed a compiler for Object Pascal for their THINK Pascal product, which could compile programs much faster than Apple's own Macintosh Programmer's Workshop. Symantec then developed the THINK Class Library, based on MacApp concepts, which could be called from both Object Pascal and THINK C. The THINK suite largely displaced MPW as the main development platform on the Mac in the late 1980s.
Symantec ported Object Pascal to the PC, and developed a similar object framework on that platform. In contrast to TCL, which eventually migrated to C++, the PC libraries remained mainly based on Pascal.
Borland added support for object-oriented programming to Turbo Pascal 5.5, which would eventually become the basis for the Object Pascal dialect used in Delphi. Delphi remained mainstream for business applications on the PC into the early 2000s, and was partly displaced in the 2000s with the introduction of the.NET Framework.
History
Apple Pascal
Pascal became a major language in the programming world in the 1970s, with high-quality implementations on most minicomputer platforms and microcomputers. Among the later was the UCSD Pascal system, which compiled to an intermediate p-System code format that could then run on multiple platforms. Apple licensed UCSD and used it as the basis for their Apple Pascal system for the Apple II and Apple III.Pascal became one of the major languages in the company in this period. With the start of the Apple Lisa project, Pascal was selected as the main programming language of the platform, although this time as a compiler in contrast to the p-System interpreter.
Clascal
Object Pascal is an extension of the Pascal language that was developed at Apple Computer by a team led by Larry Tesler in consultation with Niklaus Wirth, the inventor of Pascal. It is descended from an earlier object-oriented version of Pascal named Clascal, which was available on the Lisa computer.Object Pascal was needed to support MacApp, an expandable Macintosh application framework that would now be termed a class library. Object Pascal extensions, and MacApp, were developed by Barry Haynes, Ken Doyle, and Larry Rosenstein, and were tested by Dan Allen. Larry Tesler oversaw the project, which began very early in 1985 and became a product in 1986.
An Object Pascal extension was also implemented in the Think Pascal IDE. The IDE includes the compiler and an editor with syntax highlighting and checking, a powerful debugger, and a class library. Many developers preferred Think Pascal over Apple's implementation of Object Pascal because Think Pascal offered a much faster compile–link–debug cycle, and tight integration of its tools. The last official release of Think Pascal was 4.01, in 1992. Symantec later released an unofficial version 4.5d4 at no charge.
Apple dropped support for Object Pascal when they moved from Motorola 68000 series chips to IBM's PowerPC architecture in 1994. MacApp 3.0, for this platform, was rewritten in C++.
Borland, Inprise, CodeGear, and Embarcadero years
In 1986, Borland introduced similar extensions, also named Object Pascal, to the Turbo Pascal product for the Macintosh, and in 1989 for Turbo Pascal 5.5 for DOS. When Borland refocused from DOS to Windows in 1994, they created a successor to Turbo Pascal, named Delphi, and introduced a new set of extensions to create what is now known as the Delphi language.The development of Delphi started in 1993 and Delphi 1.0 was officially released in the United States on 14 February 1995. While code using the Turbo Pascal object model could still be compiled, Delphi featured a new syntax using the keyword
class
in preference to object
, the Create constructor and a virtual Destroy destructor, properties, method pointers, and some other things. These were inspired by the ISO working draft for object-oriented extensions, but many of the differences from Turbo Pascal's dialect were ignored.The Delphi language has continued to evolve over the years to support constructs such as dynamic arrays, generics and anonymous methods. The old object syntax introduced by Apple is still supported.
Versions
- Borland used the name Object Pascal for the programming language in the first versions, but later renamed it to Delphi. Compilers that claim to be compatible with Object Pascal are often trying to be compatible with Delphi source code. Because Delphi is a trademark, compatible compilers continue using the name Object Pascal.
- Embarcadero Technologies, which purchased Delphi in 2008, sells the Delphi integrated development environment that compiles the Delphi dialect of Object Pascal to Windows and macOS, iOS, Android and Web.
- .NET support existed from Delphi 8 through Delphi 2005, 2006, and 2007, which now has been replaced by another language, Oxygene, which is not fully backward-compatible.
- The Oxygene language developed by RemObjects Software targets the Common Language Infrastructure, the Java Runtime Environment and Apple's Cocoa frameworks for iOS and macOS.
- The open source Free Pascal project allows the language to be compiled for a wide range of operating systems, including Linux, FreeBSD, Classic Mac OS, macOS, Solaris, Windows API, the ARM instruction set architecture, and several other hardware architectures. The first version of Free Pascal for the iPhone software development kit 2.x was announced on January 17, 2009.
- The Smart Pascal language targets JavaScript-ECMAScript and is used in Smart Mobile Studio, written by Jon Lennart Aasenden and published by Optimale Systemer. The language greatly simplifies HTML5 development through object-oriented, and rapid application development methods. Smart Pascal integrates tightly with established technologies such as node.js, Embarcadero DataSnap and Remobjects SDK to deliver high-performance client–server model web applications. The language allows easy creation of visual components and reusable libraries. The Smart Pascal dialect stems from the DWScript language, extended to better integrate with the JavaScript environment and libraries, such as
asm
sections which are plain JavaScript but have access to Pascal symbols, or external classes which map directly to prototypal JavaScript classes. Smart Pascal introduces true inheritance, classes, partial classes, interfaces, a virtual method table and many other advanced constructs which are not a part of JavaScript by default. - MIDletPascal runs on the Java bytecode platform. Free Pascal targets the JVM also, with a much richer set of features.
- The Morfik Pascal language, developed by Morfik, targets Ajax-enabled Web applications. The Morfik compiler is incorporated into the company's AppsBuilder IDE and allows Object Pascal code to be used in implementing code that will execute both in the browser and on the server. It uses the Free Pascal compiler to generate native binaries from Object Pascal.
- The open source GNU Pascal compiler is available as a front-end to the GNU compiler collection, which implements the International Organization for Standardization 7185 Pascal standard, and most of the ISO 10206 Extended Pascal standard.
- A free compiler, , is available for producing code for Intel 8051 chips.
- is an open source Delphi-like IDE and compiler available for Microsoft Windows and OS/2, and is a commercial Borland Pascal compatible environment released by a company named Speedsoft that was later developed into a Delphi-like RAD environment named Sybil, and then open sourced under the GPL when that company closed down. Wolfgang Draxler now maintains the software. The compiler used seems to be located in a DLL and is not open-source.
Compilers
- Delphi is probably the best known compiler. It is the successor of the highly successful Borland Pascal and Turbo Pascal product line. It targets Windows 9x, the Windows NT family,.NET Framework, macOS, iOS, Android. Support for.NET finally became a separate product known as Oxygene.
- Free Pascal Compiler is an open-source Object Pascal compiler that supports many Pascal dialects, including Turbo Pascal 7, Delphi, and others. Currently, FPC can generate code for IA-32, x86-64, PowerPC, SPARC, and ARM processors, and for several operating systems, including Microsoft Windows, Linux, FreeBSD, Classic Mac OS, and macOS. Several separate projects exist to facilitate rapid application development with FPC, the most prominent one being Lazarus.
- GNU Pascal, while not formally aimed at the Delphi dialect of Pascal, does contain a Borland Pascal compatibility mode, and is very slowly incorporating a few Delphi language features. It is unsuitable for recompiling large bodies of Delphi code directly, but is notable as having prolific support for operating systems and hardware architectures.
- Oxygene is an Object Pascal compiler from RemObjects Software that integrates into Microsoft Visual Studio. It is also available as free command-line interface compiler that runs native on CLI. It is three compilers in one, each targeting a different platform: Echoes for.NET Framework, Mono, WinRT and Windows Phone 8, Cooper for JDK and Android, and Nougat for iOS and macOS.
- MIDletPascal is a mobile application development tool that generates Java ME bytecode.
- PocketStudio is a Pascal-based integrated development environment for Palm OS.
- Smart Mobile Studio is a source-to-source compiler that transforms Pascal source code to JavaScript
- Ultibo.org is a free pascal variant which compiles to bare hardware Raspberry Pi.
Legacy products
- Borland Kylix was a Linux variant of Delphi which only targets Intel 32-bit Linux using the Qt library. It does not work out of the box with most modern Linux distributions.
- Virtual Pascal was a free 32-bit Turbo Pascal and Delphi compatible compiler for mainly OS/2 and Microsoft Windows. Later, it also received a DOS+ Extender and an experimental Linux cross-compiler. The compiler's development stopped at about the level of Delphi 2. In 2007, its official website ceased to operate, and further development ceased.
Interpreters
Sample "Hello World" programs
Apple's Object Pascal
program ObjectPascalExample;
type
THelloWorld = object
procedure Put;
end;
var
HelloWorld: THelloWorld;
procedure THelloWorld.Put;
begin
ShowMessage;
end;
begin
New;
HelloWorld.Put;
Dispose;
end.
Turbo Pascal's Object Pascal
Still supported in Delphi and Free Pascal. FPC also packages its own substitutes for the libraries/units. Delphi doesn't. The Free Pascal 1.0 series and the FPC textmode IDE are the largest open codebases in this dialect. Free Pascal 2.0 was rewritten in a more Delphi-like dialect, and the textmode IDE and related frameworks are the only parts in the TP version of Object Pascal.Stack based allocation
program ObjectPascalExample;
type
THelloWorld = object
procedure Put;
end;
procedure THelloWorld.Put;
begin
WriteLn;
end;
var
HelloWorld: THelloWorld;
begin
HelloWorld.Put;
end.
Heap based allocation
program ObjectPascalExample;
type
PHelloWorld = ^THelloWorld;
THelloWorld = object
procedure Put;
end;
procedure THelloWorld.Put;
begin
WriteLn;
end;
var
HelloWorld: PHelloWorld;
begin
New;
HelloWorld^.Put;
Dispose;
end.
Another example:
program ObjectPascalExample;
type
PHelloWorld = ^THelloWorld;
THelloWorld = object
procedure Put;
end;
procedure THelloWorld.Put;
begin
WriteLn;
end;
var
HelloWorld: PHelloWorld;
HelloWorld2: ^THelloWorld;
HelloWorld3: ^THelloWorld;
HelloWorld4: PHelloWorld;
begin
New;
HelloWorld4 := HelloWorld;
HelloWorld2 := HelloWorld;
New;
HelloWorld4 := HelloWorld3;
HelloWorld2 := HelloWorld3;
Dispose;
Dispose;
end.
This works based on pointer copy, unless there is a specific allocation for a deeper copy.
Delphi and Free Pascal's Object Pascal
program ObjectPascalExample;
type
THelloWorld = class
procedure Put;
end;
procedure THelloWorld.Put;
begin
Writeln;
end;
var
HelloWorld: THelloWorld;
begin
HelloWorld := THelloWorld.Create;
HelloWorld.Put;
HelloWorld.Free;
end.
Note that the object construct is still available in Delphi and Free Pascal.
Modern Pascal's Object Pascal
program ObjectPascalExample;
type
THelloWorld = class
Put:procedure of object;
end;
procedure THelloWorld.Put;
begin
Writeln;
end;
procedure THelloWorld.Free;
begin
// dispose any pointers //
end;
procedure THelloWorld.Init;
begin
// initialize variables
// link methods
with Self do begin
TMethod:=;
TMethod:=;
End;
end;
var
HelloWorld: THelloWorld;
begin
HelloWorld.Init;
HelloWorld.Put;
HelloWorld.Free;
end.
Oxygene Object Pascal
namespace ObjectPascalExample;
interface
type
ConsoleApp = class
class method Main;
end;
THelloWorld = class
method Put;
end;
implementation
method THelloWorld.Put;
begin
Console.WriteLine;
end;
class method ConsoleApp.Main;
begin
var HelloWorld := new THelloWorld;
HelloWorld.Put;
end;
end.
DWScript's Object Pascal (a.k.a. Smart Pascal)
type
THelloWorld = class
procedure Put;
begin
PrintLn;
end
end;
var HelloWorld := THelloWorld.Create;
HelloWorld.Put;
The method implementation can also be made in a distinct location as in other Object Pascal dialects.
Development
Many features have been introduced continuously to Object Pascal with extensions to Delphi and extensions to FreePascal. In reaction to criticism, Free Pascal has adopted generics with the same syntax as Delphi, provided Delphi compatibility mode is selected, and both Delphi and Free Pascal support operator overloading. Delphi has also introduced many other features since version 7, including generics. Whereas FreePascal tries to be compatible to Delphi in Delphi compatibility mode, it also usually introduced many new features to the language that are not always available in Delphi.Delphi
- Covering Borland Delphi 6-7
- , Resource of Delphi project source codes.
- , Resource of Delphi Programming & Delphi Programming Forums.