Delphi for Java developers

Why is there no book titled Delphi for Java developers?

I guess I'm not the only software engineer who has been forced to learn Delphi after Java. The reason is of course not that the company I'm working for at the moment is moving to Delphi, but rather that they have some programs written in Delphi that still needs maintenance.
Learning Delphi after Java give some interesting insights into programming language design. After I started to learn Delphi, I've started to appreciate Java more and more, just because Java is so clean and so simple. I've also started to see that language features that sounds nice when you first hear of them, can turn out to create really hard-to-read code. Here are some examples I'd like to mention:
  •  the with statement in Delphi. The with statement can save you for some typing, and could even make your code look a little more elegant, however, it's one of the features that makes Delphi code harder to read. (BTW: Here is something that you can do to make your code a little more elegant, and even save yourself some typing, hopefully without making it hard to read.) 
  • Another feature that Java "lacks" is global variables. (OK, I admit, when I was younger, I couldn't understand why people whined about global variables. Having to read and understand others peoples global variables really helps a lot on that understanding..)
  • You don't need parenthesis after function/method calls if you're not passing parameters. In Delphi it's not necessary to include parenthesis after a function or method call, if there is no parameters. Seems like it's not even laziness, but rather considered best practice. Sounds smart, but at least for my eyes, it isn't obvious that "SomeMethod" is a method call.
  • More than one public class can be defined inside a Delphi "Unit" (a Delphi source code file) . Even worse, the intefaces of the contained classes are at the top of the file, and the methods that makes the rest of the class can even be mixed at the bottom of the "Unit". Of course I guess mixing implementations is bad style, but guess what: If bad style compiles, chances are somebody is going to introduce it.
  • To make things even worse, Delphi doesn't have package trees or wildcard imports, so it's even more tempting to put many classes into one unit.
  • The Delphi IDE (of earlier versions) is composed of many top-level windows, instead of a main form. Today I heard someone talking about this as one of the features of older Delphi versions, but I clearly disagree. It is however better than gimp's interface in that if you activate one Delphi window, the rest of them are also activated.
For Delphi hackers who might read this: I guess my views are heavily influenced by the fact that I learnt Java first. If I've written something wrong, please write a comment about it, or even better: write a follow-up on your blog, cause I'm trying to learn Delphi, and I know there must be some reason why so many programs are written in Delphi, except for the speed.
Btw: Here is some interesting Delphi links I found a while ago:


  1. damn, why do you do Delphi?

    I was first Delphi programmer(it was my first programming language) and then i moved to Java, because there were no Delphi jobs(in my whole life i saw maybe 5 job offer for Delphi programmer).

    If you are smart enough to learn new language you should move back to Java or even C#(its more like Delphi). Delphi is dead language, but if you really like it(i used to love it) you should see how many job offer you can find in your neiberhood for Delphi programmer.

  2. I mostly program Java and PHP. I wish I was a good Delphi programmer because I'm told that good Delphi programmers earn lots of money around here.

  3. You're not alone! :)
    I do have to learn delphi, almost from scratch (I did use some Pascal when I was young :), after almost 8 years of java programming.
    It is also for commercial reasons why I'm doing this temporarly language switch.
    A couple of things I would add to any Delphi vs. Java review:
    - The IDE. I've used Eclipse, for 6 years; having to use Delphi 7, looks like a trip to the stone age. Code Helpers, autofix, debugger, sofisticated semantic and related source search and refactor features, and the list goes on and on, for things that Delphi's IDE lacks. I've tried a little while Delphi 2009 but the fact that is still "too new" made me go back, because some components we use, aren't still available (and some might never will). I did not used 2007 because of all the horrible reviews I've read about it. D2009 is closer to Eclipse, added several of the features I mentioned before, but still the debugger and the quick fix, are missing.
    - Javadoc in line. Eclipse and other java ides, gives you a quick tooltip about what method o variable does, something very useful when you are using some 3rd. party library or some other people's code.

  4. Hi awi

    Thanks for your comment!

    You are of course right about the ide and the packages too.

    I've got a new job since then, and I'm now programming Java and php(!).

    Good luck with the Delphi programming, -as I said in the post, rumor has it that good Delphi programmers are well paid, at least here in Norway :)