Hacker News new | ask | show | jobs
by SomeCallMeTim 5437 days ago
I'm a long-time game programmer, and not at all an Apple fan (somewhat the opposite, in fact). When I picked up Android I really, really wanted to like it.

Every time I turned around, the Android platform surprised me. In a bad way. Full disclosure: I'm also not a Java fan, and think it was a completely brain-dead idea to make Java the first-class API. I'm certainly not a Microsoft fan, but even C#/Mono would have been better (not that I know any C#), if only so they wouldn't have had to waste time reimplementing the VM for licensing reasons. But it's not Java that I had a hard time with.

I've developed games on 12 different hardware/software platforms. There are so many things missing and/or broken about the way Android does things that I feel embarrassed for Google. Some of those things have subsequently been fixed, but many haven't, and some have been ignored in the bug database for YEARS now. A LOT of those things wouldn't have been problems if they didn't have so many layers between the app and the hardware (Java being one of those layers, but not the only problem).

As you say, it's really Not That Hard to just throw a simple app together that does what it needs to. Intents and Services are also ABSOLUTELY not the problem. The developer who wrote the original article didn't read enough of the docs or the right docs, or isn't as smart as he thinks he is -- the concept of Intents is not rocket science. The application lifecycle isn't even hard to understand -- it's laid out in the intro docs pretty clearly.

If only Android actually DID what those docs said, things would be a lot easier for a game developer. In fact, an "app" can be stopped and then a new one started before the old one actually receives its shut-down message. In the same (Linux) process -- so any native code with static data is still sitting around. One of many annoying problems I ran into.

I think the core mistake of almost every new platform is one of ego. "We'll design this NEW AND DIFFERENT platform in some revolutionary and awesome way, and make everyone rewrite their apps in this way feel is Better." When dealing with platforms, the one most important thing to do, in my opinion, is to HIDE the differences between one and another platform as much as possible. Android does this to some degree WITHIN the Android ecosystem, but we simply DON'T NEED multiple ecosystems. I submit it would be better for everyone if there were a single cross-platform engine that everyone used. Before I get dismissed as a kook, please think about OpenGL, and the fact that something as complex as a rendering subsystem IS in fact supported on all platforms, to everyone's benefit.

What would have been better is a library that abstracts away the fact that Android is its own unique OS, period. When I write code, I don't want it to be Android code, or iOS code, or WebOS code, or Windows [Mobile] code, or Linux code. I want it to be, as much as possible, completely cross-platform. I want the platform to fade into the background. You could bootstrap this by creating all the UI and other OS code as a portable layer that can run on many different systems.

But no new platform developer ever seems to get that, and so we end up with a new ecosystem for every new platform, and it's left to third parties to fill in the gap with cross-platform libraries. But it's not the developers -- or the users -- that big initiatives like Android get funded to satisfy.

/rant

4 comments

But no new platform developer ever seems to get that

I think everyone gets the value of cross-platform development, but in reality it's very difficult to achieve without enormous compromises and history tends to plot against it.

Apple's platform (Objective-C/Cocoa) can be traced back to NeXTstep. In 1988, it was the most progressive thing out there and some would say it still is. Apple leveraged their existing technology and ecosystem through OSX and all the way to iOS.

But the rest of the industry went in other directions. Objective-C/Cocoa would have been a strange choice for Android and would only have made it even more vulnerable to Apple's formidable patent arsenal. Instead, Android uses Java, which is also an attempt to leverage an existing ecosystem. But Android's fairly novel models of user interaction and application lifecycle required a whole new API. And Google had to reimplement the VM to avoid license fees, which still wasn't enough to avoid a patent attack.

In summary, as long as we have a) innovation and b) lawyers, we will constantly have to learn new development platforms which may not always be entirely novel.

@SomeCallMeTim >I submit it would be better for everyone if there were a single cross-platform engine that everyone used.

>What would have been better is a library that abstracts away the fact that Android is its own unique OS, period. When I write code, I don't want it to be Android code, or iOS code, or WebOS code, or Windows [Mobile] code, or Linux code. ---

There are options out there. I'm one of those 3rd parties soon releasing a comprehensive middleware solution for app dev including a lot of game dev oriented effort that provides a clean abstraction layer via a component architecture that uses a large majority of advanced Java language features under the hood without sacrificing performance.

Keep a watch out for TyphonRT; drop me an email via the contact address and I'll be glad to discuss more and make sure you get early access. I'm aiming to get it out ASAP and before I give an all day game dev workshop at AnDevCon II in November. I suppose one thing that makes TyphonRT unique is that it's a tool, framework, and future platform (PaaS). At the heart of things you can pick and choose individual blocks of functionality (tool), or utilize the runtime framework (framework), and soon there will be optional PaaS features aiding Android and cross-platform dev in the coming year after launch.

Another Java based cross-platform effort which is similar in purpose though significantly different at the architecture level is libgdx. For C/C++ check out Battery Tech and the Proton SDK for similar cross-platform efforts (both of these with even more device coverage).

TyphonRT provides that layer of sugar you seek without losing performance and creating full cross-platform execution for OpenGL apps without changing a line of code for J2SE -> Android. TyphonRT is not limited to OpenGL though and can utilize any graphics API potentially allowing a hybrid UI, but the rest of an app still being cross-platform.

Having worked intensely with Android since v1.0 and the G1 hit my hands in Oct '08 I have more than a few stories on the difficulty of low level development / games, etc. across different OS and major device hardware generations. I've experienced first hand a good deal of general engineering blunders and have found and reported a few major ones myself (you know when big G fixes a bug immediately upon being reported you found a good one; the 3.0 & 3.1 / NIO immutable endian swap issue comes to mind!).

Middleware will mature and soon provide a lot that the Android SDK lacks for certain app development areas. In many ways the Android SDK while novel in several areas is still being developed from an old engineering model, but that is seemingly unavoidable for a large organization such as Google. There are of course additional inherent problems with tying the SDK to firmware, but such is life.

I do agree with your last point though that generally the SDK in addition to the particular ecosystem quirks that have occurred over time isn't exactly indicative of satisfying developers.

Thanks, but I guess I didn't get across how much I still hate Java. ;) I feel it has 95% of the problems of C++, without the advantages (predictable speed, mostly). I'm sure your platform will be useful for anyone porting J2SE code to Android, but that's not me. And it doesn't look like you're supporting iPhone? That's a huge chunk of the market still.

I know that middleware providers will step in to fill in the gaps, but it's just annoying to be non-native on ALL platforms. And there are already a lot of options.

http://www.batterypoweredgames.com/batterytech is one that I know that's low level, for instance -- it gives you events, OpenGL and sound on Windows, Mac, iPhone, and Android. It's pretty bare-bones, though, as far as I know.

There are also stacks that allow you to write in JavaScript [1][2], 3d engines [3][4][5], and one that I just found out about one that sounds really awesome, though I haven't used it yet called Moai [6]. Moai is Lua-based, open source, supports iPhone and Android, and has a Lua-based cloud server component, so you can write in the same language for your game and for the server side in multiplayer games.

If I haven't been clear, I think Lua IS an awesome language, especially now that LuaJIT 2.0 works on Android (and at least partly on iPhone), and so I'm strongly considering using Moai for my next game.

I actually already use Lua on the server side, though I'm using a different stack than Moai (they're on Mongrel2/Tir, and I'm using Nginx with lua-nginx).

[1] http://www.sencha.com/ [2] http://www.phonegap.com/ [3] http://www.stonetrip.com/ [4] http://unity3d.com/ [5] http://irrlicht.sourceforge.net/forum/viewtopic.php?t=37235 [6] http://getmoai.com/

>Thanks, but I guess I didn't get across how much I still hate Java. ;)

Can't solve that.. ;) ;)

>I feel it has 95% of the problems of C++, without the advantages (predictable speed, mostly).

I suppose you'd have to get a little more particular in the 95% of problems angle. I have been working with Java for quite some time and TyphonRT contains necessary workarounds or API extensions enabling predictable speed. For instance TyphonRT being a Java based component architecture is highly dependent on iteration over collections of components. The custom collections API in TyphonRT has recycled and resetable iterators overcoming the "iterator problem" of the standard collections API. There is a bit more of other things done too to provide predictable runtime performance. A lot of that involves staying as memory efficient as possible and not triggering GC. Of course when things get too hairy yeah native code is used. One has to do that for physics engines (Box2D / Bullet) especially on Android. I'm really loving JavaCPP which is a relatively new effort for managing native bindings (http://code.google.com/p/javacpp/).

>I'm sure your platform will be useful for anyone porting J2SE code to Android, but that's not me.

If you are most familiar with C/C++ certainly by all means go with that and the NDK and use BatteryTech, Proton SDK, or something like that to provide the core cross-platform architecture support.

>And it doesn't look like you're supporting iPhone?

Not yet, but just like Unity which you mention cross-compilation is not out of the question. Like libgdx once the main framework is mostly finalized I'll be looking at say an Angle backed for the desktop and / or other options for expanding device and environment support. The primary goal is to create a leading edge Java framework / platform first. The platform / PaaS aspects also are a priority in the short term among many other things like strong Scala support / integration over say iPhone support. A thing to keep in kind too is that TyphonRT is not just aimed at game dev, but is applicable for all dev efforts including enterprise.

So yes, if you need cross-platform support go native or use a canned 3D engine like Unity if it matches the type of game you are trying to make.

>I know that middleware providers will step in to fill in the gaps, but it's just annoying to be non-native on ALL platforms.

Hrm? C / C++ is available on the majority of platforms... ?

>http://www.batterypoweredgames.com/batterytech is one that I know that's low level, for instance -- it gives you events, OpenGL and sound on Windows, Mac, iPhone, and Android. It's pretty bare-bones, though, as far as I know.

Yes it's not a complete game engine nor is Moai which you mention you have your eye on presently. BatteryTech, libgdx, and TyphonRT provide the core architecture to abstract the common requirements (input, audio, etc.) for real time apps & games. TyphonRT also has higher level optional components for game dev including a fully featured component oriented entity system (libgdx / BatteryTech, etc. don't). This class of tech is meant for folks that can build their own engines and perhaps their own creative games rather than trying to force canned engines to do things they are not great at doing. As mentioned though there are optional components with my efforts to further assist game dev efforts beyond core architecture abstractions.

Regardless of what you choose though I hope you make some cool games for Android! :)

>>I feel it has 95% of the problems of C++, without the advantages (predictable speed, mostly).

>I suppose you'd have to get a little more particular in the 95% of problems angle.

Hmm...getting very much off topic here, so I want to keep this brief, but roughly speaking I'm talking about the problems of the language being very verbose and missing a lot of useful features: no duck typing (C++ at least has templates, which have their own drawbacks -- Java generics need to be Object-derived), no coroutines, and no first-class functions are three examples that come to mind. Just look at the size of programs in the "Language Benchmark Game" -- Lua's entries are tiny compared to Java. Call me lazy. ;)

In addition, in Java you HAVE to force everything into an object paradigm, whether it makes sense or not. Lua can act object-oriented if you want it to, but you can also use it in other ways that simply make more sense to the problem at hand.

>Yes it's not a complete game engine nor is Moai which you mention you have your eye on presently.

No implied criticism there. As you mention BatteryTech is also low-level. There's a place for that.

For what it's worth, Moai does come with things like physics; not sure how they bind things together, but I would have guessed that they have a very basic engine with game objects. Could be wrong.

JavaCPP looks interesting, though I'm instead just minimizing my use of Java so I can have a Windows and iPhone version trivially.

>>I know that middleware providers will step in to fill in the gaps, but it's just annoying to be non-native on ALL platforms.

>Hrm? C / C++ is available on the majority of platforms... ?

Yes, but it's the API for getting events, putting up native dialogs, etc. that will be non-native everywhere. On Android more so than usual.

And actually...C/C++ isn't currently supported on Windows Mobile, at least in the public SDK, for what it's worth. Though C/C++ are supported on pretty much every platform where the company behind it isn't being stupid, yes.

No implied criticism toward your project in general, by the way. It's just not my thing, since I'm not a Java person. It does sound like you've solved a lot of the problems that people often have with Java, though, which is great.

>Regardless of what you choose though I hope you make some cool games for Android! :)

Thanks. :)

>Hmm...getting very much off topic here, so I want to keep this brief ... the problems of the language being very verbose and missing a lot of useful features

Yes, let's not belabor things, but I do want to point out that Scala essentially covers all of the points you raised. It supports duck typing (type safe too!), coroutines, first-class functions, and is more syntactically elegant. Scala even supports a particular mechanism to "sort of" support primitives w/ generics with the @Specialized annotation. So yes, I'm turning to Scala to provide additional language features and it's especially cool keeping type-safe aspects and being able to do joint compilation, so this works well for desktop / J2SE & Android integration. Of course Scala on top of the finely tuned TyphonRT / Java COP API and such is nice; more concise code for sure; this in addition to having access to all of the Java and/or Android SDK and 3rd party libraries. On the Java tip too regarding generics / Object situation TyphonRT has primitive collections available as well which is the main use case.

> Lua can act object-oriented if you want it to, but you can also use it in other ways that simply make more sense to the problem at hand.

I'd argue it's not a silver bullet as a primary language to write an entire game / engine in w/ more discussion continuing along those lines; there seems to be flexibility gained and lost. As a scripting engine that's one thing, but not a catch all for everything.

The important part here though and hopefully this ties back in a little with the OP and your concerns is that there are options available to take the edge off of mobile dev Android or otherwise and things should radically change in that regard in the next couple of years.

@seclorum is certainly correct that cross-platform mobile dev with OpenGL/ES is not out reach at all and once the C/C++ or Java decision is made depending on dev flexibility one can be creating rich content games not limited by a particular mobile OS concern.

Ultimately you want to pick the tool you are most comfortable and proficient with as in regard to indie game dev there are many other fish to fry let alone the hit based nature of the current app stores.

>For what it's worth, Moai does come with things like physics; not sure how they bind things together, but I would have guessed that they have a very basic engine with game objects. Could be wrong.

From what I read Moai supports Box2D. You know who else supports Box2D; everyone... BatteryTech, libgdx, TyphonRT, the list goes on, etc. etc. ;) It does sound like there is a basic game object API in Moai, but it only is geared towards 2D presently.

I know Robert of BatteryTech is doing a whole lot of Lua integration and work with BatteryTech, so do take a 2nd look and drop him an email perhaps.

>JavaCPP looks interesting

Indeed.. It's the 1st JNI / native marshaling assistance API that I like that takes the pain away of hand rolling JNI code. :)

>Yes, but it's the API for getting events

This is abstracted with most middleware mentioned. In fact input control is the largest category of core architecture components in TyphonRT (almost 10%).

>putting up native dialogs, etc. that will be non-native everywhere.

Why would you do this if you are creating an OpenGL/ES cross-platform game? Use a GL based GUI that will be cross-platform!

>It's just not my thing, since I'm not a Java person.

Fair enough hence why I'll stop posting on the thread! :) Though I did want mention some responses on the off the top general criticisms at the front of this reply. JVM languages will breathe some life into the Java sphere of things. This in concert with well developed middleware will make a lot of things that are hard now much easier soon enough.

It gets better.. ;P

OK, just going to answer a few points, to try to wrap this up. :)

>I'd argue it's not a silver bullet as a primary language to write an entire game / engine in w/ more discussion continuing along those lines; there seems to be flexibility gained and lost. As a scripting engine that's one thing, but not a catch all for everything.

I write a lot of the core "engine" in C++ for speed and lack of garbage creation. The game I've got on the Android market right now has about 3149 lines of C++ code specific to the game (not counting 7400 lines of auto-generated Lua bindings), but 10k lines of Lua code. Most of the game code is in Lua; is that scripting?

The engine itself has about 10k lines of C++ code, and very little Lua. I want the engine to be as fast as possible, so it's hard for me to imagine doing it in a language that isn't C or C++.

>>>putting up native dialogs, etc. that will be non-native everywhere. >Why would you do this if you are creating an OpenGL/ES cross-platform game? Use a GL based GUI that will be cross-platform!

Geting UI right is really, really hard. For the primary game UI, and dialogs with buttons, sure, all of it happens in GL.

But if I want a list dialog, or a grid view, or a WebKit view, I'm not going to want to do my own halfway implementation -- I'm going to want a dialog with a native feel. There's no game anywhere that I've used that really gets anything as simple as a keyboard entry field completely right, if it doesn't use the native UI; there are some things better left to the UI experts.

A good friend of mine is a big Scala fan, but I haven't really explored it as an option.

The thing that kills Scala for me (without knowing anything else about it) is that most platforms I write for don't already have a guaranteed JVM -- iPhone and Windows being big ones. I mean, sure you almost always have SOME JVM on Windows, but I'd likely want to be shipping a specific JVM.

And that means adding multiple megabytes onto my package size. You've got 20Mb on iPhone if you want to be able to download over the air. Adding 5Mb to support a language...isn't an option.

LuaJIT takes up about 50k. With all its libraries. And performs on par with Scala. Which is a huge win for me. How much overhead does Scala add to an app on Android? I bet it's more than that, even with the guaranteed JVM (well, DVM) preinstalled.

I've ported some 3D games, written in C++, to both iOS and Android .. and I don't get what the problem is? If you want to use OpenGL ES - just use it. Its quite feasible to have a full C++ - based game on Android and iOS, using the same codebase, with some environment-related (OS specific) glue code to get it working on the target platform.

I got my apps ported and basic iOS/Android shells set up, and I haven't had to go back to the code for the OS-specific stuff in 6 months - all the continued development work has been in C++ at the GL ES level.

So, I would say, if you do your work properly you can set up a very comfortable environment, as a games programmer, to support cross-platform development on these platforms with ease.

Yes, C# is way better for games because you can write mixed format display buffers, but Java isn't that bad as long as its JITed. It limits you to post 2.2 droids, but if doesn't have 2.2 on it, it probably has the shitest of graphics hardware anyway.

I dont get your other complaints though. Show me a developer guide for a console platform that doesn't have outright lies in it and I'll show you my unicorn.

There is a single cross-platform engine, btw, its called Unity, and if you can live with its constraints, then off you go.

Its not in the platform creators best interest to make it compatible with other platforms. So dont hold your breath for write-once that doesnt suck.

Not fond of C# or Unity, really, but there are plenty of cross platform game engines at this point; see my other post. [1]

Java is still annoying to me, even JITed. It's most of the cruft of C++/OOP without the speed. I'm a Lua fan, and a conversation here isn't likely to sway me. ;)

And it's not just mistakes; it's huge areas of the APIs that are missing or confusing or just plain poorly designed. I've developed for a lot of consoles (not current gen, but XBox/PS2 and older), so I know what you mean about docs being WRONG. But for the most part they let you do what you needed. Android just doesn't in some cases.

Try to do low-latency (or even reliable latency!) audio on Android and get back to me, for an example that Google is basically ignoring.

[1] http://news.ycombinator.com/item?id=2827513