Object Pascal
From Wikipedia, the free encyclopedia
| Paradigm | imperative, structured, object-oriented, functional (Delphi dialect only) |
|---|---|
| Designed by | Apple, Niklaus Wirth, Anders Hejlsberg |
| Typing discipline | static and dynamic (dynamic typing through Variants, array of const and RTTI), strong, safe |
| Major implementations | Delphi (x86 and CLI), Oxygene (CLI), Free Pascal (x86, x86-64, PowerPC, ppc64, SPARC and ARM), Virtual Pascal (x86), TMT Pascal (x86), Turbo51 (Intel 8051) |
| Dialects | Apple, Turbo Pascal, objfpc, Delphi, Delphi.NET, Oxygene |
| Influenced by | Pascal, Smalltalk |
| Influenced | C#, Java |
Object Pascal refers to a branch of object-oriented derivatives of Pascal, mostly known as the primary programming language of Delphi. Pascal compilers, including those for Object Pascal, generally run very fast while producing highly optimized code.
- Borland used the name Object Pascal for the programming language in the first versions of Delphi, but later renamed it to the Delphi programming language. However, compilers that claim to be compatible with Object Pascal are often trying to be compatible with Delphi source code.
- CodeGear, a former subsidiary of Borland and now a part of Embarcadero Technologies, sells integrated development environments (IDE’s) that compile the Object Pascal code to Windows.
- .NET support existed from Delphi 8 through Delphi 2005, Delphi 2006 and Delphi 2007, which now has been replaced by another language, Oxygene (see below), which is not fully backward-compatible.
- The most recent iteration of the Win32 range—Delphi 2009—introduced Unicode and generics support.
- The Oxygene programming language developed by RemObjects targets the Common Language Infrastructure solely. The Oxygene compiler has been incorporated into a new Delphi development solution owned by Embarcadero, named Delphi Prism, which is Microsoft Visual Studio based.
- The Morfik Pascal programming language developed by Morfik targets the 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.
- The open source Free Pascal project allows the language to be compiled for a wide range of operating systems—including Linux (32bit & 64bit), FreeBSD, Mac OS/Mac OS X, Win32, Win64 and Windows CE—as well as for several different hardware architectures. The first version of Free Pascal for the iPhone SDK 2.x was announced on January 17, 2009.[1] Now there is also support for embedded (ARM).
- The Midlet Pascal is aimed to the java bytecode platform.
- The open source GNU Pascal compiler is available as a front-end to the GNU compiler collection, which implements the ISO 7185 Pascal standard, and "most" of the ISO 10206 Extended Pascal standard.
- Also, a free compiler, Turbo51, is available for producing code for Intel 8051 chips.
To sum up, the word Object Pascal nowadays is used collectively to refer to different dialects of the Pascal language with object-oriented programming extension, although these dialects are mostly compatible with CodeGear's implementation.
Contents |
[edit] Early history at Apple
| This section requires expansion with: additional citations. |
Object Pascal is an extension of the Pascal programming 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 called Clascal, which was available on the Lisa computer.
Object Pascal was needed in order to support MacApp, an expandable Macintosh application framework that would now be called a class library. Object Pascal extensions and MacApp itself 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.
Apple dropped support for Object Pascal when they moved from Motorola 68K chips to IBM's PowerPC architecture in 1994.
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 instead of MacApp because it offered a tight integration of its tools. The development stopped after the 4.01 version because the company was bought by Symantec. The developers then left the project.
[edit] The Borland and CodeGear years
In 1986, Borland introduced similar extensions, also called Object Pascal, to the Turbo Pascal product for the Macintosh, and in 1989 for Turbo Pascal 5.5 for DOS.
When Borland refocused from MS-DOS to Windows in 1994, they created a successor to Turbo Pascal, called 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 (and negating having to call the New and Dispose procedures), properties, method pointers, and some other things. These were inspired by the ISO working draft for object-oriented extensions, but many of the differences to Turbo Pascal's dialect (such as the draft's requirement that all methods be virtual) were ignored.
The Delphi language continued to evolve throughout the years to support new language concepts such as 64-bit integers and dynamic arrays.
[edit] Compilers
There are many compilers that are mostly compatible with the Object Pascal language from Delphi. Many of these were created to enable Object Pascal compilation on different platforms and under various licenses.
- CodeGear Delphi is probably the best known compiler. It targets Win16 (Delphi 1), Win32 (Delphi 2+) and the .NET 1.x, 2.0 (Delphi 8, Delphi 2005 - 2007).
- Borland Kylix is a Linux variant of Delphi which only targets Intel 32-bit Linux using Qt. It is no longer updated. Modern distributions often do not work out-of-the box with it.
- Free Pascal is a command-line compiler aimed at source compatibility with the core feature set of both the Turbo Pascal and the Delphi dialects. The current version, 2.2, is highly Delphi6/7 compatible. FPC generates code for x86, x86-64, PowerPC, SPARC and ARM processors under various operating systems, including Win32, Win64, Linux, FreeBSD, Mac OS and Mac OS X (including an Xcode integration kit). Beyond command-line usage, several development environments are available for Free Pascal, in particular the Lazarus IDE.
- GNU Pascal (A separately-distributed part of the GNU Compiler Collection) While formally not aimed at the CodeGear dialects of Pascal, it 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 noteworthy as having prolific support for operating systems and hardware architectures.
- Virtual Pascal is a x86 32-bit Turbo Pascal and Delphi compatible compiler aimed mainly at OS/2 and Windows, although it also developed a DOS+ Extender and an experimental Linux cross-compiler. The compiler’s development stopped at about the level of Delphi V2; its site has been down since 2007, and development of Virtual Pascal has stopped.
- Oxygene (formerly known as Chrome) is an Object Pascal compiler from RemObjects Software that integrates into Microsoft Visual Studio. It is also available as free command-line compiler that runs native on CLI. It targets the .NET and Mono platforms.
- MIDletPascal is a mobile application development tool that generates J2ME bytecode.
- PocketStudio is a Pascal based IDE for Palm OS.
[edit] Interpreters
Pascal Script (formerly known as InnerFuse) is an open source Object Pascal interpreter/scripting engine written in Delphi. Supports a limited subset of Object Pascal.
[edit] Sample "Hello World" programs
[edit] Apple's Object Pascal
program ObjectPascalExample; type THelloWorld = object procedure Put; end; var HelloWorld: THelloWorld; procedure THelloWorld.Put; begin WriteLn('Hello, World!'); end; begin New(HelloWorld); HelloWorld.Put; Dispose(HelloWorld); end.
[edit] Turbo Pascal's Object Pascal
program ObjectPascalExample; type PHelloWorld = ^THelloWorld; THelloWorld = object procedure Put; end; var HelloWorld: PHelloWorld; { this is a pointer to a THelloWorld } procedure THelloWorld.Put; begin WriteLn('Hello, World!'); end; begin New(HelloWorld); HelloWorld^.Put; Dispose(HelloWorld); end.
[edit] Delphi And Free Pascal's Object Pascal
program ObjectPascalExample; type THelloWorld = class procedure Put; end; procedure THelloWorld.Put; begin Writeln('Hello, World!'); end; var HelloWorld: THelloWorld; { this is an implicit pointer } begin HelloWorld := THelloWorld.Create; { constructor returns a pointer } HelloWorld.Put; HelloWorld.Free; { this line dereferences the pointer } end.
Note that the object construct is still available in Delphi and Free Pascal (Delphi-compatible mode).
[edit] 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('Hello, World!'); end; class method ConsoleApp.Main; begin var HelloWorld := new THelloWorld; HelloWorld.Put; end; end.
[edit] Development
Many features have been introduced continuously to Object Pascal with extensions to Delphi, now also by Free Pascal. In reaction to criticisms, Free Pascal has adopted generics, and both Delphi and Free Pascal now support operator overloading (with different grammar, though). Delphi has also introduced many other features since version 7[2] including generics.
[edit] See also
[edit] References
- ^ "iPhone/iPod development". Free Pascal development team. http://wiki.freepascal.org/iPhone/iPod_development. Retrieved on 2009-04-13.
- ^ "New Delphi language features since Delphi 7". CodeGear. http://dn.codegear.com/article/34324. Retrieved on 2008-07-06.
[edit] External links
[edit] CodeGear
- CodeGear Delphi
- New Language Features In Delphi 2006 and Delphi 2007
- Delphi Basics - Free Source Code
- About Delphi Community
- Delphi Wiki
- Torry's Delphi Pages
- Delphi Tutorials
- Russian Delphi Club
- Object Pascal Style Guide
[edit] RemObjects Software
- RemObjects Oxygene Homepage
- RemObjects Oxygene Official Wiki
- RemObjects Oxygene Developer Resources, Articles and Videos
[edit] Introduction to Object Pascal
- Delphi - for beginners
- Collection of informative web sites for Delphi beginners
- Discovering Delphi
- MacTech Vol 2 Issue 12 1985
[edit] Delphi communities
- DelphiBasics Forum, Tutorials and Examples
- Delphi Pages
- Torry's Delphi Pages
- About.com Delphi Programming
- Merlin's Delphi Forge
[edit] Free Pascal Object Pascal reference guide
- Current version's Object Pascal Ref guide (PDF)
- Current version's Object Pascal Ref guide (html)
- Free Pascal Mac Pascal extensions status page

