C++ or C#?

  • Thread starter Thread starter Gaz
  • Start date Start date
G

Gaz

Now that Visual Studio 2005 Express final has been released, which language
should I go with, c++ or c#? I know c++ already but I haven't done any
programming for a year or two and C# seems a much cleaner language. Does
c++ code compile more efficiently? Is c++ more flexible?

Thank you.
 
Now that Visual Studio 2005 Express final has been released, which language
should I go with, c++ or c#? I know c++ already but I haven't done any
programming for a year or two and C# seems a much cleaner language. Does
c++ code compile more efficiently? Is c++ more flexible?

Yes to all questions. C++ has a much better optimizer, even when
compiling managed code (C++/CLI). Plus, you can access managed and
unmanaged code & data within the same function. But C++/CLI is
certainly harder to use and uglier than C#... and I don't think the
IDE is quite as nice, either (e.g. IntelliSense from XML comments).
 
C++ or C#, if it's managed it compiles to MSIL for both..
but C++ is much more clumsy.. akthough it gices much easier access to win32
API.
 
Now that Visual Studio 2005 Express final has been released, which
language should I go with, c++ or c#? I know c++ already but I haven't
done any programming for a year or two and C# seems a much cleaner
language. Does c++ code compile more efficiently? Is c++ more flexible?

One of the fundamental design goals of the .NET Framework is that is
programmable via multiple languages, any one of which is (or, at least,
should be!) just as good as any other, because they all compile to CLI.
Which language(s) you choose to program in should be, to all intents and
purposes, irrelevant. Of course, each language is syntatically different,
and some have one or two capabilities that others don't - a good example of
this is C#'s support for pointers, which is not supported in VB.NET.
However, these differences are quite small and, for the vast majority of
developers, of little significance.

So, which one(s) to choose? For me, back in 2002, the choice was easy. I'd
spent the last 10 years or so making a living as a jobbing contractor using
Visual Basic and all its derivatives - VBA, VBScript, AccessBasic, WordBasic
etc - never wrote a line of C++ in my life - so for my first couple of .NET
contracts I used VB.NET. However, it soon became clear to me that my earning
potential would be exponentially increased if I knew C# as well as VB.NET -
a quick look at the IT contract developer market showed the massive increase
in jobs available only to C# developers - so I set about learning C# too.
Luckily, a lot of my previous work had involved web development which meant
I was very familiar with JavaScript and, since C#'s syntax in certain areas
resembles JavaScript a fair bit, I found it extremely easy to pick up and
learn.

After a little while, I found that I much preferred C# to VB.NET, which is
not to say that I thought it was any better or worse than VB.NET, just that
I preferred it. Luckily, the demand for C# contract developers (in the UK,
at any rate) has increased over the years, and this trend seems set to
continue with the arrival of v2.0 of the Framework.

So, to recap:

1) if, like me, you're a freelance developer, go for the language(s) which
will earn you the most money

2) if you're an independent programmer maybe writing your own software for
sale, go for the language that you're most comfortable / familiar with

3) if you're programming "just for the fun of it", learn as many .NET
languages as you can.
 
In your situation, you have a real dilemma there. Both are managed, and I do
find the C# syntax to be "cleaner" (as you put it), but if you're already
familiar with C++, you may prefer to stick with what you know.

The good news is, you can use either or both. So, make a decision, and if
time and desire warrant, learn both languages. Knowing more than 1 is almost
always useful at some point!

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
There's a seeker born every minute.
- Dr. "Happy" Harry Cox
 
C#. I think it is worth the initial learning curve. I would worry less
about which syntax you use (c#, vb, c++) and more about learning .NET. You
will be far better off in the long run.

Why is so much emphasis put on syntax? I see this more from degreed
programmers. Depending on how you look at it, the code (syntax) is easily
the most insignificant part. Especially with .NET.
 
In the past such a question would start a religous war :).

The PC answer was to use the language that works best for you, and if
you came from VB it might be VB.NET and if you came from C++ if might be
C# simply because the transition was easier and the MC++ _was_ really
clunky and without a visual designer. Initially, the attempt was made so
that the environment was language agnostic so that the different
languages could produce fairly equivalent MSIL.

With VS2005, the concept of a language agnostic enviromnent is well
questionable.

MC++2.0 is the low level language that can produce more optimized MSIL
and is the clearly the language for native interop... so if you plan to
call a lot of native methods MC++2.0 is the way to go. MC++ also
supports both compile time template programming and runtime generic
programming and the semantics of a ref class on the stack.

VB.NET has the MY namespace which lets you do RAD stuff like

My.Computer.Audio.Play("C:\Beep.wav")

If My.Computer.Network.IsAvailable Then
If My.Computer.Network.Ping("http://www.microsoft.com") Then
MsgBox("Microsoft's site is available.")
End If
End If

C# is the middle ground of the "pragmatic programmer".

Regards,
Jeff
 
In the past such a question would start a religous war :).

Go Java... forget all this .Net stuff. It's for wussies.
 
Back
Top