This has been an on-again, off-again game project. Though this is the first of hopefully many weekly recaps, it's not the project's first week of development. Below is a bulleted list of 'accomplishments'.
- Moved the Game Engine's SDK modules from a single mega-repository into separate git repositories using git subtree.
- Updated CMake version to 2.8.11 to fix some issues related to Xcode project generation. CMake prior to 2.8.10 wasn't taking into account developers who installed Xcode in a directory other than the default.
- Decided on a serialization format for game data - JSON. Evaluated a couple C/C++ JSON library solutions including cjson, libjson, yajl and jansson, settling on jansson.
- Continued work on the Sprite system.
Rather unglamorous set of accomplishments. The most interesting points are the choice of JSON libraries, and the Sprite system.
Every programmer should at least know what JSON is, if not what it stands for. IMO it's easier to read than XML, and is rapidly replacing XML as a data interchange format on the web. Almost every language either natively or through standard APIs supports serializing and unserializing objects to and from JSON. That is every language but C/C++.
My requirements were support for custom memory allocation, portable, permissive license and large integer support. I checked out the following packages:
(http://sourceforge.net/projects/cjson/) I've used this on another project. API was simple: single source and header file. It's JSON integer vs. double support seemed limited (no 64-bit integer support for example.) No docs.
( http://libjson.sourceforge.net/) Not to be confused with another libjson project. Extensive configuration/customization allowed. Offers both C and C++ interface. Implementation seems a bit heavy with optional C++ exception handling and multithreading support. Good documentation.
(http://lloyd.github.io/yajl/) Support for parsing JSON on an incoming stream(!) Interface seems a bit complex, though admittedly I eyeballed the docs and headers. Docs seem spotty and unorganized.
(http://www.digip.org/jansson/) Simple interface. Popular. Minimal configuration needed with just two or three options in its config.h file. A light config is good for cross-platform support.
I ruled out cJSON due to its lack of 64-bit integer support. Libjson does more than I need. Most of the buzz online falls on using either yajl or jansson. I wasn't a fan of yajl's interface and don't need its streaming support. So I decided on jansson.
Of course upon implementing unserialization of a Sprite "database" file from JSON into my SpriteDatabase object, I found this bit of benchmark data. That site's author (Chad Austin) wrote his own JSON library and compared it against yajl, jansson and two more C++ only frameworks rapidjson and vjson. Yajl and jansson ended up being dog slow when compared with the more up to date C++ solutions.
From what I could tell, the reasons for the speed differences are almost entirely memory allocation driven - yajl and jansson employing a simple malloc per JSON node solution vs block/pool allocation solutions employed by the C++ frameworks. As anyone who understands how heap allocation works should know, fewer allocations are better than many. It sounds like I may need to reevaluate (again) my JSON solution for next week!