Xojo 2018 R1

Xojo 2018 R1 was released today.  It’s been over four months since Xojo 2017 R3 was released in December of 2017.  By any stretch of the imagination that’s a long time between updates.  Let’s start with the big ticket items that you’ll be relatively happy about.  2018 R1 has a ton of bug fixes, enhancements, and new features.  

Windows users will find things to be happy about as Xojo has gone way out their way to reduce flickering issues in the Xojo IDE and in our own built apps.  The magic behind the scenes is not that Xojo is using double buffered windows (or anything like it) but they are now freezing drawing in the window while it’s doing things in the background.  Thus the flicker is gone but at the price of speed.

If you’ve spent a lot of time working around the limitations of control flickering in Xojo, your upgrade to 2018 R1 won’t be a walk in the park.  A number of forum users have done considerable work figuring out the best way to get things to work well together.  The basic premise is that everywhere there is a Transparent, DoubleBuffer, or EraseBackground property you should turn them off.  I’m sure in the upcoming days a more thorough explanation of the best practices will turn up on the Xojo forums.

One thing that might really turn developers off is Feedback Case #51337 where Labels look ‘fuzzy’ and not acceptable to many end users.  This appears to be caused by the difference between the Direct2D drawing engine and the old GDI engine.  Before jumping into 2018 R1 you might want to do some testing to see if this is acceptable to you.

Printing in Windows appears to be better now as you can now print with higher resolution than 96 DPI.

The other big Windows feature to make it into 2018 R1 is the ability Debug and Remote Debug 64-bit Windows applications.  This is a big deal and required that Xojo upgrade the compiler to LLVM version 6.

In late beta testing I had issues with the Remote Debugger (from MacOS to Windows) not dropping down into the debugger and AutoComplete sometimes not working but those appear to be fixed just before the final release.  If you run into issues with either please report them as soon as possible!

The EraseBackground property is now gone for Canvas and Container Controls.  Container Controls have a new DoubleBuffer property that composites the control on Windows and allows for moving/scrolling controls with less flicker.

The Currency datatype is working properly again in 64-bit builds.  In previous builds the Currency comparisons didn’t always work and precision was lost when dividing Currency values.

A host of Windows framework bugs were fixed in the Listbox. The Val function in 64-bit Windows builds now returns appropriate values.  BevelButton captions and menu arrows now work properly when the DPI scale factor is greater then 100%.  Graphics TextUnit.Pixel is no longer treated as Point sizes when the DPI scale factor greater than 100%.  Please see the Release Notes for a complete list of Windows framework changes.

The Web framework received some love too.  The WebFileUploader control works with files greater than 2 GB in size and works with files with ampersands and apostrophes in their name.  It also supports drag and drop and now has a new UploadProgress event.  It also supports file multi-select to allow users to select more than one at a time.  It also has a CancelUpload method and a new UploadTimeout property.

The WebMoviePlayer now uses a native HTML5 video player on supported browsers (I believe this means all of them) and now has a separate Stop method.  Internet Explorer 9 support was removed.  WebMapViewer only calls into the Google Map API once per browser session.

The SQLite library was updated to version 3.22.  One of the big changes is that errors when creating SQLitePreparedStatments now get a more meaningful error messages versus the unhelpful ”unable to prepare” message.  SQLiteDatabase now supports AES-256 encryption.  The SQLiteDatabase now yields to other threads when it’s busy performing a long operation and using the ThreadYieldInterval property.

For many users the upgrade to 2018R1 will be a no brainer.  However, those that have a complex UI should do some testing in Windows to ensure that drawing speed is still acceptable.  Some beta testers found that the tradeoff of being flicker free was not worth the slower rendering speeds.

The Debugging of Windows 64-bit applications is a much needed and welcome feature.  Without much time to see it working (properly) I can’t give much of an opinion of it.  The compiling speed of 64-bit apps is very slow and it appears that incremental compiling is off.  I would expect the entire process to get better over time.

With this major milestone out of the way I hope we see considerable progress on Interops, creating plugins from within Xojo, Android, and Web 2.0 in the next couple of releases.  I’m sure we’ll find out more next week at XDC.

What excites you in 2018 R1 and what gives you some concerns?

Musings on the Xojo Framework

The Xojo framework was first introduced with Xojo 2014 Release 3 (December of 2014).  That’s when iOS was added as a target to Xojo.  Since it’s initial release it’s received plenty of bug fixes and some libraries have been added to the desktop, web, and console targets that use the new framework.  But it sure seems like there hasn’t been much news about the new framework.

If I go back into my archives and what I’ve reported from past XDC’s we were told in March 2014 the new Xojo framework would come first to iOS with it’s own version and then to console, web, and finally to desktop apps.  At the time I took that to mean that they’d be a replacement to the old global framework but, in retrospect, it’s obvious that they meant what they had done for iOS would get introduced to those targets.  That meant that the core data types, Auto and Text and the core classes, MemoryBlock, Date, DateInterval, Dictionary, FolderItem, Crypto, and so on, were available for use.

Some things like the Xojo.Net.HTTPSocket are now the ONLY way to communicate with some servers because it can handle HTTP 1.1 and supports proxies which the old global HTTPSocket can’t do.  So for some things we are forced to use the new version.  For some it’s quite a change because the old global version could do things synchronously but the new version can ONLY do things asynchronously.  Using sockets from the new framework is not a simple proposition.

There are still huge swaths of functionality that is not available in the new framework and if you need it you’re forced to either develop it yourself, or to use one of the open source projects the Xojo community has released.  While the community has been generous this goes against the modus operandi of Xojo where they’ve provided all of the basic functionality.  This is particularly vexing for newbies that know there’s a new framework but need functionality not provided yet.  And as someone who has tried having global and Xojo frameworks working together it’s not very fun.

Because it appears we’re not seeing much progress, Xojo developers are starting to get nervous and asking questions.  Is the Xojo framework a bust and will Xojo be going in a different direction?  I’m hoping that both of these questions get answered in a couple of weeks in Denver at the annual Xojo Developers Conference (XDC).

We already know that Xojo Web 2.0 will be introduced at XDC 2018.  If it’s still using the old global framework I think it will call into serious question on whether or not the Xojo framework is viable.  I mean, if you’re going to the trouble of rewriting the web framework, why not make it use, exclusively, of the Xojo framework?  If it’s not, why not?  

Well also know that we’re getting some major news for Android for Xojo at XDC 2018.  Will it use the new Xojo framework?  If not it’s a clear sign that the Xojo framework is dead on arrival.  If it is but Web 2.0 is not again I have to ask why not?  Xojo then is sending out mixed messages as far as what the Xojo framework means to their future.

XDC 2018 is going to be an important one.  We’re going to learn about the progress on Web 2.0 and Android.  Hopefully we’ll have reasonably firm targets for releases.  As part of that I really want to know what the status of the Xojo framework is what the future brings for it.

Other topics that I hope to hear about:  plugins made in Xojo, and Interops

What are your thoughts about the Xojo framework?

Does Xojo Crash On You? Try Clearing the Plugin Cache

Several people on the Xojo forums have complained about Xojo crashing on them multiple times per day.  I rarely, if ever, have that issue but I do occasionally get an issue where a compiled application will do something that’s batsh*t crazy and nonsensical.  

For example, I had some database code that was doing a simple database query where the error bit was returning true (or at least the compiled application was saying so).  I spent hours trying to figure out why it was returning an error.  I replaced the database file (SQLite) with a fresh file, ran the query in external editors, I did practically everything and finally I gave up.  I shutdown Xojo and restarted my iMac.  The issue persisted.

Finally I did my fixit option of last choice:  I cleared my plugin cache.  I restarted Xojo and voila!  The problem went away.

This happens once or twice a year for me.  We use a lot of plugins from Monkeybread and Einhugur (and others too) and switch versions of Xojo quite a bit so I’m never really surprised that this happens.  Usually when I clear the cache there are a LOT of versions listed.

The Xojo IDE has plugins that it has to compile and use so those that don’t use third-party plugins may also experience this issue.  And of course the project cache is true for everyone as well.

For those using third-party plugins, it’s ALWAYS a good idea to keep up to date.  I know Monkeybread Software has done a LOT of work recently getting ready for 64-bit for Windows and Einhugur has done a lot of work recently to support Gtk3 in Linux and 64-bit Windows. I know I’m still waiting on the Einhugur Treeview plugin so I can move a Linux project from 2017 R1.1 to something newer.  Before complaining to Xojo do your due diligence and check for newer versions!

So my advice is when things are acting weird, empty the plugin and project caches.  On macSO this is in ~user/Library/Caches/Xojo.  In Windows this at C:\Users\YOUR USERNAME\AppData\Local\Temp\ with two folders, XojoIDEPlugins, and Xojo scratch XXXX folder with XXXX being some specific number (build number?).  I have no idea for Linux (sorry).

This might not be a perfect solution but it might keep you from going crazy(er).

RAD Still Means You Have to Learn the Language

Xojo is a great development tool that is a Rapid Application Development (RAD) environment.  That’s marketing speak for you can get stuff done quickly.  The marketing speak isn’t wrong but for many people they think this means that Xojo is ‘easy’ and the learning curve is next to nothing.  I hate to break it to those developers, but it just isn’t true.  Xojo, like any development language has a learning curve.  It might be a lot less than others but there is definitely one.

The truth is that Xojo is RAD once you learn how it works.  This means you have to learn the basics of the IDE, the language, and the debugger.  And only after understanding the basics of Xojo can you start taking advantage of the RAD part.

There are parts of Xojo that aren’t so RAD.  One of those, in my opinion, is database coding.  You still need to know SQL, and use the basic database classes to read and write data into your application.  In fact, it’s so low level that the IDE does not help you, in any way, which may lead to database errors.  The IDE will happily let you try to put a string into a numeric field in the database.  What worse is that depending upon which database is used (looking at you, SQLite) it won’t complain when you do so (thankfully this is not true of all databases).

Putting data into a database using the database classes is a two step process.  One, you have to query the database knowing what the field names and datatypes are as there is no autocomplete for them.  Xojo will happily let you (try at least) put a date value into an integer at design time.  It’s not until you try all this at runtime that things fall apart.  The same is true for updating and inserting data.  These are the reasons why we came up with ActiveRecord – our database classes for Xojo.

ActiveRecord is our way of making the Xojo compiler a little bit smarter.  It maps each table to a class and the properties in that class map to the database fields.  ActiveRecord checks to make sure that all of the fields in the table are represented in the class.  If not it flags the developer.  (It does way more but this post isn’t really about ActiveRecord.)

From our experience, jumping straight into ActiveRecord isn’t all that helpful for new Xojo users.  It’s a shortcut and you’re depending on our code without understanding it and I strongly discourage it until you’ve gone through the pain and tedium of using the standard Xojo classes.  In fact, when we train new developers we ALWAYS have them do a small project using the standard Xojo database classes.

Then we train them in how to use ActiveRecord.  The setup is a bit more involved and it’s not a perfect system, but once they start using the Table/Field autocomplete and having the compiler warn about mismatched datatypes they start to understand how much faster they can code database applications.  We are consultants, after all, and time is money.

Rapid Application Development systems do NOT mean quick to learn and being able to create an application with no experience.  RAD means that AFTER you’ve learned how it works it can be incredibly fast.  Once you learn Xojo is *can* be very fast to develop applications.

Anyone disagree with this?  What is the best method of learning Xojo?  Online documents?  Webinars?  Videos?

What is the Best Font for the Xojo Code Editor?

Somehow, after working with Xojo for seventeen years I’ve never changed the default typeface for the Code Editor.  It’s not that big a deal, really, but there are times when the default proportional font causes some issues.  At times it’s hard to read the difference between i’s, l’s, and 1’s as they all tend to blur together.  There are also some issues with selection and cursor placement that are annoying.

If I can find the right font I’ll change in a heartbeat.  What do you use and why?

Xojo 64-Bit Debugging

We’ve migrated a couple of projects to 64-bit and for the most part I’m pleased with how Xojo handles it.  It’s pretty seamless and it just works.  I can’t ask for anything more.  Additional observations:

The lack of Windows 64-bit debugging makes life difficult.  This appears to be corrected in 2018 R1 (in beta now) so that will be a most welcome change from having to go old-school and use logging to debug my Windows applications.  64-bit debugging in macOS and Linux works just like 32-bit applications.

There is no incremental compiling, yet, in Xojo.  This makes the debug cycle much longer than we’re used to with 32-bit applications.  When you debug a macOS or Linux application the dialog is quite clear that incremental compiling is off so there’s hope that the next step in this process is to get incremental compiling working.

The 2018 R1 beta cycle has taken a long time.  Presumably the level of effort to get the LLVM compiler working for Windows 64-bit debugging was painful.  And now that it appears to be solved hopefully all the other goodies on the plate (interops, Android, web 2.0) can all proceed at a good pace.

I had an instance the other day in 2017 R3 where Target64bit didn’t work.  After struggling with it for a while (because it should have worked) I deleted the plugin cache and restarted Xojo and voila!  It started working again.  I wish I had a better way of diagnosing stuff like this.

Miscellaneous:

I’m a big fan of the Einhugur Treeview control for several reasons.  First, it’s very fast with the ability to LockDrawing.  Second, since nodes are persistent you don’t have to go to extra lengths to manage your nodes as the user expands and collapses nodes.  Load them once and they’re there for the duration.  It’s a good option, in my opinion, for really fast development work.

The only drawback I have with the TreeView control is that it’s not compatible with Gtk3 yet.  According to Bjorn it won’t be until this summer.  This means any Linux projects using it will have to stick with Xojo 2017 R1.1 until it’s updated.

Happy Coding!

Updates

One of my goals for 2018 is to write more.  So here’s an update on stuff.

We hired a new developer who comes on board in a few weeks.  I’m really excited about his Xojo experience and what he brings to the company.

The planets and stars aligned and I will be going to XDC in Denver next month.  This makes me very happy as XDC is one of my favorite events!  I get to immerse myself in Xojo for a week and see all my friends and meet new ones.  I’m not presenting so that makes life a little easier too.

The week of XDC is going to be hectic as the weekend before as the FRC robotics team my son is on will be attending the World Championships in Houston.  Last weekend they won the Heartland Regional Tournament in Kansas City.  After a pretty disastrous first day where a lot of mechanical issues arose they had a solid last day, got picked by the 3rd seeded alliance, and eventually won the tournament (an alliance is composed of three teams) and advanced, automatically, to the championship tournament in Houston.

If you are geeky and interested in what these kids build, here is the final match where they won the tournament.  https://www.thebluealliance.com/match/2018mokc2_f1m2

Serial Devices as Keyboards – Yuck!

We’ve recently had a number of projects that required the use of a serial devices in desktop applications.  In all cases the clients said the devices are, “easy to use,”  since they act just like a keyboard.  If our experience is typical then I’d hazard a guess that many Xojo developers are frustrated with them.

Several projects required the use of barcode scanner.  Having a barcode scanner work as a keyboard makes sense, I guess.  It means that it can work with literally any application, anywhere, any time.  All it needs is focus on a text field and whatever the scanner sees it puts into the control.

In another project we had an ultrasonic sensor that would take the application out of idle mode and present the user with purchasing information.  Again, it acted just like a keyboard which means it works with any application as long as you had focus in a text field.

If you happen to know WHEN this information is going to come in it’s not so bad as you can plan for it.  Putting the focus in a field and waiting for information is easy.  It’s not so easy when that information could come at any time.  Of course all of our applications had data that could come in at any time and we had to be prepared to act on it immediately.

If you rely on a TextField or TextArea getting this information the rest of your interface can really suffer.  It means that when your barcode/sensor field loses focus you have to get it back (or you lose information).  Do you do this right away or wait a few seconds?  And if you have a complex user interface how do you deal with tabbing between controls, or even simple things like a user changing a checkbox because the focus is lost on your TextField?  It can be a nightmare to try and figure out and get right.  The differences between Mac and Windows and Linux can be frustrating!

The answer that we ended up implementing was putting the barcode readers into serial mode.  I’ve not run into a barcode scanner yet that couldn’t be used in serial mode.  Every scanner has a gazillion different modes and properties (all set via barcode of course) and one of them is to make it appear as a serial device to the computer.  On Windows this is a COM port and on the Macintosh they tend to show up as a USB Modem.  If I had to guess I’d say it’s harder getting barcode readers that are Mac and Linux compatible.

Once it’s in serial mode it’s almost trivial to create a class that monitors the serial port and reads the data WITHOUT needing the focus in a TextField.  The class then distributes the data to the objects that can consume the data.  What I do is have the window or objects register itself with the class and then when the data comes in the class sends it to all registered objects.  Each of the objects has an Interface with a simple HandleBarcode method.  This is known as the Observer Pattern and there’s an example that ships with Xojo.

My ultrasonic sensor wasn’t so easy to overcome as it couldn’t be put into serial mode.  However, it did come with a Windows-only SDK (thankfully it was a Windows only project) and with a little help with Declares we were able to get it working so we could tell if someone had walked up to the device and when they had walked away.  I’m not sure what we would have done if it had been a Mac or Linux project.

Serial Devices are relatively easy to work with in Xojo (as long as they show up in the serial list).  Having to deal with devices that act as keyboards not so much.  I’d highly recommend trying to get them to work as serial devices and save yourself a ton of grief.

What’s been your experience with serial devices in Xojo?

The Sound of Silence

Hey folks!  I just wanted to let everyone know that I’m still alive and kicking.  2018 has started off busy and chaotic.

I’ve been on-site with a client for nearly three weeks since the first of the year with a project, that while fun, has been challenging.  It involves big touch screens, credit card terminals, talking to three serial devices over USB, and calling into a Windows DLL.  This is the second major project with this client.  The first one required using Xojo for iOS with an integrated barcode scanner.

My son is a senior in high school (and all that entails) and co-captain of the FIRST robotics team.  I spent a good chunk of my limited free time writing their scouting application not only for desktop (Mac and Win) but for iOS as well (using Xojo of course).  Nothing like doing a big(ish) project for free.  Oh yeah, I’m nominally the programming mentor though I’ve had to step back some (since being out of town so much).

If you want to learn more about FIRST robotics and the challenge for 2018 go look at https://www.firstinspires.org/robotics/frc/game-and-season  I can’t say enough good things about FIRST and what it’s teaching these kids.  I believe the future is bright when I see what these kids accomplish (mostly) by themselves.  For what it’s worth my son received a really nice scholarship to a good university because of his FIRST robotics involvement.

To add into this mix BKeeney Software has been shorthanded for a variety of reasons.  My workload tripled a few weeks ago and we’re actively looking for a new Xojo developer.  As if I needed more things to do.  🙂

Mostly because of senior year commitments only one staff member is going to XDC in Denver.  This saddens me, a lot, since I haven’t missed an XDC since 2004 (I think).  It also means it’s unlikely that we’ll make it to the MBS conference in Munich this Fall.

I’m looking forward to some much needed time off.  I hoping that once things settle down and a new developer (or two) is on board I can get back to writing more.  2018 is going to be a big year for Xojo with so many things coming on board (the new web framework, interops, 64-bit debugging FINALLY working in Windows, and Android to name a few).

Coding Habits To Keep You Alive When Time Travel Is Invented

When you’re writing code we all know it’s a great idea to use method, property, class, and variable names that make sense.  It also makes sense to add in comments on code that isn’t clear.  But do you code in such a way that your future self won’t invent a time machine and come back and slap you in the face?  This is how you should be coding.  You really want your future self to appreciate the work your current self is doing.

One of the current projects I’m working on interfaces with multiple devices via serial communications.  Each one of them uses a different protocol (naturally) and some of the code was written by me and some of it by others.  Before I get into the Other Peoples Code (OPC) portion I’ll talk about my experiences with coming in cold to something called ccTalk.  ccTalk is a low speed communications protocol for use with Coin and Bill Accepters.

Had I ever heard of ccTalk?  Nope.  So the first thing I did was Google it.  I found a few helpful blog posts on it (saved the links) and found a few projects in Java and in C# and downloaded what I could.  I studied their code.  I found specification documents for ccTalk and device documentation and all were immediately added to the source code repository.  Why?  Because as soon as I move on to the next project I’ll forget the details.  If the information isn’t relevant in two weeks I’ll most likely forget about it.

In writing this post, I came to the conclusion that I also need to add any required drivers to the repository as well.  From experience I’ll inevitably need them in the field and if I don’t have them on hand I’ll waste time searching for them again.  Were they sent in an email, on the packing CD, or available from the website?  If it’s in the repository I won’t have to worry about it!

In my source code I document the message numbers I’m sending to the device and putting relevant details on the response and what I’m expecting back.  For ccTalk this might be a simple acknowledgement/busy response and depending on the command some additional data.  How much data am I expecting?  Did I get less?   Did I get more?  Does the checksum match my own calculation?  Do I have a way to create a log of the communication stream and is that log in human readable form or in hex?

This might seem like overkill but I’ve had to go back to my own code years later and relearn what I did.  This has involved finding the manuals again and trust me that’s no fun.  I think it best to assume you will not be the programmer on this project in the future.  Perhaps you get hit by a bus tomorrow and your client has to find a new developer.

The OPC portion of this project is using a different serial port to a different device and has exactly 24 comments in it.  Most of the comments don’t help me.  Commenting ‘If Serial1.open then’ doesn’t help me.  There are a few ‘Return //Exit this Routine’ comments that again would be more helpful if I knew why I have to exit the routine because it’s not immediately obvious from the rest of the code.  There are no comments regarding expected data.  No defensive coding techniques to ensure that if something is missing or garbled it can handle it gracefully instead of just crashing.  Of course there was no documentation for the hardware either so I’m not even entire sure I have the darn thing hooked up properly – all I can do is assume that I did until I get that documentation.  All-in-all I want to jump through the screen and scream at the other developer to a) put in useful comments; b) include the documentation with the source code; and c) include drivers and utilities that a newbie would need!

I try to make sure, in my code, that the developer that looks at my code in six months doesn’t curse me.  I say enough bad things about myself as it is.

What sorts of things do you do to ensure future you doesn’t curse your current self?