Sign in to follow this  
Followers 0
linux

C# vs C++

21 posts in this topic

Hello everyone,
How come XNA was made in C# not C++? Many people know that C++ is much stronger than C# due to the fact that it is a lower level language. Also DirectX was originally made for C++ so using it in C# would mean that parts are begin cut off. So why C#?
0

Share this post


Link to post
Share on other sites
Why C#? Because the following statement is false:

[quote name='linux' timestamp='1296841358' post='4769611']
C++ is much stronger than C# due to the fact that it is a lower level language.
[/quote]
2

Share this post


Link to post
Share on other sites
C# is considered a more forgiving language. XNA was developed to enable hobbyist and indy game developers to compete with native games written for Microsoft platforms by the big(ger) studios.

Hobbyists/indies are more likely to trade things like full resource utilization for convenience and rapid development. For instance, using a garbage collected language vs managing memory explicitly.

DirectX is an API more than it is a language implementation of the API, you'll find bindings for many languages (including c#) that give you all the bells and whistles without "cut offs"
0

Share this post


Link to post
Share on other sites
This topic reminds me of an old joke, "In C++ it's harder to shoot yourself in the foot, but when you do, you blow off your whole leg." — Bjarne Stroustrup

The comparison made was to C. Idea being that C is even lower level than C++, thus easier to make a mistake in.

I wonder if a similar statement can be made about C# and C++.

Actually if you read Bjarne Stroustrup's FAQ (on his homepage), he mentions C# and how he's not a fan of a languages closely integrated with a proprietary OS, but he doesn't really comment on the language's functionality.




0

Share this post


Link to post
Share on other sites
[quote name='linux' timestamp='1296841358' post='4769611']
Hello everyone,
How come XNA was made in C# not C++? Many people know that C++ is much stronger than C# due to the fact that it is a lower level language. Also DirectX was originally made for C++ so using it in C# would mean that parts are begin cut off. So why C#?
[/quote]

DirectX was [b]not[/b] originally made for C++; it was made for C, and in fact the first few versions of DirectX were published before C++ was even officially a language. Doesn't that mean that using it from C++ would mean that parts are "begin cut off"? So why C++?
-1

Share this post


Link to post
Share on other sites
[quote name='Mike.Popoloski' timestamp='1296843943' post='4769634']
...in fact the first few versions of DirectX were published before C++ was even officially a language.
[/quote]
That's not even close to right.
0

Share this post


Link to post
Share on other sites
[quote name='SiCrane' timestamp='1296844637' post='4769638']
[quote name='Mike.Popoloski' timestamp='1296843943' post='4769634']
...in fact the first few versions of DirectX were published before C++ was even officially a language.
[/quote]
That's not even close to right.
[/quote]

Was it not standardized in 1998?
-1

Share this post


Link to post
Share on other sites
C++ existed as a programming language long before it was ever made an ISO standard. The first commercial release of C++ was in 1985 which was the same year that the first C++ book "The C++ Programming Language" was published. Unless, you're claiming that it requires an ISO standard to be an official programming language, in which case you're saying that Java isn't officially a programming language.
0

Share this post


Link to post
Share on other sites
Well I think XNA originally started as a replacement to managed DirectX, so the idea was for it to be managed code to begin with. A couple things fell out of this: letting Indies program for the XBOX 360, and XNA has become the 3D graphics API for the Windows phone.

[quote]
Many people know that C++ is much stronger than C# due to the fact that it is a lower level language.
[/quote]

Well I disagree that C++ is much stronger. In fact, the language barely evolves while C# and .NET makes my life easier every couple of years. In the end, you want to unload work to the GPU, so small amounts of overhead from a managed language are pretty negligible.
0

Share this post


Link to post
Share on other sites
[quote name='SiCrane' timestamp='1296845384' post='4769644']
in which case you're saying that Java isn't officially a programming language.
[/quote]

That wouldn't bother me at all B)
-1

Share this post


Link to post
Share on other sites
Ugh can we just delete these threads?

XNA is targeted at developers who don't have a huge C++ codebase to build on. C# is a better all-around language than C++. With programmable GPUs, less and less of the "must go fast" code is run on the CPU anyway, and the parts that do can be called from C#.

If that's not a good enough reason, they also don't want you to be able to run native code on XBox or phones.
0

Share this post


Link to post
Share on other sites
The original post is a bit confusing, because: XNA != DirectX. XNA is a abstraction layer over DirectX functionality. I know on PC/Windows it actually uses the DX runtime underneath, but XNA can be used on XBOX 360 and Windows Phone, too, so it's actually a multiplatform framework. Being an abstraction it sure hides some aspects but it also eases the overall use, hence forgiving again. AFAIR XNA officially is intended to be used only from C#, though. And, of course, there are means to get "bare" DirectX from C#/managed languages, e.g. with SlimDX.

"Stronger" is vague. Both languages (and others) have their advantages and disadvantages. And you can do very low-level stuff with a managed language like C#.

By the way: Was XNA really written [i]in[/i] C# ? Not C++/CLI or something ?
0

Share this post


Link to post
Share on other sites
As you gravitate towards higher level languages, everything becomes faster and also easier. By faster, I mean that you can get a game up and running much faster than a lower level language. By easier, I mean that the language is streamlined more towards people who do not want to concern themselves with the nitty gritty of programming. There are trade-off of course, functionality decreases and the programs execution time will generally decrease as well. How much this occurs depends on alot of factors, but I am speaking in generalities here, not absolutes. I realize there are examples where higher level code can create faster code than low level stuff, but in general, it does not.

So, this is why c# was created, to make it easier tor people to get into programming.
0

Share this post


Link to post
Share on other sites
[quote name='smasherprog' timestamp='1296847065' post='4769662']
So, this is why c# was created, to make it easier tor people to get into programming.
[/quote]

This is... entirely incorrect. The rest of your post is less absolutely incorrect, but pretty misleading.

I doubt we could find an authoritative 'why was C# greenlit?' answer, but it likely involves a lot of Microsoft internal specific business reasons to not use Java (due to Sun's ownership) and not use C or C++ (due to the difficulty in creating good, secure software in them). Making a language not low level is a design decision rarely made to help beginners but instead to make existing programmers more productive at stuff that doesn't require low level bit-fiddling (which is almost everything these days).
1

Share this post


Link to post
Share on other sites
I am sorry you feel that way. Hope you feel better thought. Hey, at least my post was, "less absolutely incorrect, but pretty misleading." That doesn't even make any sense.
0

Share this post


Link to post
Share on other sites
[quote name='smasherprog' timestamp='1296860517' post='4769780']
I am sorry you feel that way. Hope you feel better thought. Hey, at least my post was, "less absolutely incorrect, but pretty misleading." That doesn't even make any sense.
[/quote]
What he's saying is when you're not entirely wrong, what you're saying is misleading.

Honestly, I find it kind of silly you'd suggest C# was created to make it easier to get into programming. Higher level languages aren't made to make it easier to get into programming (arguably with the exception of the BASIC line of languages), they're made because systems these days don't need the intimate low level access and strict control over memory they used to need in order to get any resemblance of performance, and more time can be spent implementing your idea instead of boilerplate. The fact that C# is not miles behind C++ in performance and even under certain circumstances can outperform C++ is a testament to that.

Honestly though I think this thread should be closed. It's going to erupt into a war. They always do.
0

Share this post


Link to post
Share on other sites
This can get real ugly here.

A lot of entry level programming was taught in Java, in my university, exactly because it didn't have those low-level features. You could argue that higher-level languages are made for that. Though more experienced programmers like using them too, so it pretty much seems like a [i]personal preference[/i]!

[quote]Why C#? Because the following statement is false:

linux, on 04 February 2011 - 07:42 PM, said:
C++ is much stronger than C# due to the fact that it is a lower level language.
[/quote]

What does stronger mean? Someone mentioned "getting games up faster" .. ok,THAT is a definite statement. "stronger" is just an arbitrary measure, because C# DOES lack feature present in C++, and even if you don't like those feature and think they're just annoying, other people might find them quite useful.

I shouldn't argue about this, and I'm not going to post more, but it's a lot about personal preferences!

Also, XNA and C# go so well together partially because Microsoft are fans of their proprietary stuff, which, is another issue that people have with C#...but that's a whole other topic.
0

Share this post


Link to post
Share on other sites
[quote name='Milcho' timestamp='1296862775' post='4769797']
Though more experienced programmers like using them too, so it pretty much seems like a [i]personal preference[/i]!
[/quote]

No. There's significant differences between the two. Pretty much any metric you care to choose. The problem comes that for different programmers, for different problems, for different goals... there's quite a bit of variance. The best tool for the job varies, but it's certainly not based on what you like most.
0

Share this post


Link to post
Share on other sites
[quote name='Telastyn' timestamp='1296864064' post='4769804']
[quote name='Milcho' timestamp='1296862775' post='4769797']
Though more experienced programmers like using them too, so it pretty much seems like a [i]personal preference[/i]!
[/quote]

No. There's significant differences between the two. Pretty much any metric you care to choose. The problem comes that for different programmers, for different problems, for different goals... there's quite a bit of variance. The best tool for the job varies, but it's certainly not based on what you like most.
[/quote]
Edit: Yeah, I'm not going to respond to this.
I vote we close this thread.
0

Share this post


Link to post
Share on other sites
[quote name='linux' timestamp='1296841358' post='4769611']
Hello everyone,
How come XNA was made in C# not C++? Many people know that C++ is much stronger than C# due to the fact that it is a lower level language. Also DirectX was originally made for C++ so using it in C# would mean that parts are begin cut off. So why C#?
[/quote]


aside from any ridiculous and pointless arguments over which language is [i] better [/i].




XNA was done in c# for a two reasons.
- portability (bytecode level)
- security (walled off access to hardware, especially the 360)


it has very little to do with language choice (other than ms evangelising c#).

0

Share this post


Link to post
Share on other sites
XNA uses C# rather than C++ because of the fact that C# is more portable than C++. The XNA framework was designed for game development on the XBox 360, PC, and Zune. C# is very similar to Java in that the compiled code is interpreted by the platform at run time. This cannot be done with C++ without recompilation, or massive code re-writes and porting issues. So to answer your question: for portability........ and the fact that C# SHOULD be much easier for hobbyists and indie game programmers to use for quick game development.
0

Share this post


Link to post
Share on other sites
Closing topic.

Other than the fact that the information about "C++ vs C#" (whatever THAT means) is commonly available via a trivial search, these threads also tend to turn into flame wars fed by ignorance from all sides.
0

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0