XDC 2019 – API 2.0

At XDC 2019 Paul Lefebvre and Travis Hill did a session on API 2.0.  For those not familiar with API 2.0 it’s the result of the best parts of the Xojo Framework getting merged back into the global framework without the heavy use of the Text and Auto datatypes.

The first version of Xojo (AKA REALbasic) was in 1998.  Supported Mac 8.  Now in 2019 MacOS, Linux, Windows, iOS, Web, Raspberry Pi and soon to be Android.

The goals of API 2.0:

Utilities language improvements.  In 1998 no shared methods and other features available now.

Improve Consistency.  Naming was often based on specific OS things that don’t exist before.  

Better Naming.  

Exceptions, not Error Codes.  Error codes get ignored – Exceptions are now.

Fewer Globals.

More Enumerations.  Constants lead to enforcement issues.

Similar API for Controls

But overall, don’t want to change what works.  The global framework has worked great for many years.

Progress Update:

Large portion of API 2.0 will be rolled out soon.  “All” from Geoff’s keynote may not be accurate

When it happens they’ll be deprecated – NOT removed.  It’ll be there for many many years.

Stop using in documentation and code examples.

API 2.0 Benefits

Code is more readable.

Easier for new users to learn.  Most consistent for existing users.

Easier for all when working across project types.

Notable New Features

URLConnection.  New in 2018 R4.  Added Synchronous to the Asynchronous option.  Uses OS API’s.

Var and ResizeTo.  Synonyms for Dim and Redim.  Var is better term and used in other languages.  

Notable Changes

Databases

Exception Handling.  No longer uses error checking.  Works on Connect, ExcecuteSQL, SelectSQL.  

DatabaseField -> DatabaseColumn

DatabaseRecord ->DatabaseRow

Recordset -> RowSet

BeginTransaction

Binding is now embedded in the SelectSQL.  Infers the BindType from the DataType.  

FolderItem

Uses Exceptions

Open methods moved to more appropriate classes (OpenAsMovie, OpenAsSound, OpenAsVector)

Item -> Child

Listbox

ListCount -> RowCount

ListINdex -> SelectedIndex

Cell -> CellValueAt

DeleteAllRows -> RemoveAllRows

RemoveRow -> RemoveRowAt

ColumnFromXY -> ColumnAtPoint

Header -> HeaderAt

Other

ToString/FromString on Date and numeric types

String.BeginsWith, EndWith, IndexOf.  All methods will be zero based.

Timer.CallLater, Tolerance

Date intervals and time zones

Random is now a singleton class.

Point, Size, Rect no longer need the “Realbasic” prefix.

Desktop is first.  Then Web 2.0 and then mobile (first with Android then iOS).

You’ll be able to change code at your own pace.  None of the existing methods are going away.

This is a one way move.  The goal is to let older versions of the IDE still *open* API 2.0 projects.  Obviously you’ll get compile errors then.

Will deprecated stuff will not show in AutoComplete.  It’s doubtful if it will improve AutoComplete performance.

3 thoughts on “XDC 2019 – API 2.0

    • Check project will point out that something is deprecated with a replacement – similar to how it does it now. They talked about doing some automatic replacements (same function but different name) but that won’t always be an ideal situation since exceptions get thrown with errors now where the older methods just set an error bit or LastErrorCode.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.