-no export stage
-no need to validate
1. Custom binary: kri-3All scene data and resources were stored in a single binary file of a custom format.
-no external libs
-non human-readable -> difficult to debug
-difficult to validate
-resources are not separate
2. XML: kri-webXML is a well-known document format, it has the greatest language/tool support. Besides, that's what we used at my former employer company.
Lang: Dart, XML
-built-in validation with Schema
-support for default values
-need to keep Schema synchronized with exporter/loader
-bloated loading code (no 1:1 data representation)
-not clear what to put into attributes -> design ambiguity
3. JSON: claymore-engineThis is where I discovered JSON, and it immediately appealed to me because of the simple syntax and its 1:1 reflection with the data. Fortunately, this is the only format Rust had a built-in support for. However, it turned out to be a poor choice for the scene description due to the lack of heterogeneous structures.
Lang: Rust, JSON
-no heterogeneous structures -> difficult to read
From there I started looking for something like JSON but to describe the document instead of the data. I looked into YAML, which seemed nice, a bit more complex, and not supported by Rust. Then I found Candle Object Notation, which seemed like a non-ambiguous and compact version of XML, plus the 1:1 mapping to data. However, the format is not that well documented and supported... "It would be nice to have the same object initialization syntax as Rust" - I thought when this idea hit me like a train: why not use Rust then?
4. Rust: k-engineLet's just export a rust source file, which will be compiled with the application.
-free validation (your code is the spec)
-no run-time parsing -> instant loading, no run-time errors
-no need to learn new syntax
-compact (no external file needed to run)
-need to compile the scene
-bound to the language
This approach seems to be the perfect solution for my scene format. The only thing that worries me is that it depends on Rust compile times. Though, we can still parse Rust code at run time, if we want, while still verifying it at compile time. You can see an actual export result here. It is compact, easy to read, and elegant.