C# vs. C++

C

cj

I don't want to start a war but why would I choose one over the other?
First and foremost I need to keep in mind marketability of the skill and
the future of the language.

I'm getting the feeling I'll be moving from VB to one or the other. I
have some say on which but perhaps not the final decision. I have used
C and C++ a little bit years ago. I have no experience in C#. I don't
expect it to be that difficult but I hate remembering the idiosyncrasies
of too many languages so I'd like to pick one C# or C++ and make the
right choice.
 
C

cfps.Christian

Since you're moving from VB I'd say your best bet is C#. C# is very
good for handling the forms while giving the feeling of power like C+
+. Also if you're at a business C++ programmers are getting hard to
find and thus getting expensive.
 
A

Alcides

IMHO if you can choose, then choose C#. Easier to master than C++, and
hides all the pointer management you have in c++. Unless you have some
strong requirement for C++, to me it is C#.

Al.
http://alsql.blogspot.com.
 
A

Angus

There is no correct answer. It depends on what you want to do. If you are
writing business applications (ie standard data processing) then I imagine
C# will be easier for you to learn if you are coming from VB. I use C++ and
can tell you it is a steep learning curve. In my case, however, I am glad I
put myself through it.
 
P

PvdG42

cj said:
I don't want to start a war but why would I choose one over the other?
First and foremost I need to keep in mind marketability of the skill and
the future of the language.

I'm getting the feeling I'll be moving from VB to one or the other. I
have some say on which but perhaps not the final decision. I have used C
and C++ a little bit years ago. I have no experience in C#. I don't
expect it to be that difficult but I hate remembering the idiosyncrasies
of too many languages so I'd like to pick one C# or C++ and make the right
choice.

Either might be an excellent choice, depending on what you want your market
to be. C# is strictly .NET, while C++ can be used to develop for a multitude
of environments. OTOH, if you will be developing strictly for .NET, C# would
be the better choice because it's getting support for all the new .NET
features.
 
C

clintonG

Microsoft developed C# specifically for the web. VB.NET was developed and
remains being developed using C#.

What motivated me to choose C# was the indisputable fact that web
development is a client-server paradigm and as such separate language skills
are needed for client-side and server-side development.

JavaScript is the defacto standard for all client-side web development.
Since JavaScript was derived from C both JavaScript and C# have exactly the
same punctuation and nearly the same syntax and grammar making it possible
to say we can learn two or more languages for the price of one so to speak.

<%= Clinton Gallagher
 
T

Tamas Demjen

cj said:
I don't want to start a war but why would I choose one over the other?

In my opinion C# can't be completely overlooked. If you take a look at
craigslist, you'll notice that there are a huge number of C# jobs out
there. Of course there's still a market for C++ programmers, but that
tends to be the Linux/server side/embedded segment. But even as a C++
programmer, chances are that you'll have to work with C# or Java at one
point in your life.

It's an order of magnitude more difficult to master C++ than C#. In C#
it's easier to write perfectly clean code with a lot less experience.
I've seen programmers who struggle with proper C++ programming practices
and implementation details, which results in difficult to maintain code.
However, the very same people do a fantastic job when they get a chance
to program in C#, and their code quality tends to be much higher.

Dealing with existing C++ code can be a disaster when you have lots of
inexperienced programmers on your team. To program well in C++ you have
to learn disciplined modern C++ practices, such as reference counted
smart pointers, RAII, exception safety, etc. Picking up a good style is
impossible when you learn from old C++ books. Companies who hire C++
programmers tend to have lots of legacy code that I wouldn't consider
modern or easy to maintain.

When practices right, I love modern C++ a lot, but even I tend to admit
that programming in C# or Java is more relaxed.

The decision is up to you, because there's a market for good C++
programmers. For example, device drivers or game engines can't be
written in C# yet. But you have to work a lot harder to achieve success
in C++ than in C#.

If your question is related to C++/CLI (programming .NET in C++), then I
don't recommend it. You should know that Microsoft has poor Windows
Forms and Web Services development support for C++/CLI. C++/CLI
currently is a lot lower class citizen language in .NET than C#.

Tom
 
A

Alvin Bruney [ASP.NET MVP]

such as reference counted smart pointers
There's no such thing. That's why they are smart, they handle it for you.

--

Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99
 
A

Arne Vajhøj

cj said:
I don't want to start a war but why would I choose one over the other?
First and foremost I need to keep in mind marketability of the skill and
the future of the language.

I'm getting the feeling I'll be moving from VB to one or the other. I
have some say on which but perhaps not the final decision. I have used
C and C++ a little bit years ago. I have no experience in C#. I don't
expect it to be that difficult but I hate remembering the idiosyncrasies
of too many languages so I'd like to pick one C# or C++ and make the
right choice.

It depends a bit on the app.

First note that there are actually 3 choices: C#, C++ for .NET and
C++ for native.

But unless the code you want to write is special, then you should
got for C#. It is simply easier to do than C++.

That is also reflected in the job market where even though there are
plenty of C++ jobs, then C# has passed C++ in most markets and
seems headed to pass C++ in the rest of the markets soon.

Arne
 
A

Arne Vajhøj

clintonG said:
Microsoft developed C# specifically for the web.

I don't think so. I believe C# was developed to be a general
language.
JavaScript is the defacto standard for all client-side web development.

For the code part of it at least.
Since JavaScript was derived from C both JavaScript and C# have exactly
the same punctuation and nearly the same syntax and grammar making it
possible to say we can learn two or more languages for the price of one
so to speak.

C# and JavaScript both belongs to the C family of languages. But they
are somwhat different languages anyway.

Arne
 
R

RFOG

Peter Duniho said:
C++ is a dying language. [...]

Huh? Our entire telecommunications industry is written in C and C++
and
C++ is still the way to go for embedded systems.

I think he meant that "C++ is a dying language" in the same way that
FORTRAN and COBOL are "dying languages". Of course, those languages
have
been dying for decades and still are in broad use. So C++ could take a
little while to finally kick the bucket too. :)

Right. C++ is no longer taught to computer science students, at least
not as one of their fundamental skills -- Java dominates academia now,
and C# is catching on.

And I think you'll find that in embedded systems, what is actually
written is closer to C than to C++. C is going to live a long time as a
highly portable lower-level language.

I strongly disagree. Of course C++ is alive into embedded systems, but you
forget one thing: Java VM is done in C++, and if C++ disappears... Windows
will disappear because Windows is done in C and most in C++... Linux will
disappear too.

And actually it is impssible to buid an OS in Java or in a .NET languge.
..NET MicroFramework is the most low level C# and it is a layer over...
emmmm... rrrrr... ¡C++! Microprocessors that run Java are anecdotic ones,
and very expensive.

That is a common error. Java run into mobiles... because Java runtime is
done in C++ into mobiles. All software into a Phone or a PDA or a Ebook
reader, or any handheld into market is done in... in... ¡C++! They can run
Java (and .NET) because they have layers over C++ that allows run those
frameworks.

You have .NET MicroFramework, that is a layer over C++ form tiny 32 bit
microprocessors.

Canonical C# and I supponse Java does never can be languages to buil OS
because none of them can deal directly with hardware and all of them needs
a layer over hardware to run, to interpret bytecode and to convert that
bytecode into real machine codes and to convert .NET and Java system calls
into real system hardware access. How do you install an interruption
vector in C#? Or how do you configure token 0 to token 3 gate jumps and
reverse? LDT/GDT access. Convert Base memory address into process
address...

C# has pointers, but pointers in C# does not allow to access directly to
hardware.
I agree. Also, Niklaus Wirth (the inventor of Pascal) has floated some
interesting ideas for embedded-systems languages recently. They are of
course not full industrial-strength tools, but prototypes of interesting
ideas.

Back to the original poster -- One BIG point is that the transition

Visual Basic --> Visual Basic .NET --> C# --> C or C++

is a LOT easier to make than if you do the last steps in the reverse
order.



--
Microsoft Visual C++ MVP
========================
Mi blog sobre programación: http://geeks.ms/blogs/rfog
Momentos Leves: http://momentosleves.blogspot.com/
Cosas mías: http://rfog.blogsome.com/
Libros, ciencia ficción y programación
========================================
Un sistema escolar que no tenga a los padres como cimiento es igual a una
cubeta con un agujero en el fondo.
-- Jesse Jackson.
 
N

Nick

MC said:
That is a good point. Object-oriented programming wasn't mature when C++ came into use. There is a lot of bad C++ code in the world, and C++ makes it easy to write bad code and create programs that crash.

Curious. I wouldn't see C# as fundamentally better for writing
Object-oriented code. I see the two languages as essentially the same
but C# has removed the need for explicit memory management and a few
other house keeping issues (ok I know C# isn't quite as flexible and
full featured as C++). So C# is a bit like driving an automatic rather
than as stick shift. The really complicated thing is the driving not the
mundane task of changing gear.

I would chose C# as it is easier than C++ but more importantly you are
more likely to be given new code to write in C# rather than decipher
some arcane legacy system in C++.

I think C will outlive C++. C is going to continue to be a good language for small routines where performance is paramount. For such things, I find myself writing "C-barely-plus-plus," which is C with slight use of the C++ extensions. But when I want real object-oriented programming, I use C#.

I can't see why anyone would want to use C rather than C++?
 
R

RFOG

I can't see why anyone would want to use C rather than C++?

The today only reason for that is the system will not have a C++ compiler.

--
Microsoft Visual C++ MVP
========================
Mi blog sobre programación: http://geeks.ms/blogs/rfog
Momentos Leves: http://momentosleves.blogspot.com/
Cosas mías: http://rfog.blogsome.com/
Libros, ciencia ficción y programación
========================================
Un sistema escolar que no tenga a los padres como cimiento es igual a una
cubeta con un agujero en el fondo.
-- Jesse Jackson.
 
G

Giovanni Dicanio

I strongly disagree. Of course C++ is alive into embedded systems, but you
forget one thing: Java VM is done in C++, and if C++ disappears... Windows
will disappear because Windows is done in C and most in C++... Linux will
disappear too.

I agree with you, RFOG.

Only one point: Linux (the kernel) is built in pure C (not C++).

And actually it is impssible to buid an OS in Java or in a .NET languge.
.NET MicroFramework is the most low level C# and it is a layer over...
emmmm... rrrrr... ¡C++!

You're right.

Moreover, I doubt that very big and successfull apps (like Microsoft Office,
or Visual Studio, or even non-Microsoft apps like Photoshop) could be built
using C# (or Java...). Or, if they would be built with C# or some other
"managed" language, what would be the memory occupation and would they be as
snappy as the C++ versions?

Instead, for Internet stuff like ASP.NET, I think that C# (or VB.NET as
well) is a clear winner over C++.

Just use the right tool for the right job.

Giovanni
 
R

RFOG

I agree with you, RFOG.

Only one point: Linux (the kernel) is built in pure C (not C++).

Yes, my error. :) Linus Tolvards doesn't like C++. But KDE, for example,
is C++ plus meta-C++.
You're right.

Moreover, I doubt that very big and successfull apps (like Microsoft
Office,
or Visual Studio, or even non-Microsoft apps like Photoshop) could be
built
using C# (or Java...). Or, if they would be built with C# or some other
"managed" language, what would be the memory occupation and would they
be as
snappy as the C++ versions?

Instead, for Internet stuff like ASP.NET, I think that C# (or VB.NET as
well) is a clear winner over C++.

Just use the right tool for the right job.

Giovanni



--
Microsoft Visual C++ MVP
========================
Mi blog sobre programación: http://geeks.ms/blogs/rfog
Momentos Leves: http://momentosleves.blogspot.com/
Cosas mías: http://rfog.blogsome.com/
Libros, ciencia ficción y programación
========================================
Un sistema escolar que no tenga a los padres como cimiento es igual a una
cubeta con un agujero en el fondo.
-- Jesse Jackson.
 
D

Daniel Boulerice

CJ,

I guess you were surprised of how many replies you got so far!!

Anyway, if you want to move to C# or C++, know this:

a.. C# is a virtual machine - a little like java and VB already - at run-time your program is interpreted by another program called the CLR. It shields you from a lot of computer internals, but unlike VB, does a good job of offering you a nice object-oriented API. C# is just so cool for developers! The price to pay for this niceness is that programs are not as low-level as in C++, and thus will run a little slower.

b.. C++ on the contrary in just above C and assembler in terms of level. C++ will provide you with a rather direct access to the machine, a lot of efficiency, a lot of freedom. However, using that freedom and this more direct access to the OS, you will most probably hang yourself with the rope one day. It is much, much harder to harness all the power of C++, COM, Win32, etc., than it is to learn C# (as mentioned in another post). You can do programs that run faster, but you have less of a safety net when you decide to explore the untamed wilderness.

Wrapping up the above, C# is perfect for business applications that require more safety and faster development speed. I would say, in general, there way much more market for C#.

C++ is ideal if you want to do device drivers, develop system components, etc.

When it come to marketability, you have to assess your geographic situation. If you live in Silicon Valley, you probably need to develop in low-level and learn C++, or even master assembler. If you live in Montreal, the market is much higher level; C# is clearly adviseable. If you're unsure, refer to your local job web-site. Look up for what programer jobs are offered in your vicinity, and what they ask for in terms of knowledge and experience.

In any event, knowing how to manage a database is always - everywhere in the world - a wonderful though less glamourous asset.

Be good!
 
R

Rudy Velthuis

Daniel said:
CJ,

I guess you were surprised of how many replies you got so far!!

Anyway, if you want to move to C# or C++, know this:

a.. C# is a virtual machine - a little like java and VB already -
at run-time your program is interpreted by another program called the
CLR.

No, it isn't. At runtime, it is compiled just-in-time and it runs
natively, it is not interpreted. The CLR is not another program either,
it is the main runtime library that comes with .NET, and also runs
natively. AFAIK, most C++ products also have a runtime library. .NET's
CLR is just more extensive.
 
I

Ian Semmel

I don't want to start a war but why would I choose one over the other?
First and foremost I need to keep in mind marketability of the skill and
the future of the language.

I'm getting the feeling I'll be moving from VB to one or the other. I
have some say on which but perhaps not the final decision. I have used
C and C++ a little bit years ago. I have no experience in C#. I don't
expect it to be that difficult but I hate remembering the idiosyncrasies
of too many languages so I'd like to pick one C# or C++ and make the
right choice.

Over 80% of the world's financial transactions are still executed COBOL
code. Not bad for a language over 40 years old.

The point is, that companies do not rewrite their systems just because a
new technology or language comes about. Their investment is probably
many millions of dollars in software development. And if it aint broke,
don't fix it.

Although it isn't 'cool' to learn C/C++ nowadays, it will put you in
good stead in the employment market if you know them. In my opinion, it
would be easier to learn C/C++ (native) first and then go on to C#, as
you are really learning what goes on under the C# hood.

C# is a great programming language and has removed many of the sloppy
methods prevalent in C. C++ could have been a lot better than it is, but
unfortunately it was decided to make it compatible with C. With these
languages, you need self-imposed discipline to write them successfully
(although it is possible to write garbage programs in C#).
 
A

Arne Vajhøj

RFOG said:
The today only reason for that is the system will not have a C++ compiler.

There are cases (embedded or kernel) where you want very tight control
over the generated code. In which case you will either pick C or
pick C++ and only use a subset of C++ (that likely will look
relative similar to C).

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