Sponsored By

In-depth: Getting started with Google App Engine (for .NET developers)

In this reprinted <a href="http://altdevblogaday.com/">#altdevblogaday</a> in-depth piece, Novaleaf Software's technical director Jason Swearingen shares the steps he took to learn Google App Engine's basics, and to get a "hello world" app running.

March 15, 2012

5 Min Read
Game Developer logo in a gray background | Game Developer

[In this reprinted #altdevblogaday in-depth piece, Novaleaf Software's technical director Jason Swearingen shares the steps he took to learn Google App Engine's basics, and to get a "hello world" app running.] 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 I find the idea of a GAE based game server platform intriguing. But hey, I'm pretty much a one-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 are the steps I took to learn GAE's basics, and to 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 its various features. and learned from a high-level what GAE can and cannot 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 are 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 fanciness is available.

  6. Supports XMPP based chat protocol

  7. To summarize, GAE seems suitable for synchronizing with users every few minutes, so for save games, matchmaking, top scores, 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." It seems good, though their explanations detail using Eclipse, which is nice and all (and free) but not really 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 filesjavajdk1.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%libshared" also add liborm and libuser 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 three 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. [This piece was reprinted from #AltDevBlogADay, a shared blog initiative started by @mike_acton devoted to giving game developers of all disciplines a place to motivate each other to write regularly about their personal game development passions.]

Read more about:

2012
Daily news, dev blogs, and stories from Game Developer straight to your inbox

You May Also Like