"Christopher Wright" <[email protected]> wrote in message news:[email protected]... >> And finally, I would also change the format of libraries. A library would >> be one file only. No more header/.di -files; one compact file containing >> all the needed information (in a binary formated database that can be >> read very quickly). > > Why binary? If your program can operate efficiently with a textual > representation, it's easier to test, easier to debug, and less susceptible > to changes in internal structures. > > Additionally, a database in a binary format will require special tools to > examine. You can't just pop it open in a text editor to see what functions > are defined.
"If your program can operate efficiently with a textual representation..." I think that's the key right there. Most of the time, parsing a sensibly-designed text format is going to be a bit slower than reading in an equivalent sensibly-designed (as opposed to over-engineered [pet-peeve]ex: GOLD Parser Builder's .cgt format[/pet-peeve]) binary format. First off, there's just simply more raw data to be read off the disk and processed, then you've got the actual tokenizing/syntax-parsing itself, and then anything that isn't supposed to be interpreted as a string (like ints and bools) need to get converted to their proper internal representations. And then for saving, you go through all the same, but in reverse. (Also, mixed human/computer editing of a text file can sometimes be problematic.) With a sensibly-designed binary format (and a sensible systems language like D, as opposed to C# or Java), all you really need to do is load a few chunks into memory and apply some structs over top of them. Toss in some trivial version checks and maybe some endian fixups and you're done. Very little processing and memory is needed. I can certainly appreciate the other benefits of text formats, though, and certainly agree that there are cases where the performance of using a text format would be perfectly acceptable. But it can add up. And I often wonder how much faster and more memory-efficient things like linux and the web could have been if they weren't so big on sticking damn near everything into "convenient" text formats.
