3 ms·
It's fine for a personal project, but if you're thinking of writing a custom parser and grammar for configuration for a commercial project: Don't. There's a lo
by CoolGuySteve 6y ago
It's fine for a personal project, but if you're thinking of writing a custom parser and grammar for configuration for a commercial project: Don't.
There's a lot of flexibility that comes from being able to programmatically generate configs in your scripting language of choice and then ingest them in C++ with little effort. For example, being able to serialize a Python dict as json/ini/yaml/sqlite/whatever and then ingest it in C++ with some library.
It turns your complicated C++ program into a function with a dictionary argument.
I've worked on a few large programs now that have used custom config formats and it sucks. It's a waste of time trying to output correct syntax while fighting through idiosyncratic syntax choices and poorly explained parsing errors in the custom code.
It doesn't create value, it's just a thing you have to do to get to the automation you're trying to accomplish. Avoid it by not making the mistake in the first place.
- setzer22 6y agoTo be fair, S-expressions are not a made up format and in fact predate most other formats you mention.
- CoolGuySteve 6y agoYou're missing the point, S-expression parsers aren't "batteries included" in most scripting languages. The age of the format is irrelevant.
- outworlder 6y ago> It's fine for a personal project, but if you're thinking of writing a custom parser and grammar for configuration for a commercial project: Don't. I would agree. Even more so as parsers for S-expressions have existed... since 1960 or so?