By Stepan Mitkin
Part 2 of 10
The simplest form of algorithm is a sequence of actions. Let us start with the traditional "Hello world!" program. It is a sequence that contains only one action. This action outputs a pre-defined string.
This diagram consists of three icons:
There must be only one "End" icon in any diagram. The text inside the "End" diagram must be exactly "End".
More interesting algorithms have more actions. Here is an algorithm that makes the first character of a string a capital letter.
This trivial diagram illustrates a few important principles of DRAKON.
Clarity is above all. Making an algorithm appear shorter must not sacrifice readability.
Some may think that this function should be written in a shorter way. For example:
first_to_upper([First | Rest]) -> [string:to_upper(First) | string:to_lower(Rest)].
Indeed, this form is more concise. But it requires the reader to unpack the code in his head. The goal of DRAKON is to eliminate any unnecessary mental work. This is why each operation deserves its own line on the diagram.
The next icon is always below the current one. In DRAKON, consecutive icons are placed on a vertical line. The order of processing the icons is always from top to bottom. This order is not arbitrary:
The vertical line must always be straight and not have any bends and turns.
Having such a convention reaches two goals at once.
DRAKON gets rid of anything that does not have an immediate practical value. Lines always lead down, so there is no point in specifying direction. There is only one usage of arrows in DRAKON. An arrow always goes up and describes a loop. But there are no loops in Erlang, so we will not discuss them here.
Sequential programming is the main building block of algorithms. But it does not reveal the full power of DRAKON.