Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transitioning from Java to C and then C++? [closed]

Currently I am working with Java and its object oriented-design aspects (I also work with PHP/MySQL a lot). I don't implement it on the web; I just use it for designing programs for general purposes. However, now I need to learn C right now, and I have an interest in C++. I got The C Programming Language, which some people say is the best book on the subject. Can someone tell me what will be the biggest challenges, except of the String handling, in the way I think about programming design, and how I create programs? I understand that I can't have classes, but how will this impact me specifically (i.e. will I have to redesign methods and always design everything with the idea that it is harder to edit)? Also, is the jump to C++ from those languages hard? Everyone says it's a really hard language, but would some previous experience help? And with that experience would Accelerated C++ be to hard of a book to start out with?

Thanks a million.

like image 583
Brian Avatar asked Jun 08 '09 02:06

Brian


Video Answer


1 Answers

If you are used to OOP, the hardest part of the transition to a non-OO language is going to be in getting adjusted to the logistics of "simulating objects" using existing mechanism. In C, this typically involves having a struct, and then having a bunch of functions that take that struct as a parameter. With C++, you can avoid this.

However, the biggest challenge of the transition to C or C++ is going to be in getting used to pointers and to memory allocation. You will undoubtedly make mistakes initially in referencing and dereferencing, and get confused about C++ references when you work with them. You will also undoubtedly cause memory leaks or errors. And since you are working "on the wire", the crashes will not be pretty. I'm not sure that there's a way to overcome these pains but practice.

like image 61
Uri Avatar answered Oct 04 '22 22:10

Uri