473,854 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

learn C++ or C#

If I haven't made substantial investment in either C++ or C#, which language
would the experts recommend I become well acquainted with?

Daniel
Jul 17 '08
151 4557
In article news:<u0******* *******@TK2MSFT NGP02.phx.gbl>, Larry Smith
wrote:
I once met a very senior person in C++ circles (I won't mention his
name) and I asked him for his opinion. He suggested that perhaps
5% of all C++ programmers are competent.
5%? Maybe. It's certainly no more than about 10%.

The percentage doesn't change much for other languages, though, bad
programmers will write bad code in any language.

Remember Sturgeon's (second) rule.
http://en.wikipedia.org/wiki/Sturgeon%27s_revelation

Cheers,
Daniel.

Jul 20 '08 #61
In article news:<ex******* *******@TK2MSFT NGP06.phx.gbl>, David Wilkinson
wrote:
But really I do not think about porting my applications any more,
because I feel that CrossOver MAC and CrossOver Linux do a pretty
good job of running Windows applications.
That's a good point -- and well made -- and if your apps are all desktop
apps then it may be a good enough solution for you. I achieve much the
same by running Windows apps in a Windows VM under linux; it means I have
to have a licensed copy of Windows to run in the VM, which you avoid by
using Crossover (or Wine), but that is not a big problem.

Many customers, though, insist on a native application and won't accept
the additional cost in hardware resources needed by either Crossover or a
VM.

In my work I have often had to share code between a desktop application
and an embedded application, so the separation between back-end logic
(ROMmable) and GUI has been very important.

Cheers,
Daniel.
Jul 20 '08 #62
Daniel James wrote:
Thanks for that. I had seen it before ... and I don't see anything there
that suggests that C++/CLI is "not recommended" for GUI code. All Steve
says that's at all relevant is that MS don't propose to spend time writing
GUI design tools that target C++/CLI when they already have some that
target C# and there are other things they want to spend resources on to
support C++.

That's a fair enough viewpoint, and the message in the blog is that MS (or,
at least, the C++ team) are following what they believe to be the wishes of
their customers in that respect.

That doesn't mean that they don't recommend using C++/CLI, it means that
they won't provide any tools to help you do that. That's not big deal,
really, because it doesn't actually matter what language any automatically
generated code is in -- the form designer might as well spit out a compiled
assembly as C#. Microsoft do say that the C# generated by the designers
isn't supposed to be edited by the user -- that's how they get away with
emitting such poorly structured code.

You don't actually *need* to have any tools to help you write GUI code,
anyway. You can do it all by hand. The form designers may save you some
time but in a large project that time is not significant, and hand-crafted
code will be better structured and more maintainable than anything that
comes from the designers.
Daniel:

Maybe I should not say "Microsoft does not recommend" then. Do you think
"Microsoft does not promote" would be more accurate? Or do you feel that is too
strong also?

I'm sure there are some advanced users who use C++/CLI to write GUI .NET
applications, but the vast majority of the C++/CLI questions I see in the
newsgroups/forums come from novices who have downloaded VC++ Express and have
found that, absent MFC, the only out-of-the-box way to write GUI applications is
to use .NET. Many of these folks, like the OP, are not even aware that the
language they are using is not C++. They have chosen C++ because the name sounds
familiar, or perhaps know it a bit already, but the vast majority of these
people would have been batter off downloading VC# Express instead. At any rate,
they are not going to be happy if the forms designer in VC++ is crippled.

But even experienced C++ users seem to be embracing C# over C++/CLI. It's not
just the designer tools; some features (such as LINQ) are not even available in
C++/CLI. It's a shame after all the effort that went into C++/CLI (after the
initial MC++ debacle), but there it is.

What's the solution? I think MS has to fully face up to the fact that VC++ is
for native code, get the IDE back to the level of usability/responsiveness we
had in VC6, and put MFC (and the PSDK) into VC++ Express. I don't think it is
anybody's interest to "entrap" beginners into C++/CLI.

--
David Wilkinson
Visual C++ MVP
Jul 20 '08 #63
Pavel Minaev <in****@gmail.c omwrote:
On Jul 19, 4:36 pm, "Giovanni Dicanio" <gdicanio@_NOSP AM_email_DOT_it >
wrote:
[...]
>Using tools like string classes, container classes and smart pointers makes
C++ code robust and easy to write and manage.

Well, sort of. Until you accidentially invalidate an iterator by
modifying the container - U.B. Or mix signed and unsigned integer
types in an arithmetic expression and get weird results because of the
silent signed->unsigned conversion rule (and it is very easy to do so,
since a lot of standard library functions return unsigned integers -
e.g. size() of any STL container is unsigned). Or forget that
assignment operator and "copy" constructor for auto_ptr are actually
move and not copy. Or put an auto_ptr into a container (and why not,
if it lets you do so without any compaints...). Or try to make sense
of three paragraphs of ISO C++ standard describing overload resolution
for template functions in presence of partial specializations (the one
where synthetic types are involved). The problem is, you have to be a C
++ expert to write good C++ code, and, not any less important, to be
able to understand advanced C++ code written by others that's thrown
at you.
I've looked at this list and I agree with the unsigned vs. signed
issue, everything else I don't agree with. I can't see how you can
implement a dynamic array that doesn't invalidate iterators upon
insertion (might be my limited imagination, though).
I don't think I've used 'std::auto_ptr' in the last five years. If
I needed a smart pointer (which is rather rare if you use the above
mentioned tools) I needed (and used) a ref-counting off-the-shelf
one. And there's no function template partial specialization, so it
can't mess with the overloading rules.
I agree that C++ is a huge and complex beast to deal with, but I
also agree with Giovanni that a modern use of it leads to save,
robust, and easily maintainable code. Unfortunately I also have to
agree that too few programmers are using it that way.

I think it all boils down to the old observation that C's heritage
is both a bless and a curse for C++. That's valid for teaching it,
too. C++ was taught as a better C for far too long and that still
hasn't changed enough. To many studentsare taught a style that begs
for subtle bugs, alltough there are better ways to make use of the
language.
My personal opinion is that most programmers would benefit a lot
from reading Koenig/Moo's "Accelerate d C++" even though it's meant to
be for novices. I read it many years ago (because I teach C++) and
while I don't think it showed me anything I didn't know yet, it did
teach me that C++ has changed enough throughout the last 15 years to
make it possible to teach it to students in a way that makes them
programming the style Giovanni advertized from day one.
I have 15-20 lectures (90mins each) to teach C++ to students who had
one year of Java-only exposure and found that it's possible to go all
the way from "Hello, world!" to template meta-programming in that
time. I hammer a lot of rules of thumb into them and teach them a
style where C++ is a like big box of Lego bricks from which your can
safely build anything you need. I rarely ever have a semester where I
give an exercise where they have to write 'new', let alone 'delete',
but they see 'std::vector' in lesson two, along with 'std::string'
and IO. C++ is still more unsafe than other languages because it just
relies on programmers not to do stupid things, but given a modern
combination of compiler/RTL/std lib you get a lot of meaningful run-
time error messages in debug mode while still enjoying full speed in
release mode.
Don't get me wrong, C++ is a great language, and the time I've spent
writing in it was great. But from my experience, I would never let it
anywhere near domain logic except where it is spefically needed, when
I have the choice, because too many times I've witnessed how even
skilled and experienced (5+ years) C++ developers wrote some seemingy
trivial code which then broke things in subtle ways.
But that's really hard to do if you don't do manual memory and the
like. Mostly this happens because programmers only use C++ as a
better C -- which is exactly what Giovanni said would lead to subtle
bugs.
I once spent 2
whole work days in the debugger trying to find the code that lead to
"Heap corrupted" error which invariably manifested itself under
unclear conditions after the program was used for 2-3 hours. It's not
fun at all. It's also something that's much, much rarer in the
"managed code" land.
IME the crashs reported from testing tend to happen in certain parts
of the code and correlate with the style used in there. I rarely saw
more than one crash per year in my code /while testing on my machine/
and went years without having one checked in.
And that's not really hard to do if you write code the way Giovanni
suggests.

Schobi

--
Sp******@gmx.de is never read
I'm HSchober at gmx dot de
"I guess at some point idealism meets human nature and
explodes." Daniel Orner
Jul 20 '08 #64
On Jul 20, 3:07*pm, "Hendrik Schober" <SpamT...@gmx.d ewrote:
* I've looked at this list and I agree with the unsigned vs. signed
* issue, everything else I don't agree with. I can't see how you can
* implement a dynamic array that doesn't invalidate iterators upon
* insertion (might be my limited imagination, though).
Depends on the container, but that was not my point. In C#, if you use
an invalid enumerator, you will _consistently_ get an exception. In C+
+, unless you're using a debugging STL implementation (and even then
all checks are usually disabled in release mode by default), your
invalidate vector iterator will happily dereference, and you'll get a
segfault at best, and will silently read or write some random memory
value at worst - it's precisely how those "heap corruption" errors
appear.
* I don't think I've used 'std::auto_ptr' in the last five years. If
* I needed a smart pointer (which is rather rare if you use the above
* mentioned tools) I needed (and used) a ref-counting off-the-shelf
* one.
Ironically, a typical C++ refcounted smart pointer is often on average
slower than a good mark&sweep GC. Especially if you're using Boost/TR1
shared_ptr, which allocates the reference counter separately from the
object itself.
And there's no function template partial specialization, so it
*can't mess with the overloading rules.
My mistake, sorry. Just plain template specializations , not partial
ones.

By the way, partial function specialization will be in C++0x, so those
3 paragraphs might well become a few more :)
* I agree that C++ is a huge and complex beast to deal with, but I
* also agree with Giovanni that a modern use of it leads to save,
* robust, and easily maintainable code. Unfortunately I also have to
* agree that too few programmers are using it that way.
There's one more thing to it. "Modern use" of C++ really looks a lot
like C# or Java - you generally see MI only in context of abstract
base classes (read: interfaces), you see proliferation of pointers
over stack-allocated objects (again, because of interfaces), you don't
see many overly clever template metaprogramming abuses etc.

The question is then, if the "modern subset" of C++ closely matches
that of C#, but C# also doesn't have all the legacy cruft, then why
choose C++ over C# for a typical project?

(There are other valid reasons such as portability, but I'm
deliberately restricting this argument to languages only, not to
available implementations ).
* and IO. C++ is still more unsafe than other languages because it just
* relies on programmers not to do stupid things, but given a modern
* combination of compiler/RTL/std lib you get a lot of meaningful run-
* time error messages in debug mode while still enjoying full speed in
* release mode.
Until we get concepts in C++0x, essentially any C++ program that
heavily uses templates in general, and template metaprogramming in
particular (yes, that includes STL and Boost) is a rather masochistic
exercise when it comes to deciphering compiler error messages.
Don't get me wrong, C++ is a great language, and the time I've spent
writing in it was great. But from my experience, I would never let it
anywhere near domain logic except where it is spefically needed, when
I have the choice, because too many times I've witnessed how even
skilled and experienced (5+ years) C++ developers wrote some seemingy
trivial code which then broke things in subtle ways.

* But that's really hard to do if you don't do manual memory and the
* like.
Not really. Perhaps I would have to clarify - my observations were in
a development environment where knowledge of the subtleties of C++ was
encouraged and widespread, and usage of STL in its entirety - not just
strings and containers, but also algorithms, binders etc, where
possible - was mandatory; and we also used shared_ptr/weak_ptr from
Boost, as well as a couple of our own Boost-style templates. We
certainly didn't use C++ as "better C" - far from it.
Jul 20 '08 #65

"David Wilkinson" <no******@effis ols.comha scritto nel messaggio
news:ej******** ******@TK2MSFTN GP05.phx.gbl...
What's the solution? I think MS has to fully face up to the fact that VC++
is for native code, get the IDE back to the level of
usability/responsiveness we had in VC6,
100% agree!

and put MFC (and the PSDK) into VC++ Express.
VC++ Express 2008 includes PSDK out-of-the-box.
Unfortunately, MFC is not there.

So, maybe the VC2008 Express users may use WTL for GUI development (I recall
there was an article on CodeProject about that).

However, a beginner who wants to write a GUI app for Windows can save lots
of time if he uses VC# Express with its RAD-style GUI designer.

Giovanni
Jul 20 '08 #66
>I once met a very senior person in C++ circles (I won't mention his
>name) and I asked him for his opinion. He suggested that perhaps
5% of all C++ programmers are competent.

5%? Maybe. It's certainly no more than about 10%.

The percentage doesn't change much for other languages, though, bad
programmers will write bad code in any language.
That's certainly true, but comparing a typical language to C++ is like
comparing a truck full of eggs to a tanker full of nitroglycerin. If your
driver's incompetent 95% of the time then you'll either end up with a lot of
broken eggs or a lot of dead bodies.
Jul 20 '08 #67
Daniel James wrote:
In article news:<u0******* *******@TK2MSFT NGP02.phx.gbl>, Larry Smith
wrote:
>I once met a very senior person in C++ circles (I won't mention his
name) and I asked him for his opinion. He suggested that perhaps
5% of all C++ programmers are competent.

5%? Maybe. It's certainly no more than about 10%.

The percentage doesn't change much for other languages, though, bad
programmers will write bad code in any language.
But in languages like C and C++ they can create bugs that are
both disastrous and very hard to find.

Arne
Jul 20 '08 #68
Jon Skeet [C# MVP] wrote:
Java 1.4 and C# 1.0 were very similar, but the languages have diverged
significantly since then. Almost all the new features in C# 2.0 and 3.0
either have no real equivalent in Java (e.g. iterator blocks, nullable
types) or have very significant differences (e.g. generics).
I don't agree for 2.0.

My list of .NET 2.0 & C# 2.0 new features and their "Java status":

FtpWebRequest - URLConnection has had support for FTP many years
Ping - missing
HttpListener - missing
GZipStream - GZIP*Stream has existed many years
partial classes - missing
DbProviderFacto ry - JDBC worked that way always
generics - Java got it in 1.5 (and it is not that different)
nullable types - Java has had wrapper objects forever
anonymous methods - Java has anonymous classes
static classes - missing
different accessability get & set - Java getters & setters obviously can

7 out of 11 seems to be in Java .

..NET 3.0/3.5 & C# 3.0 I will agree. Java does not have much of that
stuff and it does not seem as if Java will get it either in the future.

Arne
Jul 20 '08 #69
On Sun, 20 Jul 2008 16:49:43 -0700, Arne Vajhøj <ar**@vajhoej.d kwrote:
Jon Skeet [C# MVP] wrote:
>Java 1.4 and C# 1.0 were very similar, but the languages have diverged
significantl y since then. Almost all the new features in C# 2.0 and 3.0
either have no real equivalent in Java (e.g. iterator blocks, nullable
types) or have very significant differences (e.g. generics).

I don't agree for 2.0.

My list of .NET 2.0 & C# 2.0 new features and their "Java status":
It's not clear to me that your list is a complete enumeration of all .NET
2.0 and all C# 2.0 features. Heck, you didn't even include iterator
blocks, which was specifically mentioned by Jon.

And in your own list...
FtpWebRequest - URLConnection has had support for FTP many years
Ping - missing
HttpListener - missing
GZipStream - GZIP*Stream has existed many years
partial classes - missing
DbProviderFacto ry - JDBC worked that way always
generics - Java got it in 1.5 (and it is not that different)
I suppose that depends on your definition of "that different".
Personally, I'd say it's _very_ different. Java generics are just a
compile-time wrapper. I understand why they did it that way, but it
significantly limits their utility.
nullable types - Java has had wrapper objects forever
Not the same at all. Nullable<Tisn't just a "wrapper" for value types
(though I can see why one might view them that way). In particular, using
a wrapper in Java requires boxing the value.

Of course, since in Java you can't define your own non-nullable types, the
need for Nullable<Tin Java is obviously dramatically reduced. But the
wrapper types still aren't the same.
anonymous methods - Java has anonymous classes
And is missing delegates. Anonymous methods don't really make any sense
without delegates, so sure...maybe you don't see how anonymous methods
aren't the same as anonymous classes. But they aren't.

Now, if you want to argue that C# is missing anonymous classes, I don't
disagree with that. But having anonymous classes doesn't mean that Java
supports the same thing as anonymous methods.
static classes - missing
I don't understand this. Are you saying that C# didn't get to use
"static" when declaring a class until 2.0? That doesn't sound right to
me. I'm also not clear on what you mean by "missing" with respect to
Java, since you can effectively create a static class in Java just as
easily in C#.

I must be misunderstandin g what you mean by "static classes"...plea se
elaborate.
different accessability get & set - Java getters & setters obviously can
Java doesn't even have properties. The fact that Java's relatively
inferior work-around to lacking properties inherently allows different
accessibility for the getter and setter seems irrelevant to me.
7 out of 11 seems to be in Java .
I count different: 8 of 11 seem _not_ to be in Java (that's assuming
you're correct about "static classes"...sinc e I don't understand how
you're using that term, I might be wrong there :) ). Though, since your
list of new features for .NET 2.0 and C# isn't a complete enumeration
anyway, it's not like any count of that particular list is a useful
comparison anyway.

Pete
Jul 21 '08 #70

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
3439
by: Rob | last post by:
i know javascript, vbscript, asp css and alot more and im only 14 i was wondering which is easier to learn php or cgi. any help?
42
3737
by: Bicho Verde | last post by:
I have now free time and money to do what I want :-) I have some basic skills in programming (C, Pascal, Macromedia Actionscript) but don't know exactly what to do in the world of programming. And also I don't know exactly why would I learn Python rather than C#, C++ or Perl. Basicaly I don't know where to start, if there is much to do or if it is has it seems and there is software to everything nowadays and so doesn't make sense to spend...
55
46035
by: Elijah | last post by:
I have read many of the topics on learning C++ or Java first. It seems like everyone says something different. I would like to know if I should learn C++ or Java. First a little about myself. I know PHP, BASIC, and of course HTML. I'll be 15 years old in September. I am interested in programming GUI applications. I am also interested in programming games. I know that I should learn C++ to program games, but would learning Java make the...
30
9444
by: Rhino | last post by:
I am giving some thought to applying for some jobs that want people with Java and C++ experience. I have been writing Java for several years and am fluent enough that I don't have to get help with Java very often. I have no real C++ experience and not much C experience for that matter. However, the core Java statements are "borrowed" from C and C++ has often been called "C with classes". It seems to me that it shouldn't take very long to...
8
4053
by: Hermawih | last post by:
Hello , I want your opinion about this . In order to say it clearly , I think I have to describe it in long sentences . I could consider myself as Intermediate/Advance Access Developer ; Intermediate/Advanced Database designer . Because of the requirements , I must create Web Application . Access Pages is not suitable for that so I think about learning VB Net / ASP Net . I am
21
2874
by: TAM | last post by:
Hi, I read that ASP.NET uses VB.NET instead of VBScript. I also read that ASP.NET is a subset of VB.NET. So if I learn VB.NET first then do I have the knowledge for programming ASP.NET applications or do I need to learn both VB.NET and ASP.NET. Thank you. TAM
85
4189
by: abhi | last post by:
hi everybody am new to this group and help me to learn C
31
2642
by: anand devarajan | last post by:
hi friends, im anand im just a beginner in c learning for the past two weeksnow i can write simple prgs can anyone help me to get well known to c lang so that i should able to write even tough prgs in c
34
3169
by: pandit | last post by:
hai all, i want to become a good programmer. one of my friends ( named "arnuld", he posts here infrequently), taught me Lisp. so i am not a programming beginner. i have heard these 2 points. i want to know how : 1. C gives you a strong base of Procedural style of programming which forms the basis of learning other paradigms e.g OOP
65
5319
by: Chris Carlen | last post by:
Hi: From what I've read of OOP, I don't get it. I have also found some articles profoundly critical of OOP. I tend to relate to these articles. However, those articles were no more objective than the descriptions of OOP I've read in making a case. Ie., what objective data/studies/research indicates that a particular problem can be solved more quickly by the programmer, or that the solution is more efficient in execution time/memory...
0
11031
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10685
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10763
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9518
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5750
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5942
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4563
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4162
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3188
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.