Some of the world’s weirdest codes ever written!!!


Programmers, here are the most absurd codes that you may have ever seen

Hardcore programmers will say that coding is an art or science. While learning to code is hard, tedious and excruciating, it is the end result that counts. There are millions of new programs being written every day so that our lives will be that much easier. But sometimes programmers write that one code which has no explanation. Rather it borders on absurdity.

Today, we look at some of these weirdest codes ever written. The way these absurd codes are written, only the programmer who wrote this program may be able to explain why it is so.

World’s most absurd codes ever written!

World's most absurd codes ever written!

Frank Taylor, Senior Front End Developer at Tahzoo, JavaScript found this code when his old company Megacorp was migrating Microcorp’s website into Megacorp’s CMS. Taylor says that whoever wrote this code was either perfectly incompetent or perfected passive-aggression by saying “F it all” in the CSS.
World's most absurd codes ever written!

Émile PerronWeb developer and CS graduate found this a function which ran faster than any other function or method. It was named _addslashes, so when going through the code, you’re expecting it to be some kind of improved version of the addslashes function. And that’s where you would be wrong! No wonder there were issues with the database updates/inserts in this part of the code. Oh, and needless to say, those weren’t prepared or sanitized queries. And there wasn’t much (if any) validation, either

World's most absurd codes ever written!

Software engineer, Fouad Elia Kada who found this code says that he has what the guy who wrote this code had in mind or what the code does.

World's most absurd codes ever written!

Developer, Andrew Philips explains this code. For those unfamiliar with C languages, this code scans a character array (string) looking for an element whose value is 0 (or \0 or the NULL value) and returns the index of that element, which is defined to be the end of the string. The function strlen requires that the character array passed in has a NULL terminator. The rest of the line takes the location with a Zero and assigns Zero to it.

Looking for a NULL terminator and then setting the location to the value it already contains does nothing save risking a segmentation fault because the string may not have been terminated properly, which would cause strlen to wander off the end and eventually return an index outside the allocated boundary of the array, and assigning zero to a random memory location could be out of process memory bounds or modify another, random data structure with unpredictable and incorrect results. The problems are legion and boundless.

If the string was conforming, at best it wastes time and turns electricity into heat (microprocessor) while doing no useful work.

World's most absurd codes ever written!

Software engineer, Patrick Minton who found this code says he is still pulling his hair out interpreting this one. The dreaded IF NOT / ELSE block, combined with the fact that the variable itself is true when it represents a negative state….*pulls hair out*

World's most absurd codes ever written!

Web developer Rory Glasgow found this code in a PHP script several years ago. He says he is surprised, the programmer who did this used so many variables when the same output can be obtained using simple $output = strtoupper($input);

World's most absurd codes ever written!

Software developer, Anirban Ghoshal found a bug which he was fascinated in an application designed to perform a sophisticated audit on a large array of integer values for consistency. The audit would attempt to skip values in that array that fell within a certain range (a,b)(a,b). For this range, the audit would simply return success without performing any kind of validation on the values. The person who wrote the code according to above image.

In the above code, within the if check, instead of the logical AND operator, the programmer used the bitwise OR, which made the condition true for every value in the array. It was years before somebody noticed the flaw. Apparently, everyone was pleased as punch that the audit never failed because then the program that populated the array would be pretty much the perfect piece of code ever written in the history of that organization.

World's most absurd codes ever written!

Developer Steve Savitzky says absurd code is one of his all-time favorite sorting algorithm, given in pseudo-code. The average complexity is O(n!). The worst-case complexity is infinite. You can improve it by deterministically generating all permutations in sequence, but that takes all the fun out of it.

World's most absurd codes ever written!

Software engineer, Grigory Yakushev who found this code says that the code was actually correct. They noticed the mistake when the method started to show up in profiling.

World's most absurd codes ever written!

Software engineer, Christopher Burke says that this is the weirdest code he has noticed. He says that this code is surprisingly common. He found another variant of it in a code review. “I knew p wasn’t volatile. I asked the coder if he’d overloaded the “=” operator; he said no. I asked why he’d written the code this way, and he said, “Just cleaning up some unused pointers.” Another reviewer wrote, “…you don’t need to check that p is non-null, just set it null.”

The programmer simplified the code before finalizing it.”

Above are some of weirdest codes written by programmers. If you have found any such eerie code that left you splitting your hair, kindly note it down in comments section so that we can make a part 2 of this article.

1 COMMENT

  1. hehe this are really weirdest codes have seen, am lost lolzz, i would love to learn linux. Have watched movies people doing greate sh*t with it.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Read More

Suggested Post