Programming in a Poorly Designed Language Without Tool Support Is No Fun

Who dares run this code?

Who dares run this code?

Yoda, the wise teacher of Jedi apprentice Luke Skywalker in the Star Wars movies, knows that fear leads to anger; anger leads to hate; hate leads to suffering. Likewise, corporate IT’s fear of code and the love of configuration can lead it down a path to suffering from which it is difficult to escape. Beware of the dark side, which has many faces, including vendors peddling products that “only require configuration,” as opposed to tedious, error-prone coding. Sadly, most complex configuration really is just programming, albeit in a poorly designed, rather constrained language without decent tooling or useful documentation.

Fear of Code

Corporate IT, which is often driven by operational considerations, tends to consider code the stuff that contains all the bugs, causes performance problems, and is written by expensive external consultants ( Chapter 38 ) who are difficult to hold liable because they’ll have long moved to another project by the time the problems surface. Some IT leaders even proudly proclaim that they are a “proper business” and not a software development company, so they shouldn’t bother with coding stuff.

Note

The most grotesque example of fear of code I have observed was corporate IT providing application servers as a shared service. Once you deploy code on them, you’d no longer receive operational support. It’s like voiding a car’s warranty after you start the engine—after all, the manufacturer has no idea what you will do to it!

Corporate IT’s eternal fear of code plays to the advantage of enterprise vendors who offer configuration as the safe alternative to coding. As we shall see, that’s a rather short-sighted proposition.

Good Intentions Don’t Lead to Good Results

IT’s aversion to coding originates from a good principle. Most enterprise IT rightly follows a buy-over-build strategy: buying commercial off-the-shelf (COTS) solutions not only saves IT departments time and money but also lets someone else worry about regular updates and security patches. Once purchased, solutions can be customized and configured to the enterprise’s specific needs.

Likewise, common libraries and open source tools are a great way of reusing existing work. Open source tools are also often accompanied by an extensive community that can provide support and make technology adoption easier. For example, who would you want to write their own XML serializer? There’s a library for that.

There’s a catch, though…well, actually, two: first, if you expect to configure a piece of software that you bought, you are relying on the vendor having anticipated the need for your case of customization, meaning the vendor gave you the option ( Chapter 9 ). Doing this well would mean the vendor has perfected big, up-front design, correctly anticipating all possible requirements, while the rest of us are still trying to become more Agile ( Chapter 31 ). Second, configuration means working in an abstraction provided by the software vendor. Now, abstractions are generally a good thing because they allow you to get away from the nitty-gritty details, but some abstractions also come with downsides.

Levels of Abstraction: Simplicity Versus Flexibility

Raising the level of abstraction is one of the primary techniques that makes developers’ lives easier. Thanks to abstraction, very few programmers still write assembly code, read single data blocks from a hard disk, or put individual data packets onto the network. This level of detail has been nicely wrapped behind high-level languages, files, and socket streams. These programming abstractions are very convenient and dramatically increase productivity: try doing without them!

If abstractions are this useful, you might legitimately wonder whether adding further abstraction layers could boost productivity even more. For example, you could use libraries or services for all business functions. Ultimately, you could do away with coding altogether and allow solution development simply by, let’s say, configuration. If this sounds a bit too good to be true, that’s because it is.

When raising the level of abstraction, you face a fundamental dilemma: how do you make a really simple model without losing too much flexibility? For example, if a developer needs rapid direct-access to any file location, the file stream abstraction actually gets in the way because it requires reading files sequentially. The best abstractions are therefore those that solve and encapsulate the difficult part of the problem while leaving the user with sufficient flexibility.

Note

If an abstraction takes away too many or the wrong things, it becomes overly restrictive and no longer applicable. If it takes away too few things, it didn’t accomplish much in terms of simplification and hence isn’t very valuable.

Or as Alan Kay elegantly stated: Simple things should be simple, complex things should be possible. 1 MapReduce , a framework for distributed data processing, is a positive example: it abstracts away the gnarly parts of distributed data processing, such as controlling and scheduling many worker instances, dealing with failed nodes, aggregating data across nodes, and so on. But it nevertheless leaves the programmer enough flexibility to solve a wide range of problems and was extremely widely used within Google.

When Are We Configuring?

So, if configuration promises us to abstract away the details of programming, we should look a little closer at the trade-offs that were made. But before we get there, it turns out that it’s not even trivial to determine when something is configuration as opposed to coding. The notion of configuration is mostly made by conflating several, unrelated aspects:

  • The representation (e.g., visuals versus text)

  • Whether you provide data or instructions

  • Whether you make changes before or after deployment

Let’s dissect each of these a bit.

Model Versus Representation

Coding abstractions such as libraries take away implementation details, but you’re still coding, although against more powerful objects and methods. Enterprise software abstraction often comes in different packaging, a graphical user interface (GUI) that enables spiffy drag-and-drop demos, which make the whole exercise seem trivial.

At first sight, we might believe that painting a thin visual veneer over an existing programming model can provide a higher level of abstraction. Many business users might at first agree: typing in commands surely looks like coding, whereas drawing diagrams feels a lot more like PowerPoint. Unfortunately, that’s an illusion: a GUI changes the representation , but not the underlying model . A complex model, such as a workflow engine that includes concepts like concurrency, synchronization, correlation, long-running transactions, compensating actions, and more, inherently carries heavy conceptual weight: there’s a lot of stuff to consider. Wrapping it in pretty visual packaging can make it more appealing, but it won’t remove this weight. If your synchronization bar is drawn in the wrong place, your workflow is just as broken as when making a coding mistake.

This isn’t to say visual representations have no value. For example, representing visual workflows as graphs can be naturally expressive. But although they may reduce some of the initial learning curve, they generally don’t scale very well: once applications grow, it becomes difficult to follow what’s going on via a giant canvas of symbols. Zooming out means text won’t be readable anymore. Debugging and version control can also be a nightmare given that these tools mostly lack familiar diff functions.

To test whether the visuals are just a thin veneer or really a better model, I generally apply two tests when vendors provide a demo of visual programming tools:

  • I ask them to enter a typo into one of the fields where the user is expected to enter some logic. Often this leads to cryptic error messages or obscure exceptions in generated code later on. This is “tightrope programming”: as long as you stay exactly on the line, everything is well. One misstep and the deep abyss awaits you.

  • I ask them to leave the room for two minutes while we change a few random elements of their demo configuration. Upon return, they would have to debug and figure out what was changed.

So far, no vendor has taken the bait; they presumably know that failure doesn’t respect abstraction. 2

Code or Data? Or Both?

Leaving visuals aside, at which level of abstraction can we call something “configuration” versus “high-level programming”? We’ve seen that despite repeated vendor messaging, a visual user interface doesn’t suffice. Many programmers will tell you that files in XML (or JSON or YAML) syntax are configuration. However, anyone who has programmed in XSLT, which uses XML syntax, can attest that this isn’t configuration but heavy-duty declarative programming. There’s nothing simple about it.

A better decision criterion could be whether what you provide to the system is executable or pieces of data. If the algorithm is predefined and you supply only a few key values, it may be fair to call this configuration. For example, let’s assume a program needs to classify users of different ages into children, adults, and seniors. The code will contain a chain of if-else or a switch statement. A configuration file could now supply the values for the decision thresholds; for example, 18 and 65 . This would fit our definition of configuration.

We might now conclude that changing those values is safe: typing in a number keeps you from having to understand programming language syntax and operator precedence. Alas, it doesn’t save you from screwing up the program. If you accidentally enter the values 65 and 18 , the program is likely to not work as expected. The exact program behavior in this case is impossible to predict as it depends on the way the algorithm is coded. If the program checks for children first, you may have declared everyone as a child, whereas if the program checks for seniors first, you may have made everyone a senior. So while configuration is safer, it isn’t foolproof.

The distinction between code and data blurs further when the data you enter determines execution order. For example, the “data” you enter may be a sequence of instruction codes. Or the data may resemble a declarative programming language; for example, to configure a rules engine or even XSLT. Aren’t coding instructions just data for the execution engine? Von Neumann 3 would have said so. Apparently, it’s not so black and white.

Deployment at Design-Time Versus Runtime

Another way configuration is commonly distinguished from code is that we can change configuration after the application is deployed. This is certainly useful given that we can’t foresee some parameters until runtime; for example, the number of servers we need ( Chapter 9 ). The distinction is based on the underlying assumption, though, that changing code is something that’s slow (because you have to rebuild and redeploy the whole application) and risky (because you may be introducing new defects). Microservices architectures and automated build-test-and-deploy chains put quite a few question marks behind these assumptions: they enable teams to rebuild, test, and deploy application code rapidly, repeatably, and with high quality.

Note

Rather than trying to anticipate changes for configuration, you may want to invest in your tool chain to allow incremental, rapid deployment.

This doesn’t mean that configuration is useless, but it does mean that modern software delivery has given us other tools to achieve much of what configuration was intended to do. If we can make changes in the code, we don’t have to decide a priori which parameters we allow to be configured later, leading to much simpler code. Plus, we benefit from a fast range of tools like version control, editor support, and automated testing.

Note

When enterprise vendors tout their configuration suites, I challenge them to speed up their software delivery model.

The lack of tooling makes the common assumption that configuration is safer, a questionable one. For example, “Configuration changes” have caused major outages at several cloud services providers. 4

Higher-Level Programming

In many cases, what’s being passed as configuration is really higher-level programming. For example, when composing distributed systems by connecting them via named message channels, “configuration” files often determine over which channel(s) a component communicates. Two components talk to each other when they use the same channel. Entering this data in local XML configuration files seems convenient, but it’s prone to mistakes because a simple typo would mean that components don’t communicate or are chained together in the wrong order.

Composing a messaging system isn’t a matter of configuration, but a high-level programming model for the composition layer of the system. Treating the configuration files as first-class citizens by checking them into source control and by creating validation and management tools 5 can help debugging and troubleshooting enormously.

Configuration Programming

Whenever there’s a choice to be made—in our case programming versus configuration —you can be assured that someone has found a compromise. In our case this would be configuration programming : 6 an approach that advocates the use of a separate configuration language to specify the coarse-grained structure of programs. Configuration programming is particularly attractive for concurrent, parallel, and distributed systems that have inherently complex program structures.

Configuration Hiding as Code?

So, is there a good place for configuration? Yes, for example, injecting runtime parameters into highly distributed programs or setting up cloud infrastructure ( Chapter 14 ) are great use cases for configuration. Oddly, much of these approaches run under the moniker infrastructure as code (IaC) these days, even though most of the tools really are configuration. Someone must have felt that code sounds more powerful than configuation .

Abstractions are a very useful technique, but believing that labeling something as “configuration” is going to eliminate complexity or the need to hire developers is a fallacy. Instead, think about whether this “configuration” is really higher-level programming. And in either case, make sure that it undergoes the same best practices of design, testing, version control, and deployment management that defines modern software delivery. Otherwise, you’d have created a proprietary, poorly designed language without tooling support. Then you would have been better off coding.

1 Wikiquote, “Alan Kay,” https://oreil.ly/SBC39 .

2 Gregor Hohpe, “Failure Doesn’t Respect Abstraction,” The Architect Elevator (blog), January 21, 2019, https://oreil.ly/ejTmy .

3 Wikipedia, “von Neumann architecture,” https://oreil.ly/ilzNC .

4 Benjamin Treynor Sloss, “An Update on Sunday’s Service Disruption,” Inside Google Cloud (blog), June 3, 2019, https://oreil.ly/yaGr6 .

5 Gregor Hohpe, “Visualizing Dependencies,” Enterprise Integration Patterns (blog), July 12, 2004, https://oreil.ly/1j4-7 .

6 FOLDOC, “Configuration Programming,” https://oreil.ly/DkiV0 .