Chrome (programming language)
Encyclopedia
Oxygene is a programming language
developed by RemObjects Software
for Microsoft's
Common Language Infrastructure
. Oxygene is Object Pascal
-based.
Compared to the now deprecated Delphi.NET, Oxygene does not emphasize total backward compatibility, but is designed to be a full .NET citizen and leverage all the features and technologies provided by the .NET runtime.
Starting 2008, RemObjects Software has licensed its compiler and IDE technology to Embarcadero
to be used in their Delphi Prism
product. Delphi Prism offers full integration into Visual Studio 2005/2008/2010. Starting the Fall of 2011, Oxygene is adds support for the Java and Android runtimes, as well. The Embarcadero Prism product continues to focus on .NET, with Java support being available as a separate product from RemObjects Software. Both products/platforms share the same core compiler and development environment.
Oxygene is an object-oriented
language, which means it uses classes, which can hold data and execute code, to design programs. Classes are "prototypes" for objects, like the idea of an apple is the prototype for the apple you can actually buy in the shop. You know that an apple has a color, and you know that it can be peeled: those are the data and executable "code" for the apple class.
Oxygene provides language-level support for some of features of parallel programming. The goal is to use all cores or processors of a computer to improve performance. To reach this goal, tasks have to be distributed among several threads. The .NET framework's
Operators can be overloaded in Oxygene using the
Note, that for operator overloading each operator has a name, that has to be used in the operator overloading syntax, because for example "+" would not be a valid method name in Oxygene.
Oxygene files are separated into an interface and an implementation section, which is the structure known from Delphi. The interface section follows the declaration of the namespace. It contains the
Imported namespaces have to be in the project itself or in referenced assemblies. Unlike in C#, in Oxygene you cannot define alias names for namespaces, only for single type names (see below).
Following the
As in C#, the Main-method is the entry point for every program. It can have a parameter
More types can be declared without repeating the
The implementation of the declared methods is places in the implementation section:
Files are always ended with
Although it does not introduce own "pre-defined" types, Oxygene offers more "pascalish" generic names for some of them, so that for example the
As in all .NET languages types in Oxygene have a visibility. In Oxygene the default visibility is
The visibility can be set for every type you define (classes, interfaces, records, ...).
You can define an alias name for types, which can be used locally or in other Oxygene-assemblies, too.
Public type aliases won't be visible for other languages.
As they're just .NET-structs, records can have fields, methods and properties, but do not have inheritance and cannot implement interfaces.
Interfaces are declared just like classes:
Please notice, that for properties the getter and setter are not explicitly specified.
Oxygene can create anonymous delegates, so for example you can pass methods to the
An anonymous delegate with the signature of the method
Oxygene supports polymorphic delegates, which means, that delegates which have parameters of descending types are assignment compatible. Assume two classes
Fields can be used to delegate the implementation of an interface, if the type they're of implements this interface:
In this example the compiler will create public methods and properties in
Anonymous methods are especially useful when working with code that is supposed to be executed in a GUI thread, which is done in .NET by passing a method do the
Anonymous methods can have parameters, too:
Both source codes use anonymous delegates.
Oxygene provides the
As you can see, the modifier can be used on properties which have a setter method. The code to raise the events will then be added to this method during compile time.
Program Output:
So while the name makes you think it is just another version of Delphi that is not completely true.
On top of the language differences the Visual Component Library
framework is not available in Delphi Prism.
This makes porting even more difficult because classic Delphi code relies heavily on the VCL.
Programming language
A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine and/or to express algorithms precisely....
developed by RemObjects Software
RemObjects Software
RemObjects Software is an American software company founded in 2002 by Alessandro Federici and Marc Hoffman. It develops and offers tools and libraries for software developers on a variety of development platforms, including Embarcadero Delphi, Microsoft .NET, Mono, and Apple's...
for Microsoft's
Microsoft
Microsoft Corporation is an American public multinational corporation headquartered in Redmond, Washington, USA that develops, manufactures, licenses, and supports a wide range of products and services predominantly related to computing through its various product divisions...
Common Language Infrastructure
Common Language Infrastructure
The Common Language Infrastructure is an open specification developed by Microsoft and standardized by ISO and ECMA that describes the executable code and runtime environment that form the core of the Microsoft .NET Framework and the free and open source implementations Mono and Portable.NET...
. Oxygene is Object Pascal
Object Pascal
Object Pascal refers to a branch of object-oriented derivatives of Pascal, mostly known as the primary programming language of Embarcadero Delphi.-Early history at Apple:...
-based.
Compared to the now deprecated Delphi.NET, Oxygene does not emphasize total backward compatibility, but is designed to be a full .NET citizen and leverage all the features and technologies provided by the .NET runtime.
Starting 2008, RemObjects Software has licensed its compiler and IDE technology to Embarcadero
Embarcadero Technologies
Embarcadero Technologies is an American computer software company that develops, manufactures, licenses, and supports a wide range of products and services related to software through its various dynamic product divisions...
to be used in their Delphi Prism
Delphi Prism
Delphi Prism is a rapid application development tool for the Microsoft .NET Framework and Mono, developed by RemObjects Software and distributed by Embarcadero Technologies....
product. Delphi Prism offers full integration into Visual Studio 2005/2008/2010. Starting the Fall of 2011, Oxygene is adds support for the Java and Android runtimes, as well. The Embarcadero Prism product continues to focus on .NET, with Java support being available as a separate product from RemObjects Software. Both products/platforms share the same core compiler and development environment.
The language
The Oxygene language has its origins in Object Pascal in general and Delphi in particular, but was designed to reflect the guidelines of .NET programming and to create fully CLR-compliant assemblies. Therefore not all language features known from Object Pascal / Delphi can be found any longer in Oxygene or only as legacy features.Oxygene is an object-oriented
Object-oriented programming
Object-oriented programming is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction,...
language, which means it uses classes, which can hold data and execute code, to design programs. Classes are "prototypes" for objects, like the idea of an apple is the prototype for the apple you can actually buy in the shop. You know that an apple has a color, and you know that it can be peeled: those are the data and executable "code" for the apple class.
Oxygene provides language-level support for some of features of parallel programming. The goal is to use all cores or processors of a computer to improve performance. To reach this goal, tasks have to be distributed among several threads. The .NET framework's
ThreadPool
class offered a way to efficiently work with several threads. The Task Parallel Library (TPL) was introduced in .NET 4.0 to provide more features for parallel programming.Operators can be overloaded in Oxygene using the
class operator
syntax:Note, that for operator overloading each operator has a name, that has to be used in the operator overloading syntax, because for example "+" would not be a valid method name in Oxygene.
Program structure
Oxygene does not use "Units" like Delphi does, but uses .NET-namespaces to organize and group types. A namespace can span multiple files (and assemblies), but one file can only contain types of one namespace. This namespace is defined at the very top of the file:Oxygene files are separated into an interface and an implementation section, which is the structure known from Delphi. The interface section follows the declaration of the namespace. It contains the
uses
-clause, which in Oxygene imports types from other namespaces:Imported namespaces have to be in the project itself or in referenced assemblies. Unlike in C#, in Oxygene you cannot define alias names for namespaces, only for single type names (see below).
Following the
uses
-clause a file contains type declarations, like they are known from Delphi:As in C#, the Main-method is the entry point for every program. It can have a parameter
args : Array of String
for passing command line arguments to the program.More types can be declared without repeating the
type
-keyword.The implementation of the declared methods is places in the implementation section:
Files are always ended with
end.
Types
As a .NET language, Oxygene uses the .NET type system: There are value types (like structs) and reference types (like arrays or classes).Although it does not introduce own "pre-defined" types, Oxygene offers more "pascalish" generic names for some of them, so that for example the
System.Int32
can be used as Integer
and Boolean
(System.Boolean
), Char
(System.Char
), Real
(System.Double
) join the family of pascal-typenames, too. The struct character of these types, which is part of .NET, is fully preserved.As in all .NET languages types in Oxygene have a visibility. In Oxygene the default visibility is
assembly
, which is equivalent to the internal
visibility in C#. The other possible type visibility is public
.The visibility can be set for every type you define (classes, interfaces, records, ...).
You can define an alias name for types, which can be used locally or in other Oxygene-assemblies, too.
Public type aliases won't be visible for other languages.
Records
Records are what .NET-structs are called in Oxygene. They are declared just like classes, but with therecord
keyword:As they're just .NET-structs, records can have fields, methods and properties, but do not have inheritance and cannot implement interfaces.
Interfaces
Interfaces are very important concept in the .NET world, the framework itself makes heavy use of them. Interfaces are the specification of a small set of methods, properties and events a class has to implement when implementing the interface. For example contains the interfaceIEnumerable
specifies the GetEnumerator
method which is used to iterate over sequences.Interfaces are declared just like classes:
Please notice, that for properties the getter and setter are not explicitly specified.
Delegates
Delegates define signatures for methods, so that these methods can be passed in parameters (e.g. callbacks) or stored in variables, etc. They're the type-safe NET-equivalent to function pointers. They're also used in events. When assigning a method to a delegate, one has to use the@
operator, so the compiler knows, that one doesn't want to call the method but just assign it.Oxygene can create anonymous delegates, so for example you can pass methods to the
Invoke
method of a control without declaring the delegate:An anonymous delegate with the signature of the method
DoSomething
will be created by the compiler.Oxygene supports polymorphic delegates, which means, that delegates which have parameters of descending types are assignment compatible. Assume two classes
MyClass
and MyClassEx = class(MyClass)
, then in the following code BlubbEx
is assignment compatible to Blubb
.Fields can be used to delegate the implementation of an interface, if the type they're of implements this interface:
In this example the compiler will create public methods and properties in
MyClass
, which call the methods / properties of fSomeImplementor
, to implement the members of IMyInterface. This can be used to provide mixin-like functionality.Anonymous methods
Anonymous methods are implemented inside other methods. They are not accessible outside of the method unless stored inside a delegate field. Anonymous methods can use the local variables of the method they're implemented in and the fields of the class they belong to.Anonymous methods are especially useful when working with code that is supposed to be executed in a GUI thread, which is done in .NET by passing a method do the
Invoke
method (Control.Invoke
in WinForms, Dispatcher.Invoke
in WPF):Anonymous methods can have parameters, too:
Both source codes use anonymous delegates.
Property notification
Property notification is used mainly for data binding, when the GUI has to know when the value of a property changes. The .NET framework provides the interfacesINotifyPropertyChanged
and INotifyPropertyChanging
(in .NET 3.5) for this purpose. These interfaces define events which have to be fired when a property is changed / was changed.Oxygene provides the
notify
modifier, which can be used on properties. If this modifier is used, the compiler will add the interfaces to the class, implement them and create code to raise the events when the property changes / was changed.As you can see, the modifier can be used on properties which have a setter method. The code to raise the events will then be added to this method during compile time.
Hello World
Generic container
Generic method
Program Output:
Type: System.Int32
-> a = 23, b = 15
-> a = 15, b = 23
Type: System.String
-> a = abc, b = def
-> a = def, b = abc
Type: System.Double
-> a = 1,1, b = 1,2
-> a = 1,2, b = 1,1
Differences between native Delphi and Oxygene / Delphi Prism
- unit: Replaced with the namespaceNamespace (computer science)A namespace is an abstract container or environment created to hold a logical grouping of unique identifiers or symbols . An identifier defined in a namespace is associated only with that namespace. The same identifier can be independently defined in multiple namespaces...
keyword. Since Oxygene doesn't compile per-file but per-project, it does not depend on the name of the file. Instead the unit or namespace keyword is used to denote the default namespace that all types are defined in for that file - procedure and function: These two keywords have been replaced with the method keyword
- overload: In Delphi Prism all methods are overloaded by default, so no special keyword is needed for this
- .Create: This constructor call has been replaced by the new keyword. It can still be enabled in the project options for legacy reasons
Criticism
Some people would like to port their Win32 Delphi code to Prism as is. This is not possible because while Prism looks like Delphi there are enough changes to make it incompatible for a simple recompile.So while the name makes you think it is just another version of Delphi that is not completely true.
On top of the language differences the Visual Component Library
Visual Component Library
VCL is a visual component-based object-oriented framework for developing Microsoft Windows applications. It was developed by Borland for use in, and tightly integrated with, its Delphi and C++Builder RAD tools...
framework is not available in Delphi Prism.
This makes porting even more difficult because classic Delphi code relies heavily on the VCL.
See also
- C#
- Object PascalObject PascalObject Pascal refers to a branch of object-oriented derivatives of Pascal, mostly known as the primary programming language of Embarcadero Delphi.-Early history at Apple:...
- Free PascalFree PascalFree Pascal Compiler is a free Pascal and Object Pascal compiler.In addition to its own Object Pascal dialect, Free Pascal supports, to varying degrees, the dialects of several other compilers, including those of Turbo Pascal, Delphi, and some historical Macintosh compilers...
- EiffelEiffel (programming language)Eiffel is an ISO-standardized, object-oriented programming language designed by Bertrand Meyer and Eiffel Software. The design of the language is closely connected with the Eiffel programming method...
- JavaJava (programming language)Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities...