Master Programmer wrote:
I heard from a friend that C++ is mainly being replaced as language of
choice for most C++ programmers around the world.
That is mostly hype. Yes, for some tasks C# can be a good tool if you really
don't need all the horsepower of C++.
Unless java, C# has the using statement to provide some degree object
lifecycle control, but it is still to primitive to rely on it for all
resource management.
When Java first appeared, the enthusiasm for GC was so high that all over
the place we read: "The need for the programmer, to do bookeeping are gone,
just allocate and forget, GC will take care". Many beginners did just that,
and saw their software locking, hanging, crashing or having unexpected
behaviors. Well, the memory is not the single critical resource one use
inside an object. You often open a file, a named semaphore or pipe, a
socket and so on. This are resources that you can not allow the GC to take
care of them at his own will, when he feel so.
So, the classical C++ paradigm:
x=new X(); ..... do work here .....; delete x;
has become in Java:
x=new X(); ..... do work here .....; x->Dispose();
The same amount of bookkeeping is required, and the task is a bit more
tedious. Because in C++ you know that every new must eventually "be closed"
by a delete. In java and C# you actually need to keep track of disposable
or non disposable objects.
And if you look and see that the intensive use of STL containers, smart
pointers and a carefull design can help you not to care (too much) about
deleting objects, the C++ seems like the paradigm winer here.
I often use to say: whenever complain about lack of GC in C++ don't really
understand programming to well. The creators of Java and C# being included
in this category too.
I guess this makes
sence as it means that when learning you dont have to fuck around
sencelessly with low level garbage like pointers.
I often use to say: whenever complain about lack of GC in C++ don't really
understand programming to well.
I was going to learn
C++ but if times are changing I think I will just learn C#, it seems
more modern.
I would name it "overhyped" but that is the whole point. Marketing sells.
I also thought about Java but its WAY too slow.
Is getting better all the times. Yes, it is a bit slow but definitely not
the horror story it was 10 years ago.
And also, now it is open source. This will guarantee that no company will
mess up with java agenda. C# specs can be changes by MS at all any time.
Also, they launch the new specs only when they are ready to get with a new
version on the market.
That creates an about 2 year gap betwen MS.NET and Mono project. Since most
programmers like to try the newest tools to take advantage of the new
stuff, this create a portability gap betwen the software running on Windows
and on Mono.
Most Windows programmers are also not very well educated about the
portability issues (or don't care about them) so their code is littered
with PInvoke and hardcoded path strings like "C:\\Windows\\...". This kind
of idiotic code will not run on other OS despite the existence of a
compatible .NET engine there. Java programmers on the other side are
"evangelised" about portability from cradle and java library is more
complete than .NET so you don't need to use (that often) OS specific calls.
As a result, the average java code it is way way way more portable than C#
code.
Because we don't live into a closed world, and because the technology evolve
rapidly, and because smart people don't like to be handcuffed by a
particular vendor, I strongly recommend Java over C# if you don't like C++.
I think
it should be easy to learn as I have heaps of experience making complex
programs using all versions of Visual Basic.
A VB guy actually complaining about Java speed ?
Any comparisons out there?
Yes. C++ rules, Java suck but you should always prefer Java instead of C#.