Technical Director and Chief Architect of Novaleaf Software (and Novaleaf Game Studios!) Novaleaf is Thailand's leader in real-time simulations, and is located in Bangkok. Jason is about as 'expert' at C# as one can get, and has a passion for high-performance simulations (scientific or otherwise) While Jason has a Linked-In, Twitter, and Facebook account, he never checks them. Apologies, email me!
Posts by Jason-Swearingen
  1. Kickstarter campign isn't looking so hot? ( Counting comments... )
  2. Want to get Kickstarted? Here’s what you need to know... ( Counting comments... )
  3. [Video] Why Salt is good for you: Handling password security in web applications ( Counting comments... )
  4. Getting started with Google App Engine (for .NET developers) ( Counting comments... )
  5. How to Architect a Worker Thread subsystem, step-by-step (C#) ( Counting comments... )
  6. MapFold: Simplifying Inter-Thread Communication. ( Counting comments... )
  7. Lock-Free Queue ( Counting comments... )
  8. Spatial Partitioning. Part 1: Survey of spatial partitioning solutions ( Counting comments... )
  9. Nobody Gives a Shit: Introspections of a start-up indie studio’s dealings with publishers. ( Counting comments... )
Technology/ Code /

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:

  1. GAE scales very well with multiple users (each request is on a separate thread)
  2. Storing intra-gamestate will be too expensive (GAE stores all state in database, so high-frequency read/writes will be monetarily expensive)
  3. Storing macro-level metagame information (low-frequency user information and matchmaking data) seems to be a good match for GAE's feature set
  4. Per-user server polling is the only viable option for GAE right now  (a socket api is in development but not yet ready)
  5. Threading is not supported right now (in development) so no multithreaded fancyness is available.
  6. Supports XMPP based chat protocol
  7. 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 .
So this is all fine by me.   Current GAE features seems to restrict my game-use to matchmaking services only, though if I want to get creative with the XMPP functionality, it may be possible to introduce a high-latency gamestate server, though the adding of sockets to GAE in the future also looks promising.

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:

  1. 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
  2. Install IntelliJ Ultimate (11.x is what i used)
  3. 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:

  1. Setup a new project (Java Module)
  2. Under technologies, choose "Google App Engine", choose the right SDK dir that you extracted the GAE SDK to.
  3. If not set, point JDK dir to the program files\java\jdk1.6.x dir  (File-->Project Structure-->Project)
  4. 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\
  5. 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.
  6. Reconfigure Intellij for non-case-sensitive autocomplete: File-->Settings-->Editor-->Code Completion-->Case Sensitive completion-->None
  7. seems that the basic dir layout isn't compatible with GAE.  move the META-INF dir to be under the src dir
  8. 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.