Thursday, 5 February 2009

When did we all get so lazy?

There seems to be a movement towards writing less code. I see it all the time.

  1. You have C and C# evangelists who can't stand Pascal because they can do in two key strokes, what Pascal does in nine ({ and } as opposed to begin and end;) This one's a personal preference issue. Personally I find begin and end 100 times more readable, but I also understand that others may prefer their curly braces.
  2. In my post about garbage collection, some of the commentators reminded me that if you use Delphi, because it doesn't have garbage collection, you have to write 40% more code (all those silly try..finally clauses). Again, you may have valid reasons to want garbage collection, and I respect those reasons. But don;t tell me writing less code is a good reason.
  3. The push towards functional programming is another one. I'm told that using a functional programming language for certain problems would result in me writing a lot less code. Look Ma, I wrote all that code in one line! I may be a bit harsh here, as some of the functional constructs are really elegant, but what I'm getting at is that use something by all means if it results in your code being more readable, and not because it results in a few less lines.
  4. Pascal requires an interface and an implementation section. You declare a class twice. It must be bad right? Like I've said before, for me, a Pascal class is immediately readable. The interface has no clutter. To achieve the same thing with say, a C# class you need code folding.

I could go on and on. I think the theory goes that if you can type, say 70 wpm, and that you can't physically type faster than that, then the only way to churn applications out faster is to use languages and constructs that need less typing. The theory implies that if you are writing 40% less code than I am, (and we both type at the same speed), then you're producing 40% more work than I am. What the theory conveniently ignores is that I may think 40% faster than you. I'm not saying that writing less code is a bad thing. I will always write less code if I can, but never at the expense of clarity. I will add begin and end where the compiler doesn't need them if I think it makes the code less ambiguous. I'll not use the with construct , and retype the object or record instance each and every time, if I think the code is more readable for it (it always is). The important thing to remember is the speed a developer can write good maintainable code is rarely due to the number of characters he/she can churn out. A lot of it is to do with the thought that goes into producing the code, when the hands are no where near the keyboard. It's to do with the cost of maintenance of that code. This all reminds me of those C competitions where C enthusiasts would vie to write the shortest piece of code that actually does something. It doesn't matter that you had to sit down with pen and paper for a few hours to figure out what his little program did. Aim for clarity and eliminate ambiguity. If that means you end up writing a bit more code, so be it, in the long run you'll actually save time.

How do I make the case for Delphi?

At work we use Delphi. We have for several years, and it has never failed us. The last few years we have had major problems finding good Delphi developers, so the developers we have hired have either been bad Delphi developers (who have since moved on), or .NET developers who have been persuaded to try their hand at Delphi. Most have been persuaded because they were promised that migration to .NET was on the horizon. We've got to the point were the C# and VB.NET evangelists outnumber us poor Delphi guys.

We are moving closer and closer to becoming a Microsoft shop. There's no valid technical reason for this. I suspect a lot of developers want C# and .NET on their CVs.

So, as the Delphi evangelist, how do I make the case for Delphi? The noises that keep coming out of Embarcadero are that Delphi is the best solution for creating Win32 native applications for Windows. I won't argue with that, but it's just not enough to stop the tide. I keep repeating that to the powers that be, but they can't find the staff with the skills to use the tool, so it doesn't matter how good it is. That's why I keep going on about academic licences, cheaper versions, anything to get the new breed of developers started on Delphi. What Embarcadero need to realise is that no matter how good their product is (again I agree it's good!), if the next generation are not using it, then Delphi shops like ours will move to what are perhaps inferior products, because at least they have a chance of recruiting the right staff. It's a shame, but it's true.

Wednesday, 4 February 2009

Born Again Delphi?

I've just read an extremely interesting (and long) article about the future of Delphi. The catalyst for the article was Nick Hodges post on the future of Delphi. Some interesting things on the wish list for the new Delphi.

Compiler Speed

For most of my professional life I have used Delphi, and Turbo Pascal before that. I take the compiler speed for granted, and compile my code often, just because I can. I think I'd notice if the Delphi compiler was to all of a sudden take a lot longer to produce the goods, and I would not be happy!

Interface/Implementation

I'm all for typing less code, but not at the expense of clarity. Having to declare the class in the interface section, and the implement it in the implementation section may seem like a waste of time, but it makes Pascal so much more readable than say C#. Even if we didn't have shortcuts such as ctrl+c (complete class) or ctrl+shift+up and ctrl+shift+dn (toggle between interface and implementation), I'd still want a separate interface and implementation section.

Declare Inline Variables

I've started using these in Delphi Prism, and they rock. Now this is one place where you write less code (albeit a little less), but clarity improves.

for var i : Integer := 0 to 20 do

Case Sensitivity

No. No. No. Why? Why? Why? I don't get it. If I have two variables test and Test, in the same scope, then I've just introduced an ambiguity. Which one do I use? Which one did I mean to use last year?

No. No. No.

With Statement

I don't like it, I don't use it, and I think people who write code such as :

with MyObject, HisObject, TheirObject do

Should be shot! (yes I have seen code like that)

Smart Pointers and Garbage Collection

The author is basically for some form of smart pointers and against garbage collection. I'm on the fence here. As long as anything is optional in this area, then go for it. I'll make my decision after I've seen it in action.

There were a few other points, but the ones above were the interesting ones. I just hope the rewrite of the Delphi compiler is the right thing to do. Look what happened to Netscape when they decided to rewrite their flagship product!

Monday, 2 February 2009

The Nick Hodges Podcast

I have just listened to latest podcast over at the Startup Success Podcast, with our very own Nick Hodges as the guest. I have to say it was rather disappointing. I guess for someone who laps up every mention of Delphi on the web (does the web sometimes seem very small to you?), these kind of things are always disappointing, because you never learn anything you don't already know. The disappointing thing though was every (well the really juicy ones at least) question was answered with a "I can't say more than that" or "I can't confirm when" etc etc I'm not trying to criticize Nick. While to a long time Delphi developer like myself, at first sight, Nick seems to have a dream job, if I really think about it, I'd have to say he's got a really difficult job. He's kind of stuck in the middle. The public face of Delphi, with his hands tied behind his back.

I was particularly waiting for his answer to a question I had suggested on Bob's Facebook page. The one about Embarcadero's Bizspark equivalent. I've blogged about this before, and I've since had a change of heart. It's more of a softening of stance really. Yes I'd like access to Delphi for a paltry sum, but Embarcadero are in the business of making money, not making me happy. I still think they seriously need to find some way to attract new developers, but doing a Bizspark equivalent, is just not going to work for Embarcadero. Even so, Nick didn't really answer that question either.

I have a suggestion for Embarcadero. A cut price Delphi, call it Turbo Delphi if you will, with a bare minimum of components. Just enough to get you started. Basic database access, a button, and edit box etc etc. Then have an ITunes like shop front for selling individual components(singles) or packs of components (albums). Somehow marry those components to a single licence. Buying all the components individually would cost more than buying the full product, but at least it allows users a lower entry cost, and who wants all 2321 components anyway? The store could be expanded to third party offerings. Could it work? Or would people just buy the cut price version and use freeware components? If they did, would it be a bad thing?