Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

WoA 2016 | Team Bytetroll | Postmortem

Sign in to follow this  


I'd first like to apologize for the failure to provide community write-ups during the Week of Awesome. When I had initially started, I had fully planned to write a journal post a day, however, after day two of development, it became obvious that I was going to have to push aside lesser priority tasks, as the coding portion of this project took more effort and time than expected.

Regardless, this postmortem post will be lengthy as I believe that keeping the community updated though the journal posts is not only important, but a major part of what makes the Week of Awesome competition so challenging and rewarding. One does not get the full experience of surviving a project development life-cycle if the documentation (or in this case, community) phase is skipped!

This postmortem will expand on my previous diary posts. If you have not read my previous posts, and would like to, the posts can be found in my "WoA" developer diary, which can be found at the following link:


With that all being said, lets get started with Team Bytetroll's postmortem post.

As noted in my previous posts, I had a bit of bad luck this year. My normal tried-and-true team was busy with real life and alerted me to the fact that they couldn't participate this year (although, a day or two before competition, Riuthamus found out he had the week free and decided to compete; leaving me to compete against my own team). Furthermore, I had made the mistake of following the workflow I had taken in previous years and preplanned a week from competition start. While preplanning is normally good (yet alone a must), in retrospect, I took the wrong route when it came to selecting a programming language for the project. I had initially selected Java as my language of choice for three reasons:

1) Java has fast turn around time.
2) Java (for the most part) is stable and reliable.
3) Java (for the most part) is write once, deploy everywhere.

Moreover Java seemed like the logical choice as I have many years of experience in Java development (although not writing games) and am very familiar and comfortable with the Java universe (tools, the way things are done, etc). Also, despite slot machine gameplay being the only type of gameplay I had never researched or implemented in my 15 years of working in the industry, I figured that it was a slot machine, and there shouldn't be too much logic behind it. However, again, looking back in retrospect, this mentality would soon cost me.

It is at this time, however, that I would like to note that a majority of my frustration was not with the language itself, but with the limitations of the language -- something of which I should have foreseen. My original thinking was that several games had been coded in Java, all of which have at least average console performance. I found myself overlooking the fact that Java lacks a true programmer managed memory mechanism at the language level -- which is almost a must for any game. This proved to be the real hassle. Despite me being a first time LibGDX user, I had done my required research; making sure I was aware of their memory management scheme for releasing native objects. However, for what ever reason, I overlooked this fact, and didn't plan or account for it when creating my framework. The result was that my UI class was leaking obnoxious amounts of memory due to the way that I wrapped LibGDX's native "Texture" class. To make matters worse, I knew were and why the memory was leaking, but after multiple attempts (from both I and Migi0027) to patch it, had no way to solve the problem without a total rewrite of my framework (which at that point was close to 100 files and five or six thousand lines of code). As a result, I had to resort to my backup plan; knowing full well it was going to severely hurt my week. Despite this I kept true to my original promise[1]. I quickly cloned our in-house 'javac' compiler that I wrote and maintain at work and spent the next two days adding C++ style memory management to Java (which actually turned out pretty well). While it was a pain, it solved all of my leaking memory issues, and surprisingly turned out to be easier than rearchitecting my framework. This was not an ideal solution by any means, but given the context, it was my last and only option to stay alive in the competition..

After the memory leaking issues had been resolved, I was able to continue on with my last few days in peace; ultimately wrapping up and compiling my final build the morning of competition end. Implementing and structuring the slot logic was bit of a hassle, but an event system took care of that.

Other than that, there is not much left to say. I am considering open sourcing my project and am thankful I got the chance to compete again. It was a hell of a week and I had fun. I'd like to once again thank Sean Forbes (Riuthamus) and Miguel Petersen (Migi0027-cdk) for everything that they did for me during this week -- especially to Sean, who took the time to hand draw my assets, despite him having to create assets on his own team's WoA project. To both of you, I greatly appreciate it. You allowed my project to ship (literally).

- The Troll

[1] [size=1]Before competition start I made a personal promise to myself that no matter what happened, I was going to follow through, push, and finish the project -- even if that meant that the project was going to be shipped incomplete... even if that meant that I was going to have to finish the project after competition end.

Sign in to follow this  


Recommended Comments

Wait wait wait, you modded the Java language itself for your competition entry?! That is truly impressive!


As a fellow Java dev (professionally) I am curious: Why do you have your own javac implementation?

Share this comment

Link to comment

Unfortunately, yes... and I wish I didn't have to.  One should never have to stoop to that level; ever.


To answer your question, there are several reasons that we maintain a javac implementation.


1) I had initially started the javac implementation with the release of Java 1.7.  At the time, I was doing a lot of embedded systems programming with robots (I was compiling certain files on-the-fly) and I needed to have a standalone Java compiler that resided on the system.  Sadly, this is never as easy as just copying from your JDK folder and throwing it on the local filesystem.  Furthermore, for specific projects, I had used a modified JDK, so it only seemed logical. 


2) Java is very good at what it does, but it doesn't always do it in the best way.  Java is a powerhouse, but there are limitations to the language which make it hard to solve some problems.  Take operator overloading as an example (which our javac implementation supports).  There are 100 times a day when I am trying to solve a problem using Java, only to think, "if I had operator overloading, this would have been resolved hours ago."  Instead, I usually have to come up with some crafty, dirty, or otherwise obnoxious looking way to solve this problem.


3) With Java, everything is a damned exception.  I clearly understand the need for exceptions -- both runtime and compile time, but there are certain sections of code (or hell, even projects) where you don't want to have to deal with them.  Moreover, there are situations where I know ahead of time that an exception will be triggered, but that use-case was intended and I want to purposely suppress the exception.  In Java you can't do that.  Everything is an exception (figuratively speaking) and everything has to be handled.  In the case I presented above, throwing an exception during runtime on a robot is pretty much game over.  The "finally" mechanism is there, but again, doesn't play well with all use-cases, so it is important to handle this stuff at language level, versus one of those spotty one off annotation based approaches I see everybody resort to..


As I previously noted, Java, like say C# is a powerhouse, but Java makes it hard to do things some times.  I have found that the little time it takes to maintain a compiler (especially since I am already a language buff/compiler guy and have a lot of experience writing and maintaining compilers) is dwarfed by the amount of time it saves during development. Especially when you find yourself in a situation like this.  There are other reasons for maintaining our own compiler, but again, what it comes down to is Java is good... Java isn't great.  By maintaining our own compiler, Java is great and saves us a lot of hassle.

Share this comment

Link to comment



I reckon you should write a blog post or article about how you go about doing something like that - what tooling you use, a little about the nature of jvm bytecode, grammars, etc. Maybe even walk the reader through the construction of a simple jvm-based language.


I am not sure how I would personally approach such a thing - maybe something like Antlr to build the AST from an EBNF definition and use it to emit .class files using Javassist perhaps. Or transcompile to regular java and run the Oracle or OpenJDK javac compiler on that.

Share this comment

Link to comment

It is actually funny you recommend that.  I've been considering doing something of that nature for awhile now.  I've considered taking the route Bjarne Stroustrup did with C++ -- creating a new, separate language all together. Java++ anyone?


Thankfully, most of the added functionality up until this point has been coded in raw, JDK 7 compliant Java.  All of the functionality is resolved though hooking the compiler at certain stages, processing, and then injecting the result back into the already existing trees before continuing on.


A perfect example of this injection is our operator overloading mechanism.  When the compiler goes to resolve an operator token, but detects an "overloaded" operator token the current resolve stage is halted and hooked,  After hooking, the overload is resolved (our operators work though your typical 'magic-function' ideology),  The result is then injected back into the existing trees, and all becomes right with the world!

Share this comment

Link to comment

I would also be interested to see how a person would do such a thing. I like that you were aware of memory issues early and took measures to handle them before they became a headache for the user.

Share this comment

Link to comment

I've been super busy trying to wrap up other summer projects before school starts, but once things have settled down and I have a second to breathe, I will write an appropriate article.  Had I known the interest was there, I would have done it a long time ago!


Navy, I've been long aware of Java and its memory limitations, however, up until this point -- that is, up until the point where I had to develop a game using native marshaled code, memory limitations were never an issue.  


I was aware going into this project that I would have to be careful.  I had done a lot of prior research on LibGDX and thought I had planned accordingly.  However, despite all the preparation, I still encountered issues.


I had initially detected leaking memory on day two, but it wasn't until day three (when I actually ran the project under my memory profiler) that I realized how severe the memory leaking was.  I found that I was leaking an upwards of 1GB of memory every 45 seconds.  


After many attempts to patch the leaks in code, I realized that I had to resort to my "last resort" plan to A) ensure that I could stay in the competition, and B) ensure that I didn't get a low score at judging time.  My development tower has 32GB's of 1866 MHZ RAM, so I could survive the leaking memory, but I knew that most judges weren't going to have those hardware resources available at testing time.

Share this comment

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!