Lazarus

Thursday, December 25. 2008

Lazarus

Currently I'm again involved in developing GUI software for Windows. In the past I always did this with Delphi so I thought it would be nice to use it again. I searched for a free version of it which was quite hard. How the hell is it called today? Borland Delphi? Code Gears Delphi? Turbo Delphi? Which is the newest version? Delphi 2006? Delphi 10? Where are the Personal Editions? Is there still a Kylix out there for cross-platform development? Wasn't there an announcement that Borland will switch to Eclipse for Delphi development? Very confusing situation...

I ended up with Turbo Delphi Explorer but I had a bad feeling about it and the future of Delphi at all. Turbo Delphi Explorer is slow and I think there must be some sort of memory/resource leak in it because it was getting more and more slow while working with it and only a restart of the IDE fixed the problem for some time.

So I started searching for an alternative. I already made contact with Free Pascal which I used (or better a tool from it) to create Delphi units for shared libraries I have written in C. And I was surprised to see that there is an IDE (Lazarus) available for it and I was even more surprised to see that the IDE looks like and feels like the good old Delphi from the past. I started with the standard test program: Drag a button onto the form, double-click it, write a ShowMessage-line, Press F9). It worked! Fantastic.

Next step was checking out the component library. It offers all the standard stuff known from Delphi and even some modern stuff which I always missed in older Delphi versions (Yeah, I know, current Delphi versions may have it), like a Tray Bar component, Windows XP manifest support or PNG support.

Then I tried out the cross-platform functionality. I installed Lazarus on Ubuntu Linux and compiled my program there. Worked fantastic but looked like rubish because I was only able to compile a GTK 1 program. After upgrading to the current 0.9.26 release I was at least able to compile a shiny GTK 2 application but QT is still not working. But I don't care about QT for now. GTK 2 is what matters. I have some visual problems in the forms but I'm sure I can solve them later.

After finishing my application I wanted it to be translated to German. In Delphi I did this with Resource DLLs which was pain-in-the-ass. Lazarus uses the well known gettext system for it. It was hard to find out how to use it (Because Lazarus documentation sucks) but in the end it worked perfectly and I will never miss it again.

But Lazarus has one problem which I may not be able to solve: The executable size is pretty large. On Windows a standard Hello World application is 1.5 MB large (And for this I already activated smart-linking and disabled all debugger stuff I was able to find). Turbo Delphi Explorer creates a 500 KB application with the same functionality. On Linux it's even worse: The application (which is linked to dozens of shared libraries) is 4 MB large! Without smart-linking the application is larger than 10 MB on Windows and Linux. Don't know what causes this immense size but I hope it will be optimized some day.

But in the end I will stick to Lazarus. I just finished my first application and it works great. The IDE is pretty stable for a Beta version and much faster than Turbo Delphi Explorer. Together with the free Inno Setup I can create shiny Windows applications with shiny installers without using any closed source software.

Marco van de Voort at 2009-01-09 14:59
Do not forget to strip!

It sounds like the linux bin still contains debug info
Klaus Reimer at 2009-01-09 15:06
Nope. Debugging infos are not in there. I checked the "Remove debugging stuff" checkbox in Lazarus and even the strip command on the command line doesn't make it any smaller.
Yan Chengyuan at 2009-04-15 07:23
hi!i just want to know how did you managed to use gettext for l10n or i18n.i searched for sites but still cann't get any useful information.the reason is clear,as you wrote: the lazarus document sucks!
i'll be glad if you can help me.thanks in advancd.
Yan Chengyuan at 2009-04-15 07:26
sorry i missed your i18n tutorial.but do you know how to use xml with fcl?
Klaus Reimer at 2009-04-15 07:41
Nope. Sorry.
Yan Chengyuan at 2009-04-15 18:48
thank you all the same.

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA