What's the pro/con of API 2?

What are the basic advantages and drawbacks to API 2?

Disadvantage: you need make a lot of boring changes.
Advantage: I cleaned out a lot of old code. I updated some code to be better.

My brain retains only one set of instructions. I was really happy when I finished the transition. Now I need to work again on Desktop API 2. And there are no benefits at all for this one.

Compared to what? For what reason?

The Xojo team has made two things clear: API2 is the way going forward, and API1 will continue to be supported indefinitely.

If you have an existing API1 codebase, you will eventually have to convert it, but you have the luxury of time. If you are starting a project from scratch, pretend API2 is the only option.

The only pros and cons come up in the context of comparing API2 to API1, which is only meaningful if you have long-term experience in 1. They both do the same thing, sometimes in slightly different ways using slightly different terminology. The change its largely meant to make the various functions of the API more consistent and is fairly irritating to old timers.

Sometimes the API2 way is clearer and faster than the API1 way, and sometimes it’s the inverse.

The good news is that in most cases you can freely intersperse both versions of the API (with important UI caveats). On the whole, though, stick to API2 if you can for maximum future framework compatibility.

be aware that API1 methods will never be updated if there is any problem with them in a future OS
so if you start a project, start it with API2
changing all your “old” code from API1 to 2 is painful, and I will do it on a bug to bug basis …
for example, don’t use the Date class, use the DateTime as there are errors for example in folderitem creation dates, the date is wrong but the datetime is ok. and this will never be corrected
so your old API1 code will one day have new bugs, and it may be difficult to detect and correct them…

Seems you are new to Xojo (march 13, I suppose the year is 2024).

You have no choice, mearn how to use the current version (API2) and do not look at all in the past.

This “debate” apply to people that coded using Xojo/REALbasic before 2019.

Now, this is a free world, you can do what you want.

2 Likes

For me, when create a new project I only use API2.
For older projects, I try to modernise into API2 as soon as possible. It’s the only way to take benefit for new Xojo optimisations.

Can you list them ?

I think Valdemar is talking in general terms (bug fixes, new controls, new features, all are API 2 only).

1 Like

api 2 got few new classes.
con: string class methods start at 0, not 1 for first char. so its somehow mixed.

There’s the exception of things like Integer.ToString (API2) vs str(Integer) (API1). One is a global function, the other a member of the data class.

To my mind, the most useful are the new database methods which incorporate parameter binding.

This is not a con. What starts at zero if the offset, which should obviously be zero for the first char.

1 Like

About 10 to 15 years ago in Xojo land, there were constant complaints that the language had become inconsistent. Too many Xojo engineers added features in their own way. Xojo listened to these complaints. To address the issues and satisfy users, Xojo created a new framework under the “xojo” namespace. This namespace was introduced around the time when Xojo began supporting iOS development. The Xojo framework was a separate, platform-agnostic framework intended to bring consistency to code across different platforms. This framework included new classes and data types under the “xojo” namespace, such as “xojo.core.Dictionary” and the new “Text” class, intended to replace “String”. And Xojo felt it was good.

But then, in Xojo land, there were constant complaints about this new “xojo” framework. It wasn’t well received. Many felt it was too different and made things more complex. Xojo listened to these complaints. To address the issues and satisfy users, Xojo abandoned the new Xojo framework and deprecated it. To address the community’s original concerns of inconsistencies, Xojo worked to fix the inconsistencies by adding new classes, such as “Rowset”, alongside the existing “Recordset” class in the base framework. This was called API2, and Xojo assured the community that the old classes would not be removed any time soon. And Xojo felt it was good.

However, as more API2 changes were introduced, particularly with event names in the new Desktop controls, there were constant complaints about this new API2 framework. Some long-time users were so frustrated that they left the community, unwilling to switch to API2 since it did not offer any benefits for their existing apps. We all understand their perspective, but this made Xojo sad.

But there is a brighter future now. If you are starting with Xojo today, things are much, much better. The language is arguably more consistent, and the new Web framework is showing promise. Hopefully, Xojo is happy again.

10 Likes

More to the point, it wasn’t complete. Many methods remained for String only, not Text. This resulted, if you were trying to be a good boy, and not just eating up all your greens, but also using Text instead of String, in having to keep on converting from Text to String and back again. Which made everything clumsy and slow. In the end I decided not to bother, and threw out Text and all the xojo.* stuff too.

Never did like them greens either.

1 Like

Mid() was deprecated Please use String.Middle

for backwards compatibility/migration it should at least have the same index.
i suggested option base 0 or 1 like visual basic had.

if you like zero base and -1 its ok, i like to count items or rows start by first/one.

i remember DateTime class was also new and a good feature.

In my opinion API2 is easier to use and understand and it has more features.
Anyway API1 has still one benefit: backward compatibility. To run in Windows 7 you can not use Xojo’s newest versions as Microsoft already discontinued it. Sadly I still need to keep compatibility with Windows 7 and in some cases even XP. But for new projects that do not need to run in old OS, API2 is the way to go.

1 Like