Fog Creek Software
Discussion Board




Tips, Advices for writting EASY to port code


What kind of tips, advices you would give me to write
*easy* to port code.

I'm planning to write a small video game that I would like
to port to a few system (PC, Pocket PC, Palm OS,Mac)

Is there any good articles, books regarding how to write
reliable and portable code across a wide range of platform?

Codex
Sunday, March 23, 2003

It's not a very extensive article, but it provides some key tips.

http://www.embedded.com/story/OEG20020924S0072

Myron Semack
Sunday, March 23, 2003

If you have games in mind, check out SDL, the Simple Direct-media Layer at [ http://libsdl.org ] -  It's what you should target.

If you want to target many platforms with a game, it better be a board game, or a relatively mild arcade game. Different systems differ to the extent that it's almost impossible to produce a fast paced arcade game that is addictive and compelling on more than one platform without optimizing for each platform individually.

Ori Berger
Sunday, March 23, 2003

Ori: I beg to differ.

id Software has written games for multiple platform for quite a while. I don't know about early ones, but Quake ran on DOS and Windows initially, and also had OpenGL acceleration available. Every game out of them since has. And they've always been pushing the envelope.

It's mostly done through the standard methods: wrap the important and system-dependant stuff. Rely on the OS's GL implementation.

But then again, they have many many years of experiance writing code at all the levels, so competing with him is hard 8-} But it can be done, feasibly.

Not to mention the after the fact Loki ports (not economically viable, but technically the succeeded.).

Mike Swieton
Sunday, March 23, 2003

Java?...

Java can just about do anything. really.
And it's on all the platforms that you require.

I know someone's going to jump in and say it's not performant enough. Please dont, because it's simply not true. Take this truly hot flight-sim...

    http://www.il2sturmovik.com

...it's all Java.

If pervasive computing across platform is what you're after,  Java has no equal.

Arron Bates
Sunday, March 23, 2003

All java huh?

IL-2 Sturmovik:MINIMUM SPECIFICATIONS

Computer: Pentium III 800/AMD Athlon 700 or better
Memory: 256 MB of RAM ( 512 MB is recommended)
Operating System: Windows(r)98/ME/2000/XP
DirectX: DirectX 8.1 or higher (included on disc)
Video Card: 3D video card (DirectX 8.1 compatible) w/32MB RAM (64MB recommended)
CD-ROM: 4X CD-ROM or better (Not recommended for use with CD-RWs)
Audio: Direct 8.1 compatible sound card
Internet/Network Play: Internet connection (56 kbps or better) or LAN for multiplayer
Hard Drive Space: 1.1 GB


So it's only Windows, uses DirectX, it uses dll's - so what part of it is java - the installer?

AEB
Sunday, March 23, 2003

In addition to the previous post, I can't help but note that there is nothing to download for this 'high-performance' java game.  Screenshots, sure, but I can make pretty screenshots with Gimp; it won't make a fast game.

Java CODE compiled to binaries for a single system has no reason to be slow.  But then, it also has no reason to be Java.  Multi-platform java DOES have performance issues, in spades.

Check out jEdit, and tell me that you honestly believe a text editor should take so long just to start.

Fred the Elastic Pancake
Sunday, March 23, 2003

The VM is packaged, and uses JNI native calls to their rendering engine & DirectX and the input control & sound.

If they advertised that it was all Java, people seem to remember the old 1.0 & 1.1 java apps and VM's and sandbag it. In their position I possibly wouldn't advertise it either. But it is true, the information is out there. Google away for it and other excellent examples of Java in the latest games.

And in reply to "Fred the Elastic Pancake" (dig the name BTW :), what a silly proposition that someone whiled away the hours to make a site just to link to it without having greater purpose.

The Java code wasn't compiled to native. It stayed as Java bytecode. and Java doesn't have performance issues "in spades". In many tests Java beats out natively compiled code because it's dynamically compiled instead of statically compiled.

As for JEdit... well... I don't use that puppy, but many Java IDE's have such issues as does many many native IDE's and other applications. As an aside, startup performance is being addressed in the very next java version 1.5. The Java IDE I use, IntelliJ IDEA doesn't really have a startup issue. It's the sweetest app I've seen written in anything.

All performance arguments aside, one thing that nobody really argues with about Java, it is that it's the most productive language to work with. Java's a hammer that's hit every nail that I've required it to hit, and enjoyed the results of nails it's hit by others (only app on tucows to get 5 stars on all platforms is a Java app).

But peoples, never fear... you can just take me as a rambling lunatic. Whatever I say will be met with just as eager rebuttals as my propersitions. I realise that most people here aren't giving Java a second look for anything. So I'm just going to say, sorry I bothered.

If anyone's got anything out of this tiny detour into Java... sweet... otherwise, move along, nothing to see here.

As said by Kevin Spacey's character in "Midnight in the garden of good and evil"...
"You believe what you're going to believe, and I'll believe the truth".
:)

Arron Bates
Monday, March 24, 2003

Java is the only language worthy of Enterprise software engineering. But I'm no so sure about gaming...

Tal Rotbart
Monday, March 24, 2003

---
All performance arguments aside, one thing that nobody really argues with about Java, it is that it's the most productive language to work with.
---

As a reluctant Java programmer, I will chime in and say that this has nothing to do with the language itself, but with the fact that some poor sod before you has already figured out your problem, then gone insane, and made his code downloadable somewhere.  The number of libraries and demo source code is staggering, so really, if you are actually _programming_ in Java, and not just munging some existing code together, you are probably doing something very wrong...

Also, the Java programmers of 1995-2000 set the bar extremely low, so managers don't expect very much. When I was coding 3-D math visualizations in C++ on NT, back in the old days, my bosses hated me for taking three weeks
to figure out some extremely hairy rendering code. Now with the magic combination of Java and Low Expectations, I can take a month to write a servlet that does "select * from table" and I'm employee of the month!

choppy
Monday, March 24, 2003

Mike: I'm not sure, but I think Quake was available for Dos before it was available for Windows - it definitely took some time until they released it for other platforms.

The original posted listed Pocket PC and Palm OS as target platforms. It's a totally different kind of effort to be 'cutting edge' in the Pocket PC arena and in the PC at the same time (and if you also target PS2 at the same time - well, my sympathy)

Oh, and SDL was initially created by Loki to ease after-the-fact porting, and I think all their ports use SDL (+OpenGL for some).

One more tip to original poster: Write plain C or something that compiles to plain C. Do not try to use the latest-and-greatest JVM features, C++ techniques etc - every environment has its own quirks with these. Work a little harder first, and make the porting work much easier later.

Ori Berger
Monday, March 24, 2003

Every platform have their obvious advantages.

But I think that it would all boil down to what Mr Spolsky said in one of his excellent articles about someone saying that his apps would be much easier to develop using a different technology, but that he didn't know it, so the best hammer to hit the nail for him was one that he knew, which was C++.

(I'd quote it, but I can't put my hand on it at the mo. "Lord Palmerston on Programming" covers much of it, but it's not the quote I'm after).

You would do yourself a disservice to go with anything that you're not comfortable with, if what you know can meet the grade (ie: can't write a graphics anything in ASP).

Arron Bates
Monday, March 24, 2003

http://www.avsim.com/pages/0102/il-2/il-2.html

"Next urban legend says, that IL-2 is coded in Java. Again, this assumption is based on rumors only, and has no substance. Java is used in IL-2, but just in small part. C++ is mostly used in coding this baby."


http://www.rolemaker.dk/articles/evaljava/errata.htm

"IL-2 Sturmovik (2001) by Maddox Games: Uses dirty Java by mixing Java with C++, such that logic and part of the game engine is in Java but all the graphics are in C++. This game has gotten very good reviews."


Again, this is far from a "java" game - still looking for some proof.

I've done client and server-side java development and there is a reason why I won't do client-side java again.

AEB
Tuesday, March 25, 2003

Java?? Yuck!  Write once, debug many, many, many times.

Portable code??  Forget about it.  Especially with games.

Bryan Shaw
Wednesday, March 26, 2003

>Java is the only language worthy of Enterprise software
>engineering.

This is simply untrue. Many custom applications are done with client/server still, in many languages. Doing desktop applications in Java is a waste of time. Java is OK for server side web development and such.

Patrik
Monday, March 31, 2003

*  Recent Topics

*  Fog Creek Home