LifestyleIt's not what programming languages do, it's what they...

It’s not what programming languages do, it’s what they shepherd you to


- Advertisment -

How many of you have listened, read or taken part in a discussion about programming languages that goes like the following:

Person A: “Programming language X is bad, code written in it is unreadable and horrible.”

Person B: “No it’s not. You can write good code in X, you just have to be disciplined.”

Person A: “It does not work, if you look at existing code it is all awful.”

Person B: “No! Wrong! Those are just people doing it badly. You can write readable code just fine.”

- Advertisement -

After this the discussion repeats from the beginning until either one gets fed up and just leaves.

I’m guessing more than 99% of you readers have seen this, often multiple times. The sad part of this is that even though this thing happens all the time, nobody learns anything and the discussion begins anew all the time. Let’s see if we can do something about this. A good way to go about it is to try to come up with a name and a description for the underlying issue.

shepherding An invisible property of a progamming language and its ecosystem that drives people into solving problems in ways that are natural for the programming language itself rather than ways that are considered “better” in some sense. These may include things like long term maintainability, readability and performance.

This is a bit abstract, so let’s look at some examples.

Perl shepherds you into using regexps

Perl has several XML parsers available and they are presumably good at their jobs (I have never actually used one so I wouldn’t know). Yet, in practice, many Perl scripts do XML (and HTML) manipulation with regexes, which is brittle and “wrong” for lack of a better term. This is a clear case of shepherding. Text manipulation in Perl is easy. Importing, calling and using an XML parser is not. And really all you need to do is to change that one string to a different string. It’s tempting. It works. Surely it could not fail. Let’s just do it and get on with other stuff. Boom, just like that you have been shepherded.

Note that there is nothing about Perl that forces you to do this. It provides all the tools needed to do the right thing. And yet people don’t, because they are being shepherded (unconsciously) into doing the thing that is easy and fast in Perl.

Make shepherds you into embedding shell pipelines in Makefiles

- Advertisement -

Compiling code with Make is tolerable, but it fails quite badly when you need to generate source code, data files and the like. The sustainable solution would be to write a standalone program in a proper scripting language that has all the code logic needed and call that from Make with your inputs and outputs. This rarely happens. Instead people think “I know, I have an entire Unix userland available [1], I can just string together random text mangling tools in a pipeline, write it here and be done”. This is how unmaintainability is born.

Nothing about Make forces people to behave like this. Make shepherds people into doing this. It is the easy, natural outcome when faced with the given problem.

Other examples

  • C shepherds you into manipulating data via pointers rather than value objects.
  • C++ shepherds you into providing dependencies as header-only libraries.
  • Java does not shepherd you into using classes and objects, it pretty much mandates them.
  • Turing complete configuration languages shepherd you into writing complex logic with them, even though they are usually not particularly good programming environments.

[1] Which you don’t have on Windows. Not to mention that every Unix has slightly different command line arguments and semantics for basic commands meaning shell pipelines are not actually portable.

Join the pack! Join 8000+ others registered users, and get chat, make groups, post updates and make friends around the world!
Read More

- Advertisement -
Previous articleQuit Your Job
Next articlePaxos


  1. I will have to say that I like the direction that the V programming language (vlang) is going. It has blended many good qualities of Oberon/Pascal, C, and Go. I've read a lot of debates among C and Pascal advocates, so go to see newer languages trying to find middle ground.

    Debatably, the Go language tried to put itself somewhere in the middle, as a more modern acceptable compromise with its own twists.

    The V language appears to be taking it a bit further, where readability and maintainability is more evident, and feels like a more natural feature. At the end of the day, many want to be more focused on the problems to be solved, not tripping over the eccentricities and traps of the language.

  2. PHP has to be the worst offender with its pseudo-Java boilerplate enshrined in its PSRs. PHP is a perfectly fine procedural language but version 5 was like the Second Coming of Christ with its religious devotion to all things OOP. I don't know about shepherding – with PHP it's more like being beaten over the head with a club.

You might also likeRELATED
Recommended to you

Scaling Kafka at Honeycomb

When you send telemetry into Honeycomb, our infrastructure needs to buffer your data before processing it in our “retriever”...

Covid-19 may have killed nearly 3M in India, far more than official counts show

India, from the earliest days of the pandemic, has reported far fewer COVID-19 deaths than expected given the toll elsewhere—an apparent death “paradox” that some believed was real and others thought would prove illusory. Now, a prominent epidemiologist who contended the country really had been spared the worst of COVID-19 has led a rigorous new…

To Produce or To no longer Produce: Architecture for a Warming World

THE ARCHITECTURE COMMUNITY gives itself a lot of awards, and the biggest of all is the Pritzker Prize. This "Nobel for designers," established in 1979 by the founders of the Hyatt Hotels Corporation, rewards an architect with $100,000 for "significant contributions to humanity and the built environment through the art of architecture." Each spring, the…

Show HN: “crzy64”, base64 mod aimed for fastest decoding

An easy to decode base64 modification. This is a base64 modification designed to simplify the decoding step. For the four encoded bytes, it only takes 12 operations (+ - & ^ >) to convert them to 24 bits of data. Using 64-bit or vector instructions makes decoding even more efficient. But it's bound to ASCII…
- Advertisement -

Thich Nhat Hanh, Vietnamese Zen Master, Dies at 95

Thich Nhat Hanh at the Plum Village monastery in southern France | Courtesy Plum Village Community of Engaged Buddhism Vietnamese Zen Master Thich Nhat Hanh—a world-renowned spiritual leader, author, poet, and peace activist—died on January 22, 2022 at midnight (ICT) at his root temple, Tu Hien Temple, in Hue, Vietnam. He was 95. “Our beloved…

Before wave of train thefts, Union Pacific laid off some of its police force

News organizations both locally and nationally have been covering the rise of cargo theft in L.A.’s northeast train tracks in the past few days. Anchors on morning news have been quick to point out that there have been over 100 arrests, and even Forbes have been quick to point out the staggering $5 million worth…

Must read

Bevy game engine 0.6

The Lumberyard Bistro scene rendered in the New Bevy Renderer by @mockersf Thanks to 170 contributors, 623 pull requests, and our generous sponsors, I'm happy to announce the Bevy 0.6 release on! For those who don't know, Bevy is a refreshingly simple data-driven game engine built in Rust. You can check out Quick Start…

Show HN: Stay more productive with Work Timer – Pomodoro like technique online

Work Timer is Pomodoro™ inspired technique tool to help you stay more productive and concentrate on your work.The Pomodoro Technique is a time management method that uses a timer to break work into intervals, traditionally 25 minutes in length, separated by short breaks.Need help or have a suggestion?Contact us!
- Advertisement -