3

I have quite a bit of experience in writing managed code (namely C#.net and Java), but I've been looking to become fluent in unmanaged C/C++ (as I would like to work on video games when I graduate in a few years). However, as I've been trying to make the transition, I've found that things I would otherwise consider to be absurdely simple in C#/Java to be frustratingly difficult in C/C++ (i.e. getting the length of an array. I will now forever appreciate the ease of the .Length property). So, I'd like to know if anyone has any good (preferrably free, and preferrably online) resources for a managed programmer looking to move to unmanaged code. Any advice would be greatly appreciated!

Stanley L
  • 45
  • 3
  • related topic http://stackoverflow.com/questions/45175/resources-online-to-learn-c – UmmaGumma Mar 30 '11 at 17:19
  • 3
    I would put what you know to one side and start from scratch when you learn C/C++. Some concepts will be familar to you but others are different in fundermental ways. Farther than trying to migrate, just start from the begining and you are less likely to assume C is just like C# without the #. ;) – Peter Lawrey Mar 30 '11 at 17:21
  • 1
    I'm pretty sure you can make a living writing video games in c#/XNA too. – Albin Sunnanbo Mar 30 '11 at 17:21
  • @The Elite - It is unmanaged because it has no large company controlling it? :-) – Bo Persson Mar 30 '11 at 17:25
  • pmg: Honestly, I'm not sure between the two. I'm looking to learn for the purpose of learning game development, so I'm not 100% on which one I should be pursuing (most job postings I see list "strong C/C++ skills" as a requirement, so I'd assume both). However, I've never seen a game programmer position requiring COBOL or Lisp :) – Stanley L Mar 30 '11 at 17:27
  • @Stanley - Even though an array doesn't have a .Length, a std::vector has a .size() - not hard at all! – Bo Persson Mar 30 '11 at 17:29
  • @Elite Gentleman - I was actually under the impression that C++ is ALWAYS unmanaged, except for some select cases (i.e. C++/CLI, which is a language that I still don't understand the reason for its existence). Is this not the case? – Stanley L Mar 30 '11 at 17:31
  • @The Elite Gentleman: I think he's talking about using vanilla C++ to generate native binaries, rather than using the .Net version. – John Bode Mar 30 '11 at 17:32
  • First lesson: C++ and C are distinct languages. Learn one, the other, or both, but know what you're learning at all times. Second lesson: when using C++, arrays are almost never the right answer. Use `vector<>`s. – David Thornley Mar 30 '11 at 17:37
  • C *or* C++? They are two different languages with different capabilities and philosophies. – John Bode Mar 30 '11 at 17:37
  • For one, the C++ STL is managed, else we would have all kinds of C++ library flavours. Yes, there may be no large company controlling it, but the specifications is managed. – Buhake Sindi Mar 30 '11 at 17:42
  • @The Elite Gentleman: It's a Microsoftism. Managed code is code that runs under .NET, and it does have some desirable properties. By contrast, native code is sometimes called "unmanaged". Microsoft is pushing hard for managed code to be the norm and unmanaged the exception for Windows software. It means essentially nothing outside Microsoft Windows. – David Thornley Mar 30 '11 at 17:43
  • @John Bode - see my earlier comment to pmg. Short answer to your question: I really don't know. Do you know if it is easier to learn C and then transition to C++? or vise-a-versa? – Stanley L Mar 30 '11 at 17:47
  • 1
    @Stanley L: C is the smaller language, but C++ provides better tools for managing data (the STL is your friend). C++ also provides mechanisms to make memory management easier (that is, easier than C). IMO, if you want to learn C++, it's better to start with C++ than to learn C first; the languages are different enough that you would have to unlearn some C best practices. – John Bode Mar 30 '11 at 17:53
  • @The Elite Gentelman: that's not the definition of "managed" that I'm familiar with (otherwise C would qualify as "managed" as well); to me, "managed" code runs under a virtual machine (such as the JVM or .Net) instead of as a native binary. – John Bode Mar 30 '11 at 17:55
  • @John Bode, in that case, leave C++ alone! If it gets managed, we can't be able to write assembly code in C++ or C. And besides, how will the virtual machine be implemented? In a managed language? – Buhake Sindi Mar 30 '11 at 17:59
  • @John Bode - As a matter of technicality (as I can actually talk authoritatively about this), C# does not run under a VM. In .net languages, the C#/VB/etc. you write gets compiled to an intermediade language (called MSIL). This MSIL code is what is in the .exe that the compiler spits out. When the .exe is ran, the MSIL is compiled "just in time" to native code that the computer then runs. Its a convoluted process that makes the eventual native code slightly (sometimes a lot) less efficient. I think managed refers to only that memory is managed by the computer, rather than the programmer. – Stanley L Mar 30 '11 at 20:15
  • @Stanley L: Correction noted. Thanks. As you can probably tell, this isn't my area of expertise. – John Bode Mar 30 '11 at 20:59

5 Answers5

3

http://www.horstmann.com/ccj2/ccjapp3.html looked pretty descent. I

scrappedcola
  • 10,423
  • 1
  • 32
  • 43
  • Its not as through as the book Giovanni mentioned, but it is certainly what I asked for. And still a great reference on top of that. Thanks! – Stanley L Mar 31 '11 at 14:28
2

I know this book exists: Pro Visual C++ 2005 for C# Developers. Taking a peek at the table of contents, it looks like both unmanaged c++ and c++/cli are covered; so I assume your pain points will be covered in the unmanaged sections of the book.

Sorry though, it's not free.

Giovanni Galbo
  • 12,963
  • 13
  • 59
  • 78
  • I just searched this book and turns out it is in my university's library. Who knew! (not me clearly). Anyway, thanks, this looks to be exactly what I was looking for (or at least the next best thing). – Stanley L Mar 30 '11 at 17:41
1

I'll just leave this here: The Definitive C++ Book Guide and List. This isn't a free resource list, but it's generally recommended to learn C++ with a real book, you'll get one sooner or later anyways.

Community
  • 1
  • 1
Xeo
  • 129,499
  • 52
  • 291
  • 397
1

I'm more of an experimental learner, so I would recommend something like trying to write some mods with the half life 2 source engine. There is a lot of documentation there and a decent sized community around it for when you run into trouble.

Also - before diving in, I would look into how garbage collectors work; because it is going to be up to you to do the garbage collector's job now that you won't be in a managed environment. Spend some time researching this; because most of the other differences between managed environments will become clear as you code; but the lack of a garbage collector isn't so clear and could lead to you writing code which looks ok but runs like crap.

Another thing you should be looking into is stl. You can find a lot of documentation on that at cplusplus.com. Also, here is a short; but concise tutorial on c++.

Dave
  • 6,141
  • 2
  • 38
  • 65
0

The Getting Started section of the Visual C++ Developer Center might have some useful content but it isn't specifically aimed at managed code programmers so you'll have to wade through stuff you already know.

Frank Boyne
  • 4,400
  • 23
  • 30