This is not about language, but about technology.
Why? First of all, you need to realize one important thing you don't seem to realize:
no executable module can run natively on both Windows and Mac OS X. Key word here is
natively. I mean, you need to understand how programming of native code is done: you can develop some program and compile/link it, get binary code written in CPU instructions, executable module. Then, having some OS, in its core installation, without any additional layers, you can take your compiled code and copy on this system. It will work only if the code is targeted to a compatible OS.
For example, you can develop Windows code which will run on several different Windows versions. But not on Mac OS X. And visa versa. Even of you target identical CPU and those are exact the same CPU uses on both OS.
In this aspect, these OS have nothing in common. The code will need recompilation. And even then it cannot be incompatible, due to different platform API. Only the simplest console-only code could be recompiled directly for two platforms to run natively. And yet, cross-platform development, being problematic, is still possible. You need some
abstraction layers on both systems, some platforms developed separately and ported on both systems. Your code should be developed for this abstraction layer, not specifically for core OS.
See also the comment to the question by Richard MacCutchan.
So, we need to discuss some non-native approach to cross-platform programming.
Non-native: P-code
First of all, let's explore
non-native possibilities. I would classify them into two major approaches: system working with
p-code ("byte code") and systems working with
scripting (interpretive) languages. You can find the information on the systems based on p-code here:
https://en.wikipedia.org/wiki/Bytecode[
^].
By far, two most widely used systems are JVM and CLR. JVM is implemented for nearly all modern OS, and CLR is represented by .NET and Mono for Windows, and Mono for Mac OS X. The flagship languages are Java and C#, but there is a big set of different languages giving equivalent p-code, Java byte code for JVM or CIL of CLR. Please see:
https://en.wikipedia.org/wiki/Java_virtual_machine[
^],
https://en.wikipedia.org/wiki/Java_virtual_machine[
^],
https://en.wikipedia.org/wiki/Java_%28programming_language%29[
^];
https://en.wikipedia.org/wiki/Common_Intermediate_Language[
^],
https://en.wikipedia.org/wiki/.NET_Framework[
^],
https://en.wikipedia.org/wiki/Mono_%28software%29[
^],
https://en.wikipedia.org/wiki/Common_Intermediate_Language[
^].
The issues of compatibilities between implementations of these platforms for different OS could be a topic of endless dis discussions, but generally, if you write your code in cross-platform manner, not directly using any OS-specific features, you will get the programs which can be directly executed on different OS,
without recompilation.
Non-native: scripting
Now, let's discuss the technologies using
scripting based on
interpreted languages:
https://en.wikipedia.org/wiki/Interpreted_language[
^].
As you can see, there are too many of them, to many to review any here. Except just one: JavaScript. Why? As you should understand, the abstraction layer in this case would be some run-time engine interpreting and executing the code. There is just one engine used on all general-purpose OS: JavaScript engine embedded on browsers. Can you do general software development bases on this? Yes, of course. One common misconception is that JavaScript and the browser itself is only for Web. This is not so: you can develop and run code totally independent from Web. After all, look at a couple of examples in two my articles:
Tetris on Canvas[
^],
JavaScript Calculator[
^].
The "Web factor" is the most powerful factor which lead to the states of affairs where JavaScript is the most stable and standardized language in this class of products:
https://en.wikipedia.org/wiki/ECMAScript[
^].
Two interesting examples not based on just the common-use browsers are, say, Chrome OS and Apache Cordova:
https://en.wikipedia.org/wiki/Chrome_OS[
^] (sorry that this example is unrelated to both Windows and Mac),
https://en.wikipedia.org/wiki/PhoneGap[
^],
https://cordova.apache.org[
^].
One of the limitation is file storage I/O, but this problem is solvable:
http://en.wikipedia.org/wiki/Web_storage[
^],
https://developer.mozilla.org/en-US/Add-ons/Code_snippets/File_I_O[
^].
Native: recompilation, OS and UI abstraction-layer libraries
And finally, let's quickly explore the
compiled language compiling in
native code. The abstraction layer in this case will be some OS abstraction layer, which mostly should cover one thing most problematic in terms of compatibility: the UI. This abstraction layer can be just the library with the same API implemented on both OS.
Again, its impossible to discuss all possibilities, but I would emphasize just two: Free Pascal and C++.
Free Pascal is open-source and can be developed with the IDE implemented on many platforms, Lazarus. And Lazarus comes with excellent cross-platform UI library. Please see:
https://en.wikipedia.org/wiki/Free_Pascal[
^],
https://en.wikipedia.org/wiki/Lazarus_(IDE)[
^].
This is my favorite example of such cross-platform product, still in beta and active development. You can enjoy it even now; it's actually very useful:
https://en.wikipedia.org/wiki/Double_Commander[
^],
http://doublecmd.sourceforge.net/[
^].
And, finally, about the cross-platform development in C++; please see my past answers:
Visual Studio Application for Target OS Windows and Linux[
^],
How to Compile Visual studio C++ to linux and os-mac[
^],
What`s the Problem with this Plot Program win32[
^],
writing c/c++ visual programs (cross-platform) with which IDE and compiler?[
^.
Good luck,
—SA