views:

157

answers:

5

I about to take some courses in Pattern Recognition. As i have no prior knowledge in either C or C++, my professors told me to learn a bit of one of them before the course, and learn more when doing the course.

Which one should i pick?

The prior knowledge in programming i have is limited to mostly C# but some PHP, SQL and Prolog as well.

+1  A: 

A standard library you will likely use is opencv.

C# will set you in good stead to master C/C++. You will probably be able to see through the opencv code examples and understand them.

You can likely get by with enough C you pick up from working through the examples and becoming familiar with them. The focus of the course will be on the algorithms and not how fancy your code is.

Sounds like a fun course! Good luck.

Will
Note that OpenCV has both C and C++ APIs, but it seems that the C API is more mature and more stable. (Of course you can still call the C API from C++, but that rather defeats the purpose of learning C++).
Paul R
Nobody masters C++! You just get a little better every time.
Grant Peters
+3  A: 

C and C++ are fundamentally different in the way they approach programming. If you have experience with C#, C++ would be a choice since it is object oriented as well. Also, even though they are different, knowing C++ will let you read (and mostly understand) C code as well. Also, check out this question for some information on the differences between these languages.

Space_C0wb0y
+3  A: 

I would recommend learning C++ as this probably be easiest if you know about classes etc from C#. Also you can write free functions in C++ but is harder to write classes in C.

graham.reeds
+4  A: 

The choice of a low-level language like C or C++ probably means you are into performance at the cost of the development time.

If this is your first low-level language, then learn C. It is simple, robust and proven language, and it allows to write the fast code. It has a decades long record of portability. It is much easier to integrate C code with code written in other languages. With C++ it is too easy to make things wrong. C++ requires much greater degree of language mastery and much more programmer's attention to make things right. While it is possible to write fast code in C++, it's more of an art than doing the same thing in C.

If you have only a few months to learn, then at the end you'll be able to write an OK C code, but this time is simply not enough to get enough experience with C++, hence your C++ code written in the first year or two will be awful.

See, for example, severe criticism of C++ from Linus Torvalds: C++ is a horrible language and C++ productivity. Basically, it boils down to C++ being too complicated even for professional programmers, and C++ code being ambiguous with context-dependent behaviour (this may be considered a higher-level language feature, but it makes more difficult to reason about the performance).

One of the major open source libraries for computer vision, OpenCV, is available both for C and C++, but it is also available for Python, which is a much easier language to get the things done quickly (and also to learn as a first language). BTW, I assume if you manage to offload most of the work to the library, which itself is written in C/C++, the performance cost of Python won't be huge (but generally Python is 10x slower than C).

jetxee
While some of the points made by Linus are actually valid, most of his diatribes on C++ are horrible flame war starting rants (after all, Linus (co-) *invented* flame wars). Not a good source of objective criticisms.
Konrad Rudolph
Well, probably there are better sources, feel free to suggest. While I mostly agree with Linus, I don't intend to (re-)start the flame war. My main point is that it is better to start with pure C first, not that C++ should never be used by anyone. It's not a good language for the first student project (but may be suitable elsewhere).
jetxee
Though people who come from c generally have bad habits, usually with type safety and not using [RAII](http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization).
Grant Peters
+4  A: 

Stroustrup (inventor of C++) argues that C++ is easier to learn than C:

There will be less type errors to catch manually […] fewer tricks to learn […], and better libraries available.

With that in mind, go for C++.

Konrad Rudolph