Jump to content

  • Log In with Google      Sign In   
  • Create Account


C# vs C++


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • This topic is locked This topic is locked
21 replies to this topic

#1 linux   Members   -  Reputation: 100

Like
0Likes
Like

Posted 04 February 2011 - 11:42 AM

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#?

Sponsor:

#2 superpig   Staff Emeritus   -  Reputation: 1825

Like
2Likes
Like

Posted 04 February 2011 - 11:49 AM

Why C#? Because the following statement is false:

C++ is much stronger than C# due to the fact that it is a lower level language.


Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse


#3 wanderingbort   Members   -  Reputation: 136

Like
0Likes
Like

Posted 04 February 2011 - 12:00 PM

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"

#4 Milcho   Crossbones+   -  Reputation: 1171

Like
0Likes
Like

Posted 04 February 2011 - 12:25 PM

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.






#5 Mike.Popoloski   Crossbones+   -  Reputation: 2856

Like
-1Likes
Like

Posted 04 February 2011 - 12:25 PM

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#?


DirectX was not 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++?
Mike Popoloski | Journal | SlimDX

#6 SiCrane   Moderators   -  Reputation: 9418

Like
0Likes
Like

Posted 04 February 2011 - 12:37 PM

...in fact the first few versions of DirectX were published before C++ was even officially a language.

That's not even close to right.

#7 Mike.Popoloski   Crossbones+   -  Reputation: 2856

Like
-1Likes
Like

Posted 04 February 2011 - 12:42 PM


...in fact the first few versions of DirectX were published before C++ was even officially a language.

That's not even close to right.


Was it not standardized in 1998?
Mike Popoloski | Journal | SlimDX

#8 SiCrane   Moderators   -  Reputation: 9418

Like
0Likes
Like

Posted 04 February 2011 - 12:49 PM

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.

#9 Quat   Members   -  Reputation: 402

Like
0Likes
Like

Posted 04 February 2011 - 12:59 PM

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.

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


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.
-----Quat

#10 Mike.Popoloski   Crossbones+   -  Reputation: 2856

Like
-1Likes
Like

Posted 04 February 2011 - 01:07 PM

in which case you're saying that Java isn't officially a programming language.


That wouldn't bother me at all B)
Mike Popoloski | Journal | SlimDX

#11 typedef struct   Members   -  Reputation: 230

Like
0Likes
Like

Posted 04 February 2011 - 01:08 PM

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.
Anthony Umfer

#12 unbird   Crossbones+   -  Reputation: 4863

Like
0Likes
Like

Posted 04 February 2011 - 01:11 PM

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 in C# ? Not C++/CLI or something ?

#13 smasherprog   Members   -  Reputation: 428

Like
0Likes
Like

Posted 04 February 2011 - 01:17 PM

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.
Wisdom is knowing when to shut up, so try it.
--Game Development http://nolimitsdesigns.com: Reliable UDP library, Threading library, Math Library, UI Library. Take a look, its all free.

#14 Telastyn   Crossbones+   -  Reputation: 3724

Like
1Likes
Like

Posted 04 February 2011 - 02:45 PM

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


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).

#15 smasherprog   Members   -  Reputation: 428

Like
0Likes
Like

Posted 04 February 2011 - 05:01 PM

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.
Wisdom is knowing when to shut up, so try it.
--Game Development http://nolimitsdesigns.com: Reliable UDP library, Threading library, Math Library, UI Library. Take a look, its all free.

#16 Flimflam   Members   -  Reputation: 657

Like
0Likes
Like

Posted 04 February 2011 - 05:37 PM

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.

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.

#17 Milcho   Crossbones+   -  Reputation: 1171

Like
0Likes
Like

Posted 04 February 2011 - 05:39 PM

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 personal preference!

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.


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.

#18 Telastyn   Crossbones+   -  Reputation: 3724

Like
0Likes
Like

Posted 04 February 2011 - 06:01 PM

Though more experienced programmers like using them too, so it pretty much seems like a personal preference!


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.

#19 Milcho   Crossbones+   -  Reputation: 1171

Like
0Likes
Like

Posted 04 February 2011 - 06:27 PM


Though more experienced programmers like using them too, so it pretty much seems like a personal preference!


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.

Edit: Yeah, I'm not going to respond to this.
I vote we close this thread.

#20 Matt_D   Members   -  Reputation: 247

Like
0Likes
Like

Posted 04 February 2011 - 07:39 PM

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#?



aside from any ridiculous and pointless arguments over which language is better .




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#).


your never as good as they say you were, never as bad as they say you was.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS