- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Wow, I wrote stuff like that when I was 7/8 years old on my C64... I always forget that a lot people basically start to develop their basic skills I gained before I was a teenage when they are adults... if they are lucky. Love the line numbers tho, really shows the complete lack of understand of what they are doing more than anything else.
Admin
Hey, that is advanced, and clear... they are using multi-letter variable names.... A major improvement over "single letter + optional number" naming constraints. And since no variables were scoped, there was always re-use (sometimes unintended).... just another normal day in the office back in the day...
[MaxiTB] remember there was a time when line numbers were required for basic, and many environments did NOT have a renumber capability.... so if you numbered sequentially, and needed to insert a line, you either re-wrote everything that followed, or you replaced a line with a GOSUB [and put the removed line as the first line of the subroutine --I started just one month shy of a decade before the C64 was releases ,<grin>]....
Admin
This looks very much like it started as GW Basic of similar: (mostly) 2-character variable names with a type appended ($, %, #), line numbers, horrible separation of lines with ":" etc.
Admin
What strikes me is the "Exit Function" in FormulaControlla().
Admin
must have started way before VB or the programmer never updated his Basic knowledge (pun intented)
Admin
damnit intended
Admin
Code like that - especially if it 'just works' - is like dealing with a bear. Back away slowly, don't make any sudden movements and avoid eye contact. Just leave it be and everyone will have a much happier day.
Admin
The fact that it's top(1) tier spaghetti code is tinged with irony, given that it's sourced from Italy.
But yeah, I, too, wrote code better than this in Basic before Visual Basic, or even QuickBasic, existed. (Not when I was 7 or 8, naturally, since "writing code in Basic on your own home computer" wasn't a thing in 1973-4.)
(1) "top" meaning, "at the top of a list sorted in descending order of badness," naturally.
Admin
This code is already atrocious, but 2.5 million lines of it? There may be a mad programmer at work, but there are some serious Dark Forces that let that happen. They watched from the shadows and let it fester. And now they are spreading. They may manifest in your workplace and slowly consume your soul by manipulating through the Manager-Beelzebub Association.
BEWARE!
Admin
*cries in Python*. You'd think that a language, that says "explicit is better than implicit" would not make variable declarations of all things implicit. Also, I'd love to have a
const
keyword or, better yet, const-by-default and amutable
keyword.Admin
I like how they seamlessly blend multiple paradigms at once: Structured IF statements and procedures with unstructured GOTOs and line numbers, and variable sigils with DIM statements.
But in their defense, Visual Basic doesn't tell you the line number when it throws an error unless you actually put an old-school line number in the source code. So that's sort of a valid reason to put them in.
Admin
Some part of me wants to paste this into Notepad++ and refactor it. Someone stop me, please.
Admin
2.5M lines of Basic? That's, like, Necronomicon levels of madness right there.
Admin
Most likely the Dark Forces called "Manglement that doesn't care about how software is built so long as it works", and, in reference to:
Those particular Dark Forces don't watch software development from anywhere, and don't have a conception of software festering.
Admin
At least he uses GOTO properly by using line numbers. That way the code is read only as any change breaks ALL the jumps in the code. Imagine you had access to 2.5 Megalines of basic code you can edit.
Admin
LOL. I was just thinking that's how arcane spells for summoning deep space horrors might look. The programming language doesn't matter, make it arcane enough and they will heed your call.
Admin
Once upon a time, the Evil Codebase grew, grew, and swallowed its maintainers, one by one, feasting on their flesh, bones and suffering.
Their screams still haunt the code as their tormented souls can't find a way out.
The product was shipped, and it will haunt the nightmares of countless children.
Admin
Given the time frame, would you rather it was written in Clipper? PowerBuilder? Turbo Pascal? Smalltalk/V?
Admin
That code is literally breathtaking.
Admin
I love the flow of this one. You're looking it over, see some comments like a strange incantation in a foreign language, scroll a bit further, and AAH!
Admin
Manager: "I need you to add a new feature....OH STOP CRYING I haven't even told you what it is yet.
Admin
Real men do not cry. Real men weep.
Admin
x86 Assembly. Accept no substitutes.
Admin
Here's a Halloween horror story: A VB6 mess like this also powers one of the major railroad dispatch systems in the US. It's way more than 2.5M lines. Be afraid
Admin
OMG. This is probably the worst code I've ever seen here, and that's saying something
Admin
There’s another horrifying reason to use line numbers in VB6: error handling. You know how modern languages have nice stack traces? In VB6 you don’t get a stack trace so much as a couple global variables. The global variable that tracks which file the error was in is fine, but the global variable that reports what line the error occurred on? Of course it doesn’t contain source file line number, it reports only the BASIC line number and so if you don’t number your lines it just reports Null all the time.
(In work on legacy VB6 applications I refused to number lines, but I certainly have had to temporarily number a bunch of lines just to figure out exactly which was throwing an error.)
Admin
That's why any serious BASIC programmer (JK IKR) would number their lines in steps of 10, which they actually did here. As an added bonus, the line numbers not divisble by 10 obviously indicate later insertions and thus serve as a revision history, obviously obviating any need for source control.
Admin
My thought processes:
That's odd, I didn't even know that you could use line numbers in Visual Basic
I wonder why he used line numbers.
It couldn't possible be because....
Noooooooooooooooooooooooooo......
Admin
It's not spaghetti code. At least the fragment we see here isn't. It's actually fairly well structured, if you look at where all the
goto
s actually go. There's no jumping between subroutines. There's no jumping into the middle of a for loop. There's no jumping back into the middle of a logical block of code, well, not much. Most of the goats are simulating concepts from structured languages.Real spaghetti code like the stuff I used to write when I was 13 is vastly worse than this. Sadly I can't show you because I don't have any means of reading my Commodore PET diskettes, which some might say is fortunate.
Admin
But some code is just white, to stay with the bear analogy.
Admin
At least this isn't Excel formulas, where even the Excel functions are translated...
Admin
No, changes do not break all the GOTO's. In all versions of BASIC that allow line numbers, editing doesn't renumber the lines except when you retype a line number. So the line numbers are labels, except there's no meaning (but considering the variable names, do you think a text label would be any more meaningful?) But with every line numbered, every line may be the target of a GOTO and you have to read the whole program to find out which are. In the older versions of BASIC, I used to print the program on wide ledger paper, then draw arrows showing each GOTO or other control transfer. Imagine doing that in a 2.5M line program! (Around 400,000 pages of printout. It would fill a room, I think. Also, on a server or shared mainframe, they'd cut off your printing privileges, at the very least. That was never a problem working in TRS-80 BASIC - I expanded my RAM to the maximum of 48K of RAM, but the program size was still rather limited, and I don't remember ever running the dot matrix printer for more than half an hour at a time.)
Oh, although the line numbers are labels, they must be sequential. Notice how most of the line numbers end in '0', but some end in '5', and one in '1'. They were originally generated (by a setting in the editor) to count by 10's so changes could be inserted between the original lines. But I am a little freaked by how few insertions there are for a program this big and this old. Either this segment of code was pre-planned remarkably well so it was never necessary to insert two lines between the original lines, or it got so messy that someone had to renumber it manually, re-typing the numbers and tracking down and editing each GOTO affected.
Admin
Yes, it's reasonably well structured. I can write a structured program in any language, including the many embedded control programs I've written in Assembly. I hope I've never done this, but I suspect there are coders who don't need GOTO to write an unstructured program in any language.
Admin
Pollack might be recognizable as Polish notation so for me it seems as a parser of mathematical expressions.
Admin
Did early versions of VB lack an "else" or "else if" keyword? Or did the original creator not know of such advanced concepts?
Admin
Yes, ELSE is a very recent addition, in fact there was no token like that in C64 BASIC. However Amiga BASIC already had ELSE... and labels and sub routines.
Admin
Meanwhile, lines
Rem ----
indicate later removals (compare lines 19640-19650 and where they lead).Admin
I used to write Basic code with line numbers on my Apple II back in the 1980s. (Saved on audiocassettes—no floppy drives yet.)
I can still vividly remember the very first time I saw code with indents, semicolons, and no line numbers (it was in Pascal). No lie, my mind was BLOWN. That was a real "here's this guy living in the year 3000" moment.
Admin
And now you have the good idea of how our genome works.
Admin
Yeah, but with Microsoft Amiga Basic 1988 those days were in the past, because that one introduced labels to BASIC. So using line numbers is something really, really ancient by now.
Admin
Actually looks like Fortran code that was ported and not updated in any way.
Admin
And who overlooked an almost perfect wording to instead call Mr Midgely "The Man Who Sold The World" ? A missed opportunity to describe him as he was - "The Man Who Soiled The World"
Admin
No, it was never FORTRAN. FORTRAN never had line numbers at the left. Some programmers would set their card punches to auto-number at the far right, so if you dropped the card deck you could use a sorter to put the cards back in order, but those weren't BASIC line numbers, and the FORTRAN compiler just ignored them. Also, FORTRAN never used arbitrary numbers as labels, it never restricted variable names to 2 letters, and I never saw a FORTRAN program where the programmer had not attempted to make the names and labels meaningful - although with only five letters in some dialects, they were often ambiguous.
It was clearly written in an early version of BASIC, anywhere from the very first BASIC interpreter (Princeton BASIC, circa 1968) to the IBM BASIC embedded in ROM in the first PC's. I worked in both of those and several other dialects. The best thing about them was that when better Basic languages came along right up to VB6, the old programs were easily imported - but unless someone wanted to rewrite 50% of the code, the most annoying features of the earlier Basics (GOTO's and line numbers everywhere) remained in the program.
Admin
Just give the code to ChatGpt. I did, and it happily refactored it into quite readable code. I hope they have unit tests to ensure it still works as expected tough :-)
BTW, I think the code in "FormulaControlla" actually does nothing and just accepts all formulas as being valid, since the 3rd and 4th line are "FormulaControlla = True, Exit Function"
Admin
“Lasciate ogni speranza, voi ch’entrate!”