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: