Skip navigation.

Syndicate

Syndicate content

User login

Things I do after programming in a language for too long

I’ve been going back and forth between C++ and C# alot in my current job. When switching between languages, certain elements bleed together leading to the same mistakes over and over. Some of mine:

C# to C++

  • Putting array braces ([]) on the type instead of the variable name (eg, int[] whatever in C# vs int whatever[] in C++)
  • Writing string literals with naked double quote (ala ") instead of the L prefix to denote Unicode
  • Naming methods with PascalCase instead of the camelCase in our C++ convention
  • Throwing exceptions with new, which particularly sucks since it won’t yield a compile error
  • Testing objects for null

C++ to C

  • Prefixing string literals with L to denote Unicode
  • Throwing exceptions without new
  • deleteing objects when I’m done with them
  • Setting variables to NULL instead of null
  • Testing a variable for non-zero-ness implicitly, like if (whatever) instead of if (whatever != null)
  • newing types with default ctors without parens, eg new SOME_STRUCT instead of new SOME_STRUCT()

Other

I have similar problems with other languages, but the only one that really jumps out at me now is using/not using semicolons when transitioning to/from VB/VBScript. Thankfully I haven’t had to do that in such a long while I cannot recall what other differences tripped me up.