Elements RTL

Elements RTL (also referred to as RTL2) is a new cross-platform base library and abstraction layer that allows you to write code (in any of the four Elements languages) that can easily be shared across all four platforms (.NET, Cocoa, Java/Android, and Island). Is is introduced in Elements 9.1.

Elements RTL provides abstractions for common low-level types such as Strings ad Collections, and tasks such as value conversions, text encoding and mathematical operations. It also includes fully native, cross-platform XML and Json document implementations.

Elements RTL supersedes and replaces Sugar. Applications using Sugar should port over to Elements RTL easily, since many APIs are the same or similar.

Using Elements RTL

A pre-compiled version of Elements RTL is included with Elements, and can be added to your projects via the Add References dialog in Fire or Visual Studio, where the Elements library should show automatically. The New Project dialog in Fire will also give you the option to start new projects based on Elements RTL.

Simply adding the reference and adding the RemObjects.Elements.RTL namespace to your uses/import statements will make the Elements RTL classes available for you. For ease of use, we recommend adding RemObjects.Elements.RTL to the global "Default Uses" Project Setting.

Classes and Types

Currently, the following major types are supported/implemented. Unless otherwise noted, all parts of Elements RTL are available across all platforms, including Island.

Classes

Enums

Exceptions

Attributes

Aliases

How Elements RTL Works

A Large portion of Elements RTL is implemented using an Elements compiler feature called Mapped Types that allows platform-native classes to be accessed using a different, shared API defined by Elements RTL.

For example, RemObjects.Elements.RTL.Dictionary is the class Elements RTL provides for working with a dictionary of keys and values. The class, and its methods, can be used on .NET, Cocoa, Java and Island in exactly the same way, so code that makes use of a RemObjects.Elements.RTL.Dictionary can be compiled for all platforms. But it is not a "real" class. Instead, it is a mapping to

  • System.Collections.Generic.Dictionary<T,U> on .NET
  • java.util.HashMap<T,U> on Java
  • NSMutableDictionary on Cocoa
  • [RemObjects.Elements.System.Dictionary](../IslandRTL/Classes/Dictionary from Island RTL on Island

That means that when your code is using RemObjects.Elements.RTL.Dictionary on, say, Cocoa, the compiler will actually translate it to code that directly works with an NSMutableDictionary. The same code, compiled for Java, will seamlessly use a HashMap.

This has several benefits:

  • Rather than "reinventing the wheel", Elements RTL makes use of existing (and well-tested) classes and APIs provided by the underlying frameworks.
  • Elements RTL never boxes you in; you can always access features of the underlying framework classes, simply by casting (although of course that part of the code then becomes platform dependent).
  • Casting between Elements RTL and framework classes is toll free, so your platform-specific UI code can be written to use the regular framework classes, but can seamlessly pass those into your share business code, which expects and works with Elements RTL classes.

Contributing

Elements RTL is open source and available on GitHub. It also ships pre-compiled and pre-installed with Elements 9.1 and later. Contributions are welcome.

The bulk part of Elements RTL is written in the Oxygene language, but you can open the Elements RTL projects in Fire and Visual Studio 2017 without requiring an Oxygene license, so even C#, Swift or Iodine developers can contribute. We accept contributions in any of the four Elements languages.

See Also