-3

I'm curious to know are there any advantages or disadvantages to creating a named binary format as opposed to an unnamed one? I can only think of a increase in the required disk space.

Roughly speaking a named binary format is a binary format in which you can identify the data parts by using their name (int, byte). The names are stored in the output file itself as well

Example difference in usage:

  • unnamed: input.nextByte(); input.nextInt();
  • named: input.getByte("name1"); input.getInt("name2");
15
  • I think your question is too specific, and if there are no official docs clarifying that, your only chance to find this out is to ask Mr. Persson himself.
    – scriptin
    Commented Jul 13, 2017 at 20:06
  • 1
    Yeah, now it's much better, but could you explain what "named" means? I doubt it's a common term since I've never heard of it elsewhere.
    – scriptin
    Commented Jul 13, 2017 at 20:19
  • Roughly speaking it means that you can identify specific data (like int, byte) so instead of accessing the data like this format.nextInt(); format.nextByte() you have format.getInt("name"); format.getByte("name").
    – Mibac
    Commented Jul 13, 2017 at 20:21
  • Are those names stored in files?
    – scriptin
    Commented Jul 13, 2017 at 20:31
  • 1
    What is the problem with “Pros and Cons”?
    – user22815
    Commented Jul 14, 2017 at 1:22

1 Answer 1

2

The main advantage is you don't need to know the exact position and sequence of every piece of data in your file. Your expected usage is wrong. You wouldn't already know the data type and name when you got to that point in your input. You'd first read a byte to see what data type you had, then the next two bytes to see the length of the name, then the name, then the data itself. Then you'd put that into some sort of dictionary and continue reading.

This is a huge advantage when you're dealing with schemas that rapidly change. Also when you want your data format to be semi-open for modders and mapmakers. It also makes caching easier, as you don't have to write things out to disk in a strict order.

3
  • How does it help modders? If there are some mods installed and they always load in the same order doesn't that guarantee that they will always read the data in the same order and therefore have no problems even without names?
    – Mibac
    Commented Jul 13, 2017 at 22:27
  • Having to always read it in the same order is not a benefit. It makes it very fragile to changes, and requires those changes be communicated extremely precisely upon every revision to modders. Commented Jul 14, 2017 at 2:19
  • It also helps with diagnostics and debugging. You can create a dump of the data that actually makes sense, telling you what may be missing or superfluous. Commented Jul 19, 2017 at 2:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.