Tutorial :Learn C# to transition to C/C++?



Question:

Alright, so I just took an introductory class into Computer Science and the school's language choice was Java (I have basic knowledge of concepts like polymorphism, encapsulation, etc..). I want to learn C++ then C (I hear that one should learn C++ first then go to C), and was wondering if C# is a nice transitional language because of the language similarities between Java and C#. So will learning C# first help me get a better understanding of C++ later?

I appreciate any help. Thank you.


Solution:1

Doubtful. C# is not significantly more C++-like than Java. It does support pointers in unsafe code, but beyond that I can't think of any reason it would make an especially good bridge from Java to C++. Also that is a feature I suspect more likely to be used by developers coming from the other direction. If you have other reasons for learning C# I say go for it, but for the purposes of transitioning more easily to C++, I'd say skip it.


Solution:2

I feel that the easiest transition from Java to C and C++ is to first start with C.

Get a feel for pointers and not managed memory.

Then, once you get a feel for the hard stuff in C and C++, tack on objects and the STL with C++.

That is how I learned, and it was a very easy transition for me.


Solution:3

If you are primarily interested in learning C++ do not learn C# because while on the surface they look very similar, in practice they are quite, quite different.

I highly recommend learning a programming language that does not use a managed memory system. The reason is because when you deal with such a language you are forced to learn the intricacies of memory management yourself. You can't rely on a garbage collector for anything really because it is up to you when objects/structs live or die.

C is a very small language and probably faster to learn than C++ but you may pick up bad habits from C if you ultimately want to use and learn a modern object oriented language. Learning C first is not a requirement.

My ultimate recommendation is go straight to C++ and get a feel for it.


Solution:4

If you already know Java, C# won't teach you much more about C++ than you already know.


Solution:5

Learn C first and foremost to get a feeling of dealing with unmanaged memory. Then apply what you have learned about object oriented concept to that unmanaged world with C++. Introduce yourself into differences of C++ like virtual methods, multiple inheritance and so on.

Read books about best practices. Learning C++ alone doesnt make you a C++ developer instantly. It is a federation of languages, you better have to know how to use that language.


Solution:6

Just learn C. Don't bother with "transitions"; if your goal is to learn C, just jump directly to it. Java shares enough syntax with C to be close enough that you don't need to worry about C++; you'd just get sidetracked with C++ things. C is important enough to learn on its own, without trying to "soften the blow".


Solution:7

Java is object-oriented, C++ can be object-oriented, and C# is mostly OOP, but that is the main similarity.

C# has changed a great deal from Java so unless you look at C# for .NET 1.1 you will be learning a language that is very different from Java, and if your goal is C then you will be moving away from that.

C is a structured language, so the mindset is different than the other three, as you no longer have objects, and you have to worry about the memory collection yourself, no garbage collection.

Pointers was the hardest part of C for me to learn, once I understand that C was easy.

Once you know C, and if you already know Java, then C++ will have less to learn.


Solution:8

I don't think there is any language which gives a smooth transition to C++, except maybe D.

Concepts almost unique to C++ and D:

  • RAII -> deterministic resource management that is hard to use wrong and trivial to use right. You don't learn that in C# or C, you'll only learn manual resource management there.
  • Template Metaprogramming -> Turing completeness at compile time. Though most programmers won't need this and this is less common; usually you'll find this in the form of libraries (most prominent example: Expression Templates)
  • Compile time, duck typed generic programming -> C++ comes with many type-agnostic algorithms and containers. C# generics are strictly typed and put more restriction on clients.
  • Different paradigms: procedural, object oriented, generic, and a bit of functional programming. C#, Java and C teach only a subset of them. In C++, you have the opportunity to learn when which is most appropriate.
  • const correctness and a library that is const correct.

I don't like that many programmers reduce the comparison of C++ or C to C# to "you can have pointers in C#, too", because that does really not value the real differences.


Solution:9

Always learn in the order things were invented, not other way around.

EDIT: The advise to first learn C++ then C is pretty insane... I mean C++ is a superset of C, once you've learned C++ there's nothing to be learned in C except what it lacks comparing to C++. It's easier to make sense of why things were added as language evolved rather than guess why weren't C++ features implemented in C.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »