1

Are there any ready-to-use and maintainted for a long time "universal" binary formats that I could use for free? I'm writing a game in Java and I considered writing own binary format to save maps to, but then I thought: maybe there're some solutions ready-to-use?

By "universal binary format" I mean format that will allow me to save any common structure (String, int, float, double, custom structures like Vector3f - 3 float values as one object, etc.), will be space, RAM and CPU-efficient and will have parser (and saver) written in Java.

Is there anything like this available? Or must I write my own format?

m4tx
  • 4,139
  • 5
  • 37
  • 61
  • Why a 'binary' format as opposed to, for example, XML? – Andrew Thompson Jun 30 '13 at 12:35
  • I will use that format to store maps for my 3D game. There may be hundreds or event thousands of object - every one will contain a few properties. XML would be inefficient for that, providing files that will be big (XML files aren't space-efficient); parsing also won't be fast (remember that I must parse a lot of floats and ints; storing them as text isn't a good idea). That's why I prefer binary format over XML here. – m4tx Jun 30 '13 at 12:38
  • 1
    *" (XML files aren't space-efficient);"* They are if you zip them. Besides, hard disk space is cheap. *"parsing also won't be fast.."* Did you ascertain that by profiling or by staring at tea leaves? Don't fall into the trap of 'premature optimization'. – Andrew Thompson Jun 30 '13 at 12:41
  • "They are if you zip them." Yay, 1 more expensive operation to do when loading and saving a map. :) Please remember that I'm writing a game. I don't want to let the user wait an "hour" to load a map. I don't want to let the user wait an "hour" whenever (s)he presses Ctrl+S in Map Editor. I want a solution that will be as fast as it can. Do you enjoy playing games where every map took a lot for load? Do you think that storing integer and float values as plain text is really THAT efficient? I don't think so... :) Btw., I'm using XMLs in this project, but for less expensive things. – m4tx Jun 30 '13 at 12:49
  • 1
    @m4tx You're probably right, xml probably will be slower, but the important thing is that (a) you check thats true (b) you check its the dominant cause of slowness, otherwise you may be doing all this work for nothing (point (b) is especially important to check early on) – Richard Tingle Jun 30 '13 at 13:51

1 Answers1

3

Hava a look at

There are also various performance comparisons about e.g. Benchmarking

Bruce Martin
  • 10,358
  • 1
  • 27
  • 38