Visual Programming and Why It's a Bad Idea
Visual programming technologies sound good in theory, but can they deliver on those promises in full? Read on for some insight.
Join the DZone community and get the full member experience.Join For Free
A visual programming language is one that allows the programmer to create programs by manipulating graphical elements rather than typing textural commands. A well-known example is Scratch, a visual programming language from MIT that's used to teach children. The advantages given are that they make programming more accessible to novices and non-programmers. There was a very popular movement in the 1990's to bring these kinds of tools into the enterprise with so-called CASE tools, where enterprise systems could be defined with UML and generated without the need for trained software developers. This involved the concept of "round tripping," where a system could be modeled visually, the program code would be generated from the models, and any changes to the code could be pushed back to the model. These tools failed to deliver on their promises and most of these attempts have now been largely abandoned.
So visual programming has failed to catch on, except in some very limited domains. This is fundamentally attributable to the following misconceptions about programming:
- Textural programming languages obfuscate what is essentially a simple process.
- Abstraction and decoupling play a small and peripheral part in programming.
- The tools that have been developed to support programming are unimportant.
The first misconception holds that software development has significant barriers to entry because textural programming languages obfuscate the true nature of programming. The popularity of Scratch among educationalists plays to this misconception. The idea is that programming is actually quite simple and if we could only present it in a clear graphical format it would dramatically lower the learning curve and mental effort required to create and read software. I expect this misconception comes from a failure to actually read a typical program written in a standard textural programming language and imagine it transformed into graphical elements of boxes and arrows. If you do this it soon becomes apparent that a single line of code often maps to several boxes and since it's not untypical for even a simple program to contain hundreds of lines of code, this translates into hundreds or even thousands of graphical elements. The effort to mentally parse such a complex picture is often far harder than reading the equivalent text.
The solution for most visual programming languages is to make the "blocks" represent more complex operations so that each visual element is equivalent to a large block of textural code. Visual workflow tools are a particular culprit here. The problem is that this code needs to be defined somewhere. It becomes "property dialogue programming." The visual elements themselves only represent the very highest level of program flow and the majority of the work is now done in standard textural code hidden in the boxes. Now we have the worst of both worlds, textural programming unsupported by modern tooling. The properly dialogues are usually sub-standard development environments and enforce a particular choice of language, usually a scripting language of some kind. Visual elements can't be created except by experienced programmers, or understood except by reading their underlying code, so most of the supposed advantages of the visual representation are lost. There's an impedance mismatch between the visual "code" and the textural code, and the programmer has to navigate the interface between the two, often spending more effort on conforming to the needs of the graphical programming tool than solving the problem at hand.
Which bring us to the second misconception, that abstraction and decoupling are peripheral concerns. Visual programming makes the assumption that most programs are simple procedural sequences, somewhat like a flowchart. Indeed, this is how most novice programmers imagine that software works. However, once a program gets larger than a quite trivial example, the complexity soon overwhelms the novice programmer. They find that it's very hard to reason about a large procedural code base and often struggle to produce stable and efficient software at scale. Most of the innovation in programming languages is an attempt to manage complexity, most commonly via abstraction, encapsulation, and decoupling. All the type systems and apparatus of object-oriented and functional programming is really just an effort to get this complexity under control. Most professional programmers will be continually abstracting and decoupling code. Indeed, the difference between good and bad code is essentially how well this has been done. Visual programming tools rarely have efficient mechanisms to do this and essential trap the developer in an equivalent of 1970's BASIC.
The final misconception is that visual programmers can do without all the tools that have been developed over the decades to support programming. Consider the long evolution of code editors and IDEs. Visual Studio, for example, supports efficient intellisense allowing the look-up of thousands of APIs available in the base class library alone. The lack of good source control is another major disadvantage of most visual programming tools. Even if they persist their layout to a textural format, the diffs make little or no sense. It's very hard to do a "blame" on a large lump of XML or JSON. Things that make no difference to the functional execution of the program, such as the position and size of the graphical elements, still lead to changes in the metadata, which make it harder still to parse a diff. Textural programming languages have learned to separate units of code into separate source files, so a change in one part of the system is easy to merge with a change in another. Visual tools will usually persist as a diagram per file which means that merges become problematic, made harder still when the semantic meaning of the diff is difficult to parse.
In conclusion, the advantages given for visual programming tools, that they make the program easier to create and understand, are almost always a mirage. They can only succeed in the simplest of cases and at best result in the suboptimal situation where the visual elements are simply obfuscating containers for textural code.
Published at DZone with permission of Mike Hadlow, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.