What's the best cross-platform language?

54e97bcc4e4a2fc8f5f05594afd1683a
0
Gnarlyman 101 Jan 15, 2012 at 04:53

So…

In the sea of languages and APIs and whatnots out there, I’m trying to figure out exactly what’s the best compromise to make it easier to develop my games for PC and Mac OSes. Being a neophyte to this, I’m not exactly sure how to ask the question. I’d like to find a language and a few APIs by which it is easy to use to produce platform-independent code, or at least code that only require minor tweaks to hop around from OS to OS. I’m willing (and able) to go through a few hoops and code things like custom wrappers to handle it all. Even if I have to code a bit more to make things more adaptable, I’m cool with that.

Thanks!

28 Replies

Please log in or register to post a reply.

6837d514b487de395be51432d9cdd078
0
TheNut 179 Jan 15, 2012 at 22:36

Believe it or not, the answer to your question is “most”. Whether it’s C/C++, Java, C#, Python, Ruby, HTML, etc. These all work on Windows and Mac. It really boils down to what you are willing to work with. Sooner or later, you’re going to have to learn them all anyway :)

54e97bcc4e4a2fc8f5f05594afd1683a
0
Gnarlyman 101 Jan 15, 2012 at 23:53

I see. I’m just trying to avoid dealing with too many versions of final code. Really, I’m only familiar with the XNA platform using C#. I’ve always been curious what all is involved in producing a Windows port of a game and then a Mac; as in, what adjustments, if any, are done, and is so, in what part of the development do whatever differences manifest as issues?

Also, I’ve come across haXe on here. Did some research on it. Looks pretty good… Can it handle high-end game programming? If so, that looks like a really favorable option.

B5262118b588a5a420230bfbef4a2cdf
0
Stainless 151 Jan 16, 2012 at 11:02

haXe is okay at what it does, it’s no good for cross platform high end games. Even flash is being dropped in mobile devices, Adobe have stated they are no longer developing for it.

They have moved into HTML 5 development tools.

Doing true cross platform development is a pain, you have there options

1) Compile time generation
2) Interpreted code
3) Translated code

Compile time generation means that when you hit build all, a version is built for each platform supported, so you have one binary for each platform.
You have to rely on whomsoever creates the system to provide libraries and a compiler for each platform.

Interpreted code is the way Java ( puke ) works. You have a virtual machine for each platform but one binary. Generally virtual machines are limited in that they can only support the minimum spec hardware available. Since they have to run on all of the supported platforms, it’s tricky to get the VM to support special case hardware.

Translated code is the one I like, you compile to an intermediate bytecode that is translated into native code when you load the binary. You have a single binary that runs on all supported hardware without recompilation. You get the best mix of portability and speed.

Whichever system you plump for you are still going to end up with run time flags to handle missing hardware ( or maybe compile time flags for the 1st option)

Cross platform coding isn’t yet a simple task, unless of course you are only worried about a small subset of devices, but with the number of mobile phones still increasing and the number of games machines pretty constant, well it’s up to you how far you want to go.

820ce9018b365a6aeba6e23847f17eda
0
geon 101 Jan 16, 2012 at 13:00

I would say, it’s not so much a matter of what language you use, as what libraries you use.

If you stay with cross-platform libraries like SDL and OpenGL, your code will work on pretty much any (library-supported) OS.

8676d29610e6c98d6dd2d9c38528cd9c
0
alphadog 101 Jan 16, 2012 at 14:26

@Gnarlyman

What’s the best cross-platform language?

Everyone’s jumped the gun. You want a cross-platform language for what end? It’d be a different answer if you wanted to make a YATC (Yet Another Tetris Clone) versus I want Crysis 15 on everything. :)

54e97bcc4e4a2fc8f5f05594afd1683a
0
Gnarlyman 101 Jan 16, 2012 at 22:45

Hum hum, wow. You know, it was easy cruising around planning my game development around the 360 and XNA! I’ve recently realized that I really want to go PC, as I’m tracking trends about console gaming, online stuff, and generally, PC and digital purchases being the growing way to go.

Alphadog: no, lol, not a YATC; “real deal” games. I’m fairly content to master something essential like OpenGL and its shader libraries and use that to write cross-platform code. To be honest, out of the confines of console planning, I’m even confused somewhat as to all the levels of code–the various binary codes, compiler functionings, etc. I learned that stuff somewhere in the past, but being a 360er, I’m having to get a little more techie about what I usually just muddled over a bit more in abstractions. All I know is… I’d like to have a website where I let a user download what amounts to the “engine”, and then download “gamefiles/game packages” for each game I produce that the engine will intake. I’d like to have it all work on Windows and OS X. Linux, I dunno, I’ll start with the biggies. If I can employ a single content type (OpenGL and associated shaders, for instance) and make it all simple for me to hit both platforms, it’d be awesome.

B5262118b588a5a420230bfbef4a2cdf
0
Stainless 151 Jan 17, 2012 at 10:15

Have a look at Scrumm (may be Scrumm VM) , it was an engine for point and click adventures that has been re-engineered.

Now I don’t think you could use it as is, but it might give you some ideas about how you want to design your engine.

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 168 Jan 17, 2012 at 17:05

It’s ScummVM I think you’re thinking of, not Scrumm. Anyway, I haven’t looked at the source code, but realize that this engine is basically a reverse-engineered emulator for a proprietary engine that’s almost 25 years old now…so it may not have the best design or coding practices :)

54e97bcc4e4a2fc8f5f05594afd1683a
0
Gnarlyman 101 Jan 17, 2012 at 17:15

I’ll have a look at anyways, scope it out, see if there’s anything I can adapt in any way. Like I’ve said before, I’m just looking for the most straight-forward solution to allow PC and Mac gamers to download my engine and what game packages they would like and have it running in a jiff without hardware or code errors or checks. I’d just like to find a language (doing C++ and C# right now), a few basic APIs (OpenGL seems great), and code ‘er, get ‘er done, and have a nice package that’s fits most places. It’s hard to navigate the right solution to finding a home for my designed and protoyped code (away from that nice XNA world, that is… :(), especially with all sorts of things like binary codes builds, compilers, what that all means on different platforms. Sort of totally confused about all that right now. I’d stick to XNA, but I really truly need to target the other format.

820ce9018b365a6aeba6e23847f17eda
0
geon 101 Jan 18, 2012 at 11:14

More games besides Scumm-based ones have used a VM with a minimal executable. A great example is Another World. It was relatively simple to port to a lot of platforms since all that needed porting was the VM, not the game code.

http://fabiensanglard.net/anotherWorld_code_review/index.php

B5262118b588a5a420230bfbef4a2cdf
0
Stainless 151 Jan 18, 2012 at 11:30

The way we started was by creating macros for everything.

So you wrote the game in our own macro code, then just included a header file for the z80 or the 6502 or the 68000.

While that technique is way, way, out of date, the principle is still valid.

How about you take the source code of one of the many scripting languages and port it to the targets you want to support. Extend the basic language with a native rendering library, and code everything for that.

Or if you are only targeting PC and MAC, stick with the XNA you know and get involved in the mono port of XNA.

Don’t have time to look for the link, but I did look at it some time ago and there was quite a bit of progress on the project last I looked

8676d29610e6c98d6dd2d9c38528cd9c
0
alphadog 101 Jan 18, 2012 at 19:58

@Gnarlyman

I’d like to have a website where I let a user download what amounts to the “engine”, and then download “gamefiles/game packages” for each game I produce that the engine will intake.

In that case, any engine will do. Any engine loads a game world, or elements thereof. The fact that the download source is online vs local is a minor distinction.

Look for a few modern, cross-platform engines with source to learn from them. SFML, Irrlicht, etc. These all target the main OSes, but not many have desktop + mobile targets *and* available source. Then, to learn, get on forums to talk to the devs and ask why they made some of the decisions they made.

BTW, the upcoming Win8 platform screws up the cross-platform scene. And, depending on the extent of “cross-platform”, if you go with C#/Mono, you can add engines like Axiom and Horde3D. It’s not so much that the engine is cross-platform, as it runs on a layer that is itself cross-platform.

There’s also OpenTK to look at for cross-platformy ideas in the game dev realm.

820ce9018b365a6aeba6e23847f17eda
0
geon 101 Jan 19, 2012 at 10:49

@Gnarlyman

I’d like to have a website where I let a user download what amounts to the “engine”, and then download “gamefiles/game packages” for each game I produce that the engine will intake.

That’s exactly what Unity does. Since you already code in C#, you should feel right at home.

8676d29610e6c98d6dd2d9c38528cd9c
0
alphadog 101 Jan 19, 2012 at 15:20

What Geon said. I re-read your email, and realized you want to make cross-platform games. Somehow I thought you wanted to make a cross-platform engine…

54e97bcc4e4a2fc8f5f05594afd1683a
0
Gnarlyman 101 Jan 19, 2012 at 17:12

Great stuff, thanks. Great forum here, by far the best one I’ve been on.

So, it looks like something like Unity would do the trick. However, I wanna make sure I’ll be able to add my own “extensions” to the engine. That’s the reason I was developing my own prototype engine code in the first place, as I want to implement my own algorithms, shaders, and flat-out engine design pieces at certain places. Whether or not to take an existing engine and add-on or modify or to just build my own is the issue. I have several different approaches to matrices, lighting, and polygon manipulation that I’ve developed, and I’m figuring, what with help on this forum, that I’ll actually be able to use an existing 3D engine/platform and modify/add rather than cook my own deal up from scratch. The main thing is, I’d like to jump on board to an existing engine/API that can handle window functions, already has a math set, has interfaces with which to talk to the GPU, and…all that low to mid-level hard-core tech stuff that cooking up from scratch would be fairly bonkers to do.

So, in a way, I’m trying to have both cross-platform games AND a cross-platform engine. If XNA and that mono port deal could do the trick, or if I could structure my own C# code around Unity, then I’m good. But what’s this about Win8? Do I need to be planning around that? If so, does that screw up either or both of the XNA and Unity schemes?

B5262118b588a5a420230bfbef4a2cdf
0
Stainless 151 Jan 20, 2012 at 11:02

Win8 is a big argument at the moment.

It is organised in two layers. The new front end is based on HTML 5 and does not support any legacy code (no XNA, no Unity, etc.)

However Win8 intel based machines can still run legacy code, they just cannot use the new front end.

(Note this does not apply to risc based Win8 machines, even C# apps will not be supported on them which I find stupid)

Well at least that’s the state of play as I know it. There are a lot of arguments about what Win8 really is, and mixed messages coming out of Microsoft are not helping.

Just look at http://forums.create.msdn.com/forums/t/91616.aspx and you will see what I mean.

820ce9018b365a6aeba6e23847f17eda
0
geon 101 Jan 20, 2012 at 13:50

@Gnarlyman

Great stuff, thanks. Great forum here, by far the best one I’ve been on.

I know! always competent, helpful people around. I’ve been on this forum since Flipcode closed, and there since ‘99.
@Gnarlyman

I want to implement my own algorithms, shaders, and flat-out engine design pieces at certain places.

Algorithms - no problem.
Shaders - no problem
Engine design - might be a problem. It depends on what you want to do. If you buy the most expensive license (very, very expensive), you get access to the source, I think.

8676d29610e6c98d6dd2d9c38528cd9c
0
alphadog 101 Jan 20, 2012 at 15:55

@Gnarlyman

But what’s this about Win8? Do I need to be planning around that? If so, does that screw up either or both of the XNA and Unity schemes?

Windows 8 will create a dichotomous platform:

  • Metro/WinRT which currently is somewhat restrictive, where Unity may or may not go (and currently, the web player will not work there)
  • Desktop, where the current Unity will keep on being available. What this means is that, until some sort of “Unity For Metro” comes out, you will not be selling Unity games for Metro through the Windows Store. (Although, the store, I think, will have links to outside sites, but that means you have to run a store yourself.)

Anyways, Win8 is a long way out (release is maybe mid next year?), and will have a long adoption and transitional period after that…

54e97bcc4e4a2fc8f5f05594afd1683a
0
Gnarlyman 101 Jan 20, 2012 at 16:49

Thanks all, good input. Now, my turn…

Wowzers, I totally wasn’t up to speed on Win8. (I’ve been slowly migrating in body and consciousness towards Mac, and now other things are forcing me to get realz with Win and all.) I find that all quite odd… Is there a particular and strong reason why MS is flipping over so much of the apple cart for the new OS? I do understand, and applaud, much newness and more streamlined/simple techs when redoing an OS, but it doesn’t seem like backwards integration is huge there. I would wish that such things like XNA wouldn’t be “legacy” things that require a bit of shapeshifting to work, but something that can take a seamless step into the new environment. Darn… Crossplatform stuff was hard enough, nevermind crossing a platform within a platform…

Several peeps on that forum mentioned D3D11. Would using D3D within a simple .NET environment right now be the best way for me perhaps? I suppose I’d just have to wing it more on my own with the engine components. Not crazy about D3D being only Win though… Perhaps just OpenGL is my way to go. …Is that going to fly on Win8? Also, I couldn’t tell exactly the gist about C++ and C#’s future there…

Also, on Unity: I downloaded it yesterday, played around with it, learning about it. It seems it’s more of a “game creation” environment more than an actual code-oriented software (although I know that’s there judging from online tutorials). I need to be able to programmatically mess around with nuts and bolts polygon and vertex info, lighting junk, blah blah, basically a bunch of custom shader and algorithm stuff that needs to fit in the pipeline in its heart. I’m trying to ascertain how much of the raw pipeline Unity shields you from, which is something I’m trying to avoid. Deal is, as mentioned above, I have my own set of polygon and lighting algorithms which are unorthodox in some ways, and I’m trying to find an engine, platform, API set, etc., which allows me to use the root, raw basic graphics functions (like displaying a window and handling polygon and world matrices…simple simple) and then program the rest on my own. Unity looks awesome; I just need to be able to get down ‘n dirty with the code.

8676d29610e6c98d6dd2d9c38528cd9c
0
alphadog 101 Jan 20, 2012 at 21:26

@Gnarlyman

Is there a particular and strong reason why MS is flipping over so much of the apple cart for the new OS?

Nobody knows for sure. The most visible reason is to begin a transition from a desktop-only OS to one that can bridge multiple device types and thus stay relevant and plugged into where the biggest growth is happening. The other reason is to start a move away from the archaic Win32, which is very much tied to x86, and be able to move a little more swiftly with different architectures, namely ARM chips.
@Gnarlyman

I need to be able to programmatically mess around with nuts and bolts polygon and vertex info, lighting junk, blah blah, basically a bunch of custom shader and algorithm stuff that needs to fit in the pipeline in its heart.

Well, looks like you want something lower level then that offer you much more control. (Or, you want to purchase Unity and source) I would consider looking at Axiom. It’s a port of OGRE to C#, rides over Mono. Mono itself has C# targets for Android and iOS. One thing I’ve not found, but not looked for, is if someone has combined all these things into a really portable engine that usues C#. I happen to like that language, generally-speaking.

B5262118b588a5a420230bfbef4a2cdf
0
Stainless 151 Jan 21, 2012 at 10:12

@Gnarlyman

Would using D3D within a simple .NET environment right now be the best way for me perhaps?

Sorry, not even this is safe. I have been yelled at in other discussions for saying this but, I know I have read that Microsoft have announced they will be dropping .Net.

I cannot remember where I read it, but I remember it sparked a big meeting at work as one branch of our code relies on .Net.
@Gnarlyman

Unity looks awesome; I just need to be able to get down ‘n dirty with the code.

I am the same, hate “engines” like this that seem to be designed for graphics artists to create games.

54e97bcc4e4a2fc8f5f05594afd1683a
0
Gnarlyman 101 Jan 21, 2012 at 16:06

Thanks alphadog, I’m checking out axiom as we speak.

RE Win8: so, any read if people are excited about this? I gather it’s a push towards a very streamlined OS, taking into account that today’s OS is much more than what they used to be, and still are to a great degree. That is, with almost all devices and softwares out there making a “unified” push to some degree (as much as it is possible with whatever it is), merging together into a great technological whole, it seems Win8 is geared much more than Win32 to encapsulate all of this. However, I still never like when newness means making past things “legacy”, versus nice, seamless incorporation and integration. It also hurts when, in the midst of the modern tear to unify all technologies and devices into a streamlined body, several different companies are producing their own unified technologies…

Gosh, to just be able to program games, man.

RE Unity: yeah, that’s what it seems like to me, Stainless. I’ll check it out though, see if there’s anything I can garner from it.

820ce9018b365a6aeba6e23847f17eda
0
geon 101 Jan 21, 2012 at 22:35

@Gnarlyman

Also, on Unity: I downloaded it yesterday, played around with it, learning about it. It seems it’s more of a “game creation” environment more than an actual code-oriented software (although I know that’s there judging from online tutorials). I need to be able to programmatically mess around with nuts and bolts polygon and vertex info, lighting junk, blah blah, basically a bunch of custom shader and algorithm stuff that needs to fit in the pipeline in its heart.

Unity is a game creation tool. But it also let’s you “script” almost everything in C# (and their “Javascript” wannabe or Boo). Check out the scripting documentation, and you will get a better idea of what is possible.

You can’t really “mess around with the nuts and bolts”. But there are a lot of thing you can do anyway. You mention vertices and polygons. That’s no problem at all. You can access them individually with your code, or (I believe) through vertex shaders.

The lighting is implemented with shaders, so it should be no issue at all. You can create completely custom shaders with HLSL. (I think it was HLSL. Could be one of the other perhaps?) You can even create fallback fixed function shaders. You can also define in what order shaders should be rendered etc. if that is important.

Again, read the documentation. Unity is MUCH more competent than just a drag and drop toy game creator. Check out the games on their gallery.

A638aa42130293f319eda7fa4ba121f4
0
fireside 141 Jan 21, 2012 at 23:17

I just need to be able to get down ‘n dirty with the code.

You can add your own vertexes, shaders, etc, but you would be doing it calling Unity functions. If you already have code written, it would probably be a big rewrite. If you are using Unity, it’s generally for all the visual editors, etc. If you don’t plan on using those, it would probably be better to use opengl with something like SFML.

54e97bcc4e4a2fc8f5f05594afd1683a
0
Gnarlyman 101 Jan 22, 2012 at 05:43

Thanks a lot geon and fireside, awesome awesome. That def gives me renewed hope about Unity. One of the things I really really dig about Unity is how streamlined the cross-platform production is. Unless I misunderstood the basic rap sheet on it, it lets you whip up your game and then, with what amounts theoretically to a “one-click” dealio, produce an end package tailor made for whatever it may be…Win, Mac, Linux, Steam, heck, even iOS stuff. If I can work with the code pipeline–manipulate vertices, matrices, lighting, etc., custom shader, blah blah, it’d be totally dandy. Otherwise, I’m leaning towards OpenGL and SFML or whatnot. If I can do the aforementioned stuff in Unity, however, it’d be golden.

PS–on a totally unrelated note of unrelatedness–how to get an avatar up? None of the image posting things are working…not the image uploader, URL linker…nothing.

54e97bcc4e4a2fc8f5f05594afd1683a
0
Gnarlyman 101 Jan 22, 2012 at 07:03

PPS–here’s a quick hitlist, specifically, of things I’m looking unto Unity as far as if it’d be able to handle:
-Custom shaders for polygon and per-pixel lighting; basically, I need to be able to totally control all lighting functionings with custom algorithms.
-I need to be able to generate basic meshes in-game and then use custom algorithms to “mold” them realtime.
-I need realtime access to line segments; manipulate them and their onscreen drawing
-Total control in the AI department
-I also would like the ability to create, form, and animate objects within Unity without prior 3D model importation. More specifically, I want to be able to, like in something like OpenGL and XNA, input vertice points via code and manipulate and animate the resulting models via some of my own algorithms.

6837d514b487de395be51432d9cdd078
0
TheNut 179 Jan 22, 2012 at 15:31

@Gnarlyman

with what amounts theoretically to a “one-click” dealio, produce an end package tailor made for whatever it may be

Keep in mind it’s no cookie cutter process. A game that runs well for the desktop may require some quality downsizing to run well on mobile devices. If you build your games with good programming design patterns (particularly read up on the model-view-controller), you can minimize the amount of maintenance necessary to support multiple platforms.
@Gnarlyman

I also would like the ability to create, form, and animate objects within Unity without prior 3D model importation

I haven’t used Unity, but I’m pretty confident such a popular engine can do all of your above requirements. Most animation is done using bones (aka skeletal animation), which Unity does support. Lots of people make and sell games based off Unity, so give it a try and see where you go.

54e97bcc4e4a2fc8f5f05594afd1683a
0
Gnarlyman 101 Jan 22, 2012 at 20:33

Thanks T.N., well taken.

RE Unity and bones and all, I just posted a new thread in Graphics Theory and Programming about such things. If you can find it and have any insight as to my Q’s, it’d be great. Whatever the case, thanks for the input you’ve given.