473,839 Members | 1,532 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# vs. 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.
Jun 27 '08
151 4297
Alvin Bruney [ASP.NET MVP] wrote:
[...]
>The single most glaringly obvious example of what I mean is that you
can't do template metaprogramming in C#, but there are others.

And what is that good for? [...]
It shifts tasks from the run-time to the compile-time. IMO
the biggest advantage of this is that you catch more errors
at compile-time. OTOH, this allows C++ to rival FORTRAN's
speed for some applications, which for some people is far
more important.
I wouldn't call these obscure features.

Schobi
Jun 27 '08 #61
In article news:<48******* *************** *@news.sunsite. dk>, Arne
Vajhøj wrote:
C# also has abstract classes and even though abstract classes can
be used instead of interfaces, then interfaces especially when
combined with the only inherit from one class but implement
multiple interfaces rules really guide users towards good
OOP style.
I think your notion of "good OOP style" is misplaced. You are saying
what Java programmers have been saying that for some time -- because
Java doesn't give them any choice.

You are, of course, free to follow that convention in C++ -- but if you
do so you will be limiting your design choices. There is nothing
inherently wrong with allowing a class to inherit from multiple
concrete base classes, and doing so can be a useful way to encapsulate
common aspects of behaviour shared by several classes. This can
simplify design and reduce code sizes.

Cheers,
Daniel.
Jun 27 '08 #62
In article news:<10******* *************** ************@mi crosoft.com>,
Alvin Bruney [ASP.NET MVP] wrote:
Don't confuse flexibility with lack of safety -- you can have the
one without the other.

How is this confused? My point was C# is not less flexible because
it allows pointer tricks, ...
... and your point is misplaced because it is largely not the ability to
perform "pointer tricks" that makes C++ more flexible or more powerful.

Yes, being able to manipulate machine addresses through pointers may
make C++ a suitable choice for very low level code (firmware, drivers,
etc.) -- which C# is not -- but on most modern architectures (with
hardware memory management and address remapping) C++'s addresses don't
correspond to meaningful physical memory addresses anyway.

No, pointer manipulation is not what we're discussing, here.
The single most glaringly obvious example of what I mean is that you
can't do template metaprogramming in C#, but there are others.

And what is that good for?
If you have no conception of the answer to that question I can't hope to
persuade you that you are missing something very important.
I wouldn't go searching for obscure features to compare against C#.
What I would do is compare common code paths and implementation.
Like it or not, C++ is a dying sport. Holding on to obscurities
will not inject life into it.
There's nothing obscure about TMP. It's what makes the C++ standard
library so hugely powerful, it's what makes some of the amazingly useful
libraries in, for example, Boost possible. Modern C++ code is built on
templates and it makes the language hugely more powerful than a
classical OOP language like C# or Java could ever hope to be. Even if a
C++ programmer never writes a single template in his whole life he has
all the power of those libraries to draw upon.
more strictly, to provide a plugin replacement for Java
That's new. By the same token C++ was what to C?
C++ is based on C, but is not a simple replacement. The syntax of C++ is
almost a proper superset of that of C (i.e. most, but not all C source
will compile correctly if fed through a C++ compiler) with new semantics
and new functionality that represent an evolutionary increase in
flexibility and power.

C# is based on Java. It has a slightly different syntax and a different
set of runtime APIs, but it is semantically very similar -- a little
better, because some of the mistakes of Java were not repeated, but
largely similar. Where is the evolutionary advance here? Nowhere.
It's time to let go of C++. Really, it is. It's done for.
You really have no idea.

Cheers,
Daniel.

Jun 27 '08 #63
In article news:<48******* *************** *@news.sunsite. dk>, Arne
Vajhøj wrote:
I'd call that a positive result! Certainly better than getting 50
mediocre programmers.

Seen from a puristic point of view I will agree. But there
is this aspect of the world called money - we need millions
of programmers to code business apps.
10 first class programmers will do more useful work in less time than
50 mediocre programmers ... and you will get fewer bugs.

In a world with concerns such as money you can't afford the mediocre.

Cheers,
Daniel.
Jun 27 '08 #64
Alvin Bruney [ASP.NET MVP] wrote:
It's time to let go of C++. Really, it is. It's done for.
Says who?

C++/CLI as a first class .NET language does indeed appear doomed. Maybe using
C++ for .NET was a bad concept from the beginning, or maybe it was done in by
the flawed initial version of MC++. But, anyway, it seems dead.

C++/CLI is great for inter-op, but that is a limited market compared to all the
things that C# can do in .NET.

But native C++ lives on, both as a cross platform language, and in many
MFC/Win32 applications that are never going to switch to .NET. The Visual C++
team is strongly committed to improve the native coding experience in the next
version of Visual Studio, after many years of neglect.

It is a pity that MFC is a bloated and not very elegant framework, but it works.
It can still be used to create applications that would be difficult to do in C#.

And if you do not like MFC, there are WTL, wxwidgets, QT ... A lot of C++ code
is non-GUI anyway.

C++ is not dead yet. And C# is not the perfect language either. Too much
influenced by Java, IMHO.

--
David Wilkinson
Visual C++ MVP
Jun 27 '08 #65
ajk
On Tue, 24 Jun 2008 08:42:43 -0400, David Wilkinson
<no******@effis ols.comwrote:
>C++/CLI as a first class .NET language does indeed appear doomed. Maybe using
C++ for .NET was a bad concept from the beginning, or maybe it was done in by
the flawed initial version of MC++. But, anyway, it seems dead.

C++/CLI is great for inter-op, but that is a limited market compared to all the
things that C# can do in .NET.
what exactly can be done in C# that can't be done in C++/CLI (VS
2008)?

Jun 27 '08 #66
Daniel James wrote:
In article news:<10******* *************** ************@mi crosoft.com>,
Alvin Bruney [ASP.NET MVP] wrote:
>>Don't confuse flexibility with lack of safety -- you can have the
one without the other.
How is this confused? My point was C# is not less flexible because
it allows pointer tricks, ...

.. and your point is misplaced because it is largely not the ability to
perform "pointer tricks" that makes C++ more flexible or more powerful.

Yes, being able to manipulate machine addresses through pointers may
make C++ a suitable choice for very low level code (firmware, drivers,
etc.)
-- which C# is not
Hm, why ? Singularity / Cosmos are operating systems in C#. The
MicroFramework targets embedded devices.
-- but on most modern architectures (with
hardware memory management and address remapping) C++'s addresses don't
correspond to meaningful physical memory addresses anyway.

No, pointer manipulation is not what we're discussing, here.
O.k. pointer manipulation is the main task of C ;-).
[...]
There's nothing obscure about TMP. It's what makes the C++ standard
Hm, which C++ standard library is using meta templates ? IIRC Tr1 will
use them, boost library uses them but the STL ?
library so hugely powerful, it's what makes some of the amazingly useful
Which powerful standard library in C++ can I use for file operations ?
libraries in, for example, Boost possible.
Boost is a good, cool library - sure. But these libraries get somewhat
bloated, because of all the template stuff and compilation slows down
more and more.

And for example I dare to say that boost::function has a higher
overhead, than C# delegates.
Modern C++ code is built on
templates and it makes the language hugely more powerful than a
I thought it to be so too. I have implemented discriminated unions, used
type lists as they are in Loki for example and all the nice stuff.
What I got was unreadable, hard to debug and bloated code which needed a
very long time to compile.

The one compiler emitted code with a size of 3MB, the other one compiled
the same sources to 6MB.

After I had replaced all the TMP stuff by generated code the code size
could be reduced to 1MB.
classical OOP language like C# or Java could ever hope to be. Even if a
C++ programmer never writes a single template in his whole life he has
all the power of those libraries to draw upon.
Could you give me an example (part of a library), which is more powerful.
>>more strictly, to provide a plugin replacement for Java
That's new. By the same token C++ was what to C?

C++ is based on C, but is not a simple replacement. The syntax of C++ is
almost a proper superset of that of C (i.e. most, but not all C source
will compile correctly if fed through a C++ compiler) with new semantics
and new functionality that represent an evolutionary increase in
flexibility and power.
But C++ inherited the worst from C - macros.
C# is based on Java. It has a slightly different syntax and a different
set of runtime APIs, but it is semantically very similar -- a little
better, because some of the mistakes of Java were not repeated, but
largely similar. Where is the evolutionary advance here? Nowhere.
- LINQ
- Delegates
- Library, which isn't bound to a single language
- Lambda expressions
- Implicit typed variables
- and many more

C++ will get some of these too, but then the argument that C++ hasn't
invented these could be used too.

>It's time to let go of C++. Really, it is. It's done for.

You really have no idea.
Hm, I once was a die hard C++ developer and argued the same way. But
today I'm not that sure about C++ and it's future.
I would prefer >every time< a native C# or would prefer the 'D'
language, if it would be better supported by most of the commercial
developer tools and could (directly) compile (old) C++ code.

Have you used another language than C++ too, to make a good comparison ?

I don't want to start a language war - better said continue one. But I
too think the evolution of C++ is currently too slow and heading in the
wrong direction, since modules in C++ are still delayed. If I compare
what abstraction level I can reach for example with F# and how I'm still
able to use my C# code easily, I don't think that C++ is still the
>only< way to go.
Cheers,
Daniel.
Cheers,
Andre
Jun 27 '08 #67
Andre Kaufmann wrote:
Daniel James wrote:
>Yes, being able to manipulate machine addresses through pointers may
make C++ a suitable choice for very low level code (firmware, drivers,
etc.)
>-- which C# is not

Hm, why ? Singularity / Cosmos are operating systems in C#. The
MicroFramework targets embedded devices.
An desktop/server OS is huge today.

Large parts of an OS can be written in managed code.

But some things has to be written in unmanaged code.

I don't know how much. Maybe 5%.

Even Singularity has a small amount of C++ and assembler.

If we go to embedded devices with much less features then I would
expect the percentage to go up.

And do not get me wrong - I am expecting the next major OS to have
huge part written in managed code. But as expressed in another
subthread - we may have to wait some time for the next major OS.
Boost is a good, cool library - sure. But these libraries get somewhat
bloated, because of all the template stuff and compilation slows down
more and more.
Compilation speed is usually not important.
>C# is based on Java. It has a slightly different syntax and a
different set of runtime APIs, but it is semantically very similar --
a little better, because some of the mistakes of Java were not
repeated, but largely similar. Where is the evolutionary advance here?
Nowhere.

- LINQ
- Delegates
- Library, which isn't bound to a single language
- Lambda expressions
- Implicit typed variables
- and many more
Actually the Java library is not bound to the Java language. You
can use it in Ada (jGnat), Python (Jython) etc..

Arne
Jun 27 '08 #68
David Wilkinson wrote:
C++/CLI as a first class .NET language does indeed appear doomed. Maybe
using C++ for .NET was a bad concept from the beginning, or maybe it was
done in by the flawed initial version of MC++. But, anyway, it seems dead.

C++/CLI is great for inter-op, but that is a limited market compared to
all the things that C# can do in .NET.

But native C++ lives on, both as a cross platform language, and in many
MFC/Win32 applications that are never going to switch to .NET. The
Visual C++ team is strongly committed to improve the native coding
experience in the next version of Visual Studio, after many years of
neglect.
I tend to agree.

People that want to write managed code chose C# instead of C++/CLI. It
is simply easier.

C++ will most certainly live on for many years.

I am a bit skeptical about MFC though. I think MFC will be
squeezed hard by .NET in the next 10 years. As the UI's need
to get a major rewrite then the apps will switch to .NET !

Arne
Jun 27 '08 #69
Daniel James wrote:
In article news:<48******* *************** *@news.sunsite. dk>, Arne
Vajhøj wrote:
>>I'd call that a positive result! Certainly better than getting 50
mediocre programmers.
Seen from a puristic point of view I will agree. But there
is this aspect of the world called money - we need millions
of programmers to code business apps.

10 first class programmers will do more useful work in less time than
50 mediocre programmers ... and you will get fewer bugs.

In a world with concerns such as money you can't afford the mediocre.
If you look out in the real world, then you will see that
is not the general opinion.

Arne
Jun 27 '08 #70

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
11260
by: William C. White | last post by:
Does anyone know of a way to use PHP /w Authorize.net AIM without using cURL? Our website is hosted on a shared drive and the webhost company doesn't installed additional software (such as cURL) on the server because of that. Our site will have an SSL certificate next week, so I would like to use AIM instead of SIM, however, I don't know how to send data via POST over https and recieve data from the Authorize.net server over an https...
2
5860
by: Albert Ahtenberg | last post by:
Hello, I don't know if it is only me but I was sure that header("Location:url") redirects the browser instantly to URL, or at least stops the execution of the code. But appearantely it continues to execute the code until the browser send his reply to the header instruction. So an exit(); after each redirection won't hurt at all
3
23047
by: James | last post by:
Hi, I have a form with 2 fields. 'A' 'B' The user completes one of the fields and the form is submitted. On the results page I want to run a query, but this will change subject to which field is completed.
0
8504
by: Ollivier Robert | last post by:
Hello, I'm trying to link PHP with Oracle 9.2.0/OCI8 with gcc 3.2.3 on a Solaris9 system. The link succeeds but everytime I try to run php, I get a SEGV from inside the libcnltsh.so library. 354 roberto@ausone:Build/php-4.3.2> ldd /opt/php4/bin/php libsablot.so.0 => /usr/local/lib/libsablot.so.0 libstdc++.so.5 => /usr/local/lib/libstdc++.so.5 libm.so.1 => /usr/lib/libm.so.1
1
8617
by: Richard Galli | last post by:
I want viewers to compare state laws on a single subject. Imagine a three-column table with a drop-down box on the top. A viewer selects a state from the list, and that state's text fills the column below. The viewer can select states from the drop down lists above the other two columns as well. If the viewer selects only one, only one column fills. If the viewer selects two states, two columns fill. Etc. I could, if appropriate, have...
4
18313
by: Albert Ahtenberg | last post by:
Hello, I have two questions. 1. When the user presses the back button and returns to a form he filled the form is reseted. How do I leave there the values he inserted? 2. When the user comes back to a page where he had a submitted POST data the browser keeps telling that the data has expired and asks if repost. How to avoid that? I tried registering all POST and GET vars as SESSION vars but
1
6882
by: inderjit S Gabrie | last post by:
Hi all Here is the scenerio ...is it possibly to do this... i am getting valid course dates output on to a web which i have designed ....all is okay so far , look at the following web url http://www.mis.gla.ac.uk/biquery/training/ but each of the courses held have maximum of 8 people that could be
2
31455
by: Jack | last post by:
Hi All, What is the PHP equivilent of Oracle bind variables in a SQL statement, e.g. select x from y where z=:parameter Which in asp/jsp would be followed by some statements to bind a value to :parameter I dont like the idea of making the SQL statement on the fly without binding parameters as I dont want a highly polluted SQL cache.
3
23612
by: Sandwick | last post by:
I am trying to change the size of a drawing so they are all 3x3. the script below is what i was trying to use to cut it in half ... I get errors. I can display the normal picture but not the results of the picture half the size. The PHP I have installed support 1.62 or higher. And all I would like to do is take and image and make it fit a 3x3. Any suggestions to where I should read or look would be appreciated.
0
9854
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9696
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10903
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10645
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10290
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9425
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7827
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4482
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3131
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.