Oxygene Language Platform Differences Overview
To do: MOVE TO SHARE BETWEEN LANGUAGES!?
We strive for 99% language compatibility, but due to the nature of the platforms and underlying runtimes, a small handful of language features will not be available on all platforms, and a few platform-specific features are provided that don't make sense on the other platforms.
Also read in more detail about edition-specific language features:
Garbage Collection vs. ARC
In most code scenarios, GC and ARC will behave pretty comparably, and
code written that deals with object references generally will look the
same — i.e. will not worry about explicitly freeing object memory. There
are, however, some subtle differences, in particular when it comes to
dealing with retain cycles, which GC has no
problem resolving, but which can cause leaks in ARC. Special Storage
Modifier keywords (
strong (implied by
unretained) are provided to help with this on the
Also unique to the Cocoa platform, the
autoreleasepool keyword is provided to manually
instantiate additional auto-release pools, where needed. This is seldom
the case, but might be necessary in some specific cases. The topic on
ARC will go into this in more detail.
Blocks (a.k.a. .NET Delegates)
Blocks, i.e. method references, are supported on on all platforms, but there are some limitations.
block keyword is provided on all platforms, and synonymous with the now deprecated
delegate keyword (refer to the Blocks topic for reasons for this change).
Oxygene has support for inline block types in method or property declarations. This syntax is supported on all platforms, but limited to block signatures that match an existing
Func delegate signature on .NET.
Note that on Cocoa, the
method keywords will declare C-level Function Pointers when used for block type declarations, rather than true Objective-C blocks (i.e. C's
* syntax opposed to
^ block syntax). Only the
delegate keywords declare true Objective-C blocks. (On .NET and Java, all 5 keywords behave the same way.)
Since on .NET and Java it has never been recommended to use
method for block declarations, it is recommended to consistently stick to
[[block (keyword)|block]] for cross-platform code.
Note: For RemObjects C#, this equally applies to
delegate types. Inline
delegate type declarations are permitted. Because C# does not use different keywords like Oxygene does, the
[FunctionPointer] [Attribute](Special Attributes (Cocoa)) can be applied to mark a delegate as a function (and not a block) pointer in C#.
C Runtime Heritage and Influences on Elements for Cocoa
Due to it being built on the Objective-C runtime, which itself is a true
superset of standard C, Oxygene for Cocoa gains support for a wide
variety of concepts from the C language, not the least of which being
access to the vast C runtime library, with
printf() and thousands of
other well known functions, records and types. Due to C being inherently
non-object-oriented, this means Oxygene for Cocoa provides access to
non-OOP libraries and functionalities in a manner that would have been
deemed "unacceptable" on the strictly-OOP .NET and Java platforms.
Examples of these are more liberal use of pointers and reference parameters, global constants and functions, and the more traditional method-less Record types.
For the purpose of cross-platform code, this is mainly irrelevant, as such code can (and should) stick to using the higher-level OOP based features and functionality.
Custom Attributes are supported in the
.NET and Java editions, but not on
Cocoa. However, the standard attribute syntax with
square brackets (
) is supported on Cocoa to specify a limited range
of special attributes defined
by the compiler (as on the other platforms). These special attributes
are not backed by classes.
Since aspects essentially run as part of the compiler, aspects continue to be written using in .NET, no matter the target platform. Aspects can be created so that they are platform-independent and can be applied to any of the four platforms. In fact, that is the default behavior.
Properly named aspects (with the
*Aspect class name suffix) can be applied like regular attributes on all platforms.
Miscellaneous and Minor Differences
- semantics differ between .NET, Java and Cocoa.
- Nullable Types, like boxing, have some limitations on Cocoa (namely that they support only numerical values, and no Records).
- Arrays support differs on Cocoa, with the availability of non-object Open and Static Arrays.
- As part of ARC, Storage Modifiers are supported on Cocoa only.
- Interfaces support
optionalmembers on Cocoa.
dynamictype is only supported on .NET and Cocoa, and on the latter maps to
idtype and provides sightly different usage semantics.
unsafecode is not supported on Java, and all code is assumed to be
unsafeon Cocoa and Island, making the keyword ignored/unnecessary on that platform.
- Generic co/contra-variance is supported on .NET only.
- Differences in [Pointer References in Oxygene for Cocoa](Pointer References in Oxygene for Cocoa).
externalkeyword is supported on .NET (P/Invoke) and Java (JNI), but not applicable on Cocoa.
- Parallel "for" loops, parallel sequences and queryable sequences are currently only supported for .NET.
The list below represents minor differences that exist now but are planned to be rectified/unified in future language updates:
- Special Java-style exception handling extensions will be a new platform difference, once implemented.
- BigInteger support is currently only supported for .NET. Support for Java & Cocoa is under review for a future update.
awaitis currently only supported for .NET. Support for Java & Cocoa is under review for a future update.