Fog Creek Software
Discussion Board




Welcome! and rules

Joel on Software

Learned C++, but C# is looking good

Ok, here's the deal... I took a class last year and learned C++. This was just the language itself, not the Windows API, or any of the library stuff. Since then I've been involved in other projects, and haven't actually written anything in C++ yet. That's about to change.

We're going to take existing C++ (Visual C++ 6.0) code and port it to .Net, then add a lot of new stuff. I suggested that since we already have a VERY experienced C++ coder, it might make more since if I use C#. That way we'd have the build-anything-you-could-ever-possibly-need power of C++, combined with the more rapid development of C#. (I read somewhere that C# manages memory itself, and that's one of the biggest reductions to the development time. Is this true?)

Someone suggested that since I already know C++, I should just go with that. So here's my question... it seems to me that the biggest learning curve will involve .Net itself, and since I'd need to brush up on C++ syntax anyway, wouldn't it be just as easy for me to go with C#?

I already know a couple of other languages, and don't have a hard time learning new ones. What's your guys' opinion on this?

HeyCoolAid!
Monday, June 28, 2004

The transition from C++ to C# is really very easy, just forget about 90% of the cryptic stuff. :)

You can do Managed C++, that is C++ for .NET, but the current syntax is a bit of a mess and will completely change in the next revision (Whidbey / .NET 2.0 / Visual Studio 2005). So you'd probably not want to learn MC++ right now.

Memory is managed by the .NET virtual machine (CLR, Common Language Runtime), by the way, not by the C# language proper.

Chris Nahr
Tuesday, June 29, 2004

Sorry if this is a dumb question, but it sounds like you're saying that plain 'ol C++ is not the same as Managed C++. Did I interpret that correctly?

HeyCoolAid!
Tuesday, June 29, 2004

Yes, that is correct. In order to interface with .NET code, use the Framework library and managed memory and so on, you must use a special version of C++ called "Managed C++". That's basically C++ plus a bunch of new keywords. It's really ugly right now and will get nicer in the next release, but it will still be a language extension.

Plain C/C++ can't interoperate with .NET unless you restrict yourself to calling C/C++ libraries from your .NET program. That's certainly doable and not even difficult but it's quite slow, thanks to the necessary marshalling betwee managed and unmanaged memory.

Chris Nahr
Wednesday, June 30, 2004

> I already know a couple of other languages, and don't have a hard time learning new ones. What's your guys' opinion on this?

For new .NET code I'm using C#: it seemed to me that "Managed C++" is especially for porting "legacy" C++ code into the .NET environment ... and as Chris said, I thought it looked ugly; for new .NET code I prefered C# (a language designed from the ground up for that job).

> Plain C/C++ can't interoperate with .NET unless you restrict yourself to calling C/C++ libraries from your .NET program.

I haven't tried this but I think that .NET assemblies can be invoked as if they were COM objects ... and C++ can invoke COM objects.

Christopher Wells
Thursday, July 01, 2004

Correct, you can expose .NET assemblies as COM components. I wouldn't want to use COM components from C++, though! It's possible but quite ugly...

Chris Nahr
Thursday, July 01, 2004

Oh come on Cris, it ain't that hard.  #import is your friend.

Alex (Yes, that Alex)
Thursday, July 01, 2004

You mean those new Microsoft extensions for interoperating with COM? True, that should make it easier. I've never used them, my experience with COM dates back to when we didn't have all those new toys you young whippersnappers had!

Chris Nahr
Friday, July 02, 2004

"...Ok, here's the deal... I took a class last year and learned C++. This was just the language itself, not the Windows API, or any of the library stuff..."

why.. thewindows API *is* made of the language..


"..Since then I've been involved in other projects, and haven't actually written anything in C++ yet. That's about to change.

We're going to take existing C++ (Visual C++ 6.0) code and port it to .Net, then add a lot of new stuff. I suggested that since we already have a VERY experienced C++ coder, it might make more since if I use C#. That way we'd have the build-anything-you-could-ever-possibly-need power of C++, combined with the more rapid development of C#..."

Why is C# more rapid? The GetCulturalAttribute classes?
Are they even calling them that this second? That's more of a VB thing.


(I read somewhere that C# manages memory itself, and that's one of the biggest reductions to the development time. Is this true?)

Someone suggested that since I already know C++, I should just go with that. So here's my question... it seems to me that the biggest learning curve will involve .Net itself, and since I'd need to brush up on C++ syntax anyway, wouldn't it be just as easy for me to go with C#? .."

If you know C++, even at an introcuctory level - writing a "HelloWorld.cpp" app.. then you'll see what a mega-joke it is. But, keep your hopes up. Change will come.

I already know a couple of other languages, and don't have a hard time learning new ones. What's your guys' opinion on this?.."

Well, it's nothing fancy smanchy, our individual guys think, but C# has the potential to unleashes the mega-power of
Juptier, and make myths come true. You could even put the
universe in a box.. like a pizza box.. or a lunch box, to go with your hard-hat.. (acutally, if you look at your win95/98 screen savers it's not origional.)

I've transfered data from a unix ox to Windows NT before, down here. 
You must be right.

Master of the universe
Friday, August 06, 2004

"..The transition from C++ to C# is really very easy, just forget about 90% of the cryptic stuff. :).."

actually, if you are sane, it's better to remember it.

Master of the universe
Friday, August 06, 2004

Managed C++. I'll say it was.

Master of the universe
Friday, August 06, 2004

*  Recent Topics

*  Fog Creek Home