473,400 Members | 2,163 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,400 software developers and data experts.

C++ vs C#

Hi,

I'm sorry if this question comes inapropriate but hope you can help me
answer the following:

What is the difference between C++ and C#. Can I use C++ code within the C#
code. I've heard postive things about Framework which should be similar to
MDSN - or what is it better/worse?

Please tell me why I should go for C-sharp instead of C++

Thx
Nov 17 '05 #1
5 1652
"TStoltz" <st*****@hotmail.com> wrote in message
news:42******@news.wineasy.se...
Hi,

I'm sorry if this question comes inapropriate but hope you can help me
answer the following:

What is the difference between C++ and C#.
C# is a member of the C family of languages, much like Java. In fact it
shares many similarities with Java since both target a managed environment.
C# could be seen as a "simple" C++, without macros, templates, and multiple
inheritance. It adds first class support for properties and events, and
replaces function pointers with delegates, which are effectively type-safe
function pointers. C# 2.0 has generics which are similar in some respects to
C++ templates. C# also does not support deterministic finalization, since it
relies on the .NET garbage collector to handle memory.
Can I use C++ code within the C# code.
Not directly no. C# can call into other .NET assemblies, including ones
developed with Managed C++, or C++/CLI (both are basically C++ flavours
targetting .NET). Via COM Interop C# can call C++ code which was compiled
into a COM DLL, and via PInvoke C# can call C++ code compiled into a Windows
DLL.

Managed C++ and C++/CLI offer an additional interoperation capability called
IJW, which allows you to use unmanaged C++ code in your managed C++ DLLs.
Needless to say this is very useful if you have a lot of C++ code you need
to work with.
I've heard postive things about Framework which should be similar to MDSN -
or what is it better/worse?
Do you mean MSDN? If so, this is just the Microsoft developer documentation.
The Framework is the actual .NET system.
Please tell me why I should go for C-sharp instead of C++
There's no hard and fast rule here. Basically if you've decided to target
the .NET Framework, and you're not doing too much communication with C++
code, then C# will generally get your code out the door quicker and with
less bugs. This is a function of both the cleaned up syntax and the memory
management features of the .NET framework (which are also available with
Managed C++ and C++/CLI).

I much prefer C#, since I find it has a much cleaner syntax than C++ and
less ambiguities. Switching from C++ to C# led to a 50%+ developer
productivity boost on one of the projects I was involved in. That said, C#
is not a panacea for all ills, and sometimes you are better off with C++,
but these situations are few and far between in my experience.
Thx

Nov 17 '05 #2
x-no-archive: yes

C++ is a pedal to the metal nitty gritty very high performance object
oriented programming language with wide support, an excellent STL (Standard
Template Library) and many other libraries and lots of books written for it.
It is a very complicated language however and you'd better get real used to
pointers, references, and pointers to pointers, and pointers to references
of pointers to objects containing arrays of pointers if you want to use it.

If you use C++ to program for Windows you will have to learn five thousand,
four hundred and fifty-two (5,452) different macro names for strings and no
two are really compatible with only 314 different versions of every function
needed for each one: LPSTR LPCSTR LPPCSTSTRST WCTSTR WPCSTR STRWPPCSTR STR
cstr cstring CString WCString WCpyString <string> wstr strcpyw strcpyl
lstrcpy cpycpystyr STSTRSS CSTRWP LPSTRCPY LWPSTR CSTRWPLSTR ... etc.

C# is a high performance (managed) interpreted object oriented language.
Lots of books, expanding libraries, lots of support and an excellent .NET
framework. It has simplified programming for Windows and seems to be the
future of programming for Windows. Yes, engines for the language are being
developed for other than Windows platforms. It stays relatively
uncomplicated until you get into interfaces, delegates and attributes etc.
In C#, strings actually seem to make real sense.

You can mix C++ and C# languages but there are considerations when you do
so.
TStoltz wrote:
Hi,

I'm sorry if this question comes inapropriate but hope you can help me
answer the following:

What is the difference between C++ and C#. Can I use C++ code within
the C# code. I've heard postive things about Framework which should
be similar to MDSN - or what is it better/worse?

Please tell me why I should go for C-sharp instead of C++

Thx

Nov 17 '05 #3
Stephen <st*****@online.nopam> wrote:

<snip>
C# is a high performance (managed) interpreted object oriented language.


C# isn't interpreted - it's JIT compiled. There's a big difference.

(I broadly agree with the rest of your post.)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #4
On Mon, 9 May 2005 14:15:44 -0400, "Stephen" <st*****@online.nopam>
wrote:
x-no-archive: yes

C++ is a pedal to the metal nitty gritty very high performance object
oriented programming language with wide support, an excellent STL (Standard
Template Library) and many other libraries and lots of books written for it.
It is a very complicated language however and you'd better get real used to
pointers, references, and pointers to pointers, and pointers to references
of pointers to objects containing arrays of pointers if you want to use it.

If you use C++ to program for Windows you will have to learn five thousand,
four hundred and fifty-two (5,452) different macro names for strings and no
two are really compatible with only 314 different versions of every function
needed for each one: LPSTR LPCSTR LPPCSTSTRST WCTSTR WPCSTR STRWPPCSTR STR
cstr cstring CString WCString WCpyString <string> wstr strcpyw strcpyl
lstrcpy cpycpystyr STSTRSS CSTRWP LPSTRCPY LWPSTR CSTRWPLSTR ... etc.

C# is a high performance (managed) interpreted object oriented language.
Lots of books, expanding libraries, lots of support and an excellent .NET
framework. It has simplified programming for Windows and seems to be the
future of programming for Windows. Yes, engines for the language are being
developed for other than Windows platforms. It stays relatively
uncomplicated until you get into interfaces, delegates and attributes etc.
In C#, strings actually seem to make real sense.

You can mix C++ and C# languages but there are considerations when you do
so.
TStoltz wrote:
Hi,

I'm sorry if this question comes inapropriate but hope you can help me
answer the following:

What is the difference between C++ and C#. Can I use C++ code within
the C# code. I've heard postive things about Framework which should
be similar to MDSN - or what is it better/worse?

Please tell me why I should go for C-sharp instead of C++

You should not if you have competence in c++. If you dont or worse
have been VB programmer by all means use c#. It gives you access to a
broad framework, although no low level access like c++. Also it is
more forgiving like java with regard to complexity and memory
management.
If for instance you want to write essentially two tier applications(
database with some gui) then by all means use c#, java, delphi, vb.net
or whatever low level encapulating language).
If on the other hand you think complexity is your job stay with c++.

Hope it helps,

Rick

Thx


Nov 17 '05 #5
Rick Elbers <ri*********@chello.nl> wrote:
You should not if you have competence in c++. If you dont or worse
have been VB programmer by all means use c#. It gives you access to a
broad framework, although no low level access like c++. Also it is
more forgiving like java with regard to complexity and memory
management.
If for instance you want to write essentially two tier applications(
database with some gui) then by all means use c#, java, delphi, vb.net
or whatever low level encapulating language).
If on the other hand you think complexity is your job stay with c++.


That depends on what you mean by complexity. It's perfectly possible to
write complex apps in C# - the difference is that the code itself
doesn't tend to look as complex as it does in C++.

I see nothing wrong with C++ programmers taking up C# as a "cleaner"
language than C++. Yes, C++ has added complexity within the language
itself, but many people think that's more of a bad thing than a good
thing. As I say, you don't need a complex language to create complex
apps.

Of course, there are things you *do* need C/C++ (or another low level
and unmanaged language for), but it's more a case of level of interface
with the hardware and OS which is important than the complexity of the
app in question.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #6

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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...
0
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,...
0
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...

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.