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.
Worlds most absurd codes ever written!
Emile PerronWeb developer and CS graduate found this a function which ran faster than any other function or method.
And thats 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 werent prepared or sanitized queries.
Developer, Andrew Philips explains this code.
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.
The problems are legion and boundless.
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.
It was years before somebody noticed the flaw.
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.
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.
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 wasnt volatile.
I asked the coder if hed overloaded the = operator; he said no.
Another reviewer wrote, …you dont need to check that p is non-null, just set it null.
The programmer simplified the code before finalizing it.
source: www.techworm.net