software = science + art + people
— - title: Lacunas Everywhere date: 2014-07-16 slug: lacunas-everywhere redirect_from:
author: Daniel Hardman date: 2014-07-17 08:41:10 comment: | David: the problem I’m highlighting doesn’t require a new programming language; it could easily be solved by extending existing ones. In fact, I even toyed with the idea of writing up a proposal for C++17… However, “extending” doesn’t just mean adding a library or package into the core runtime; it would require a change in assumptions about what we believe is valid content for code. For that reason, I suspect that existing languages won’t glom onto it.
In my next couple posts, I’ll describe the solution. I’ve been slow to post, lately, but I’ll try to write them quickly so you’re not left hanging for too long. :-) I’m not trying to be mysterious; I’m just having a dickens of a time pulling half a dozen mental threads into a coherent tapestry.
Your connection with Knuth is an interesting one. I’ve heard of literate programming, and I’ve read some stuff by him before, but I am not very familiar with the specific idea you describe, so now I’ve got a new homework assignment. — - I’m told that in Czech, the word “prozvonit” means “to call a mobile phone and let it ring once so that the other person will call back, saving the first caller money.”
How would you translate this word to someone in New Guinea who has never experienced electricity, let alone a telephone or a bill from Verizon? You wouldn’t. This is an example of a “lacuna” — a translation problem caused by semantic gaps in a target language. Lacunas occur in programming languages. You might know a few; maybe you wish C++ had python-style generators — or that Java had Haskell’s notion of pure functions — or that C supported PHP-style string interpolation. But what if I told you that semantic misalignment between any pair of programming languages is just minor details? What if I claimed that all programming languages I’ve used have numerous, pernicious, and expensive semantic gaps? That we don’t see these gaps for the same reasons that a stone-age hunter-gatherer fails to notice his inability to discuss patterns of cell phone usage? Would you think I’m crazy?
Well, how many of the following scenarios sound familiar? (If this list gets too long, just read a few — but I wanted to show you how pervasive the problem is…)
this.size = size; this.color = color
. (Imagine if you could simply note a "copy args" intention and have the compiler generate the rest — automatically updating the assignments as code evolves...)// IF YOU EVER MODIFY THIS ARRAY, MAKE SURE YOU ALSO // MODIFY THE HANDLING ROUTINES IN xyz AND abc !!!(Imagine if semantic coupling were directly expressible to a compiler...)
I could go on. All day long, every day, developers around the world wrestle to codify constructs that really don’t map well onto the semantic space that their chosen language provides. Their language may be Turing-complete, but that doesn’t mean it’s semantically rich. The problem, I think, is caused by our industry Everything else goes in the comments. But programming languages have a dual audience (humans as well as compilers) — and the thinking, messy half of it gets neglected. We have a lacuna humana.
Perhaps you’re saying to yourself: “Language X has a way to solve problem Y.” At the micro level, I don’t necessarily disagree. I have written unit tests that (sort of) proved thread-safety in a codebase. I’ve created scripts that proved copyright/license compliance. I have found clever ways to enforce one or two high-value coding standards. I know about Ada’s numeric range types. I’ve decorated python code in such a way that prototype code was discoverable, so we wouldn’t ship it. I’ve used @Override
in java. The const
and constexpr
keywords in C++ tell you solve human problems, your coding tools are crippled by the narrow scope of the language they support. How much wasted time is attributable to issues like what I’ve listed?
Perhaps you’re saying to yourself: “Use the right tool for the right job. A programming language shouldn’t have the fuzzy jobs in the examples above.” Really? Almost every piece of code on the planet ends up having some kind of copyright/license associated with it. The license can be described in text, and it directly impacts hthe software is produced and consumed — but the language of the software should only concern itself with classes and functions, and ignore this issue? A language shouldn’t be indicted for creating useless redundancy that undermines encapsulation and the accuracy of docs? A language is well designed, even if it generates tons of useless warnings, displayed redundantly, for all time, to all coders who work on a codebase? I’m not claiming that tech writers should create content in the same programming language as developers, or that graphic artists should start coding instead of photoshopping their icons. We don’t need to compile gantt charts. I’m just saying that even within the domain of problems that software engineers usually own, our languages are too semantically barren to solve lots of real-world problems. This costs us real time and money.
It doesn’t have to be this way. If you’re following my blog, you know that I’ve been designing a new programming language. One of its most important innovations offers a quantum leap in semantic density, without lots of noise or bother. I’ll be explaining this feature, “marks,” in a series of follow-on posts. I hope you’ll subscribe or check back to see where I’m headed.