C++ or C#?

Started by
33 comments, last by CTar 16 years, 11 months ago
I posted it in a jokingly way as I know the poster didn't ask about D, but I do believe D is superior to both C++ and C#.

C++
- Pros:
* Everyone else uses it
* Systems level programming language
* Cross platform, as long adhere to a strict set of rules (see: http://www.mozilla.org/hacking/portable-C++.html )
* No VM
- Cons:
* Horrible language design
* Difficult compiler implementation
* Very slowly dying due to the likes of D, C#, Java and their next generation ilk

C#
- Pros:
* Better language design than C++ (this is not very hard to accomplish)
* Microsoft Owns It
- Cons:
* Microsoft Own It
* Microsoft does not support a true cross platform nature that C# could have
* Virtual Machine prevents it from being a systems level programming language

D
- Pros:
* Better language design than both C# and C++
* Cross platform without sacrificing features
* No VM, therefore can be a systems level language
* Fast compile times
* Can do crazy things like generate near-optimal x87 asm code for BLAS1 basic vector operations at compile time. ( http://www.dsource.org/projects/mathextra/browser/trunk/blade/Blade.d ) or create a raytraced scene at /compile/ time, without running an exe. ( http://www.digg.com/programming/Ctrace_A_compile_time_raytracer_in_D )
* Not owned by microsoft
* Very fast language evolution
* Walter Bright takes suggestions from the programming community about which features he should add/remove, therefore the programmer almost has a slight ownership of the language/compiler
- Cons:
* Not everyone uses it yet, but then again this is a matter of time
* General lack of maturity (ie. lack of libraries and books). This being the case, you have to be a pretty competent programmer to use D.

There are also projects in the works like tioport (Automatic port of Java --> D code, SWT is already successfully ported for multiple platforms, but is still in its early stages) and bcd (Automatic creation of D interfaces that allow you to call C/C++ libraries). Both these projects are on http://www.dsource.org .

I don't use C# because its strongly tied to Microsoft. I don't use C++ because programming C++ is a chore. I'd recommend the D language over both.

Just in case you are scared by the lack of D libraries, here is a link to a D project that uses PhysX physics engine, RakNet networking library, OpenGL + Cg, etc. Pretty much everything you need you can have with D, if you put in the effort for it or use somebody else's effort.

http://www.team0xf.com/
Advertisement
You are silly. Please learn more about the C# language before stating incorrect data as fact.

Quote:
C#
* Microsoft Owns It


Blatant misinformation. Microsoft owns the Visual C# compilers, along with the .NET library, and I am not surprised in the least that the main Windows implementation of C# is owned by Microsoft, just like I am not surprised that the main Windows implementation of C++ is owned by Microsoft. Or does Microsoft own C++ as well [smile]

C# itself is not owned by anyone, but rather overseen by a standardization committee that is completely independent from Microsoft.

This annoying "owned by Microsoft" stigma is utterly false. True, Microsoft has currently the best implementation of a C# compiler and library around, but this does not make it the owner or the language, nor does it taint your project in some mystical way if you use open source compilers and libraries on an open source OS to develop in C#.

What's more, the Visual C# 2005 IDE is possibly the best game development IDE available right now, it integrates flawlessly with both DirectX and XNA, and even the non-gamedev portions of it are lightyears ahead of most competition in terms of productivity and features. Factor in the plugin system, and you have access to refactoring tools, profilers and other extremely useful third-party programs, transparently integrated in the IDE. So, Microsoft supporting C# that well is more of a boon than a burden to me.

Quote:
* Microsoft does not support a true cross platform nature that C# could have


C# runs on any Windows (including handheld), the latest XBox, any Linux (including handheld), and any OS X, as long as either .NET or Mono is available. What's more, C# runs on all of these without requiring you to recompile, you just have to transfer the binary there. I had lots of fun compiling code on Visual Studio, and then moving it to our Unix-based server cluster, where the code ran flawlessly without the smallest porting effort.

Of course, this cross-platform compatibility is not supported by Microsoft, which only supports the Windows-based implementation of C#. And, to be honest, Microsoft does not support the cross-platform compatibility of C++ or D either. Why would Microsoft port any language to an operating system it isn't responsible for?
Quote:Original post by clayasaurus
C++
- Pros:
* Everyone else uses it
This isn't just a "pro", it's more of a marketing thing : "Because just about everyone can't be wrong"...
* Systems level programming language
* Cross platform, as long adhere to a strict set of rules (see: http://www.mozilla.org/hacking/portable-C++.html )
* No VM
In this day and age, VM's aren't necessarily a bad thing, but alas. I've got a feeling I'll get back to this
- Cons:
* Horrible language design
Yeah, it's got a horrid history to look back at
* Difficult compiler implementation
* Very slowly dying due to the likes of D, C#, Java and their next generation ilk
Here you're really hoping this is true. Compilers are slowly getting better at what they (are supposed to) do, a ton of consoles/portables have just been launched that eat C/C++, there's a new standard on the way, and then I won't talk about every single user, library, community that breathes C/C++

C#
- Pros:
* Better language design than C++ (this is not very hard to accomplish)
Heh heh
* Microsoft Owns It
Not really, no
- Cons:
* Microsoft Own It
Again, not exactly
* Microsoft does not support a true cross platform nature that C# could have
For starters, you've got the XBox360. And then there's Mono, albeit this isn't really MS related, but then again, MS doesn't really _own_ C#
* Virtual Machine prevents it from being a systems level programming language
Not necessarily a bad thing, as evidenced by new security ideas behind modern OS's

D
- Pros:
* Better language design than both C# and C++
I could raise the same argument here as you did for C# vs C/C++
* Cross platform without sacrificing features
* No VM, therefore can be a systems level language
* Fast compile times
Come on, even the compiler you yourself posted is from the same guys that created an excellent and more importantly _efficient_ C/C++ compiler. It's not the only one either.
* Can do crazy things like generate near-optimal x87 asm code for BLAS1 basic vector operations at compile time. ( http://www.dsource.org/projects/mathextra/browser/trunk/blade/Blade.d ) or create a raytraced scene at /compile/ time, without running an exe. ( http://www.digg.com/programming/Ctrace_A_compile_time_raytracer_in_D )
Crazy shit, but the latter is as useful as programming a recursive Fibonacci algorithm using templates at compile time in C/C++
* Not owned by microsoft
Wow, MS must have gotten really evil the past 5 minutes
* Very fast language evolution
As with all projects with a limited community
* Walter Bright takes suggestions from the programming community about which features he should add/remove, therefore the programmer almost has a slight ownership of the language/compiler
- Cons:
* Not everyone uses it yet, but then again this is a matter of time
Which is what they said about Java, some decades ago
* General lack of maturity (ie. lack of libraries and books). This being the case, you have to be a pretty competent programmer to use D.


As fas as books, "C++ Primer Plus" is one of the most clearly written and comprehensive beginner C++ books I have run across.
How do you define a VM? What the .NET framework's implementation has is generally not considered a VM.

Quote:Original post by clayasaurus
C++
...
* No VM

Like C# and D, and Is that supposed to be a good thing? There is no reason to mention something which none of the languages have and forgetting to mention it at C# gives the wrong impression.

Quote:* Horrible language design

That is your opinion. I actually think C++ did better than D considering its design goals (general-purpose with bias towards system programming, backwards compatibility, control, etc.).

Quote:* Difficult compiler implementation

IMO the user shouldn't care about that. Compilers like Visual C++, Intel C++ and GCC shows that it can still be done well.

Quote:* Very slowly dying due to the likes of D, C#, Java and their next generation ilk

Popularity shouldn't isn't a measure of how good a language is.

Quote:* Virtual Machine prevents it from being a systems level programming language

What WM? Microsoft's implementation doesn't have one. Also you do know Microsoft created an OS almost entirely in an extension of C# right? (they called the language Sing# and the OS Singularity if you're interested)

Quote:* Better language design than both C# and C++

I completely disagree. This is your opinion only.

Quote:* Cross platform without sacrificing features

Cross-platform? I haven't looked into it, but what platforms does it support that C# doesn't?

Quote:* No VM, therefore can be a systems level language

No. It doesn't turn into a systems level language because it isn't interpreted.

Quote:* Fast compile times

Does it beat C#? Do you have any benchmarks which support this? (I honestly don't know whether it beats C#)

Quote:* Can do crazy things like generate near-optimal x87 asm code for BLAS1 basic vector operations at compile time. ( http://www.dsource.org/projects/mathextra/browser/trunk/blade/Blade.d ) or create a raytraced scene at /compile/ time, without running an exe. ( http://www.digg.com/programming/Ctrace_A_compile_time_raytracer_in_D )

I haven't looked at the raytracer. Partially because I don't see why it's useful and partially because I don't have the time (EDIT: This doesn't mean I don't see the possibilities presented by a strong compile-time code generator and this may be one of the few things which I agree D have done better than C# and C++). However I did look at Blade.d and you do realize that it's barely D right? Here is some code from a function called:
// Use ESI as the index register.char [] result="asm {"\n~"L1: \n"~ "  movapd XMM1, [ESI+EAX];"\n~ "  mulpd XMM1, XMM2;"\n~ "  addpd XMM1, [EDI+ESI];"\n~ "  movapd [EDI+ESI], XMM1;"\n~ "  add ESI, 16;"\n~ "  js L1;"\n~ "}"\n;return result;

You can do the exact same thing in C++ with inline assembly.

Quote:* Not owned by microsoft

Like both of the other languages.

Quote:* Very fast language evolution

Is this necessarily good? Unstable interfaces, an indication of design problems, etc. Too much evolution is bad, but some is good. C# also develops quite fast and it just got a bunch of stuff like lambda expressions and LINQ.

Quote:* Walter Bright takes suggestions from the programming community about which features he should add/remove, therefore the programmer almost has a slight ownership of the language/compiler

I don't consider this a good thing. A good language designer should be able to design the language practically himself. Coupled with fast evolution it sounds like a sure way to introduce bloat and remove consistency. I have to admit though that I don't know about exactly how the process of accepting new features work.

Quote:* Not everyone uses it yet, but then again this is a matter of time

Everyone sounds a bit optimistic.

This topic is closed to new replies.

Advertisement