Scott Hanselman

Visual Basic 6, Ruby and Getting Off My Lawn

June 9, '12 Comments [45] Posted in Musings
Sponsored By

Why hate on Visual Basic? Because it's successful.David Platt has a great article called The Silent Majority: Why Visual Basic 6 Still Thrives. Even though I studied C++ in school, my first corporate job was in Visual Basic 2, then quickly VB3. By the time VB6 came out it's fair to say I could make that thing sing. It's funny how the older and more successful a language is, the more likely the language literati are to bash it. Bigger targets are, well, bigger.

Visual Basic 6 first shipped in 1998, so its apps will have at least 24 years of supported lifetime. Contrast that with the Microsoft .NET Framework 1.0 (2002), which is incompatible with Windows 7 (2009). - David Platt

You could get SO much work done SO quickly in Visual Basic 6 and that itself made the experience of coding in it fun. Once you added in some of the advanced techniques with tools like Dan Appleman's SpyWorks and other comparatively low-level API tools, it was arguably near as powerful and productive as its more advanced brother, MFC and C++.

Another key to the success of Visual Basic 6 was the much shorter learning curve demanded by its limited feature set. Learning to drive a bus takes much less time than learning to fly a fighter jet. Becoming a good Visual Basic 6 programmer took much less time than becoming a good C++ programmer, the primary alternative at the time. - David Platt

A Hacker News discussion started up around this article and one HN'er said what I've been saying for years (emphasis mine):

For those who have never used it, VB6 syntax is actually very similar to Ruby. It uses English language words instead of braces, does not require parentheses, and uses dynamic typing.

VB6 is also quite fast, all things considered, and runs on lots of fairly old hardware.

Don't get me wrong, I'd never choose to use it, but for those who use it day to day it offers overall simplicity and flexibility that few mainstream languages can match. - grandalf

and the obvious followup...

The irony is, [today's] Ruby "rockstar ninjas" are doing exactly the same work that used to be done with VB and Access. - gaius

This is true...20 years later and it's all still text boxes over data. Even the most advanced client side JavaScript single page apps are often shadows of their terminal and text mode grandparents.

Ruby does feel in some ways like the VB of two decades ago. Quick, is this Ruby or VB6?

class MyClass  
def describe
print self.class
end
end

What about Fibonacci?

Public Function Fib(ByVal n As Integer) As Integer
If (n < 2) Then
Fib = n
Else
Fib = Fib(n - 1) + Fib(n - 2)
End If
End Function

Of course, Ruby can do it with a ternary operator.

def fib(n)
n < 2 ? n : fib(n-1) + fib(n-2)
end

And VB6 has only IIF() for that so we get this

Public Function Fib(ByVal n As Integer) As Integer
Fib = IIf (n < 2, n, Fib(n-1) + Fib(n-2))
End Function

Sure VB6 had/has its problems, but this was a great environment a LONG time ago and even though a lot of unskilled people created a lot of crap, a lot of skilled people created a lot of useful apps that are still running today. And I understand why.

The things that Visual Basic 6 did still need doing. - David Platt

Disclaimer - I currently work for Microsoft on the Web Team but this post has nothing to do with that. I have worked here about 5 years but I worked elsewhere for much, much longer. I dabble in Ruby and other languages on the side so don't get my grudging respect for Visual Basic 6's special brand of cheesy pragmatism twisted.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by ORCS Web
Saturday, June 09, 2012 11:17:07 PM UTC
I'm interested in seeing if LightSwitch fulfills the promise of being able to fulfill some of the old Access/VB niche.
Saturday, June 09, 2012 11:22:47 PM UTC
This time, I think this a big stretch here.
VB is very verbose - I don't really see the same correlation you do.

You really think this:
def fib(n)

Is similar to this:
Public Function Fib(ByVal n As Integer) As Integer

?
Steve
Saturday, June 09, 2012 11:59:20 PM UTC
If I'm not mistaken, the VB6 Fibonacci implementation with IIF won't work; IIF is not equivalent to the conditional operator: it's a function, not an operator, so both arguments are evaluated. So it will cause infinite recursion, and eventually a stack overflow (at least that's what happens in VB.NET; I assume IIF is also a function in VB6)
Sunday, June 10, 2012 12:11:27 AM UTC
The superficial syntactic similarities (alliteration!) are a bit of a red herring I think.

The key thing about VB6 was that its IDE was pioneering, outshining anything around at the time, as far as I know. The language itself, however, was a hack (with good (OLE)COM support nonetheless) and I was so glad to ditch it and move to C# when the opportunity arose.
Sunday, June 10, 2012 12:11:46 AM UTC
VB6 was my first experience with programming way back in high school. I remember being so surprised at how easy it was to set up a form and write some code to make things happen. I experimented with Java and JavaScript afterwards, but just couldn't bridge the gap between languages until college some years later. I later moved to VB.NET, then to C#, and dabbled with several other languages since. But it was VB6 that got me started.

I have fond memories of VB6.
Sunday, June 10, 2012 12:16:54 AM UTC
To be clear, I am not trying to draw anything other than the most TRIVIAL of parallels here. VB was a great little dynamic language back in the day and it works fine on Windows 8 today. Folks got a lot done with it and I see tiny shadows if Ruby sometimes. That's all. Nothing to see here! ;)
Scott Hanselman
Sunday, June 10, 2012 12:33:50 AM UTC
I cut my teeth on VB6 20 years ago, and shocked the cobol world I was working in, with how quickly I could produce a usable client solution with fancy UI elements like combo boxes and radio buttons.

I working on reporting for manufacturing solutions coded in .Net, however VB6 is still the best way (quick/nasty) to interface with some very primitative COM based dll's for some of the hardware.
Sunday, June 10, 2012 1:00:31 AM UTC
I still think there is an opportunity for some one to build a VB6 runtime on top of the CLR. Not a code conversion tool per se, that's already (or it was) built into Visual Studio and never worked that well. I want to be able to run a VB6 dll directly; BUT also have the ability to swap out certain functions/classes with .Net code. I think this would be a great way to move forward some of the VB legacy.
James
Sunday, June 10, 2012 1:25:41 AM UTC
Sometimes I just would like to fire the new IDE in Visual Studio 2012 and open the old VB6 projects. VB6 is still the quick dirty way of have the work done.
Sunday, June 10, 2012 1:58:08 AM UTC
Remain calm folks. Scott is not saying VB6 = Ruby. Far from it. Scott is simply remarking on the Deja Vu that seeing VB6 code gives you once you've been working in Ruby for some time. It's really not a stretch.

Superficial or not, the fact is VB6 doesn't have brackets or semi-colons or return statements. In fact, after a drink or two, it even starts to look-and-feel like duck typing. It even has support for object oriented programming.

Seriously...Nothing to see here!

Sunday, June 10, 2012 2:43:55 AM UTC
Pardon my noticing, but VB6 came out in 1998. 2012-1998 is 14 years, so saying you started programming 20 years ago or that VB6 has been supported for 24 years is rather a large stretch in computer years.
John
Sunday, June 10, 2012 2:59:17 AM UTC
VB2 came out in 1992 when I started with it. That's 20 years.
Scott Hanselman
Sunday, June 10, 2012 3:01:35 AM UTC
VB6 was great for getting things done quickly - sometimes too great. One of my managers knocked up the UI for upcoming project and said "Look what I've done in 30 minutes without any experience, now please fill in the backend for me".

But programming in it, especially if you had any C++ and OO knowledge felt somehow dirty; there was no inheritance for example. The thing which turned me off forever was when I ran up against the VB6 control limit - the number of unique controls that could appear in a window; it was something like 200, but there was a workaround to add them to an 'array of controls' or something. The whole language felt like a gigantic kludge.
Sunday, June 10, 2012 3:04:08 AM UTC
I'd have to agree with Innes. It was more about the IDE than anything else and Microsoft is still eating everyone else's lunch with Visual Studio, IMO.
Sunday, June 10, 2012 5:46:37 AM UTC
The orginal 1989 code name for what later become VB was "Ruby".

http://www.cooper.com/alan/father_of_vb.html

Jim Reitz
Sunday, June 10, 2012 5:50:56 AM UTC
From my perspective, if a developer can show me application(s) built with VB6, mad respect. If that's ALL you can show me? You're not a developer - you're a dinosaur. I learned to code with VB4-5. I wax nostalgic on things VB from time to time. Still, software is built on progress and innovation much more than any one language, no matter how popular.
Brian
Sunday, June 10, 2012 7:24:42 AM UTC
Very verbose syntax though...

By the way, classic ASP with VBScript should still work on Windows Server 2012 or even Windows Azure right?
Mike
Sunday, June 10, 2012 7:25:04 AM UTC
the only good reason for using vb6, back in the old days of VB6 is having never tried Delphi.
carlo
Sunday, June 10, 2012 8:54:41 AM UTC
Just remember that all of us reading Hanselmans blog are more of 'fighter pilots' and less 'bus drivers'. The bulk of the people still using VB6 every day probably don't even know who Scott is. They just use it.
Sunday, June 10, 2012 9:57:53 AM UTC
To John: vb6 just got full support for win8, meaning it will have at least a lifetime of 24 years.
Sunday, June 10, 2012 11:31:22 AM UTC
My main problem maintaining old stuff with VB6 is the IDE.
VB6 in Visual studio would be very good.
You can already code PHP and Ruby in VS, so...
Sunday, June 10, 2012 2:43:53 PM UTC
I remember working on an internal system that started as a Access VBA prototype and then was continually developed over the course of 6 more years. The whole system was a developer's nightmare.

I will never be able to forgive VB for spawning VBA. VB wasn't a true object orientated programming language and it's ugly step sister VBA wasn't even supported by a proper development environment.

How many simple VB/VBA systems turned nasty once they started to grow?
Sunday, June 10, 2012 3:03:23 PM UTC
That problem is most acute regarding Office, where the users and environment are most likely to be of the kind described by David Platt; and where not even an imperfect substitute exists. You can do desktop VB6 with other tools. You can't do VBA with other tools (VSTO dosn't enable the same use cases). Microsoft ships Office's 2010 version with a 1998 development IDE.
Sunday, June 10, 2012 5:59:06 PM UTC
Comparing VB6 with Ruby is like comparing a trabant (http://ro.wikipedia.org/wiki/Trabant) with the latest the Tesla sedan. They are both cars ...
Sunday, June 10, 2012 8:51:38 PM UTC
@James If you really want to use some .NET-ish goodness from VB, there is always VBCorLib...
Sunday, June 10, 2012 8:57:05 PM UTC
I regards to your comment that
even though a lot of unskilled people created a lot of crap
let's us not forget Sturgeon's Law

90% of science fiction is crap because 90% of everything is crap
Monday, June 11, 2012 2:28:33 AM UTC
Visual Basic Has been the vehicle to many of my house payments over the years ... many thanks to Microsoft and the VB team :)
Jim Rae
Monday, June 11, 2012 8:36:47 AM UTC
While C# and Ruby occupy most of my coding time these days, I still program in VB6. Well, Excel/VBA really, but the runtime's the same. It's seemed to me for a long time now that @James' notion of the VB6/CLR (or more likely DLR) combination is the key to moving user-written Office automation into the 21st Century (moving a VBA-savvy user up to VS and - ugh - VSTO or similar) is several steps too far.

Monday, June 11, 2012 3:56:27 PM UTC
Hi,
I was just thinking about doing a simple Metro app and really missing the simplicity of VB and windows forms. Where is the tool that hides all the XAML stuff. I don't want to have to jump into writing XAML or use Blend in order to get simple things done.

I do wonder if we are going backwards.

Martin
Martin
Monday, June 11, 2012 6:20:59 PM UTC
Like any language, I have seem some ugly VB6 code, and some beautiful VB6 code. VB6 could do pretty much anything. I still have some websites that run off of VB6. I don't mean Web Documents or whatever they gave to do that stuff, or even the IIS DLLs things you could do, I mean, a full on EXE written in VB6 that serves HTML back. And it's fast.

In another project, using Subclassing, I wrote an app that allowed our estimators to load up an image (pdf, tif, bitmap, jpg, pretty much anything) of the building we were bidding on building. It had real-time viewport functionality, allowed you to draw transparent lines over the top of the drawing in all sorts of patterns and colors, measured those lines, scaled it up to real world lengths and allowed our estimators to quickly bid multi-million dollar jobs.

And it was fast. I mean, it beat the pants off of anything you could buy on the market for under $1000 a copy. I was able to drop down into Device Contexts, create brushes, etc, all without the help of DirectX or GDI+ or anything. Merely using BitBlt and the Win32 OS level GDI functions and objects.

Don't let anyone tell you that you couldn't do something in VB6 (and 5, really). I mean from the End User's perspective. If a program does task X, then it's a success.

The IDE was incredible. You could pause code execution, write code, and continue on right there. No mocked up Edit and Continue, no annoying message boxes about how you can't edit running code, etc.

I love .Net. The IDE is even better than VB6 in almost every way. The language features and extensions are fantastic.

But programming in C# over VB6 does not make you a more competent programmer.
Monday, June 11, 2012 8:08:55 PM UTC
Wait, what's the "Getting off my lawn" part in the title?
Monday, June 11, 2012 8:20:24 PM UTC
The biggest problems I had with VB6 were
1) Editor inheritance - No real way to do inheritance other than copy-pasting method implementations or making private instances of the base class in the derived class and calling methods against that.

2)Strings and Variants - Man, if you really needed to do heavy duty string parsing, VB6 was not your man. You had to dive into the undocumented things like StrPtr and VarPtr and use the Win32 API.
Monday, June 11, 2012 8:39:10 PM UTC
Brad - "Get off my lawn" is what old people say to young people. Google it. ;)
Monday, June 11, 2012 11:42:30 PM UTC
Sadly, Microsoft have never matched VB6 with regards to ease of use and rapid development. They are trying to recapture the RAD space with LightSwitch, but I haven't really been impressed with what I've seen - it's slow, it's clunky, and I can't just drag and drop my controls where I want them.

Craig Schwarze
Tuesday, June 12, 2012 12:49:00 AM UTC
And jsut how long did it take for your final FIb function in VB to return a value ?

http://msmvps.com/blogs/bill/archive/2012/06/12/why-a-little-bit-of-vb-is-a-bad-abd-thing.aspx
Tuesday, June 12, 2012 1:53:37 AM UTC
Perhaps the ship has sailed, but I would love to see a "VB Lite" or "VB RAD" for .NET that basically emulated the old VB6 interface, except it's in XAML and compiles to .NET IL. Something like that could still be a winner for internal LOB applications.
Tuesday, June 12, 2012 8:03:59 PM UTC
Great - so VB6 gets to live on, while .NET 4.5 dies a horrible death. Way to go, Microsoft.
Friday, June 15, 2012 6:58:00 AM UTC
Urgh, this brings back so many memories, think I just threw up in my mouth
Thursday, June 21, 2012 8:51:06 PM UTC
Scott, When you compare the simplicity of VB6 to the tangled mess of html, javascript, and whatever flavour of .NET you use, which all have to weaved and mashed together into some sort of pulp that resembles a functioning application, then you see that VB (even without inheritance and (real) pointers and all the things it missed) is like an elegant yacht alongside a sunday afternoon raft race effort.
Noone can deny the power of web applications, and SOA, and all these things of course, but the way we develop them today is still hideous.

We're still waiting for "real" edit and continue after what eleven years of .NET..... ;)

Some days I miss Mort....

http://vb.mvps.org/vfred/Trust.asp
Tuesday, July 17, 2012 7:09:52 PM UTC
I wrote many application in VB6 of which still run today. One I wrote while I was in school learning C then about 7 years ago I re-wrote it in VB6. That VB6 application has been running in our enterprise on our servers everyday with only 1 break in 7+ years. About 3 months ago it failed to the point that we had to pull out the source code to look it. We had found 1 bug in 7 years that if you deleted a specific folder the application would break.

I wrote many other applications in VB6 that generated so much profit for our company in hours saved. I still dabble with the VBA IDE in Word and Excel just for the time savings it has over .NET.
Friday, August 17, 2012 2:20:14 PM UTC
Scott, I've got a VB6 app that I recently ported to Ruby on Rails and I have to say the parallels are striking to me between Ruby and VB6. I do really appreciate some of syntax flexibility offered by Ruby. Thanks for drawing the line between these two technologies.
Monday, August 27, 2012 11:22:48 PM UTC
I just went to a Windows 8 Developer Camp. In the intro talk the speaker asked for a show of hands.

Who's been programming Windows 8? --- some hands.
Who's been programming in .net? - - - lots of hands.
Who's still programming in VB6? - - - My hand was the only one left in the air. :-\

(and they all moved away from me.....)

:-)
Wednesday, February 13, 2013 11:26:59 PM UTC
Going to the VT terminal article, I recently created an ASP.NET 4 web app that mimics the basics of the then current AS400 "green screen" app in most every way; and even improved on a few things! It truly is about design.

As far as VB6 goes, at my current place of employment, I am supporting several VB6 apps that have been around since VB6 was first released. Do I like it? No, but I don't hate it, per se. Are we having trouble supporting them? Oh, yes, that's why we are rewriting them in WPF and .NET 4.5. We are finding it more difficult find VB6 developers...
John Baughman
Wednesday, April 03, 2013 1:02:25 PM UTC
I am one of those old guys that has said "get off my lawn" before. Professionally, I have programmed in over 30 languages, including 80888 assembler and was on a team that wrote a proprietary compiler back in the 90's. To me, VB was an incredible leap forward at the time. That is what makes it memorable. Of course a fool, even with a good tool, is still a fool. Anyone can write crap or gold in any language. VB made it easier to write crap. It also made it easier to write good code as well. Microsoft continues to improve their language products and right now, my environment of choice is VS2012, C#, .NET 4.5. At the time, VB was awesome and was a great chapter in the saga of programming languages. I wouldn't write anything new in it these days but for its time, I thought it was fantastic.
Friday, June 21, 2013 9:38:11 AM UTC
"Microsoft ships Office's 2010 version with a 1998 development IDE." That's wrong. Office 2010 = vba7.

On the other hand, while Ruby has several advantages, when dealing with databases I will always prefer Access VBA. It is just simpler, self contained... and faster if you compare it with Ruby's ActiveRecord.

Diego Pereira
Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.