I want to learn the C# language and I was wondering if prior knowledge of C++ would make it easier to learn? I have a large background in Java and am currently programming in (and therefore constantly improving on) C++. Would knowledge about the C++ syntax and structure help me understand C# more quickly, or is C# more akin to Java?
|
migrated from stackoverflow.com May 6 '11 at 8:29
|
Short answer: Yes Long answer . . . Especially with regards to memory management, both C# and Java use garbage collection, C++ does not. Like C++ C# will let you into the bowels of the machine, you can do your own memory management if you really want to (but it's not advised, and rarely needed - in almost 10 years developing on .Net I've never needed it). However C# has the However C# has diverged from it's Java like roots, with better support for Generics, lambda calculus and variance on generic types. So in that respect it's feature list is more like C++ than Java. However, syntax wise, it's still more like Java. That said, the underlying libraries (i.e. the .Net Framework) are very different from what you will find for either C++ or Java, and this will be your largest learning curve, however, it's quite a gentle curve and well worth it, as the framework is incredibly rich and is a joy to use. Hope this helps. |
|||||||||||||||||
|
|
|
|||||
|
|
c# is much closer to Java than to c++. It will be fairly easy to transition to C# from Java as they are both managed languages and you don't (generally) need to worry about memory management like you would have to with C++. The syntax of C# is similar to Java, the main differences are that you would have to learn the differences in the libraries for doign common functionality, like file access. There are also some 'gotchas' to watch out for |
|||
|
|
|
If you want to learn C#, start developing in C#. A lot of the useful effort will go to learning the .NET framework rather than the syntax, which will seem familiar with your knowledge from Java. Have a look at C# in Depth which should keep you entertained and educated for a few years while you're learning. |
|||
|
|
|
With respect to learning C#, C++ will hardly add anything to Java (without adding junk, like low level pointy stuff, with it). Beyond the superficial syntactic similarities , C# and C++ models are worlds apart. |
|||||
|
|
IMHO, the main problem when learning any new language is not the syntax but the class library, i.e. how you do things... |
|||
|
|
|
|||
|
|
|
No. If your intention is to only learn C# and you think of C++ as a beginners guide to C# you are wrong. C# is a lot more simpler than C++ in terms of refrences and (absense of)pointers. You will first learn C++ and its associated dangers and then learn how to "solve them" in C#.You will first learn what a "friend" is in C++ and then learn that it isnt present in c#. Then you will want to wonder why it wasnt included in C# . Save yourself the trouble and learn C# directly |
|||||
|
|
It certainly helps as the syntax is very similar. This is very superficial, however. You may be doing things the c++ way which is not idiomatic c# (say You will need to remember that you don't have control over memory allocations and shouldn't use pointers... Visual Studio and IntelliSense help a lot with learning the difference in syntax, it's the different philosophy (GC language) you need to keep in mind. |
|||
|
|