It’s 1986. You’re working on the Russian’s Buran space programme – trying to create a re-usable space vehicle which will exceed the capabilities of the American’s “Space Shuttle”.

There’s a problem. You have very complicated real-time algorithms which you need to review, improve, optimise, and then turn into code. How do you do it?

Obviously, you invent DRAKON!

ДРАКОН, “dragon”

Backronym for “Дружелюбный Русский Алгоритмический язык, Который Обеспечивает Наглядность.”

Translation: “Friendly Russian algorithmic language that guarantees clarity.” Drakon on Wikipedia

Drakon allows you to transform this:



Into This:



Frankly, it’s a little bit like magic.

Why Use Drakon?

I’ve only just started exploring the possibilities of Drakon – so I have a convert’s zeal and a neophyte’s experience – but here’s the elevator pitch.

Human eyes and brains are optimised for looking at shapes and patterns – not lines and lines of text. Drakon allows you to spot errors in your algorithms before you commit them to code. Once you have drawn out the code using the visual editor, it can automatically produce clean and efficient code in Java, C#, C/C++, Python, Tcl, Javascript, Lua and Erlang.

It really is amazing when you start to use it. If you have a complex process, a knotty algorithm, or any large scale information that you want to convey to an audience – Drakon is perfect.

Let’s take, for example, Dijkstra’s algorithm. When expressed in Python, it takes a savant to intuitively understand what the algorithm does – even if it is well commented.

It takes someone with a lot of experience to spot inefficiencies or problems.

Here’s the algorithm expressed in Python.

from priodict import priorityDictionary def Dijkstra(G,start,end=None): D = {} # dictionary of final distances P = {} # dictionary of predecessors Q = priorityDictionary() # est.dist. of non-final vert. Q[start] = 0 for v in Q: D[v] = Q[v] if v == end: break for w in G[v]: vwLength = D[v] + G[v][w] if w in D: if vwLength < D[w]: raise ValueError, "Dijkstra: found better path to already-final vertex" elif w not in Q or vwLength < Q[w]: Q[w] = vwLength P[w] = v return (D,P) def shortestPath(G,start,end): D,P = Dijkstra(G,start,end) Path = [] while 1: Path.append(end) if end == start: break end = P[end] Path.reverse() return Path

Now, let's take a look at how that would be constructed in Drakon.



With almost zero knowledge you can quickly and easily see where your mistakes are. Drakon flowcharts can be exported as images, blown up on projectors, or simply emailed around.

Once you're happy with the diagram, you click a button and it spits out JavaScript, Java, C#, C/C++, Python, Tcl, Lua or Erlang.

What Have I Used It For?

My dad wants some help building an app. Like the dutiful son I am, I agreed and asked him to send over what he had so far. This is what I got.



Not exactly the easiest of things to work from, dad!

So, I began transcribing the algorithm by hand into JavaScript. It quickly became a mess of if...else, nested conditions, and general spaghetti code - I think I even threw in a GOTO statement 🙂

None of which was made easier by the fact that there were some obvious errors in the original flow chart. "Yes" where "no" was meant, lines which criss-crossed each other, etc.

After an hour or so of using Drakon for the first time, I'd transformed the pen and ink drawing into this:



Perhaps not the finest flowchart known to man, but a lot easier to understand. I was able to make changes, see where the errors were, optimise the flow. My father - who has no knowledge of JavaScript - was able to look at the chart and verify that it was correct.

Most importantly, I clicked a button and it generated the sort of intricately nested JavaScript which would have taken me all day to write by hand.

Finally, there's no save button! Every action is automatically saved without the need for any user interaction. Stepan Mitkin, the Russian developer behind the current open source Drakon project, says:

The "Save" button is obsolete. Pressing "Save" is boring and stressful work. Boring work must be done by the machine.

Writing algorithms is boring, stressful, repetative, error-prone work. Let Drakon do it for you.

Getting Started

Download Drakon for Linux, Mac, Windows.

On Linux, you'll need to install a few dependencies.

sudo apt-get install tk tcl libsqlite3-tcl tcllib libtk-img

To run, open the command line, navigate to where you unzipped the files and run:

tclsh drakon_editor.tcl

or, simply:

./drakon_editor.tcl

Drakon files are SQLite 3.6 databases – so you are not locked in to a proprietary file format.

BONUS!

Several years ago, the Technikmuseum Speyer in Germany purchased Buran Analog BST-02 – one of the craft used for test flights in the Soviet Buran programme. I was in Düsseldorf at the time and got to watch it being sailed down the Rhine. Magical!

