| Previous page | Next page | Contents | Home | Obix pragmatics |
Readability is more important than number of keystrokes!
Consider the following statement written in a programming language like Java or C:
|
Visibly, this statement is used to display a message to the user. We suppose
that Utilities is a class, because it is a convention that class
names start with an uppercase letter, and we believe that the programmer knows
and applies this convention. We suppose that the message displayed is "Readability
is important!". Parameter RED must be,
also by convention, a constant, and we guess that it is used to define some
color, but we don't know if it is the color of the text, or the text's background,
or whatever. And we have no idea about what the last two parameters are used
for. There is a lot of uncertainty when reading the above statement. If we want
to know more we have to look at the definition of the function (if we know where
to find it and have access to it) or we must read the technical documentation
(if it exists and is up to date).
Obix uses a different syntax to avoid such error-prone uncertainties. The above statement would be written like this:
|
Sure, the programmer has to type a little bit more (if he doesn't have a smart ide). But, the source code is more readable and understandable. There are no, or at least much less doubts about what the programmer really wants to do. In Obix, every input argument assignment must be written as:
input_argument_id = expression
Besides the better understandability, this syntax eliminates the risk of erroneously permuting two arguments of the same type and adds compile-time error detection when a command's input argument list is changed.
By the way, this syntax for a command's execution would be very appropriate for a speech recognition system. Imagine how ordering a cup of coffee to a coffee machine would be easy, by saying:
'service' 'coffee machine' 'command' 'make coffee' 'with milk' 'yes'
'with sugar' 'no'
The above code is just one example of the 'readability is more important than writability' principle. Other examples can be found in the tutorial.
| Previous page | Next page | Contents | Home | October 2004 |