C# Intended To Replace C++ ?
I am Just curious.
Do MS created C# so it will replace C++ (both Managed and Unmanaged) ?
please give your opinion. Thank you.
[145 byte] By [
kaixa] at [2007-11-20 0:42:28]

# 1 Re: C# Intended To Replace C++ ?
Certain (aspects of) applications which were previously done in c++ can now be done much easier using .net, such as gui programming and boring office apps, but i can't see c++ being totally replaced. C++ has access to all the windows functions, and you do advanced stuff like kernel programming which i don't think you can do with .net. If c# was meant to replace manged c++ then i doubt they would have created managed c++. managed c++ is great when you want to combine managed and unmanaged code.
dave2k at 2007-11-9 12:18:18 >

# 2 Re: C# Intended To Replace C++ ?
I agree. Managed C++ is great. But, hearing all those hype about how easy programming with C#. like MS says, "C# is language with the power of C++ and without its complexity".
Well, it sure is promising...or maybe i am wrong...:-|...
kaixa at 2007-11-9 12:19:18 >

# 3 Re: C# Intended To Replace C++ ?
Both C# and managed C++/C++/CLI have their place. Personally I'd use C# with p/invoke for just about everything, but I've used managed C++ projects in the past to fix problems.
Darwen.
darwen at 2007-11-9 12:20:16 >

# 4 Re: C# Intended To Replace C++ ?
...And Cilu will say that C++/CLI produces optimised IL code better than C#.
For writing UI I'd say C# is infinitely better than C++/CLI.
For writing clean and understandable code C# is better than C++/CLI.
If you want to produce the most optimised managed code then C++/CLI is better than C#.
However if you really want to write fast code then native C++ code is better, and put it into a dll and interface using P/Invoke.
And if you want to write really, really fast code then write it in machine language, put it into a dll and interface using P/Invoke.
And machine language is easy... see my series of articles here. ('http://www.dev-archive.com/Cpp/Cpp/cpp_mfc/tutorials/article.php/c9411/')
Darwen.
darwen at 2007-11-9 12:21:21 >

# 5 Re: C# Intended To Replace C++ ?
If you look at how various languages and features have evolved, once upon a time there was Visual Basic and Visual C++, and there were Office programs. Office programs had their own built-in scripting language for writing macros.
Visual C++ could compile standard C++ code but also came with the MFC library.
Inter-process communication was done with DDE. Then came the improved OLE and COM and COM remained stable for a while. VB was Microsoft's "pet" language, and the Office macros were changed to use VB.
Meanwhile programming evolved further, we got multi-threading, more network-connections, internet etc. Java came along with in-built library features and could run on any platform that had a virtual machine. Java is owned by Sun OS so Microsoft had to come along with their own variety, and C# emerged. Meanwhile the COM framework had its many problems, so was replaced by .NET.
With C# now being Microsoft's new pet language, they effectively designed C# around .NET so it would fit the model perfectly, then started adding support for other languages.
In my opinion, many people who used MFC as their GUI have changed to C# under .NET. While they didn't dare touch VB, C# is a much better language (more OO) and there is a general feeling that it's a language that's useful to know (lots of jobs in it) so they make the effort to learn it.
Those who were writing C++ under COM have also moved over to .NET. They may use C# again as the native language.
Apps ported from C++ may be ported into CLI because it's probably easier to port to than to C#. I don't know if many new apps are written in CLI but there are no doubt a few that will favour it.
Often the decision to write in one language rather than another is taken because the particular language happens to be more popular at the moment. A lot of programs were written in Java for that reason in the late 90s/early 00s just for that reason.
# 6 Re: C# Intended To Replace C++ ?
[ Moved Thread ]
NoHero at 2007-11-9 12:23:23 >

# 7 Re: C# Intended To Replace C++ ?
No, why it should? C++ is for manipulating memory, C# is for manipulating objects. In C++ (or lower languages), you can touch hardware directly, it is much better language to write OS and drivers than C#. Writing OS in C# is as fool idea as write business web application in C++. There allways must be language with lower capabilities like in C++ to write CLR or JVM or other virtual machine.
C++ and C# will keep their place, at least revolutionary new hardware will be developed. However, C# will take more and more portion of common daily developer's work.
# 8 Re: C# Intended To Replace C++ ?
I see. Thanx For all the inputs...
seems like C# more suitable to write common GUI program that only care one thing : "It's just work", where it doesn't care about resources management, since most computer nowadays is more than enough to run standard windows program such as office, minesweeper or etc.
Correct me if i am wrong, since i don't know a jack about C#.
Until now, i am staying with Managed C++ until i find a good reason to switch using C#...
kaixa at 2007-11-9 12:25:30 >

# 9 Re: C# Intended To Replace C++ ?
well managed C++ and c# are the same really. you have access to the same libraries and can do the same thing. the only difference is in the syntax, and even that isn't a world away from c# syntax. dot net (any language) and unmanaged c++ complement each other very nicely.
dave2k at 2007-11-9 12:26:27 >

# 10 Re: C# Intended To Replace C++ ?
...Writing OS in C# is as fool idea...
fyi, Microsoft Research have been researching into this. Here is a page to the video where they boot up Singularity.
Singularity IV: Return of the UI (http://channel9.msdn.com/Showpost.aspx?postid=227260)
If you are interested to know about its design, you can search "Singularity" in Channel 9 for the eariler 3 videos where they discussed about its design.
# 11 Re: C# Intended To Replace C++ ?
I have forgotten this, but it doesn't change my opinon. C# (.NET respectively) can became the primary OS language (or better - platform how to comunicate with the OS) as Objective-C is of NextStep. But you need a VM (or CLR in case of .NET), which cannot be written in C# directly, because it MUST be able to control the hardware directly. By OS, I mean scheduler, memory manager, I/O facilities and so on which I cannot imagine to be written in higher language like C#. OS can be unified with CLR, but never could be written without knowleadge and usage of underlying hardware.
# 12 Re: C# Intended To Replace C++ ?
One thing I like about .Net or C#, is its Garbage Collector.
Imagine you run a C++ application which allocates and deallocates really a lot of memory during its operation, after a long time, you will find that its performance will degrade, as it cannot find enough memory to allocate as the memory is defragmented and the OS have to resort to its pagefile. Actually there are enough memory for it, but many of the freed memory blocks are not big enough for the allocations or the poor memory allocator keeps finding among the freed memory big enough for its allocations, thus the slowness.
.Net application does not have this problem, as its GC compacts its memory time to time after reclamations. Unfortunately, C++ cannot have this, as pointers point to unique memory locations, if the location changed, all pointers pointing to it have to change as well.
Please note when you use a string class, you are using memory allocation as well because the string object allocates its buffer on the heap.
# 13 Re: C# Intended To Replace C++ ?
I have forgotten this, but it doesn't change my opinon. C# (.NET respectively) can became the primary OS language (or better - platform how to comunicate with the OS) as Objective-C is of NextStep. But you need a VM (or CLR in case of .NET), which cannot be written in C# directly, because it MUST be able to control the hardware directly. By OS, I mean scheduler, memory manager, I/O facilities and so on which I cannot imagine to be written in higher language like C#. OS can be unified with CLR, but never could be written without knowleadge and usage of underlying hardware.
One of the videos(cant remember) which says it is impossible unless we have a managed processor (instead of native processor). LOL.
# 14 Re: C# Intended To Replace C++ ?
Iirc on memory management, you can't explicitly delete object reference on C# right ?
since it can be done on MC++.
kaixa at 2007-11-9 12:31:29 >
