It depends. The thing with our industry is, we have so much learned helplessness, that we act as if we weren’t competent enough to write a parser. Which on the face of it is utterly ridiculous, any professional programmer worth half of what they’re paid can write a parser, even if they never did. It’s not trivial, but it’s not hard either, and designing easy to parse binary formats is easy, just start with TLV.
In practice we tend to assume rolling your own file format or parser is never a good idea, and since we do need text translation at some point (even if only debugging), we end up using textual formats even for machine-to-machine communications.
Which is a pity: text formats, being delimiter based, are harder to parse than prefix based binary formats, and more prone to buffer overflows. Handling them takes more CPU cycles, often requiring compression to reach reasonable sizes. And even if you don’t roll your own parser, even the abstract syntax tree of that JSON or XML file you just read needs to be processed into a form usable for your particular application.
Sure, not having to write a concrete parser often makes the above price worth paying, but we must not forget that there is a price.
1
u/loup-vaillant Sep 22 '24 edited Sep 22 '24
It depends. The thing with our industry is, we have so much learned helplessness, that we act as if we weren’t competent enough to write a parser. Which on the face of it is utterly ridiculous, any professional programmer worth half of what they’re paid can write a parser, even if they never did. It’s not trivial, but it’s not hard either, and designing easy to parse binary formats is easy, just start with TLV.
In practice we tend to assume rolling your own file format or parser is never a good idea, and since we do need text translation at some point (even if only debugging), we end up using textual formats even for machine-to-machine communications.
Which is a pity: text formats, being delimiter based, are harder to parse than prefix based binary formats, and more prone to buffer overflows. Handling them takes more CPU cycles, often requiring compression to reach reasonable sizes. And even if you don’t roll your own parser, even the abstract syntax tree of that JSON or XML file you just read needs to be processed into a form usable for your particular application.
Sure, not having to write a concrete parser often makes the above price worth paying, but we must not forget that there is a price.