Monday, July 27, 2009

Transition from C to C++

I have been working as a software developer for five years since year 2003. I have been spent four years at the beginning of my career on C language and one year on C++ language since I am working as a game developer on last year.

From my perspective, C and C++ are pretty much the same. What I mean is in terms of programming syntax and semantic. C programming syntax is still compatible under C++ environment where the file extension was saving under CPP file. But if C++ syntax was saving under C extension and try to compile it with C compiler, it will prompt a syntax error.

I have compiled a list of key note for C programmer making transition from C to C++:
  • C++ has smart pointer whereas C is pointer.
  • C++ adopted functor whereas C is using function pointer.
  • Memory allocation should adopt RAII technique.
  • Should not rely much on structure whereas should focus more on object design.
  • Should familiar with template design as this will utilize the code reuse concept.
  • Error handling should be done on one side by using exception. Return code only indicate the status of the execution of a process, not to instruct what should be done next.
C++ is a powerful language, programmer should aware of what they coding so that this language is not overuse. For example:
  • Multiple inheritance should use carefully because this will increase the risk of code maintenance as the hierarchy level was increase.
  • goto keyword should use extensively in the code as this will lead the program flow much more complicated.
Here are some good books that worth to read:
  • Accelerate C++: Practical Programming by example
  • Effective C++
  • Exceptional C++ and More Exceptional C++

No comments: