Today I filled in certain gaps in my java knowledge. I wanted to start using C++ since c# is a microsoft only language. I really like how Visual stuidios looks compared to other compilers but I’m seeing that it wont compile on a mac or linux. I did some reading that it wont compile on mac, but if I code somthing in Visual studios and export the project, will it work on all platforms(windows, mac, linux)?
You know, you can get answers much faster on google.
C# has been an “open” language for years now (see Mono).
Cas
I did :-\ , I just didn’t find the answer I was looking for.
I know about mono, but I mean software alone, not games.
You’re thinking about Unity or MonoGame. Mono itself is a straightforward cross-platform implementation of the C# CLR - nothing to do with games.
Cas
You’re thinking about Unity or MonoGame. Mono itself is a straightforward cross-platform implementation of the C# CLR - nothing to do with games.
Cas
Oh, I thought mono was only for xna conversion. I’m so excited!
If you’re wanting to do cross-platform development on Windows, stay away from Microsoft products/tools.
Have a look at MinGW+MSYS, or Cygwin to allow some use of important UNIX tools. (Sorry, too lazy to provide links.)
The LLVM and GCC toolchains are probably about equal. LLVM is fresher and better designed for cross-platform development, but GCC has been around longer and is pretty solid
EDIT: Alternatively, you could have a look at Rust, which aims to be a competitor with C++.
Today I filled in certain gaps in my java knowledge. I wanted to start using C++ since c# is a microsoft only language. I really like how Visual stuidios looks compared to other compilers but I’m seeing that it wont compile on a mac or linux. I did some reading that it wont compile on mac, but if I code somthing in Visual studios and export the project, will it work on all platforms(windows, mac, linux)?
You can write cross-platform C++ using Visual Studio IDE (no ‘s’) and use the Visual Studio compiler and debugger to compile and debug under windows. You’d then take the same code and use a different IDE+compiler to build and run on other platforms like linux and mac (for mac, have a look at XCode).
The main snags are:
-
Unlike java, you’ll need to compile separately on each platform. Cross compilers exist but for desktop platforms aren’t usually that good. For big projects you’d typically have a build machine that runs different OSs in virtual machines to do all your builds.
-
It’s much harder to write cross platform C++. There are very few cross-platform apis, and even the ones that are cross platform need hand tweeking with per-platform #ifdefs (eg. BSD socket code on windows uses slightly different types than on linux and osx). If you go this route you’ll need to either write lower level code for each platform, or use a library (such as libpng) which provides cross-platform functionality for you. Additionally, different compilers have different quirks and handle standard C++ slightly differently, meaning you have to compile and test for each platform much more.
I would be incredibly careful about heading down this route. C++ is exceptionally low level, and writing a full game requires a lot of system level functionality. You will spend at least half a year just getting a basic pong game compiling and running identically on windows/linux/mac.
What problem are you looking to solve, exactly?
Vaguely on topic, personally I loathe the days I have to open Visual Studio. Compared to Java IDEs it feels so primitive and klunky.
If you want to do cross-platform, use a cross-platform ecosystem like Java.
You can use Visual Studio as an IDE for GCC. You have to use makefiles(and I used MSVS 2k8 so I’m not sure if this works on newer versions). With makefiles, you can set your arch targets(not that I’m good with makefiles).
I really don’t like to use MSVS as an IDE(except for when coding in C#). Why not use Eclipse CDT? I personally use CodeLite with Mingw though(Lightweight and cross-platform).
I used the Eclipse CDT to develop the Steampuppy libraries (well, to compile them on Linux, at least) and it made a lot of hair-pulling and wrangling incomprehensible commandline stuff go away. Wretchedly I had to use Xcode on the Mac. I think I cried the whole time.
Cas
@Orangy Tang I just wanted to dabble with other languages. I remember I started out with c#, and as a begginer switched languages every time i had a problem. I did have a Java textbook so i stayed with Java . I thought c++ was the foundation of most languages and when you code in it, it compiles on any OS. Is that only with the JVM?
@princec
Gosh, what a a pain.
I simply installed TDM GCC on windows and installed Code Blocks. The same IDE on Linux and also on Mac. (Installing XCode on mac also installs GCC) so it works the same way.
@Orangy Tang I just wanted to dabble with other languages. I remember I started out with c#, and as a begginer switched languages every time i had a problem. I did have a Java textbook so i stayed with Java . I thought c++ was the foundation of most languages and when you code in it, it compiles on any OS. Is that only with the JVM?
There are compilers for just about any OS you care to mention … the trouble is each OS works in rather different ways, so you have to put various macros in to your source for each difference to smooth over the cracks. Worse, you have to also accommodate occasional changes in machine architecture which C++ does not smooth over for you, either, eg. endianness, memory coherency behaviour, etc. (though the very latest C++ standard has apparently standardised on that last one at last). All of this stuff was helpfully abstracted over by higher-level programming languages such as the CLR and JVM.
In short it’s a royal pain.
There are two sorts of programmers you find in the wild: the ones that work in the bowels of the machine, covered in soot and oil and with odd personality disorders, tics and twitches - these are the guys that do the difficult stuff in C++ or C or even assembly. Then there are the ones like us, who live in the fresh air above and build beautiful castles atop the dangerous, dark, oily works beneath the earth. We are the lucky ones.
Cas
I was going to post saying: yeah I hate C++, but let’s not exaggerate. Basically you only have two OS families to think about unix-like and windows. And only two CPU families intel-a-likes and arm. So the #if defined(…) blocks aren’t so bad if you plan a little. And I was going to go on and lay out how you can work with C++ in a limited way and not cause yourself too much grief. You know what? Screw that.