26

VB3.

In my last rant I mentioned I used to convert VB3 code to .Net. Before that, I used to work on the VB3 product itself. This software emulated something from the real world, and as such complied with a bunch of regulations that changed on a regular basis, and always had additions and removals that were to be done on a strict schedule (e.g. "we're adding a new product next month, so we have to be able to sell it by the first of the month"). As such, it was a huge sprawling mess.

One day, I was given a task to change some feature slightly. The task was simple enough and really only required adding one line of code. I added that line and clicked "Run".

Error: Too Much Code

What? What do you mean too much code? I asked a colleague for help. "Oh, don't worry, it happens when a function is too long. Just remove one or two of the comments and try again." The comments were, naturally, old deleted code that was quite meaningless so I had no qualms about removing some. It worked, and I went on with my life.

This started happening on a regular basis on our larger functions. But there were always comments to remove so it wasn't a big issue.

One day, though, it happened on a five-line function. This was puzzling - the error had always happened when a function was too big but this one clearly wasn't. What could the error mean? I went to the same colleague.

Apparently, there's also a limit to how big the entire code base can be. "Just find a function that isn't used any more and delete it." And so I did. There were many such functions, responsible for calculating things which no longer existed so they were never called. For months, I'd find functions and remove them. Until there weren't any more. I checked every function and subroutine in our codebase, and they were all used; I checked every possible code path and they were all needed.

What do I do now, I asked? The colleague, who was an expert on VB3 but worked on another project, came and take a look.

"Look at all these small functions you made! No wonder you're running out of space!" Apparently each function created a lot of overhead in the compiled executable. The solution was clear. Combine small functions into large monolithic ones, possibly passing flags in them to do completely unrelated things. Oh, and don't comment on the different parts because we have no room for comments in our code base.

Ah, the good old days.

Comments
  • 4
    Oh my fucking god. This sounds like a nightmare. Please tell me you're actually putting in an effort to make up for this in your .NET port of the codebase.
  • 4
    @NiPfix my .Net port was over a decade ago.

    Nowadays I consider this part of the reason I'm a good developer and code reviewer today. I've seen how bad it can get and I will always do everything in my power to avoid it.
  • 1
    wtf!! Comments are counted in the limit? Shouldn't they be ignored by compiler?
  • 1
    @gitpush haha, "should".

    If I understand the situation correctly, the compilers had an internal limit of 64K for many various things. One of those things was the token list returned from the parser. Since a comment is a token, it would take that space - and you'd have to delete a number of comments for every line of actual code you wrote.
  • 1
    @configurator I am so damn lucky that I started my journey on VB6 though were tiny programs and real shit started in 2006 with HTML then vb.net where life was much easier compared to what you mentioned in your rant 😓
Add Comment