Mike MacDonagh's Blog

Somewhere in the overlap between software development, process improvement and psychology

Category Archives: linux

Linux GUI Development: Lazarus 1.0 Review update

A while ago I wrote a review of Lazarus 0.9.30 and it came out with the 63% mainly because the installation process was so horrible. Well now it’s almost a year later and v1.0 has been released so it’s only fair I update my comments…


It’s still not exactly shiny but, and it’s a huge but, it is simple and it works! 🙂 To install on Linux I had to download 3 .deb files (1 for Lazarus, 1 for the compiler, 1 for the source) and then I could install them by simply doing:

doing sudo dpkg -i *.deb

It’s worth tidying up any old Lazarus installs first which you can do by running my script here.

Downloading *.deb files and installing them is pretty normal for linux users so although it’s not a shiny wizard installer or single command it is simple and most importantly it just works! I’m going to upgrade this from 1/19 to 8/10

First Impressions

A lot of the little niggles have gone away and it’s a much more stable, solid feeling environment. It does still load up with a million windows (Delphi style) and feel a little old fashioned (a lack of wizzy GUI controls and UI customisation, single window mode etc.) but being open source and written in itself I can change these things if I want to reasonably easily. In fact loading up the AnchorDockingDesign package makes the IDE a docked single window affair and there’s plenty of 3rd part controls to download and play with.

Normal multi-window interface for Lazarus
Lazarus as a single window IDE

There’s still no multi-project support and recompiling the IDE to get a new component on the toolbar feels a bit weird even if it does work perfectly well. I’m going to stick with 6/10 for those reasons.

The GUI designer and Code Editor haven’t really changed since my last review and so they stay happily at 9/10.

Language features

The handling of generics has improved since I last looked at Lazarus and all seems to work pretty well now 🙂

Otherwise nothing much has changed, no  multicast events or garbage collection but those things don’t really slow me down much. That’s why I gave it 6/10.

Despite the lack of some of these things the language has always been and still is quite elegant (other than the nasty globals), it’s got an excellent simple OO implementation and it’s really easy to quickly put an app together – oh yeah and it’s cross platform.

Cross-platform and backwards compatible

Lazarus works on windows, linux and mac. You can write a bit of code and natively compile it on each platform making for lightening fast code with no external dependencies. Write once, compile anywhere. You can already (partially) compile for android and other platforms are possible – anywhere the fpc compliler can be ported your code could work. That’s pretty impressive and it just works brilliantly.

Similarly all that ancient Delphi code can be loaded up edited and compiled and largely just works. Brilliant again. For that reason I’m going to bump up the language features to 8/10. (9 when android is working well).

I’ve not tried the feedback process again since v1 so I’m going to leave it at 7/10.


Despite it’s old fashioned feel in some places it’s simplicity is elegant and actually quite powerful. If you know the Object Pascal/Delphi language then it’s so fast to create good looking cross platform apps that it’ll knock your socks off.

When I pick up a new language I tend to do a challenge to load an xml file into a multi-column listview and create a details form to edit the selected row. In Java, something so apparently simple is a massive pain due to the imposition of the MVC pattern on everything. In C# it’s pretty easy, I can go MVC or not. In mono it’s reasonably easy too, although not the same easy and not as easy to get away from MVC.

In Lazarus it’s really easy, and it works fast and well on 3 major platforms. That’s a killer feature.

Category Score
Installation 8/10
First Impressions 6/10
GUI Designer 9/10
Code Editor 9/10
Language Features 8/10
Feedback process 7/10
Cross-Platform 10/10
Overall 81% – Easy to use and powerful

In my previous review I said I couldn’t really recommend it, and that made me sad. Now I can recommend it, in fact it’s quickly becoming my technology of choice for linux gui development, because it’s quick to put things together and they look good. Just maybe Lazarus is living up to it’s vision and bringing Delphi back to life, but bigger and better than it was before!

SimpleGit is developed in Lazarus


Can’t open links in Firefox on Ubuntu when it’s open – Fixed!

This is a little obscure but there’s a number of people with this problem and too many “simple” answers that just don’t work. There are a number of situations that cause Firefox to respond with an error message when you click on a link from outside of the browser (like Thunderbird or any other application that try to launch a url). You get an error message saying:

Firefox is already running, but is not responding. To open a new window, you must first close the existing Firefox process, or restart your system

The normal reasons for this are things like locked profiles etc. which are well covered here. But some users get this error message even when Firefox is open and there aren’t locked profiles 😦 The solution is to edit the way that Ubuntu invokes Firefox.

Grab a terminal and go to ~/.local/share/applications this is Unity stores it’s information for launchers in the unity dock thingy. You should have a Firefox.desktop in here, you might have several in which case the one called “Firefox Web Browser.desktop” is probably the one that Ubuntu is using by default.

Edit the file and have a look at the “Exec=” line about 4 lines down. In my case the problem was caused because this line was referring to an old profile that I’d previously removed trying to fix the problem. If you’re not sure what it should look like set it to “Exec=firefox %u“, save, exit and click links once more 🙂

Woooo Ubuntu Running On Android looks cool

Recover lost or corrupt LibreOffice doc files (or any deleted media files)

Today I had the great misfortune of suffering a power based computer crash just after lunch. I’ve been writing a huge educational document for a client but I wasn’t too bothered because I’d been saving manually fairly frequently and I’d also got the options set to keep a backup copy.

After rebooting I was somewhat dismayed to find that my doc file couldn’t be auto-recovered by LibreOffice. In fact it’d changed to 0 bytes long! I tracked down the auto-backup files and found them in


Unfortunately they were all 0 bytes too 😦 After some rapid passing through of the stages of denial, anger, despair and finally acceptance accompanied with a fair amount of swearing I realised that the file contents were likely still there on the disk but not in a file. What I needed was a bit of forensic disk analysis to try and recover at least some of my content. If you’re on linux you can do this fairly easily using foremost originally intended for law enforcement purposes and kindly provided by the US Government.

If you’ve not already got foremost then you need to install it

sudo apt-get install foremost

You then need to know which partition your file was on, just run a mount command and see which partition is mounted on the bit of directory structure your file was in. If you haven’t got a clue what any of this means it’s probably the one near or at the top of the output of mount that says something like

$ mount
/dev/sda1 on / type ext4

Then you can use foremost to scan the partition looking for things like “doc”s and recover them to a folder somewhere. So next create a folder to put the recovered files:

mkdir ~/recovered

Then it’s time to scan.

sudo foremost -t doc -i /dev/sda1 -o /home/mike/recovered

The folder “recovered” will start (very slowly if you’ve got a big disk) filling up with recovered files named things like 646546789.doc. Hopefully one of these will be a recent copy of your missing file. If you find one that is, it’s worth looking through the others as some of them might be later versions. All in all I only lost a paragraph of about 6 lines in my doc after recovery 🙂

Top tip: the less you use your computer between realising you need to do a recovery operation and doing this set of steps the more luck you’ll have recovering missing content.

Good luck 😀

Linux GUI Development: Lazarus 0.9.30 review and screenshots

This blog is part of a series looking at programming tools on linux and covers Lazarus 0.9.30

EDIT: Since I wrote this Lazarus v.1 has been released  so I’ve updated my review here.



I’ve always liked Wirthian languages since programming in Modula-2 and university and Delphi late because they’re very readable and promote good programming practices in the structure of the language. Also, I like Wirth’s law “Software is getting slower more rapidly than hardware becomes faster.” from A Plea for Lean Software even if it wasn’t actually him that came up with it.

When I made the jump from Windows to Linux I was on the search for a nice high level language to do GUI development stuff in. In searching I came across Lazarus. Lazarus is a free cross-platform IDE which provides the Delphi experience for Linux (and Windows). Rather than Java’s “write once run anywhere” Lazarus aim’s for “write once compile anywhere” courtesy of the Fee Pascal Compiler (FPC). On top of the compiler Lazarus comes with the LCL (Lazarus Component Library) which gives a single interface for GUI programming despite underlying differences in implementation.

Lazarus is at 0.9.30 so it’s not a v1 product yet… However I’m not going to give much benefit for that since it’s been around for both windows and linux since 2008 and is available from the Ubuntu Software Centre.


Oh dear… the most important part of a software package, since if it fails your software doesn’t get used and for Lazarus it just sucks! When I first tried to install Lazarus it took me over 20 times to get it actually working. A comment from the Lazarus forum replied: “…20 times isn’t that much…” as if this is acceptable. Ok, so it’s free and open source but if it’s not accessible people won’t use it. It’s so hard to get running I’ve posted twice on the topic (and had a significant amount of hits from people with the same problems).

Worse, upgrades to Ubuntu have totally broken the installation and it’s not properly compatible with the new Ubuntu overlay scrollbars leading to focus problems with windows, text boxes and menus.

Basically, unless you really care it not going to be easy to get going. 1/10

First Impressions

Once I finally got it running my immediate reaction was summed up by the word “w00t“. Despite the always ugly multi-window layout here was an environment and language I knew like the back of my hand (so long as I rewind my memory 15 years) and could quickly put together good looking cross-platform apps in minutes 🙂

Normal multi-window interface for Lazarus

Lazarus as a single window IDE

It is possible (by recomiling the IDE) to get a single window mode which is a bit more modern. I was little disappointed to see that it didn’t have multi-project support but at least it’s solid and works if a little old-fashioned feeling. 6/10

WARNING: Due to problems with focus, the current version is close to unusable in Ubuntu 11.10.

GUI Designer

The GUI designer is solid and works well. Guidelines, alignment indicators and a pretty good set of visual components make putting together a simple form trivial. There’s no layout controls as you get in many newer GUI IDEs (flex boxes, tables, fixes vs.s flow etc.) but the use of anchors and panels means this isn’t a problem. The GUI designer feels a lot like the Delphi designer 9/10

Code Editor

The code editor features all of the old colour schemes and look and feel of Delphi with all of the modern stuff you’d expect like code folding, code completion etc.  The link between code and visual elements is easy to manage, especially with the excellent Actions feature. The Lazarus code editor is actually an improvement over the old Delphi editor 9/10

Language Features

Global variables are still there, I understand taking them out would cause problems for supporting old code bases but it’s still a shame.

The language is a good simple OO implementation but it misses out on some modern features like extension methods, anon methods, iterators, code attributes/decoration, multi-cast events…

Generics have been added but they feel a bit like a bolt on in this version, especially as when compared to their simplicity in languages like c#. Here’s the same example I used in the c# mono review in Lazarus.

generic TGList<T>; = class
  Items: array of T;
  procedure Add(Value: T);

TBlobList = specialize TGList<Pointer>;


sb := TStringList.Create();
for n :=0 to Length(blobs.Items)-1 do
Memo1.Text:= sb.Text;

I’ve created my own base generic collection here and then specialised it for a custom type. All seems to work pretty well.

Finally.. there’s no (limited) garbage collection. Although visual elements are dealt with when you close a form (it’s normally too late by then if there’s a problem) there’s no garbage collection which means in that code above I need to change the TStringList.Create to:

sb := TStringList.Create();

All in all, although it used to be a neat elegant language, and it still is Object Pascal just feels a bit old fashioned and clunky now. Sadly I’m going to have to give this 6/10

Feedback Process

The main feedback mechanism is the Lazarus site with wiki and forum. The forum’s fairly active but there seems to be an acceptance of problems such as the installation issues which is worrying.  7/10


Although the current version doesn’t really work with Ubuntu 11.10 the previous (and I hope future) configurations provide a pretty easy to use solid GUI design and code experience if a little old fashioned.

The community is reasonably active but a lot of the Lazarus usage seems non-English meaning the resources are sometimes a little hard to understand for me and since Pascal is  a bit of a niche language these days there’s not much non-Lazarus resources that can apply (except for old Delphi resources).

Although I’m predisposed to be positive about Lazarus to be honest I can’t really recommend it unless:

  • You’re an old Delphi developer looking for some nostaligia
  • Someone who hasn’t accepted Delphi is dead (even the website set up to refute this http://www.isdelphidead.com/ is dead!)
  • You need to quickly produce something very simple for multiple platforms and don’t know any other languages
Category Score
Installation 1/10
First Impressions 6/10
GUI Designer 9/10
Code Editor 9/10
Language Features 6/10
Feedback process 7/10
Overall 63% – Sadly not good enough

Ngrams for nerds

Pictures that are worth 500 billion words!

Google Ngram Viewer shows graphs of how many times words or phrases have occurred in a set of 5 million books over the years. They’re a really interesting way of seeing trends in information and relative importance between words. It’s free and easy so check it out.

Here’s some I recently ran that I found interesting. I ran most of them from 1950 onwards and  the info only goes up to 2008.

Comparison of programming languages

Programming Languages

Ngram link – When looking at this you’ve got to mentally remove the baseline Java and Pascal references from the 1950 as they’re about coffee, islands and mathematicians. Interesting to see Java so dominant.

Programming paradigms

Programming Paradigms

Ngram link – I found this one really interesting. Compared to the others in my query “structured programming” had a lot more books written about it. I wonder how much this is a reflection of the rise of the internet… these days although there are lots of programming books the primary source for learning a language is online material?



Ngram link – I was a little surprised to see RUP so much more prevalent than agile but then I did have to add “software development” to the term to avoid including the bendy and stretchy. Also as with the previous one I suspect that there’s a difference here between a vendor driven process with supporting books and a more open source philosophy on agile as a generic umbrella for methodologies, and therefore more online sources. As Ivar Jacobson says: “No one reads process books

Shareware, Freeware and OSS

Shareware, Freeware and Open Source

Ngram link – This one speaks for itself 🙂 I wish I could have worked out how to add “expensive vendor products” to the query!

User Stories vs. Use Cases

User Story vs. Use Case

Ngram link – Ah yes, this argument again. Interestingly this dominance of use case over user story in written books correlates with query stats between user stories and use cases on by blog and the ivarjacobson.com site. Personally I think they’re both great and complimentary, I often use them together on software projects.

Windows vs. Linux

Windows vs. Linux

Ngram link – Yep, Linux beats Windows at every turn.

More Ngrams!

For more fun with Ngrams watch this very funny video explaining this stuff

Install single window Lazarus 0.9.30 in Ubuntu 11.10 step by step

I’ve previously blogged on installing lazarus on ubuntu but unfortunately upgrading to ubuntu 11.10 broke my lazarus installation 😦 Here’s how I fixed it all.

1. Totally remove previous Lazarus and fpc installations

sudo apt-get purge lazarus*
sudo apt-get purge fpc*
sudo rm -Rf /usr/lib/fpc
sudo rm -Rf /usr/lib/lazarus
sudo rm -Rf /usr/share/fpcsrc
sudo rm -f ~/.fpc
sudo rm -Rf ~/.lazarus
sudo rm -f /usr/bin/lazarus*
sudo rm -f /usr/bin/lazres*
sudo rm -f /usr/bin/lazbuild*
sudo rm -f ~/.local/share/applications/lazarus*

2. Install fpc so you can use it from the command line

sudo apt-get install fp-compiler-2.4.4

You can see if this has worked properly by writing a hello world command line app, comiling it and running it before you’ve even tried to install lazarus. Save the following in a file called cmdline_helloworld.pas:


writeln('hello world!');


Then compile using

fpc cmdline_helloworld.pas

and run using:


Free Pascal Compiler use on the command line

3. Install lazarus

sudo apt-get install lazarus

You probably need to disable overlay scrollbars otherwise you can get problems using menus and dialogs in Lazarus and apps made with lazarus:


if you don’t want to make such a global change then just make a script to start lazarus like this:


4. Change IDE settings to make it easier to use with Unity

Unity is annoying for many reasons, but it doesn’t deal with multi-window apps like Lazarus very well. So here’s some suggestions to make it all behave a bit better.

First, if you use a taskbar plugin like tint you can have Lazarus only show one button rather than loads on the task bar (Environment -> Options -> Window and slect “Show single button in Taskbar” at the top.

Second, I recommend making lazarus use single window mode. This is a little experimental but I think it’s a major improvement over the old-fashioned pre-Delphi 2005 layout.

Normal layout:

Normal multi-window interface for Lazarus

To transform Lazarus into a single window mode application you need to install the AnchorDockingDsgn package which is helpfully installed with Lazarus. On ubuntu in a standard installation it’ll be in /usr/lib/lazarus/0.9.30/examples/anchordocking/design.

Do this as sudo otherwise the recompiling process doesn’t have enough rights to backup packages and wotnot. So start lazarus by doing

sudo lazarus-ide

In Lazarus File -> Open and browse to anchordockingdsgn.lpk

When the package editor comes up select the install button. Lazarus will ask for confirmation and tell you only static packages are supported so you need to rebuild lazarus (that really needs sorting out!), say yes and then sit back and enjoy the compilation process.

Next time you start Lazarus it’ll be in single window mode. For some reason the Object Inspector (F11) isn’t docked by default but you can easily add it yourself.

Lazarus as a single window IDE

Ubuntu 11 Unity: Making it useable with application menus and taskbars

Application Menu

Call me old fashioned, it’s probably true but I can’t get going with unity. Where’s the app menu? I need it! Ok I can just press the “Super” (windows key) and type for whatever I want, and accessing my most popular apps is easy enough but what about the thing I use to edit music meta data, can’t remember it’s name right now….  Or the thing that grabs stuff from the internet and adds it to my build logs, what category is that in again… And what did I download and install from the uber duper super software centre that I thought looked cool…

All these questions and more are normally answered by the Application Menu. I need it back! After upgrading to Ubuntu 11 I got so frustrated with Unity I decided to install Gnome 3 to bring it back, but some evil Unity conspirators have infiltrated the Gnome developer team and persuaded them to kill the app menu too. It’s time to fight back against this conspiracy that’s trying to turn our desktops into smart phones. To do that, just install classicmenu-indicator from Florian Diesch

sudo add-apt-repository ppa:diesch/testing

sudo apt-get update

sudo apt-get install classicmenu-indicator

Once installed, run it: Alt-F2 type classicmenu-indicator and you’re good to go 🙂



Again I know that there’s ways of clicking on what’s running from the Unity dock, but for me it’s not very reliable in terms of popping up. In fact the Gnome3 dock is better, it kind of pings out of the top corner but both Unity and Gnome 3 have done away with taskbars for the current running windows. I use a lot of windows when I’m doing stuff, split between multiple workspaces and I just want a simple bunch of buttons to make life simple for me. Thankfully the same solution works for both Unity and Gnome3 and magically supports multiple monitors beautifully: tint2

sudo apt-get install tint2

You’ll also need to get it to auto-run which you can do by running


and adding /usr/bin/tint2 as an startup application, then you’ll need to log out/log in for it to run up 🙂

For me adding these bits are enough to make Unity usable 🙂

I finally managed to install lazarus 0.9.30 and fpc 2.4.2 on Ubuntu

[Update: this post was from May 2011 for Ubuntu 10, for Ubuntu 11 see here]

I tried updating apt sources with “deb http://www.hu.freepascal.org/lazarus/ lazarus-stable universe” but got an error:

Failed to fetch http://www.hu.freepascal.org/lazarus/dists/lazarus-stable/Release  Unable to find expected entry ‘universe/source/Sources’ in Release file (Wrong sources.list entry or malformed file)

I tried checking out the daily source from SVN but couldn’t work out how to make it all build properly. I tried the daily downloads of deb packages but got an error on starting that said “LCLBase 1.0” – “Unit not found: RegisterLCL” error.

I tried downloading various archives full of stuff and either making, installing debs or whatever with a variety of problems. Often there were broken package dependencies around e(.g. “package lcl-units-0.9.30 is not installed”).

Finally I found a way that worked over the weekend so I thought I’d share it for others having these difficulties. First if you’ve got a corrupt/broken installation or an old version installed it’s a good idea to get rid of it. I did this by doing:

1. Delete any existing FPC and Lazarus stuff, conflicts between versions are the source of many of the problems!

sudo apt-get purge fpc lazarus*
sudo rm -Rf /usr/lib/fpc
sudo rm -Rf /usr/lib/lazarus
sudo rm -Rf /usr/share/fpcsrc
sudo rm -f ~/.fpc
sudo rm -Rf ~/.lazarus

2.  Download and extract the fpc packages (although at time of writing the ones packaged with ubuntu 11.10 are good enough – 22/10/11) and the latest lazarus packages. This ends up with two folders full or .deb files. Going into the fpc one first, then the lazarus one and entering:

sudo dpkg -i *

Installs FPC and then Lazarus.

3. Finally run Lazarus from your main menu, weird unity thingy or whatever you use 😀

Moving from windows to Ubuntu, music, media centers, office and more

I feel like I jumped ship from Windoze to Ubuntu about 6 months before everything starting making sense in linux land.

I got fed up of my computer, which is reasonably powerful, taking ages and ages to startup, login and show me FireFox so thought I’d try Ubuntu. Installing as a windows app was so simple and it was so slick and fast that I was pretty much instantly converted and went the whole hog and now there’s not a trace of windows on my primary PC.

There were a few important things, some of which I couldn’t sort out instantly and some of which I had to wait for a few months for the next awesome and free Ubuntu release (a major one every 6 months) but now they’re all pretty much sorted 🙂

  • Media player that can sync playlists to my iPod – When I first got Ubuntu it came packaged with a media player called Rythmbox, at the time it didn’t sync playlists to my iPod, now it does. I had to search a bit for a script to transfer my ratings from iTunes to Rythmbox –  a bit convoluted but only took 5 mins and, more importantly, it worked!
  • A decent big screen media center app – it seems I’m both fortunate and unfortunate in having an nvidia graphics card. The most popular media centers (like XMBC and variants like Boxee) don’t work for me. I currently use Moovida which is good, but not perfect.
  • My various bits of hardware like my wireless printer, wireless mice, extra functional keyboards etc. – they all just worked 🙂 I also have a mini handheld keyboard thingy that didn’t just work but the fix for that is in the next release of Ubuntu in April 😀
  • Connecting to my work’s Outlook – Using Thunderbird this has now been achieved, it was quite involved so I’ll post about it as another post in a bit and update a link here when it’s done.
  • Messing around with screen settings – I flip between a dual screen setup and a large HD tv screen for media so need to change screen layout and resolution with a single button press, on windows I paid for UltraMon to do this on Ubuntu I achieved it using auto-disper for free!
  • Security, virus checking, firewalls etc. was all a bit different, so I’ll post about that separately too and update a link from here.
  • What about my favourite apps? I’ve managed to find through the Ubuntu Software Centre (a bit like an app store but free) a whole bunch of replacements straight away from LibreOffice for MS Office to loads of utilities and free games. I couldn’t really live without FireWorks and Dreamweaver just because I’ve been using them forever, but they work just great on Ubuntu with Wine (Pinta is a reasonable FireWorks alternative for Linux)
  • Development… that’s definately a whole other topic! But needless to say there’s loads of options and choices, finding one that suits you is the trick. I’ve had minor to major problems installing most development environments but an early favourite (due to my Delphi background) was  Lazarus – I’ve since moved to the much better MonoDevelop
%d bloggers like this: