They said that C# is better and easier than C++. They also said that I should stop coding in C++ and go to C# or java instead. I know how to code in C++ and java but never tried coding using C#. I love C++ over all of them. Are they right or wrong?
They said that C# is better and easier than C++. They also said that I should stop coding in C++ and go to C# or java instead. I know how to code in C++ and java but never tried coding using C#. I love C++ over all of them. Are they right or wrong?
C++ and C# and completely different and almost incomparible. C# is much higher level, same as Java. Because of this they are both somewhat easier to use than C++, but easier doesn't always equal better.
That C# is easier and better than C++ is bogus. Same applies to Java.
C++ offers a lot of tools to help development and in the coming standard, even more so, making it easy to develop in C++ as well as very flexible and powerful. And it's also faster than both Java and C#.
What C++ mostly lacks is a standardized library of functionality aka dotNet and a graphical framework.
So that basically means it's like comparing apples and tomatoes. Use what you like.
Yeah, java was so easy. When I try to make a program in Java, everything was so easy. You just go on their API and look for the class that fits on what you need then you're done. But I just dumped it and continue studying C++.
Oh yes, another thing is that C++ is classed as native, and is mostly backwards compatible with C. Therefore, a lot of stuff, API and such is actually written for C and not C++.
This makes it a lot more difficult to use these things because C is a low-level language. Another flaw that adds negative points to the use of C++ in the real world, though it isn't really the language's fault.
Well those people will get some sense slapped back into them when they realize to get a job these days you usually need to know C++, and if you are applying for C# they ususally want ~10 years experience (which is ridiculous).
Besides the honest truth is that if you know C++ very well, transitioning to C# is quite easy.
learn both. and a dynamic language like python or ruby.
Depends on what you're writing, doesn't it?
That's been the diametric opposite of my experience; most of the listings I've seen want C# or Java.
Anyhow, to the original poster, they're different tools for different jobs. C++ gives you more control, but at the same time, it also is more complex.
Personally, when I write software for myself, I almost invariably use C# just because the development time is greatly reduced, and several common bugs are either caught at runtime (e.g. buffer overrun) or simply can't happen (e.g. memory leaks from failing to destroy objects).
GUI work is also fast and incredibly easy in C#. I used to do my GUI work in MFC back in the day, and before that I did pure WINAPI, and C# GUI work is almost a joke it's so simple.
Also, I like C# in that it is native Unicode throughout; in C++ I always used Unicode but it required additional developer work to use. I know any C# application will work with any file I have, regardless if the name is in english, chinese, korean, etc.
I work primarily in C# and while it is managed, that doesn't make it "easier" by any means. Making any kind of software requires you to know much more than the basics, and anyone still fighting over languages really miss the point. Great software has been made in both C++ and C#, even Perl, VB, and Ruby, so it's hardly the language, just the person behind the keyboard.
As with Java, there seems to be a lot of hand-wringing in the C# community on how to detect and remedy memory leaks.
The anti-C++ propaganda fomented by the Java and C# communities is fun to read sometimes.
C# is very much like Java re: memory. You don't have to manually manage it, until you do. The sales schtick by the snake oil salesmen of both languages has doubtless led to sloppy, leaking code.
In general, though, C# memory leaks happen in three basic ways:
1. You actually have a pointer to the memory somewhere that you haven't gotten rid of. Not truly a leak, just bad coding.
2a. You called unmanaged code that allocated memory, without freeing it.
2b. You used a GDI object without disposing it. Technically this isn't a permanent memory leak, as during finalization the memory is returned, but that will happen at some indeterminate point in the future when the GC feels like it.
And yeah, while you can't completely ignore C# memory management, it has a lot of advanced stuff as default -- for example, it will dynamically move objects in memory to avoid memory fragmentation. Doing THAT in C++ is a huge pain unless you code with that in mind from the first line.
I would give them the benefit of the doubt and say that it is just a case of where the Law of Leaky Abstractions takes effect.Quote:
Originally Posted by medievalelks
In a way, with a modern OS that reclaims memory when the process is terminated, this would then be true for C and C++ programs as well. "Not truly a leak, just bad coding."Quote:
Originally Posted by Cat
That has been my experience as well.
Memory leaks happen quite often to me in C#, generally when I forget that I'm not in C++, and need to explicitly free some resource. Generally this happens when you beat the GC, and try to access a resource that it hasn't yet free'd - such as reading a file that you recently wrote, and the old file object hasn't yet been garbage collected. The fix is obvious to a C# programmer: I should have free'd it manually by using .Close() or using(). But I'm a C++ programmer - I'm used to stuff deterministically freeing itself when it goes out of scope. :-)
C# GUI work does make Win32 look incredibly slow, I will admit. However, I still find it incredibly hard to do some basic tasks (have a dialog that is not resizable, but it fitted to it's contents! This was hard in Win32, and subsequently everything else, as Win32 controls have no way to get a bestfit size...)
I feel like you left out some of the better parts of the language - lambda expressions, a really, really awesome standard library (half of System, including String, regexes, threading, containers, binary file io, and more!)
I'm a C++ guy. My advice to the OP would be to learn at least C++, if not C or some close language. Knowing memory management is invaluable. I've seen programmers go both ways: C++ to Java/C#, and C#/Java to C++, and the C#/Java programmers coming into C++ generally have the harder time.
That said, I see a lot of people wanting programmers for C# or Java, and I program primarily in C# for the place I work. (I do a bit of VB6 too - don't shoot me, it's not by choice...)