Programming Humor 3

Once upon a time I saw a code with a “logic” containing something like this:

If c < 0 or d=0 or c >= 0 then a = 1

If a = 1 then
  b = 0
  a = 1
End

No comments saying what the hell was that, so I commented it out for a future revision and just simplified it:

a = 1
b = 0

I’ve found this kind of thing around many times, specially in codes from government agencies.

2 Likes

My favorite legacy code was a ‘progress bar update section’ with code that was commented as…

'Add 40 here because otherwise it doesnt work for some reason

…needless to say, this is where it was crashing

2 Likes

One thing that Xojo brought to me when I started using it, and that I wasn’t used to, was finding an abusive use of timers everywhere and conflicts between them. It was brought to my attention that some code in ARM crashed, because for ARM, one event was firing out of the expected order of the developer, but worked flawlessly on Intel. For ARM, 2 events switched places, probably due to some use of timers internally instead of a queue of events. Using Queues, when you say RunFIFO(fireA); RunFIFO(fireB) you will run the events fireA() followed by fireB() always, but if you use a RunInOneMillisecond(fireA); RunInOneMillisecond(fireB); you have no guarantee of the sequence.

COBOL originally had an ALTER statement which was used to change where a GOTO jumped to. Something like this:

if a=0 then
alter 100-here to goto 100- HELL.

A debugging nightmare since the debuggers of the time didn’t have a call stack. Had to make use of many display statements.

Thankfully the ALTER statement was removed from the standard although I think it is still supported by some compilers as legacy code.

The Sigma-7 FORTRAN compiler had the following. You could put a label number in an integer variable (such a JAIL) and then put GO TO JAIL in your code.

This caused the compiler to emit the following warning:

WARNING: GO DIRECTLY. DO NOT PASS GO AND DO NOT COLLECT $200.

2 Likes

Turbo Pascal for DOS had a language ability is later versions (for the IDE anyway, not the apps it produced). It read the compiler messages and such from a simple text file. One enterprising chap I know changed the “; expected” message to read “purple worm expected”. Strange chap but it always makes me laugh when I use PHP or other languages that require a ; end of line.

1 Like

“;” is not an EOL, its an EOS (End of Statement).

You can write things freely spreading by multiple lines due to it as:

x = ObtainData()
             .Preprocess()
             .Interpolate()
             .RemoveNoise(); // clear end of "x = chain()"

Some people prefer that instead of languages that needs “continuation signs” for that. It’s a trade-off…

x = ObtainData() _
             .Preprocess() _
             .Interpolate() _
             .RemoveNoise() // it ends here, after all that noise of 3 dead worms
2 Likes

That is ME in spades… mind, you don’t hear the explitives coming out of my mouth…

1 Like

https://devdadjokes.net

2 Likes

Not really the point, but correct.

That’s a fun thread, I shouldn’t miss the “dead worms” joke.

I know this will sound pedantic, but…

What if c is NaN ? See NaN - Wikipedia

Depending on programming language, that could slip through that If statement, right?

Ints can’t be NaN

I was unable to correct that for many days, until I saw the lights (use some .Child"")


BaPict_FI = Source_FI.Child(Source_FI.Name + " - Data:" +"images:" + Banner)

Explanation:
a. I am old.

b. This code is related to html; it adds a banner into the top of an html document. I had my brain set to “programming html” and until it changed to Xojo, I was unable to understand my mistake.

And I replaced ‘:’ with ‘/’ in case it worked (or the reverse !).

Why Microsoft Word is the best IDE for programming - YouTube

2 Likes

13 Likes

90 ohm cows
Cows

3 Likes

Actually they’re 9 ohms. The third colour represents the exponent of the multiplier.

3 Likes

You are correct with a four color resistor. On a five color resistor, they are 90 ohms. Both are right

1 Like