RemObjects Software
Home | Products | Trials | Shop | Support | About |

The Oxygene Language

Oxygene, the language and compiler that drives Embarcadero Prism™ and our upcoming Project "Cooper" is a modern language that was developed from the ground up for the managed environment. It was designed to fit in well with the .NET and Mono framework and the Java runtime, to leverage the strengths of these platforms and to not artificially attempt to persist outdated paradigms that no longer have a place in managed code. As such, it is designed around concepts like garbage collection and generics, has deep support for the single-rooted type system and the pure OOP nature of the CLR and JVM, and integrates new language concepts such as sequences and nullable types natively into the language.

Being based on Pascal and Object Pascal, developers coming from a background in Delphi/Win32 or other Pascal dialects will feel right at home with Oxygene. It will expose them to two brand new platforms with many exciting new capabilities (both on a language and framework level), while allowing them to leverage all their knowledge of Object Pascal. The many new language features that Oxygene provides are designed to work intuitively, fit in great with the "Pascal look and feel&" of the language and stay true to Pascal's design philosophy.

Oxygene provides a true super-set of what is available in C#, VB.NET amnd Java as well as the underlying CLR/JVM environments. This means that C# and Java developers switching to Oxygene will not miss a single of their favorite language features. At the same time, Oxygene provides a wide range of extra features – from Class Contracts to AOP – that are not available in Java or C#.

The following sections will cover some of the language highlights.

Cirrus – AOP for .NET

With Cirrus, Oxygene extends the .NET attribute system with full support for Aspect Oriented Programming*, allowing the developer to separate concerns such as logging, security or other functionality orthogonal to the regular class hierarchy into Aspects that can be attached to classes or their members, as needed.

Functionality that otherwise would need to be reimplemented in various places across an application or framework can be encapsulated in reusable form and maintained in a single place. Oxygene allows developers both to reuse existing aspects written by third parties or included with the compiler’s standard aspect library, as well as to create their own Aspects.

Class Contracts

Class Contracts allow you to specify constraints for your classes and methods right in your code and have violations to these constraints flagged with assertions at runtime, in debug builds. This makes it easier to locate bugs caused by erroneous parameters or mismatched assumptions between developers, because instead of hard-to-track misbehaviors, your code will break with clean and sensible error messages, if constraints are not met.

"require" and "ensure" clauses are supported at the beginning and end of method bodies to validate input parameters and startup conditions, as well as validate the result.

Class-wide invariants can be specified that will be enforced whenever any method or property accessor of your class finishes – making it easy to check for overall consistency of your class without the need for validation code to be repeated in every method.

Parallel Development

With processor speeds having reached a cap (and even having gone slight down again) at the 3GHz level and new hardware improvements being done by increasing the number of CPU cores, rather than their speed, it has become more important than ever for developers to create applications that run multi-threaded and can leverage these multi- and many-core computers.

Oxygene includes state-of-the-art language features that ease the creation of multi-threaded applications. From its support for asynchronous methods and code blocks over parallelized for loops to its future types that integrate natively with the type system, Oxygene provides what developers need to leverage the full CPU power of modern computers.

Enhanced Nullable Types and Nullable Expressions

Oxygene enhanced the support for nullable types beyond the basic runtime offering, making them a full language feature that fits in neatly with the other types rather than having nullable types feel like a runtime trick. For example, variables defined as nullable Int32 allow full access to members of Int32 and behave like a true Int32 in every sense – with the addition of allowing nil values.

Nullable expressions take this yet another step further and provide full support for nullable types in arithmetic and other expressions, making the language integration of nullables even more seamless. Casting between compatible nullable types, such as assigning a nullable Int32 to a nullable Int64, etc., is also possible

In combination with the powerful ":" operator (described below) and the valueOrDefault() Compiler Magic Function, nullable types in Oxygene are easier to use than ever, and feel more natural than in any other .NET language.

Duck Typing and Soft Interfaces

New in version 5, Duck Typing lets you treat objects as if they implement interfaces they do not actually implement, provided they expose the necessary methods to qualify for that interface – according to the motto that if it looks and quacks like a duck, you can treat it as if it were a duck. Soft Interfaces* take this concept to the next level by letting you define interfaces that any object with the matching methods will automatically conform to – without the need for ducking.

Read more about Duck Typing on our What's New page.

Colon ":" Operator

Oxygene introduces a revolutionary new operator that can be used anyplace the familiar "." can be used, be it to access a method, properties or other members of a type. Different from the "." operator, which requires the value on its left to be assigned (and will usually throw a NullReferenceException if it is not), the new ":" operator will allow to call members on any value, including nil. If the expression on the left of the colon is nil, the entire expression will automatically short-circuit to return nil as well.

This makes it very easy to access nested members in object hierarchies, when multiple if assigned() checks would otherwise be needed.

var lGreatGrandDadsName := lUser:Parent:Parent:Parent:Name;

Sequences and Query Expressions

Query Expressions, also known as "Language Integrated Query" or LINQ for short, are a powerful language feature that allows you to combine the querying capabilities of database languages such as SQL and apply it to any type of data, natively within the Oxygene language.

Queries can be written to work on any type of structured collection, from simple lists and arrays to database tables and other data structures. Combined with libraries such as XLinq or DA LINQ from Data Abstract, the feature can be used to efficiently query data from database sources and XML documents, without actually retrieving the entire set of data into memory.

Lambda Expressions

Mostly used alongside LINQ and query support, lambda expressions provide a unique syntax for passing dynamic expressions as part of method parameters.

var lFiltered := lUsers.Where(u -> u.Age = 35);

Class References & Virtual Constructors

Oxygene offers support for strongly typed class references, alongside virtual constructors and virtual class methods. This makes it easy to implement the Factory Pattern or dynamically create object instances based on runtime information, without having to go through reflection or slow weakly-typed mechanisms such as .NET type activators.

And There's More...

Of course these are just a few examples of the literally hundreds of language features and enhancements Oxygene brings to the table.

Remember, Oxygene offers a full feature superset of C# and Visual Basic .NET – in addition to the many advanced and unique feaures it has to offer.

You can read more about these and all the other features in our Oxygene Language Wiki at wiki.oxygenelanguage.com.