Jump to content
  • Advertisement
Sign in to follow this  
Hrafnorri

C# more portable than C++?

This topic is 3085 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello Forum
I'm thinking about learning C# or C++ to make 2D game and I started reading about C++ a few minutes ago and it says C# is much more portable than C++. This is what it says "To create a c++ program that would run in a variety of environments, several different executable versions of the program are needed." so my questions are the following:
Is C# more portable than C++? and if so how hard is it to make a C++ program that works in variety of environments?
And if I'm trying to create a 2D game for Windows which language should I choose C# or C++?

Share this post


Link to post
Share on other sites
Advertisement
In my opinion C++ is more portable compared to C#.

But I think for a small 2D game that would only run on Windows choosing C# would be smarter. You don't really have a portability problem if you only make it for Windows.

Share this post


Link to post
Share on other sites
What the heck does "more portable" mean? C# can be run on a wide variety of platforms. C++ can be run on a wide variety of platforms. There's a lot of overlap between the two, but there are platforms that don't run C#, and platforms that don't run C++. C# conveniently tends to use a unified binary for some platforms, but that's a relatively minor detail. And it doesn't work switching between the regular framework and compact, for example.

Share this post


Link to post
Share on other sites
As reptor said, the real question is why do you care if it's portable or not if your goal is to make a 2D Windows game?

C++ do indeed need recompilation for binaries to work on different platform, but the exact same code will often do. It's just a matter of re-building it with another switch to the compiler. http://gcc.gnu.org/install/specific.html

As for C#, while it's true that the same binary could run in different platform, that's because it's managed code ran by the installed library dlls on the system. Problem is, these dlls were originally only available on Windows. A project called Mono ( http://www.mono-project.com/ ) started which allow you to execute C# binaries on many platforms, but I never tried it.

The biggest decision would probably be which third party libraries your application will use. If you use a graphical library like SDL, it will be easy to cross-compile. But if you choose DirectX/XNA, don't expect your game to be running on embedded Linux soon.

Share this post


Link to post
Share on other sites
Thanks guys, I have decided to go with C++ and so far it has been the most user friendly language I have ever learned. But you know have only been reading about it for a day now so that might change :D

Share this post


Link to post
Share on other sites
Huh! C# is much more friendlier (or "forgiving") and easier than C++.

I use C++ though ;)

Share this post


Link to post
Share on other sites
Quote:
Original post by Shanee
Huh! C# is much more friendlier (or "forgiving") and easier than C++.

I use C++ though ;)


I'll second the fact that c# is more user-friendly and does a lot more work for you to begin with. It has a simpler syntax similar to that of Java. It's object-oriented, and that's very crucial. Lastly, you get XNA. XNA isn't going to help with your portability (you'd need an emulator for non-Windows platforms) but it's still a powerful tool.

Most programming languages are highly portable, so that's not a huge issue. I personally don't think that using a language because of its popularity is always a good choice. Syntax is important, and so are the paradigms involved.

Share this post


Link to post
Share on other sites
C# is much more friendly as compared to C++
In fact C# code is much more understandable, and you spend most of your time creating the actual game code, unlike C++ which is superior but requires a lot of unnecessary code and thinking.
XNA framework is much easier to use as compared to native DirectX or OpenGL or most of the other libraries.

Anyway, the thing you read actually means this:
Say you create a program in Visual C# using .NET... When you give it to people, the program will run on all versions of Windows regardless of the hardware / software specifications.

C++ however would require you to compile the code specific to the target architecture, software, etc... Usually this wouldn't matter since most programs would work on any version of Windows anyway.
Like 32 bit software runs on 64 bit Windows anyway, and most software does not have compatibility problems between versions... In case this happens with the C++ problems, C# would run smoothly on all windows platforms.

C# is Windows only, this is where C++ would be more portable... C++ code works on almost all platforms and OSes. Only limitations are the libraries and Widows / Linux specific code that you create.

Share this post


Link to post
Share on other sites
I'm not an advocate for mono, altough it might seem this way since I've posted more on the subject before.

But, mono seems to be a decent way to port C# to other platforms (Linux and OSX among them). Has anyone tried this? Sounds from the deep argue it's a better crossplatform choice than Java (since mono software will be as native as .Net in Windows).

Share this post


Link to post
Share on other sites
I doubt mono works well with DirectX or XNA... There are some other libraries that can be used, but none are "very" good.

The OP, however wants to create a "Windows" game so Linux / OSX compatibility shouldn't be their major concern.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!