views:

71

answers:

4

Hi everyone,

This is a general question. I wanted to know from your experience which typos are the hardest to find or debug in your code. A back story would be nice :)

Thanks!

+1  A: 

Many people find that the equality operator in C/C++ is a real pain, because it can be easy to typo/confuse to be the assignment operator:

if(grade = 16)
{
}

vs

if(grade == 16)
{
}

They have so much problem with this, that there is an idiom to avoid this problem:

if(16 == grade)
{
}

...because the compiler would catch the typo.

Merlyn Morgan-Graham
A much better way: set the compiler warning level to /W4 and you will get a warning for such typos.
Stefan
I agree (depending on the language/compiler.. C#?) I have done this typo once myself, in ten+ years of programming, and I caught it after one crash and 30 seconds of debugging. This sort of readability hit isn't worth it, but I guess to each their own.
Merlyn Morgan-Graham
I'm not going to upvote, neither will I downvote, this is a known hazard which can be picked up with lint or gcc.
PP
+4  A: 

I have Cyrillic keyboard installed on my computer which I switch to using Shift+Alt. While I was typing my code I accidentally switched to Cyrillic and typed a variable name using a Cyrillic character which looked very closely to an ASCII character. It took me a while to understand why my code wasn't compiling.

As it was a short snippet and I couldn't find the reason of not compiling I decided to rewrite it and imagine how surprised I was when it worked. I saved the working version to a new file and typed a few CTRL+Z to get the previous version which once again looked the same but it didn't work. Only when I performed a binary comparison on the two files I understood what the problem was.

Darin Dimitrov
+2  A: 

I'll start things off just to get the ball rolling. When working for one of my previous employers, we had a big release scheduled at a major telecom client aboard.
Because we added many new features and it was a relatively new system we did many tests and a long QA process and were anxious towards the release.
When we were convinced everything was WAD, we sent our integration team to install the product at the clients telecom system.
Once installed, all hell broke lose the clients systems failed all servers stalled and nothing went online.
The management went into panic mode, angry emails to the team leader and the developers people who were involved directly with the new features were flown abroad to the client to try and debug / appease the enraged telecom provider. The client was losing millions for each day his system was down...

At some point all developers started to feel like they're gonna get axed. If you receive an email from the VP of a 5000 employee company mailed directly to you asking for explanations then you know it can't be good.

At the end the problem was found, the cause:
At the JVM properties you can define the size of the heap before garbage collection is called, the integrator that installed the system typed 1024*k* instead of 1024*m* which caused all the machines to go into constant GC and die. That single letter caused my company about 4-6 Million $

Enjoy

Asaf
What is the default? Good case for scripting the whole process? ;)
Merlyn Morgan-Graham
Java... dependent on such fine tuning of memory parameters you might as well program in C++...
PP
A: 

Any typo in PHP?

Dario
Or regular expressions :)
Merlyn Morgan-Graham