• (nodebb)
    We can only hope that this code has finally been retired, but given that it was still in use well past the end-of-life for Classic ASP, it may continue to lurk out there, waiting for another hapless developer to stumble into its grasp.

    Many veteran software engineers have to always keep their eyes peeled for bad code lurking in our software.

  • Naomi (unregistered)

    Of all the bizarre naming choices out there, dim for a variable declaration has got to be pretty high up there. (I know what it means, but it's still bizarre.)

  • L (unregistered)

    I thought the answer was "it contains nan"

  • EM (unregistered)

    How silly! Everybody knows that the correct way to do that is:

    Dim params : params = Split(String(7,”,”), ",")

  • (nodebb) in reply to EM

    That's the revolutionary new zero based array size number system! You're a genius.

  • (nodebb) in reply to Naomi

    It was a pretty Dim-witted naming choice!

  • (nodebb)

    {facepalm} After 40 years, I thought I had seen every type of "bad code that actually works". But this one truly left my jaw hanging open and me thinking WTF . . .

  • (nodebb)

    VBScript was more JavaScript with VB synatx and had actually little to do with VB6 otherwise. It was completely redundant because JS was supported by every browser, VBScript basically only by Internet Explorer. There was one benefit to VBScript, it made handling ActiveX objects way easier - again, that was something very Windows specific, but I encountered a few of those in my career.

  • Lurk (unregistered)

    It's been quite a while, 20+ years, but, IIRC, there's a useful difference between

    Dim params(8) and Dim params : params = Split(",,,,,,,", ",")

    The first gives you an uninitialised array (null variants, Nothing in VB land, and you can look up variants - horrid things - for yourselves) the second gives you an array of 8 empty strings. By doing the latter subsequent code doesn't have to check for Nothing (null) before every operation on an array element. It would have been better if the array type had been specified as string because as it stands it's still (again IIRC) an array of variants, but the code really isn't as stupid as it looks at first glance.

  • (author) in reply to Lurk

    So, I will say regarding that- I opted to crunch this down into a Representative Line, but the submitter supplied more context- the next lines were a loop which initialized each element in the array. Good thought, though.

  • Argle (unregistered)

    Centuries ago, Mozart wrote his "Musical Joke" that showcases all the mistakes beginning and/or incompetent composers write. I've been tempted to accumulate all the screwy things I've encountered over the years and put them into one "working" program. Sadly, I don't think I and deal with so much stupid in one place.

  • m (unregistered)

    Well, as everybody surely knows, split("", ",") is the only[1] way to get an array with zero elements, so it totally makes sense to initialize all[2] other arrays the same way.

    1. there are some functions in some COM dll, which should be able to set an array to zero size, but they fuck up some internal state, and you get weird errors later

    2. so what about arrays with 1 element? Yeah, well, this is VB we're talking about, so why do you expect this to make any sense?

    (this dev has not touched VB for almost a year, and does not miss it at all)

  • (nodebb) in reply to Naomi

    Of all the bizarre naming choices out there, dim for a variable declaration has got to be pretty high up there.

    The history is pretty straightforward and mostly innocent. Back in the dark ages, VB had no variable declaration, variable typing was done by suffix. Before variable declaration was introduced, arrays were. So, enter the Dim statement to describe the dimensions of the array.

    When variable declaration was added, it was chosen to not create a new keyword, but reused the keyword that was already used to declare arrays.

  • Tim (unregistered) in reply to Jaime

    VBScript was designed to be familiar to VB programmers, but the type system is/was completely different

  • Tim (unregistered) in reply to MaxiTB

    not really - VBScript was used extensively in Windows outside the Browser - most notably for Active Server pages but also for general scripting

  • (nodebb) in reply to Jaime

    DIM as the general variable declaration statement in modern BASICs reminds me of all the various meanings of static in C. Another case of coopting an existing keyword rather than creating a new one.

  • (nodebb) in reply to Tim

    I think you are mixing up VBA and VBScript when talking about "outside of the browser". And classic ASP was dead around 2001 because it got replace by ASP.net ... and before that it played a very underwhelming role.

  • (nodebb)

    As far as I remember you could use two different languages with classic ASP: VBscript (VB) and Jscript (Javascript).

  • Old VBer (unregistered)

    In any case, the previous developer needed to make an 8 element array to store some data. ?Traditionally, in VBScript, you might declare it like so: Dim params(8)

    VBScript arrays by default were (are?) zero based DIm params(8) gives a 9 element array.

  • (nodebb) in reply to MaxiTB

    No, not really.

    Group Policy for instance could run both VBScript and batch files.

    Windows still actually comes with 2 executables that can run .vbs (VBScript) files, wscript.exe for a graphical version, and cscript.exe for a command line version.

    Prior to powershell, one useful purpose for vbscript for instance was retrieving the OU that a computer is in on the domain controller, or getting the current computer name, etc...

  • Duke of New York (unregistered)

    "Why don't you make like program and beat it?" — Biff Tannen

  • löchlein deluxe (unregistered)

    Weeeeeeeell, this one has an obvious-ish way forward to default values, doesn't it, so… 3.6 röntgen, not great, not terrible?

  • Officer Johnny Holzkopf (unregistered) in reply to Barry Margolin

    Also in C: Borland C (for DOS) had the "auto" keyword, meaning something different than it does today (see: auto / static / register).

  • (nodebb) in reply to MaxiTB

    classic ASP was dead around 2001

    That's nice to know considering I am working on a Classic ASP project right this minute.

    Actually, what I am working on is even more of a WTF since it started life as Microsoft Front Page which then had carefully created ASP scripts inserted

  • (nodebb) in reply to jeremypnet

    Oh boy, I'm sorry about that. Obviously with JSP arriving at the end of the millennium and Java pushing itself into colleges, ASP was already declared dead before MS brought out ASP.net in 2001 - must be hard working on an old relic like that.

    Microsoft Front Page giggle - that's a product I haven't heard about for at least two decades. I actually had no client that had it in use. I tried it out when I was in school, but preferred to actually write my HTML by hand. Ah, that was the good old times where MS pushed web functionality into everything. Obviously it had little chance against the competition like Dreamweaver, but because it pretty much came along for free, some of my co-students use it to prototype their private webpages.

  • (nodebb) in reply to ray73864

    Oh yes, you are correct. There was the niche use by admins and ops while there was this limbo period, but I luckily never had to work in an environment like that. WSH was notorious instable and prone for security issues, so in most companies I worked at with a proper software dev department, shell scripting before PS was pretty much not allowed beyond simple batch files. But I guess I worked mostly in companies with a proper software department present, I guess for smaller companies with more relaxed security standards there could have been broader adoption.

  • Loren Pechtel (unregistered)

    Once again, not a WTF. CPU wasteful, but code efficient. It's been a long time but I don't see any other way to fill the array with empty strings with one statement.

Leave a comment on “How is an Array like a Banana?”

Log In or post as a guest

Replying to comment #:

« Return to Article