[PC-BSD Dev] RFC: Choice of a Less Error-Prone Scripting Language for Configuration Scripts + Standard Data Format
torsten.eichstaedt at web.de
Thu Mar 7 14:35:41 PST 2013
Hello to all!
[The following proposal is meant for one of the next releases, not for
immediate hacking of existent code, of course!]
REQUEST FOR COMMENT
- DRAFT -
I propose to
1. Re-write and refactor the configuration & installation scripts in PCBSD in
a less error-prone scripting language than shell script.
2. Change the configuration data files to a standardized, human-readable and
simple data format. My suggestions are YAML or JSON.
It is common sense that shell scripts lack built-in support for
modularisation and test capabilities, and are especially weak concerning
string handling, fault-tolerance, re-usability and maintainability; this is
only a partial list of inherent weaknesses. Thus, it is commonly believed
that once a project gets bigger, shell script's weaknesses prevail their
advantages; they become a risk and should be replaced by an advanced,
superior (scripting) language.
Currently, many backends throughout the PC-BSD configuration & installation
handling are implemented as shell scripts, and their inherent weaknesses are
the root cause of many -- often subtle and/or trivial but nasty -- bugs. In
particular, robust string- and exception handling are major requirements of
configuration handling. Many experienced developers add built-in test
capabilities to this list.
Using a more advanced scripting language would certainly improve the
situation, especially concerning the topics noted above.
Then, the use of a standardized data format for configuration data is a
simple practical consideration: Programming libraries exist
- to test the validity of the data and the data files,
- to read and write syntactically correct data files robustly.
Thus, through the use of such well tested, mature libraries, a standardized,
simple data format will improve robustness and fault-tolerance.
For the two formats I propose, YAML or JSON, libraries for shell scripts are
available as well; thus, their use is independent from changing the
configuration & installation scripts to another language.
I propose to pick one scripting language and one data format throughout
PCBSD configuration (if at all possible). JSON is (mostly) a subset of YAML.
Both are (more or less) simple, platform-independent, human-readable, and
widely supported in all major programming languages.
Up to my current research, YAML has the advantage to allow comments; but
there's probably an easy work-around for JSON by simply including a field
named "comment" or "note" of type "string" where needed.
inhibits this. There are pros and cons concerning this. For security, it's a
no-go, for practical reasons it can sometimes be of advantage.
it is used in QML, and QML certainly is a very appealing choice for GUI-fied
configuration tools. Nevertheless, bindings for Lua to Qt exist, and the
interpreter is very small. Both languages are well-founded, widely used, easy
to learn, and allow for rapid development cycles as they are scripted. Many
open-source modules and libraries are readily available to prevent the
developer from reinventing the wheel.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Dev