Early programmers had to represent code using binary, octal, or hex numbers. This gave way quickly to representing programs as text to be assembled, compiled, or interpreted by the computer. Even today, this remains the most common way to program, but there have been attempts to develop more visual ways to create programs graphically. If you program microcontrollers like the Arduino, you should check out XOD and see how you like visually creating software. The software is open source and currently, can target the Arduino or Raspberry Pi.
You can launch the IDE in a web browser or download a local copy. You transfer nodes from a palette into a grid-like workspace. These nodes might be inputs, outputs, processing blocks, or represent real-world I/O devices. Nodes have inputs and outputs of specific types and you connect them together, connecting like types only, although there are blocks that can convert.
For example, to the right is a simple set of nodes that forms the prototypical flashing LED program. A clock node creates a pulse that toggles a memory element and a digital output accepts both the signal and a constant value indicating which port it represents.
This is a simple example, but it does show the intuitive flow of joining nodes. There is a reasonable array of node types and sufficient documentation.
There are out-of-the-box nodes for ultrasonic sensors, temperature sensors, servos, LCDs, buttons, and H-bridges. You can create your own super-nodes (patches) and you also can make multiple disjointed flows to execute more than one task at a time.
When you generate the code you get a lot of boilerplate that sets up the run time system and the nodes you use. Your main code appears to be in an evaluate function. For example, here’s a snippet of the code that corresponds to the simple graphical blink program:
void evaluate(Context ctx) State* state = getState(ctx); TimeMs tNow = transactionTime(); TimeMs dt = getValue<input_IVAL>(ctx) * 1000; TimeMs tNext = tNow + dt; if (isInputDirty<input_RST>(ctx)) if (dt == 0) state->nextTrig = 0; clearTimeout(ctx); else if (state->nextTrig < tNow else // It was a scheduled tick emitValue<output_TICK>(ctx, 1); state->nextTrig = tNext; setTimeout(ctx, dt);
There are a few rough edges, which isn’t surprising for new software. For one thing, nodes have fixed numbers of inputs and outputs. So if you want, for example, a ten-input AND gate, you’ll have to build it. Another apparent issue is there is no way we found to select a lot of items at once. If you decide you want to move a whole bunch of nodes down to make room for something new, you are going to be in for a lot of work.
There are other drag-and-drop programming languages, of course. We’ve covered Scratch for the Arduino and the Raspberry Pi, before. However, this is a dead simple way to try flow-based programming with minimal setup.