3 ms·
Well, as long as you are the only one editing them, it doesn't make a difference where you put the limit between code and data. This changes once you release th
by Kliment 17y ago
Well, as long as you are the only one editing them, it doesn't make a difference where you put the limit between code and data. This changes once you release though. Configuration files are meant to be user-edited as part of standard functionality, program code is not. Your users expect nothing major to break if there is a syntax error in the config file. Does that make your entire program crash with an undecipherable (to someone unfamiliar with the language or programming in general) error? You want to be as robust as possible when reading user-editable files, and directly executing them as code could cause problems. There is also the security and stability issue associated with encouraging users to enter code into a config file. Do think about it. This, to me, is the main reason for treating data as separate from code. You have to be robust about parsing data, your compiler has to be robust about parsing code.
- CyberFonic 17y agoThe most convenient way to have config files is to have a sensible default value for everything. So as much as possible the program should run in spite of config errors. If that is not possible, then the diagnostics need to be very explicit. Any code, e.g. startup scripts should be ideally in a separate file. In the *NIX tradition these are usually of the form .foorc where 'foo' is the name of the app, and the '.' hides the file from normal directory listings. Ideally, it would be nice to pre-parse such startup code and only execute if it is syntactically correct.