A case for visual programming languages
I wrote this essay as part of a school assignment, which mandated I write it in a certain style. This is why it is written in a different style from my other posts.
In this essay I'd like to explain why I came to the conclusion that visual programming languages should be taken more seriously. I should probably start by explaining why I use textual programming languages. When I was a kid I wanted to make my own video games, I had the option to take a game programming class and middle school. This is was where I learned my first programming language, it was a visual programming language called alice. It could only be used to create very simple video games, This was kind of fun to do but I couldn't make anything useful with it. All of the other visual programming languages I've used (snap! and scratch), were the same, they were easy to learn, but they couldn't be used to do any serious work. In addition, they all relied on a drag and drop model of programming, where I would drag and drop blocks that snapped together to write my programs. This meant every time I wanted to use a statement I would be forced to look through a menu and find what I needed. I could discover every feature of the language by snooping around. This is great if you're a child who's new to programming, but became a hindrance as I improved. I got to a point where I already knew what blocks I wanted, and yet I still had to look through menus to get them. It was like I was trying to carve a marble statue with a tooth pick. When I switched over to using textual programming languages these problems went away. Instead of having to look through a menu to find an “if statement block” I could simply write “if (condition) {statements}”. What used to be multiple clicks of a mouse turned into a many of key presses on a keyboard. The other advantage was that the textual programming languages were general purpose, I could use them automating all sorts of tasks that would be tedious to do manually. Sure, the textual programming languages had a steeper learning curve, since I had to read a manual to find the staments I could use, and I had to worry about mistyping words, or missing a semicolon. But once I learned them the textual languages, I was far more efficient in writing them than I was for any visual programming language. I came to view visual programming languages like training wheels, I was done with them, I could ride my bicycle, I didn't need them any more. I concluded visual programming languages were only good for education and couldn't be used get any serious work done. This seems to be the most popular opinion amongst programming language users and programming language developers. Visual Programming language designers usually market their languages for education, or for use by non-programmers (like musicians in the case of Pure Data).
I've mentioned two problems with visual programming languages in the above paragraph, That they are domain specific, and that they have clunky user interfaces (having to click through menus). There are a couple programming languages that solve the first problem, PWCT (Fayed et al, 2020) is an example. It's a general purpose programming language that is purely visual. The second problem can also be solved, but I haven't found a visual programming language that solves it. This is probably due to social reasons. A blog entry by Stanislav Datskovskiy titled “Englebart's Violin”, explains the reasons well, but the gist of his argument is that in the field of computing, most user interfaces are designed like kazoos, rather than violins. Kazoos are easy to learn, but sound quite bad, Whereas violins are hard to learn and sound much better (2012). In this case the Visual programming Language designers have been designing kazoos, rather than violins. They have made their user interfaces easier to learn, at the expense of making them harder to use for experts.
The good news is that there's no reason that we can't make a visual programming language like a violin. In my years of programming, I've looked at many text editors and integrated development environments. I eventually settled on using GNU Emacs because it was highly customizable, and had a large community of developers that are willing to make writing code more efficient. As I got better with Emacs, I started to realize that it's much more efficient to work with code structures rather than plain text. Instead of typing out an “if” statement by hand, Emacs has keyboard shortcuts that let allow you to insert an if statement with a single keystroke, and fill in the data as you go. There are also extensions that allow you to navigate and manipulate programs at a syntactic level (Esterhazy 2017), rather that manipulating them letter by letter. After using these features, I realized that they were much more efficient than typing everything out by hand, but I also saw an irony. The Irony was that it would be much easier to program these tools if they had started with a visual programming language, rather than making them manipulate plain text. The best text editors work with programs as if it were a tree of language statements, rather than a string of text. Visual programming languages don't have any strings of text, they only have language statements. In that sense, good text editors poorly emulate what a good visual programming language's UI would be. If the designers cut out the middle man (that being the strings of text) and kept the same user interface, then we'd be much better off. In my personal experience, it is a pain to write Emacs extensions that work with a program's syntactical structures, since you have to parse the code before you do anything with it. A visual programming language's editor necessarily has the blocks of code to work with, so there's no need to parse the program, I would only need to ask my editor for a tree of blocks and then write a program that works on the tree. It would also avoid the problem of syntax errors, structural editing only works on plain text if the program has no syntax errors. This becomes a problem because every time you type or delete a character, you have a chance of introducing a syntax error into the program. For instance in C, if you write half of a function call (eg. “foo(” ), then your program becomes unparsable until you fix add the ending parenthesis to the call (Turning “foo(” into “foo()”). This isn't a hypothetical problem. I often want to look back at code to figure out what I should put in my function before I close it. Visual programming languages obviate this problem because they force the programmer to always write syntactically correct code.
Visual programming languages have many other advantages to textual programming languages. I'll bring two of them to attention, the first is that formatting is automatic, In textual languages you usually have to format the code manually, which is frustrating. I have personally seen tons of programs written by others where the formatting was noxious to me. Even if the code is formatted well, there's only one representation of the code. Every piece of whitespace looks the same to each person reading the program. Which means that everyone has to choose standard way to format their code if they wish to work together. Much like HTML, Visual programming languages separate the content of programs from their presentation. So each person's editor could be configured display the source code however they want. Which means there's no need to force everyone to agree on the same standard.
The second improvement is related to metadata. A program benefits from having lots of meta data associated with each section of code. For instance, it would be nice to know if a block of code has any unit tests associated with it somewhere else. In textual programming languages, It's hard to keep meta data associated with programming language statements since the text is constantly changing. This isn't a problem with visual programming languages because they can track every change to a block as it happens, so It would be much easier to attach meta data to a block of code. As an example, when I want to comment my code I have very few options. The comments are embedded within the text, so they fight over the same space. If I make my comments long, then they clutter up the program, so I have to choose between making my comments long and explanatory, or making my program easier to skim. If I were to use a visual programming language, it would be easy to associate a comment with a block of code. I would then have a lot more options on how I want my comment to be displayed. If it is short, I could present the comment as a tab on the side of the code. If it was long, I could make it a hyperlink to a larger document. I also wouldn't have to worry about my lines becoming too long, since the program would know how to indent them. It would be like Microsoft Word, where each line could be as long as you want, and the Program Editor would know how to wrap the statements properly. Snap! is a visual programming language with this feature.
In conclusion I think that a visual programming language could be superior to a textual one, Given that we actually try to make one for experts. It would allow us to focus more on content, and less on presentation, while allowing us to document our code better, and edit it better proficiency.
Bibliography
Datskovskiy, Stanislav (2012). Engelbart's Violin.
Esterhazy, Paulus (2017). Structural Editing, a Guide for the Perplexed – Paulus Esterhazy.
Fayed, Mahmoud S. and Al-Qurishi, Muhammad and Alamri, Atif and Hossain, M. Anwar and Al-Daraiseh, Ahmad A. (2020). PWCT: a novel general-purpose visual programming language in support of pervasive application development, CCF Transactions on Pervasive Computing and Interaction.
Datskovskiy, Stanislav (2012). Engelbart's Violin. http://www.loper-os.org/?p=861 .
Esterhazy, Paulus (2017). Structural Editing, a Guide for the Perplexed – Paulus Esterhazy. https://youtube.com/watch?v=ubcERtDyLDw .
Fayed, Mahmoud S. and Al-Qurishi, Muhammad and Alamri, Atif and Hossain, M. Anwar and Al-Daraiseh, Ahmad A. (2020). PWCT: a novel general-purpose visual programming language in support of pervasive application development, CCF Transactions on Pervasive Computing and Interaction.
By Logan Andersen. This work is licensed under CC BY-ND 4.0
You can see my other blogs here.