Monday, July 27, 2009

Why we say c++ is not platform independent, as a game developed in c++ can be played on any sysyem?

this question was asked by a inreviewer to me. plz answer. we say that if we change a system then the program written in c++ gives errors if we try to run it on other system. then how the games are running successfully? plz answer

Why we say c++ is not platform independent, as a game developed in c++ can be played on any sysyem?
C++ is platform depending meaning that it has to be recompiled for each platform you want it to work on.





That means that you have to compile it for the PS2, as well as the XBox, as well as the Gamecube. You have to compile the game 3 times in order to make it available on 3 systems. The code works, being platform dependent doesn't necessarily mean it will produce errors.





Just so you know, sometimes compiling a big program or a game can take a day (sometimes even 2). Plus there are occasionally some differences - mostly in the interfacing mechanisms (controllers) that need to be changed. However, good programmers write a single part of the program that have the things that need to change between different systems, so they just replace the code with something a little bit different and the rest of the game works fine with it. This is called porting the code, and if you program with porting in mind it makes porting the code much easier.





Programming languages like Java rely on an interpreter. Which means that all you do is compile 1 time and that 1 thing you compile will run on anything that can run java.











That's what it means to be platform dependent/independent.
Reply:Platform independency need to be checked across OS as well using the same set of compiled files, something ran on Windows PC system here and run on another Windows PC system does not mean independent. Nor was a recompiled code. You could write a game, as simple as it could've been, on Windows, compiled it and ran, but when you move onto a Mac or Linux it need recompiled then it is not in a platform independent form.


No comments:

Post a Comment