Developing cross platform desktop applications

Right from the beginning of my interest in programming; I’ve always had a thing for developing apps. Apps in the classic sense; the ones with a lot of bells and whistles that used to dominate the Windows landscape of yesteryears; the same ones usability experts would now cringe on looking at. That was probably because of the way I was introduced into programming. Starting with the good old QBasic; then moving on to Visual Basic – the only language where even your grandma could build an app in minutes. I was a tiny bit succesful too. I had this simple application called e-Diary which was basically just what its name stated. At its peak it had around 50-60 downloads a day and around 15k users who had registered via email to me. I’m still proud of that minor achievement; even though e-Diary has now vanished without a trace mainly due to my lack of interest in maintaining it; and the fact that all VB6 apps crash on modern versions of Windows :)

After all these years; after working on embedded devices and the web; I finally got a chance to build a real app on the desktop. Despite my long standing interest in this field; I was totally lost. The whole landscape was now very different – and I to spend a few days researching what works and what doesn’t.

I ended up choosing Python, Qt and the PySide python bindings for Qt. Why?

  1. I prefer working on Linux; my target was however Windows. The gamble on Python and Qt to be truly cross-platform as they both claimed. Paid off!
  2. My C++ days are long gone; I don’t think I can write 5 lines of good code in C++ anymore. Next choice was Java; but I was just a bit scared of over-engineering if I started with Java. So the natural choice was Python; even though I was not yet proficient in it.
  3. Next question was which GUI framework to go for. I saw Qt and to be honest I fell for it at first sight. It had everything I had dreamed of during my VB6 days.
  4. PySide vs PyQt was the next question. The product had a commercial angle to it; PyQt seemed more mature but had the GPL restriction or pay a very hefty licensing fee for a commercial app – so again was left with the Nokia supported PySide. Worked for me.

So that was it. I developed it completely on Linux. Since I am an IDE person; I opted for Eclipse with the Aptana Python plugin. After making sure it worked well in Linux; the next step was packaging it for Windows.

Now this was a challenge. The app required a Python install (15 MB) and a PySide install, including the Qt Libs (around 25 MB). This meant a total weight of 40 MB; for my app code that ran into just a few hundred kBs. Plus the ugliness of using consoles and shortcuts to run the application using python. Well, the perfect solution for that was PyInstaller. It worked like a charm and I was left with an exe file and only the absolutely necessary python modules that were needed. Running it through UPX futher reduced sizes and my whole app along with the libraries were now a saner 7 MB.

Next I ran them through the excellent InnoSetup tool; to create a Windows installer wizard that everybody is familiar with and the product was ready to be shipped.

Sun’s Oracle’s VirtualBox avoided the clumsiness of rebooting into Windows to do all the above; I just ran Windows on my Ubuntu installation as a virtual machine.

All this was surprisingly easy; just needed some figuring out initially. But once you get the hang of it; developing cross platform applications (at zero cost) is surprisingly easy. All tools I’ve used for this (except for Windows off course) are free and open source software.

So what are you waiting for? Start with those application ideas that you all have! It’s still fun!

12 Comments

My Programming Progression and the Language Block

Tech content advisory : Non-techies exercise caution reading this, maybe a bit of geek overload in here. :)

Like most people (ok, geeks!) of my generation, my first tryst with programming was with BASIC. Sometime during the mid-90s my dad gave me a book on BASIC programming, which he found in some book expo he attended. During that time, I had just about barely used a computer, and I didn’t really have an inclination towards technology at all. I do not know what made my dad buy that book for me, but that single thing changed a lot of things – a defining point in my life, if you may. That was my first spark. I just loved how programs were written, the system and the method in them fascinated me – to the point that I persuaded my dad to buy me a PC (It was a big deal then – to put that into perspective, I guess the computer density in my suburb at that point of time, would have been probably < 10 in a 5km radius).

So I got my first chance to try out some real programs. I got QBasic 4.5 installed from a floppy disk and merrily enjoyed my time making text scroll around, drawing human faces, creating monotone music, yada yada. I just fell in love with BASIC – for the simple reason that I didn’t even know alternatives existed and I could program as though writing in English. Even now, I feel so sad when people say BASIC is evil. Maybe it is, but it did end up as a stepping stone to where I am now. Eternally grateful for that.

A few years later, I got my hands on Visual Basic. Boy did that change the game altogether. I could make Windows apps now – with all those shiny text boxes, 3d effects, command buttons! And for the first time I found that I could monetize my hobby. Those days were just wonderful, that awesome feeling of having dispensable income while you are still in school! I saved up all the bits of money I got then doing mini-freelance projects and ended up buying my first camera – one that I still own. Technically here though, I have to agree with the critics. I had learned so many bad practices doing VB that I had a tough time unlearning it all. But whatever it may be, it was definitely worth it. I cannot remember another time, when I had so much fun doing programming. Nothing absolutely matched VB for me in that!

My first encounter with a ‘serious’ language was, again like most people, C and C++. This was a different beast altogether. I had a strong aversion to the language when I first learnt it in school, but slowly but steadily I have grown to respect it. I am still nervous doing C, but no other language actually gives me that feeling of solidness. Can be slippery, but still solid if you do it right. And that’s definitely the language that has lasted the longest for me. I still enjoy doing stuff in C.

College taught me some very interesting languages like Pascal, COBOL and Assembly. Pascal I loved, because of its cleanliness, but I never had any real use with that (except for the exams off course). COBOL was already of archaeological interest only, but served as a measure that gave me an idea of how much languages had progressed since the ’50s. Assembly was my new friend. But refusal to invest time on it (and basic laziness) has never let me really delve into that deeper.

Sometime sandwiched between all those I came across PHP. And that was only because I wanted to do web (this site basically). And web was just about getting trendy at that time. I have always had a love-hate relationship with this one. I used to hate a lot of it, when I was using it for only personal stuff. But ironically after having to professionally code in PHP, I kind of appreciate the language a bit more. That might raise a few eyebrows – but it’s true. It’s not as perfect as Haskell, but in my opinion it does its job well.

My first real ‘career’ language was Java. And the one in which I can say I am the strongest in. It’s bloated, it’s over-engineered – over-engineered, well I guess that was the buzz word for me. I think I like a bit of over engineering. It was more fun designing for the Java than actually doing stuff in Java. That’s obviously also its biggest pitfall. I cannot say I love Java, but I do like it a lot. And it did improve my design skills a lot and taught me how to think big – really big (and off course it paid my bills for 4 years!)

Then I joined MobME. Things were different here – very different. People coded in Python, Ruby, Clojure, Haskell, PHP.. what not. I was a bit overwhelmed at first, but yeah I got used to it. Python – I liked, maybe because it looked BASIC like and invoked a bit of nostalgia, PHP I had already met. Then there was Ruby.. and here’s were I get the mental block. I just can’t get myself to code in Ruby. I’m in a room filled with Ruby enthusiasts, but I just don’t get it. I even went to a RubyCon for inspiration, but no spark. I read everywhere that Ruby brings back the fun to programming. But I still don’t get that feeling. Have been wondering about that for long, why does the whole world get it, but not me! This post is a result of thinking about that loud. Maybe it’s because of all the unkown magic that happens behind what I type? Or is it that my mind far too entrenched in the bracey C-esque languages? I would never know…

Ah well, let’s leave it there then, for I have to go write a billing engine for a service in Ruby… Wish me luck, or a lot of people are gonna loose a bit of money ;)

7 Comments

Euphoria – The Language

Let me introduce to you, a little known (probably even unheard of) language called Euphoria. It is a flexible and powerful language that is surprisingly easy to learn and claimed to be simpler than BASIC and more powerful than C. Well that’s something to live up to!

Euphoria is a relatively new language developed by Robert Craig in the early 90’s. It was probably envisaged as a cheaper alternative to Microsoft’s QBasic. It was initially an interpreted language for DOS. Today it is still an interpreted language, but is now 32-bit and supports all leading platforms – Win32, Linux and FreeBSD. It is does not claim to support OOP, but from what I read it is quite possible to implement OOP concepts in Euphoria.

The syntax structure of Euphoria is a seamless mix of the two different worlds of the BASIC and the C style of coding, along with some touches of PASCAL. This might seem a very difficult concoction but it they have managed to do it quite elegantly. I have to say, it is one of the neatest languages I have ever seen.

So why go of Euphoria? Firstly, it so small and simple making it ideal for that quick bit of programming you need to do. It is quite simple for a beginner to learn too. But that doesn’t mean Euphoria is not powerful. The first big use of Euphoria was in fact to create games. It does a good job there too. Squid Blaster is a game created in Euphoria. Have a look. That should give you some idea about its potential.

A simpler example. Here is how you would add 5 to all elements in an array.

x = {1,2,3,4,5}
x = x + 5

After execution x would now contain the values {6,7,8,9,10}.

Euphoria is fast. Euphoria is interpreted. Again ideal for those one-off bits of programming, but at the same time powerful enough to support complex graphics. Well a good testimony to this is that the Euphoria distribution comes with the source code for the Euphoria interpreter written in Euphoria! :)

Point three. Price. Well nothing can beat Euphoria in that respect, since the SDK comes absolutely free!

All in all, Euphoria is something worth a try. It may not be a language you absolutely cannot live without. But do have a go. It costs nothing and you never know, one day you might be saved by Euphoria.

Links:

PS: For those returning readers, if you are wondering what happened to the “Roads less travelled” tag I had advertised so lavishly.. I have decided to use that name for something more interesting. The lesser known technology articles will now be filed under “Stumbled Upon”. Sorry for the confusion.
2 Comments