C# vs C++

C

cr113

I'm thinking about switching some of my apps from VB.NET to either C#
or C++, just for the experience. I'm leaning towards C# since I had the
misfortune of having to maintain a windows program written in C several
years ago. Trying to find all the memory leaks drove me nuts.

Basically the apps I write in VB.NET are very simple. I normally prompt
the user for an excel file. Then I take that excel file as input along
with some data from Access tables and create a new excel file for the
user. Pretty simple stuff. VB.NET is ideal for this, it's effortless.
But that's the problem, my programming skills have turned to mush.

I have a couple of questions. Will learning C# give me any C++
experience? I'm hoping the 2 languages are close enough that if I had
to get a job in C++ knowing C# would help. Also I keep hearing that C#
can't do low level programming that can be done in C++. Does anyone
have a specific example of this or is it just a myth? It looked to me
like the unsafe keyword in C# might do some low level stuff.
 
R

Randolpho

No, learning C# will not give you C++ experience. The two are similar
and have similar keywords and syntax (although C# is closer to Java
than C++ in that regard), but C# anc C++ are different enough that you
cannot claim to know one just by knowing the other.

Although once you understand programming in general and the basic
concepts, it's usually very easy to move from one language to
another... learning C# and understanding it (especially reference vs
value types, garbage collection, and unsafe pointers) will help you to
learn and understand C++.

Given that you come from a VB.NET background, I would recommend you
learn C#, as you'll at least get to keep working with a familiar API
like Windows.Forms. From there, I would highly recommend you learn C++
as well -- it's a good thing to know -- by starting with Managed C++ or
C++/CLI, both of which are C++ flavored .NET, which will give you the
benefit of continuing to work with a familiar API. Once you understand
managed C++, you can move on to unmanaged C++.... that's when the
quirks will really start to get to you, since the way standard C++
deals with types varies drastically from the way C# does.

Finally, to answer your question about unsafe C#... with the unsafe
keyword, C# can do things that might normally require C/C++. C# can
interoperate with C and C++ libraries, for example, and even handle
some of the "low level" stuff like reading from the serial port.
However, C# is not designed for this directly; it's unwieldy and really
only intended for interoperation with C/C++ libraries, and often adds
marshalling overhead. C++ is much more efficient for that sort of
thing. It's a "right tool for the job" kinda thing.
 
C

Chris Crowther

Randolpho said:
interoperate with C and C++ libraries, for example, and even handle
some of the "low level" stuff like reading from the serial port.

Although if you're using .NET 2.0 you might be better off using the
System.Ports.SerialPort class for that :)
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

I have a couple of questions. Will learning C# give me any C++
experience? I'm hoping the 2 languages are close enough that if I had
to get a job in C++ knowing C# would help.

They are close, but not the same , FAR from it. the syntax is very similar
to such a degree that you may read and understand C code. not always
though, I have seen C declarations of macros that are far from simple :)
Also I keep hearing that C#
can't do low level programming that can be done in C++. Does anyone
have a specific example of this or is it just a myth? It looked to me
like the unsafe keyword in C# might do some low level stuff.

What low level stuff are you talking about?

there are things that you cannot make in managed code, like drivers. not
even in VB.net :D
 
S

sloan

You'll have better migration success going to c#.

The syntax is different, but normal directly parallels vb.net stuff.

C# , I call it "microsoft java" when I'm joking around with guys at work.

But c# will not let you become a c++ developer.

I'd look into "design patterns" .. If you're at a learning plateau, go to
www.dofactory.com and try out the free design patterns.
It takes years to master design patterns, not days.
Read that again. Then again. Going thru a few examples at dofactory or
reading a book doesn't make you a knowledgable in these areas.

Design patterns are at a higher level than a specfic language. I can talk
about design patterns wth any OO person (java, c#, etc).
The syntax becomes secondary to the design.

http://spaces.msn.com/sholliday/
I have a factory design pattern there, using 3 different methods.


...
 
C

cr113

sloan said:
You'll have better migration success going to c#.

The syntax is different, but normal directly parallels vb.net stuff.

C# , I call it "microsoft java" when I'm joking around with guys at work.

But c# will not let you become a c++ developer.

Here's my plan. First I'm going to switch my code over to C#. Then
C#.ASP. Then move my data from Access to SQL server.

Since I've been doing database apps my whole career (15 years), I'm
thinking that C++ will not help me that much. C++ seems to be used more
for technical stuff like writing drivers.

Thanks for the input!
 

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