Is VC++ any "better" than C#?

J

jmDesktop

I only ask this because I feel "cheated" by the framework whenever I
see things such as some of the SDK programs and examples that require
regular old C++. There are some things, at least it appears to me,
that you need to know C++ for in order to do things in Windows. I
feel cheated because it makes me think that there's more than I can do
because I am sheilded/helped by the framework.

If I learn VC++ would i be helped here when I have to break out of the
framework and use or even undertand the C++ used in Windows? Is there
any advantage to using visual c++ .net? It doesn't seem like a lot of
people use it, but I haven't done a tremendous amount of searching for
it.

Don't take it wrong. I like the framework very much and couldn't do
anything of any substance without it. Thanks.
 
J

jmDesktop

I only ask this because I feel "cheated" by the framework whenever I
see things such as some of the SDK programs and examples that require
regular old C++.  There are some things, at least it appears to me,
that you need to know C++ for in order to do things in Windows.  I
feel cheated because it makes me think that there's more than I can do
because I am sheilded/helped by the framework.
If I learn VC++ would i be helped here when I have to break out of the
framework and use or even undertand the C++ used in Windows?  Is there
any advantage to using visual c++ .net?  It doesn't seem like a lot of
people use it, but I haven't done a tremendous amount of searching for
it. [...]

Is there "any" advantage?  Sure.  But that's a pretty broad question,so  
you get a pretty broad answer.  :)

Prior to my experience with C# and .NET, the vast majority of my  
programming experience was with the unmanaged Windows API and C/C++.  I 
have found that prior experience to be _very_ helpful in figuring out some  
of the more esoteric or poorly-documented areas of .NET.  While .NET ought  
to be a complete abstraction away from the unmanaged API, it turns out  
that it inherits a lot of the underlying quirks.

But in terms of actually _doing_ things in your program, I have found that  
.NET provides the vast majority of functionality one might need.  It has  
been very unusual for me to find that I need to use parts of the unmanaged  
API that aren't available through .NET, and even in the cases when I do, I  
practically always have been able to do it via the p/invoke system rather 
than writing my own C++ code.

I would guess that for most of the "programs and examples that require  
regular old C++", there are in fact C# ways to accomplish the same.  So 
it's not so much that you're being constrained by C#, but more just that  
the history of Windows programming includes a _lot_ of C/C++ code and so  
of course many of the older sample code is going to be written that way.

I do believe that learning the unmanaged, C-based Windows API could help a  
person understand .NET better and use it more effectively.  But on the  
other hand, that learning doesn't come without a cost.  While having the  
prior experience has helped me, it took years to accumulate.  I think that  
for a person learning .NET now, you might as well just learn things  
through .NET rather than trying to become an expert in the unmanaged API  
as well.

As for specific code samples and tasks that aren't targeted at the C#/.NET  
developer...if you have specific examples that you want to use but don't  
know how, I'd say a better approach would be to provide a link in a  
question to this newsgroup and see if someone can help you navigate the  
sample.  I don't think that it's so much a matter of .NET getting in your  
way, as it is just that some non-.NET samples might need a bit of  
translation before they are useful in the .NET world.

Pete

Thanks. One example I came across was video capture. There are folks
out there that have written .net wrappers, but they do not appear to
be "official" and state things like "Don't use this in production."
Well, if I do and it breaks, then when can I say? "Uh, I used this
guy's stuff off of CodeProject and yeah, he said not too." If I'm
going to use it I have to understand it to maintain it.

The guy on CodeProject and other sites knew C++ and could understand
it enough to write the wrapper. I couldn't have done it, but if I
knew more C++, perhaps I could have. I was hoping that if I started
using VC++ .NET that I might understand more, but I don't know. Maybe
I'd be able to at least read it better. I have had some C++, just
beginner stuff, so I can follow it and know what the constructs mean,
but that's about it. It's the low level stuff that I'd like to know
how to do because it seems to come in handy at times when looking at
MS's documentation.
 
J

jmDesktop

Thanks.  One example I came across was video capture.  There are folks
out there that have written .net wrappers, but they do not appear to
be "official" and state things like "Don't use this in production."

Well, that's an interesting example, if for no other reason than that the 
DirectShow video capture stuff is a reasonably straight-forward and  
natural thing to access from .NET using the p/invoke stuff.  You may be 
referring to the DirectShow.NET project, which I haven't used but  
understand to be a pretty good wrapper for DirectShow.

As far as it not being "official" and not for "use in production", that  
sort of thing is true for pretty much anything you find outside the normal  
Microsoft API documentation.  Even plain old C++ samples often come with a  
similar caveat.

Personally, I don't think I'd ever write "don't use this in production" in  
any sample code I make available, but I certainly feel that there's an  
implied "use at your own risk" that goes along with _any_ sample code.
Well, if I do and it breaks, then when can I say?  "Uh, I used this
guy's stuff off of CodeProject and yeah, he said not too."  If I'm
going to use it I have to understand it to maintain it.

That's true...if you're going to incorporate some code into your own  
projects, it may behoove you to understand what the code is doing.  If  
nothing else, doing otherwise risks getting someone's trojan hidden in  
your own code.  :)

But to some extent, it's hard to know where to draw the line.  If a  
component you use in your own code comes from a trusted source, do you  
really need to know how it works?  After all, I assume you haven't tried  
to examine the implementation of .NET to determine for yourself how it  
works, even though much of .NET is basically just a wrapper on the  
unmanaged Windows API.

Likewise, if you find a library that you can use in your own .NET code and  
which has a public API that is completely defined in terms of managed  
code, as long as you trust the source, does it matter whether you know  
exactly what's going on within the library?

Again, I realize in some such cases there may be warning against using the  
library in production code, but to a large extent I believe that those  
kinds of warnings are "CYA" measures.  Any rational, thinking person  
should be able to make a decision for themselves as to whether a publicly 
available code sample or library is actually of high enough quality to use  
in production code, regardless of whatever warnings come with it, with the  
expectation that with adequate testing one can confirm or refute any  
assumption of quality.
[...] I have had some C++, just
beginner stuff, so I can follow it and know what the constructs mean,
but that's about it.  It's the low level stuff that I'd like to know
how to do because it seems to come in handy at times when looking at
MS's documentation.

Well, as I said...I do believe that there's value in learning the  
unmanaged API as well as being familiar enough with C/C++ to navigate any 
example code related to the unmanaged API.  So if you're of the mind to 
learn that, by all means do.  But I wouldn't consider it a prerequisiteto  
writing .NET code, and it may be that you will find it just as effective  
to learn as you go along, inasmuch as you need that knowledge at all.

Pete

I think I have/had a fundemental misunderstanding here. Does VC++ use
the .NET runtime? I was thinking it did and was just another language
choice like C# or VB.NET. I thought this because all the express
editions were on the same download page. Is VC++ totally separate?

Thanks again.
 
A

Arne Vajhøj

jmDesktop said:
I only ask this because I feel "cheated" by the framework whenever I
see things such as some of the SDK programs and examples that require
regular old C++. There are some things, at least it appears to me,
that you need to know C++ for in order to do things in Windows. I
feel cheated because it makes me think that there's more than I can do
because I am sheilded/helped by the framework.

If you need to work a lot with a C/C++ API like Win32 and various
OLE/COM stuff, then learning C/C++ obviously has advantages.
If I learn VC++ would i be helped here when I have to break out of the
framework and use or even undertand the C++ used in Windows? Is there
any advantage to using visual c++ .net? It doesn't seem like a lot of
people use it, but I haven't done a tremendous amount of searching for
it.

True.

My impression is also that people code in C# or native C++ and
primarily use C++/CLI for glue.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top