Here at Novaleaf, we make consumer apps in addition to games. Our first web app is a Thai specific computer hardware eCommerce web app built on Google App Engine (GAE), using Java.
I’m historically (and well, currently) a .NET developer, but find the idea of a GAE based game server platform intriguing. But hey, I’m pretty much a 1 trick pony: “C# or nuthin.” (I can write C++ but hate it), so how do I get into the world of “weird” java buzzwords like servlets and WAR, in addition to the platform specific knowledge that makes up GAE?
One way would be to force one of Novaleaf’s webdevs to sit down and teach me. I might just do that, but… after I give it a try myself. Here’s the steps I took to learn GAE’s basics, and get a “hello world” app running. I hope it’s useful for other .NET developers looking to expand their skills in a relatively painless way.
First: Get a high-level picture.
I skimmed Google’s online resources about GAE and it’s various features. and learned from a high-level what GAE can and can not do, and what it will be able to do in the near future. I prefer to do this high-level overview first to frame the capabilities of the platform, so later when doing in-depth tutorials I can frame the knowledge in context to how it’d fit into my project’s needs.
I was a bit surprised about how well described it is, at least relative to Sun’s Java/Javadoc references. I am sure that for Java developers, the documentation is perfectly fine… but for people starting out, it’s a bit painful to figure out the difference between J2SE, J2EE, that Java “2″ is actually v1.2, etc etc… Anyway, no need to go into that here, right ;)
Second: will GAE do what I need?
Once I understand the general capabilities of GAE, I ask myself if it will do what I need? Well, I have a ton of ideas floating in my head, but to put this in perspective for a “simple game server” here’s some key points:
- GAE scales very well with multiple users (each request is on a separate thread)
- Storing intra-gamestate will be too expensive (GAE stores all state in database, so high-frequency read/writes will be monetarily expensive)
- Storing macro-level metagame information (low-frequency user information and matchmaking data) seems to be a good match for GAE’s feature set
- Per-user server polling is the only viable option for GAE right now (a socket api is in development but not yet ready)
- Threading is not supported right now (in development) so no multithreaded fancyness is available.
- Supports XMPP based chat protocol
- To summarize, GAE seems suitable for synchronizing with users every few minutes, so for savegame, matchmaking, topscores, achievements, etc. but not for high-frequency use .
Third: Find a good book.
I searched amazon for the highest rated books on the matter, and settled with “Programming Google App Engine“.
I am currently on chapter 2 of this book, following the tutorials to put together a “hello world”. Seems good, however their explanations detail using Eclipse, which is nice and all (and free) but not realy that user friendly to .NET developers comfortable with Visual Studio.
Fourth: Setting up the right tools
I did some research as to the most visual-studio-like java IDE, and came up with IntelliJ. Their Ultimate Edition also comes with GAE and Google Web Toolkit integration, so seems great to me. I’ll quickly summarize the steps I take to get the tools setup:
- Install Java6 JDK from Sun’s website (J2SE x64 is what I used) http://www.oracle.com/technetwork/java/javase/downloads/index.html Note that you must use v6.x with GAE
- Install IntelliJ Ultimate (11.x is what i used)
- Download and extract the GAE SDK to some reference folder on your HD: http://code.google.com/appengine/downloads.html#Google_App_Engine_SDK_for_Java
Run IntelliJ and create a new project with the following options:
- Setup a new project (Java Module)
- Under technologies, choose “Google App Engine”, choose the right SDK dir that you extracted the GAE SDK to.
- If not set, point JDK dir to the program files\java\jdk1.6.x dir (File–>Project Structure–>Project)
- Add J2EE servlet references: File–>ProjectStructure–>Libraries–>AppEngine API–>Classes->Attach Directory: “%PATH_TO_APP_ENGINE_API%\lib\shared” also add \lib\orm\ and \lib\user\ and \lib\
- Add GAE Javadocs for inline documentation: File–>ProjectStructure–>Libraries–>AppEngine API–>Specify Documentation URL–>“http://code.google.com/appengine/docs/java/javadoc/” also add “http://docs.oracle.com/cd/E17410_01/javaee/6/api/” for the shared library stuff, as GAE ships with parts of J2EE, but without the docs of it, so you have to point to Sun’s docs instead.
- Reconfigure Intellij for non-case-sensitive autocomplete: File–>Settings–>Editor–>Code Completion–>Case Sensitive completion–>None
- seems that the basic dir layout isn’t compatible with GAE. move the META-INF dir to be under the src dir
- For JPA persistence to work (needed for the book’s tutorials) you must change some settings: File–>Project Structure–>Modules–>Web–>GAE. Check “Run Enhancer” and set the persistence options to JPA.
After that, you should be able to follow the tutorials as shown in the Book I mentioned earlier, or get started with google’s own tutorials.
Summary: Pretty easy!
In total, I spent about 3 days figuring out these details and finish up my first “hello world” app and getting it published on GAE. If this information proves useful (or not), please leave a comment. I’d love to hear.