Home
Archives
About us...
Advertising
Contacts
Site Map
 

ruby in steel

 

Visit the Bytegeist Archives...

bitwise technical editor Dermot Hogan has managed and developed global risk management systems for several major international banks and financial institutions. He is known for his sunny disposition and his jovial personality (he claims).

This month Bytegeist emerges from the COM galleys for a break. OK – a rant then…

 

RAD MANNERS

...why Ruby reminds Dermot of VB while C++ reminds him of Boris Karloff.

Here’s a puzzle: how to shift a 64 bit quantity by a given number of bits. Easy! But in Visual Basic 6 (VB6)?. I was somewhat intrigued by this question since it involved a) VB6 and b) an operation which doesn’t exist in that language. It’s now been five years (I think) since Microsoft announced that VB6 was officially dead and sat back on its collective backside to collect the .NET upgrade fees. It’s still waiting.

Plunging back into VB6 after a gap of a couple of years was, to put it mildly, a bit of a shock. My first reaction was simply “Yuk!” followed by “ How quaint!”. It was like stepping back in time – no .NET framework, a pre-historic version of Visual Studio and this weird, weird language, which I’d forgotten how to program.

But gradually (ok - after installing the VB6 MSDN help system vintage 2001, actually), it began to come back to me. And I was quite surprised. First off, VB6 in Visual Studio 6 is fast. On my old 800MHz laptop with a style-cramping 256MB of memory, it performed like a champ. In contrast, Visual Studio 2005, really, really struggles on that configuration. Secondly, I was struck by how simple Visual Basic 6 is – far simpler than Visual Basic .NET (VB .NET). VB6 doesn’t have very much syntax and neither does it have very many functions. I don’t quite know how many, but there must be around a hundred in all - of which, I would guess, about 20 (such as the string manipulation functions like Left) are commonly used.

And because VB6 is simple, it’s quick to program. I was expecting to have real trouble trying to do things with no .NET Framework to assist. Instead, with one exception – I couldn’t for the life of me remember how to format a string – it was faster than using the Framework.

Now this was a straightforward program with no complexity - converting between bytes and strings and so on - but it did strike me very strongly that that is what many (possibly most) people who write programs want to do: write simple code that gets the job done. Note that I didn’t say ‘programmers’ but rather ‘people who write programs’. There’s an important difference. Programmers tend to earn their living by writing programs, but the other guys don’t. I remember one person who wrote to me some time ago was a doctor. He didn’t write programs for a living – he made sick people well again. But he did write programs to help in that task. See the difference?

It’s a difference Microsoft has missed with VB .NET.

VB .NET is a general purpose programming language all too similar to C#. It isn’t a rapid application development language like VB6, in its time, was. This contrast between what VB .NET is and VB6 started me thinking about what’s involved in a RAD language and system.

“C was a RAD language in the 1980s – it was easy to write programs in, it didn’t get in the way, and it had minimal syntax. Compare and contrast the current Stroustrup C++ monster.”

First off, what constitutes a RAD system has changed over time. What was a RAD system for a DOS based PC would not serve for a Windows 95 environment. Similarly, what was RAD for a Windows environment won’t do the business in an AJAX web environment. But there are some defining characteristics  that a RAD system must have.

It must be lightweight syntactically. You can’t write programs quickly if you are having to look up how to write the stuff in a tome of several hundred pages. The third edition of Stroustrup’s C++ book is 900 pages. The original edition of the K&R book was about 100 pages (from what I remember). And, yes, C was a RAD language in the 1980s – it was easy to write programs in, it didn’t get in the way, and it had minimal syntax. Compare and contrast the current Stroustrup C++ monster.

Next it must be easy to debug. Most time spent programming is spent debugging and you can only program at the speed you can debug. That is one of the things that was revolutionary about VB6 – ‘edit-and-continue’. Amazingly, Microsoft dropped it for VB .NET – that’s probably one of the reasons for the poor take-up from VB6. Though, I do have to say in Microsoft’s defence here that I believe the Visual Studio team would have liked to ship it but there’s only so much you can do in a given time. To misquote Andrew Marvell (To his coy mistress), “the grave’s a fine and private place, but none I think do there Visual Studio 9™ embrace”. Even more amazingly there are some folk out there who think that edit-and-continue is a Bad Thing. Well, there are also people who believe the earth is flat. Edit-and-continue is one of the most productive programming tools ever invented. Period.

Lastly, I think that you need some form of application generator. These have been around for years in one form or another and they haven’t been that wonderful, in my view. The idea is that you specify in some sort of high-level, generic way, the sort of thing you want to do and then press the button. After a good bit of whirr, whirr, clank, clank, flashing of lights and emission of steam out pops your application. Complete with documentation. Of course, it doesn’t work like this – if it did, programmers would be queuing up at the soup-kitchens. All the programmers I know drive BMWs.

“Rails – the Ruby application generator - does seem to me to the way that RAD systems have to go…”

This brings me on to Ruby. Strange to say, I haven’t actually done that much Ruby programming: instead, I’ve been slaving away in the galleys programming COM interfaces in C# for the Steel Ruby Visual Studio IDE. I’ve done ‘em by the dozen, and it’s hard work, I can tell you.

But Rails – the Ruby application generator - really does look interesting. With a few mouse clicks, you can knock out a simple website attached to a database. This isn’t a panacea and I suspect that Rails is rather fashionable and therefore over-hyped. I’ll find out a good bit more about how useful Rails really is in the next few months. But Rails in some form does seem to me to the way that RAD systems have to go. Instead of in the old VB6 world where you hooked up a form to a database on the PC, you need to be able to do the same in the AJAX environment. Rails is one of the very few tools I’ve seen that attempts to do this in an reasonable manner.

But I’d go further than that. When I was typing in the VB6 code for my little bit-shifting application (about as far from Rails and AJAX as you can get), I had the strange feeling that I was typing, not good old VB6 code, but Ruby: no semi-colons and with a cavalier attitude to brackets. It sounds bizarre – a sort of programming synaesthesia. But it’s true. In Ruby, while there is a lot of syntax – and some of it bad and dangerous to boot - you can get going very quickly. More, you can produce useful programs by knowing just a few functions. You don’t have to be a programming genius. If it sounds like programming in VB6, it is.

It still beats me why Microsoft didn’t see this. Instead of producing a VB equivalent of Ruby, it’s produced a clone of C#: “Hey, Steve, I’ve got  a great idea – why don’t we have two of them there general purpose languages?” “Fantastic Bill! We can wipe Sun’s clock twice now!”.

But there are a number of downsides to programming in Ruby. All is not quite as it seems – as you’ll find out after about five minutes programming in it. To get a flavour of what’s amiss see “How Ruby Sucks”. Note that this little diatribe isn’t penned by some dyed-in-the-wool Java hacker. It’s by the language’s author and designer, Matz himself. For a less impartial view (but still pretty close to the mark), try http://www.lrde.epita.fr/~didier/comp/ruby.php.  Ruby is nowhere near ready to replace Visual Basic. In passing, I’d also like to say that having programmed again in VB6, I’m not that nostalgic about it. Try debugging a bit-shifting program with no hexadecimal display: I’ll take Visual Studio 2005 any day, thanks.

But for now, all Ruby needs now is for someone to come along and tie it up into Visual Studio and wire up Rails properly for multiple tables. Hmm, back to my COM oar in the galleys…

June 2006

Bytegeist Archives

 


Home | Archives | Contacts

Copyright © 2006 Dark Neon Ltd. :: not to be reproduced without permission