​

DRAKON-Erlang: Visual Functional Programming

Home|Download

By Stepan Mitkin

Part 2 of 10

Previous|Contents|Next

Sequence of Actions

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.

Hello world in DRAKON-Erlang

This diagram consists of three icons:

  • The name of the function is placed at the top in the "Header" icon.
  • The rectangle is an "Action" icon. An "Action" icon is an order to do something.
  • The diagram ends with an "End" icon.

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.

A sequence of actions

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:

    • Moving down is very natural in our material world with gravity. Dropping things does not require any effort.
    • The descending order is very familiar because it is used in text. The next line goes beneath the current one.
  • The vertical line must always be straight and not have any bends and turns.

    Having such a convention reaches two goals at once.

    • It develops a habit for the reader. Diagrams that follow the reader's habit are predictable and fast to read.
    • Arrows can be replaced with plain lines. Arrow heads create visual noise. They clutter the diagram with redundant visual details.

    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.

Previous|Contents|Next


Contact: drakon.editor@gmail.com