473,320 Members | 1,829 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

C# vs C++

Is C# better than C++?

What are the advantages of C++ over C# and vice versa?

Thanks and regards
Metal
Nov 17 '05 #1
17 1320
Metal,

C# is a lot better C++.
For one, C# is part of .NET, so it has a lot of good features like
managed code.
In C++, with the use of pointers, the code can be very unsafe and it
isn't 'visual'; in other words, all the code that you need to write is
all done by YOU.
Besides, currently now and into the future people are using things like
Windows Applications, Web etc. C# makes it so much easier to devolop
those kind of applications.

However, there ARE SOME advantages of C++ over C#, I must admit.

This is an interesting topic,

Visually Seen #

Nov 17 '05 #2
C# ...

* is a cleaner language that is easy to program, read and maintain
* has a much higher productivity rate
* contains features that allows you to generate HTML documentation from
XML tags that describe your methods, properties, events and fields
* eliminates the need for pointers, which are essentially useless
* almost everything in c# including basic data types are derived from a
common class and therefore share common functionality
* uses a fairly consistant model for inheritance, interfaces, delegates
and events
* eliminates garbage collection and the need to manually destroy
objects
* is based on using managed code so that you are not required to
release memory on objects
* uses namespaces so that you can properly organize your classes into
logical units
*

C++...

* good for higher performance (math, graphics, etc)
* required to work with lower levels (device drivers, etc)

Most people who have developed with both languages will sooner choose
C# over C++ for most application development. C++ will not dissappear
(at least not yet) and has its place but it is an archaic language that
is complex, messy and out-of-date with the times.

Best Regards
Johann Blake

Nov 17 '05 #3
You really cannot use the "it's part of .NET" as an argument for C#
being better than C++. That is because C# is a language and is
independent of the platform. C# can run on other operating systems
using platforms other than .NET. While C# running on Windows developed
using Visual Studio .NET does make use of the .NET framework, these are
advantages of using the .NET framework and not the language itself.

Best Regards
Johann Blake

Nov 17 '05 #4
C# is a managed language - it requires an environment that has facilities like delegates, metadata extensions (attributes) and garbage collection (remember there is no delete keyword). I'm not aware of any C# implementation that is not CLR (or at least CLI) based and frankly I can't see a way of there being one.

Of course your argument holds true for reason's other than you've stated: because C++/CLI (the new managed C++ language) is part of .NET in the same way.

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

You really cannot use the "it's part of .NET" as an argument for C#
being better than C++. That is because C# is a language and is
independent of the platform. C# can run on other operating systems
using platforms other than .NET. While C# running on Windows developed
using Visual Studio .NET does make use of the .NET framework, these are
advantages of using the .NET framework and not the language itself.

Best Regards
Johann Blake

Nov 17 '05 #5
There's no such thing as a "managed language" when talking generically
about programming languages. The word "managed" was coined by Microsoft
and has to do with the .NET Framework and not the language itself.
There's nothing preventing someone from writing a C# compiler that
generates machine code for some microcontroller where no CLR is even
required. In such a case, you can't call this "managed".

Johann Blake

Nov 17 '05 #6
What I'm saying is that I can't see how you'd get away without a GC being there - it, as a language, requires runtime support.

Managed has everything to do with the .NET framework. Code that runs within the confines of the .NET framework is termed managed. Yes managed was coined by Microsoft - but so was .NET.

Regards

Richard Blewett - - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

There's no such thing as a "managed language" when talking generically
about programming languages. The word "managed" was coined by Microsoft
and has to do with the .NET Framework and not the language itself.
There's nothing preventing someone from writing a C# compiler that
generates machine code for some microcontroller where no CLR is even
required. In such a case, you can't call this "managed".

Johann Blake

Nov 17 '05 #7
GC is only relevent in the world of Windows where keeping memory clean
and reusing previously created object instances has definite
advantages. But it is still only a "nice-to-have" feature, not a
"must-have" feature. The language can exist without it and in fact
does. My point is C# is NOT dependent on any sort of runtime support as
you imply. Only within the context of Windows programming using Visual
Studio .NET does that hold true.

Regards
Johann Blake

Nov 17 '05 #8

From ECMA 334 (The C# Standard) Section 10.9
"C# employs automatic memory management, which frees developers from
manually allocating and freeing the memory occupied by objects. Automatic
memory management policies are implemented by a garbage collector."

If it doesn't have a GC, it's not C#.

----
Nigel Norris

"Johann Blake" <jo*********@yahoo.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
GC is only relevent in the world of Windows where keeping memory clean
and reusing previously created object instances has definite
advantages. But it is still only a "nice-to-have" feature, not a
"must-have" feature. The language can exist without it and in fact
does. My point is C# is NOT dependent on any sort of runtime support as
you imply. Only within the context of Windows programming using Visual
Studio .NET does that hold true.

Regards
Johann Blake

Nov 17 '05 #9


Metal wrote:
Is C# better than C++?


Bananas are definatly better than bicycles.

--
Helge Jensen
mailto:he**********@slog.dk
sip:he**********@slog.dk
-=> Sebastian cover-music: http://ungdomshus.nu <=-
Nov 17 '05 #10
Johann,
But it is still only a "nice-to-have" feature, not a "must-have" feature.


I think for C# garbage collection is a "must-have" feature of the
environment. How would you release for reuse the memory in absence of GC?
The language does not offer a delete operator or any other mechanism...

Just my two cents.

Regards - Octavio
Nov 17 '05 #11
"C# is a lot better C++"

"BETTER" is a very relative term, depending on the task and requirements C#
can be better than C++ or C++ can be better than C#.

One of the main differences between C# and C++ is that C# has the concept of
managed code. In C# the programmer does not have to concern himself about
allocating and releasing memory, this is all done by the .Net CLR and garbage
collection. Basically in C# when an object goes out of scope, i.e. it is no
longer referenced by any other object, it has the possibility of being
cleaned up automatically, but this mechanism is non-deterministic. An object
will only be cleaned up when the Garbage Collector runs (you can call
GC.Collect(), but this is not recommended, the GC algorithms are coded to be
optimal and will do a better job than you calling it manually).

It is possible to use pointers in C#, but then you must put the code inside
an unsafe block which may not allow it to be run in some environments where
security restrictions are high and unsafe code is not permitted to run. Also
as with C++ if you use pointers and allocate memory dynamically then you run
the risk of memory leaks if you foget to deallocate the momory after use.

The possibility of not having memory leaks is a big plus for C#.

C# is also designed to be a secure language, it is not possible to have a
buffer overflow exception in C#, which is easily done in C++, which is the
cause of a lot of security bugs and viruses. the worst you should get in C#
is an exception being thrown.

Also C# is compiled into an intermediate language called IL, just like Java
is compiled into JavaBytes. because it is not compiled to any specific
hardware you can write a CLR for each type of hardware or OS and run the same
code without modification. As well as being a plus this can be seen as a
negative because there is more overhead in translating the IL language to
machine at runtime than natively running the machine code. I believe it is
possible to compile C# to a native platform but I do not have any experience
of C# native vs C++ performance so I cannot comment on this.

The list of comparisons can go on and on, here are just some of the points.

Mark R Dawson.


"Visually Seen #" wrote:
Metal,

C# is a lot better C++.
For one, C# is part of .NET, so it has a lot of good features like
managed code.
In C++, with the use of pointers, the code can be very unsafe and it
isn't 'visual'; in other words, all the code that you need to write is
all done by YOU.
Besides, currently now and into the future people are using things like
Windows Applications, Web etc. C# makes it so much easier to devolop
those kind of applications.

However, there ARE SOME advantages of C++ over C#, I must admit.

This is an interesting topic,

Visually Seen #

Nov 17 '05 #12
Metal wrote:
Is C# better than C++?

What are the advantages of C++ over C# and vice versa?

Thanks and regards
Metal

Note, I have 20+ years of experience in C, 10+ years in C++ and about
1.5 years of C#.
Better for what?? I work on a large medical imaging and reporting
system. C/C++ is the best choice for our imaging system, due to the
requirement to interface with some third party code. Also, imaging
processing seems to be faster in unmanaged C++. Now the
reporting/graphing system is in C#. Very easy to program/develop. I
believe you can develop/implement and test up to 5 times faster in C#
over c++. One task which would have taken me 2 weeks in C++ was done in
about 3 days in C#.
Nov 17 '05 #13
I respectfully submit that no language is "better" than another in some kind
of simplistic, definitive way. Nor is there a bullet-pointed list of
immutable "advantages" of one language over another. No one can possibly
give you an intelligent answer to "is language A better than language B"
unless they know what tasks you want to apply those languages to, and what
your personal requirements and preferences are.

Languages are tools. Each one has what are generally regarded as strengths,
but their greatest strength is also their greatest weakness. For example
from the 10,000-foot level, C#'s basic strength is that it's an excellent
general purpose language for developing line-of-business applications.
That's also its basic weakness -- if you're writing, say, a real-time device
driver.

So, as with most things in the real world, the answer is, "it depends" --
and even then, you may well disagree with my criteria for evaluating the
languages in question.

Lastly, I'd like to suggest that you may not necessarily be well-advised to
be evaluating languages. Platforms, by which I mean framework libraries,
are probably more important, and these days do not necessarily correspond
one-to-one with languages. For example, any of the thirty-some languages
currently hosted by the .NET runtime (only three of which are sold by
Microsoft as part of the .NET SDK) are more or less equivalant and
applications coded in any of them will tend to look very similar because
they all talk to the same API. Some, like VB, have backward compatibility
baggage where you have the option, to an extent, to structure your syntax
against a legacy API in addition to .NET, but that is only a consideration
if you are porting legacy code or a parochial viewpoint where you want to Do
Things The Way They've Always Been Done.

So for me, the question is, how does the .NET platform (regardless of
language) compare with other platforms such as J2EE (which happens to be wed
to just one language, Java).

--Bob

"Metal" <me***@despammed.com> wrote in message
news:OY*************@TK2MSFTNGP14.phx.gbl...
Is C# better than C++?

What are the advantages of C++ over C# and vice versa?

Thanks and regards
Metal

Nov 17 '05 #14
microsoft is dumping support for C++ next year. that does give you a hint
about what is better. go figure.

--
Regards
Alvin Bruney
[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc, Amazon, B&H etc
-------------------------------------------------------------------------------
"Metal" <me***@despammed.com> wrote in message
news:OY*************@TK2MSFTNGP14.phx.gbl...
Is C# better than C++?

What are the advantages of C++ over C# and vice versa?

Thanks and regards
Metal

Nov 17 '05 #15
Really? It would seem strange to dump a language 6 months after giving a major refit in C++/CLI. What leads you to that conclusion? Regards Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk microsoft is dumping support for C++ next year. that does give you a hint
about what is better. go figure.

--
Regards
Alvin Bruney
[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc, Amazon, B&H etc
-------------------------------------------------------------------------------
"Metal" <me***@despammed.com> wrote in message
news:OY*************@TK2MSFTNGP14.phx.gbl...
Is C# better than C++?

What are the advantages of C++ over C# and vice versa?

Thanks and regards
Metal


[microsoft.public.dotnet.languages.csharp]
Nov 17 '05 #16
Did you know that C# was derived from 'D' which has similar Object
Orienting Programming concept. I suspect Microsoft simply rebranded 'D'
to C# for marketing reason...very smart move.

It true that C# is easier because you do not have to deal the pointer
which bring in memory leakage issue (due to type or array
incompactibility).

C# work heavily with .net framework and are closely interlinked,
designed to ensure all objects is managed safety. This bring
significant stability and operation. I just often wish there is more
tools and choice available for the window forms...which seem outdated
(for VS 2003).

While the library is extensive...it easier to work with internet,
ethernet, USB and so on. *but* you have to be aware of behaviour of
ther serial data transfer, because once eithernet is converted into
serial (RS232) at the other end....the data is no longer secured and
prone to bits flips after certains time.

However C++ still play important role for embedded computing and
smaller self contained computer.

In conclusion...I support C# programming environment because it less of
the headache and easier to work with them, it easier to read than
VS.net Basic version. I hope to move on into DirectX 3D drawing using
C#...

Nov 17 '05 #17
Did you know that C# was derived from 'D' which has similar Object
Orienting Programming concept. I suspect Microsoft simply rebranded 'D'
to C# for marketing reason...very smart move.

It true that C# is easier because you do not have to deal the pointer
which bring in memory leakage issue (due to type or array
incompactibility).

C# work heavily with .net framework and are closely interlinked,
designed to ensure all objects is managed safety. This bring
significant stability and operation. I just often wish there is more
tools and choice available for the window forms...which seem outdated
(for VS 2003).

While the library is extensive...it easier to work with internet,
ethernet, USB and so on. *but* you have to be aware of behaviour of
ther serial data transfer, because once eithernet is converted into
serial (RS232) at the other end....the data is no longer secured and
prone to bits flips after certains time.

However C++ still play important role for embedded computing and
smaller self contained computer.

In conclusion...I support C# programming environment because it less of
the headache and easier to work with them, it easier to read than
VS.net Basic version. I hope to move on into DirectX 3D drawing using
C#...

Nov 17 '05 #18

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

Similar topics

3
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)...
2
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...
3
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...
0
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. ...
1
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...
4
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...
1
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 ...
2
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...
3
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...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
1
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.