Archive for August, 2013

Second Impression of Lazarus/FPC

Sunday, August 25th, 2013

I finally had a few hours to work on hcOPF support for FreePascal which I had started some time ago.  I downloaded the Lazarus 1.0.10 installer and ran it in my development VM.  Then I continued creating new FPC projects, attempting to mirror the Delphi ones.  What I found, is that as a Delphi developer, the combination of Lazarus with FreePascal is far from a seamless transition if you are trying to migrate a framework.  There are numerous unit differences and the FreePascal compiler has significant differences from Delphi’s compiler even in Delphi compatibility mode.  The way Lazarus handles package projects is different, as are all GUI dialogs for the compiler paths and conditional defines, and even the IDE windowing.  It all takes a little getting used to.

The compile cycle seems to be longer using Lazarus, and the debugging tools are IMHO much more primitive than Delphi.  For instance, you cannot evaluate expressions such as Person.AttributeByName(’FirstName’).Value like you can in Delphi. The debugger visualizers are also quite a bit different from Delphi.  Due to an incomplete port, the IDE crashed while tracing the code with a 219, resulting in an empty LPI file for subsequent runs.  On the plus side, it loads SO much faster than XE4, being almost instantaneous, that such crashes aren’t a real impediment and I’m sure are an unusual situation.

Of course I miss having GExperts and cnPack functionality.  It’s unfortunate that no other IDE exposes the same OpenTools API interfaces used by such projects, so a developer could take them along.  I also really liked the CompBar substitute for the D7 component palette, and if I could install CodeRush for D7 in Lazarus I would be sold ;-) .

There are a lot of little differences, but a lot of the time, it’s simply an issue of getting familiar with the IDE.  For instance, it took me a while even to figure out that Delphi’s Browse Back/Forward is called “Jump Forward/Back” in Lazarus and was mapped to different keys.  I remapped them (try that in Delphi) to use Alt+Left Arrow/Rt. Arrow and I was happily drilling through the code again.

The demo I am working on porting uses a Firebird database with the IBX connectivity layer.  After looking at all the Lazarus database examples I had decided that it was going to be a longer porting effort until I ran across the IBX port from MWA Software.  I downloaded and installed it, and suddenly I could use my datamodule from Delphi without a problem. I thought I was home free, until I found I needed to install some design-time code into the IDE and I couldn’t resolve “Designer.GetComponent(Value)” in a TComponentProperty editor.

I will continue working on my FPC port as time permits.  Lazarus is truly an impressive IDE with some nice features such as closing All Other Pages in the editor.  I am sure as I spend more time, I will discover many other tools made by developers for developers (not a marketing department), and I really like the back to basics, no fat approach.  It’s as close to having an open source version of D7 as we will ever get.   It is also nice to be able to choose your UI Widgetset instead of being locked into a proprietary vendor solution.  What is equally as impressive is how the open source community is developing viable technologies for iOS and Android in addition to the impressive OS list that the Lazarus/FPC combination could already target.

If you are interested in learning ObjectPascal, or targeting Linux or Mac OS/X with 64 bit native code, or even considering Android/iOS development, the no cost, open source, Lazarus/FPC combination is worth a look.

XE5 World Tour Smaller than XE4?

Friday, August 23rd, 2013

I just checked out the World Tour for XE5, and despite the buzz about iOS development with Android support just around the corner, it appears as if the XE5 tour has fewer stops than the XE4 tour.

EMBT is no longer stopping in Calgary, Alberta, Canada (the IT capital of the west) where I reside.  In fact in Canada the map shows only a single stop in Western Canada, but when you click on it the dialog shows two stops; in Montreal and Toronto.

XE5 World Tour - Single Canadian Destination

XE5 World Tour - Single Canadian Destination

Apparently the map is based on a JPG image file rather than demonstrating Delphi google map integration, and there is no single source of truth, so something has gotten out of sync.

I certainly hope this is not another indicator of the decline of Delphi users.

Delphi Packaging and Pricing a Mystery

Tuesday, August 20th, 2013

If you already upgraded to XE4, but didn’t buy the mobile pack, it appears that EMBT penalizes you if you then want to upgrade to the mobile pack.  According to this pricing page, the mobile pack AddOn is $499 if you already own XE4 or not.  Seems to me it should be $449 to reflect the upgrade cost from XE3 to XE4 if you bought the special, or whatever you paid for your upgrade.

What is also baffling is that there appears to be no way to experiment with the iOS mobile pack.  The trial says it contains “Trial includes Delphi, C++Builder and HTML5 Builder. Instant Trial includes Delphi and C++Builder.”.  There is no mention of the mobile pack which for many would be the primary incentive for buying an upgrade over XE3, and the reason EMBT is reporting year over year growth.

The Dangers of With

Friday, August 9th, 2013

I have known about the dangers of using the with statement for a long time now.  Today, I encountered a new one.  I was refactoring code in a datamodule used to iterate over a dataset and insert each record into the database (a common construct).  The numerous ParamByName() calls were enclosed in a ‘with query do’ and I received a run-time error in a FieldByName() call.  The FieldByName() was to be called on the dataset which was not yet part of a with clause so it resolved to the query and of course the field didn’t exist.  A classic problem with using FieldByName() exacerbated by the with statement.

The issue I didn’t expect, was when I tried to modify the with statement the XE4 IDE stopped responding.  I waited a few seconds thinking it would come back after the the parser finished.  It didn’t.  I decided to go for lunch…when I came back about 20 minutes later the IDE was still unresponsive and I had to kill the process.  Thankfully I have always enabled the Autosave options in the IDE, so I didn’t really lose any work.

You Clumsy GIT

Monday, August 5th, 2013

I recently ran into an issue when refactoring a project, in which the compiler was reporting an error that a method had insufficient arguments.  Using Ctrl + clicking to drill through the code clearly showed a parameterless overload.  Error insight also seemed to be off exactly one line.

Rearranging the methods within the unit didn’t change the outcome, but it showed that after a particular line there was an issue, because Ctrl + clicking on a local variable no longer jumped to it’s declaration, but one line above.

Using NotePad++ to show all control characters, there didn’t seem to be anything other than the normal <CR><LF> characters at the end of each line.  Once we performed a conversion to Mac/Unix format and back to Windows in NotePad++, the issue was resolved.  It appears that GIT must have changed an EOLN marker at some point and we simply didn’t notice it in Notepad++.