-
Notifications
You must be signed in to change notification settings - Fork 88
Graphical Programming and Waterbear
As computers become faster and more sophisticated, programming languages are increasingly free to focus on providing convenient and useful abstractions for human programmers, as opposed to fixating on performance concerns. Unless a certain task relies heavily on the speed of the code, such as rendering graphics or processing large amounts of data, the performance lost using a higher-level language is more than made up for by development speed and lower likelihood of errors. Different programming languages are designed and lend themselves best to various tasks. Scripting languages such as Python and Ruby boast permissive type rules, simple syntax, and low overhead when developing programs. Languages such as C and C++ let users write fast, concurrent programs, which is important when performance becomes an issue. Functional languages such as Ocaml and Haskell let users express programs in more mathematical and type-safe ways. Despite all these varying benefits and differences between languages, all commonly used languages are entered as text into a computer. Various text editors make development easier, with convenient tools such as syntax highlighting, autocompletion, and management of external files. However, the basic way we represent programs as lists of strings does not change.
When programming, the intended behavior of the program does not often translate well to code. During development, I often create intermediary stages of diagrams, pictorially representing data structures, functions, etc that will then be translated into code. The code itself does not obviously represent its own behavior in a visual way. The process of understanding and debugging the code’s logic is therefore tedious and time-consuming. This process would be accelerated if code visually represented its own logic in a higher-level way.
With faster processors and graphics on computers today, it’s possible to represent code and logic in more sophisticated ways than simple text (colored or otherwise). Block-based code generation tools such as Waterbear have the advantage of abstracting out the low-level code, so that a user can focus more on the logic of the program they are creating rather than how it translates to code. For example, using Waterbear’s sprite blocks, a user can easily draw shapes to a canvas. Moving, rotating, and changing the color of the shapes is simple to accomplish using the many blocks supplied. It’s satisfying to be able to immediately create output and get a project going with almost zero overhead. Assembling the blocks themselves also offers some considerable convenience over simply entering code into a text editor. Initializing variables in Waterbear creates variable blocks at the top of the variable’s local scope. The block’s color corresponds to the variable’s type. This presentation makes reasoning about variables much more intuitive and fast. Similarly, when adding a block to a script, the IDE outlines the valid areas in which to put the block in yellow. This is invaluable for beginners who might otherwise flounder with the complex syntax of standard programming language.
Unfortunately, current block-based programming approaches only go so far. While being incredibly beginner-friendly, fun, and satisfying to program with, such tools don’t scale well to intermediate and expert-level programmers. As the size of a file increases, it becomes much harder to navigate and find the appropriate areas in the program. This gets further complicated by the fact that there’s no real way to import and access scripts in one file from another. Therefore, scripts written in Waterbear don’t support modularity and reusability well. Finally, the drawback from abstracting away much of the details of the code itself is a loss of control. The user can’t leverage the full power of the code that is generated by using Waterbear’s blocks.The blocks themselves do not constitute a fully-featured programming language.
However, as Waterbear grows and develops, it can maintain its strengths while expanding its capabilities. Blocks can be added to represent functions, function calls, and more advanced data structures such as trees. Hopefully, block-based programming can go from a teaching tool to an all-purpose toolkit, helping beginners and experts alike.