Previous: Gift vs. Reputation in OSS
Next: Moral Dunning-Kruger
I've started programming early, in 1984 when I was 11 years old. Back then I just had an idea of what the program should do and I did whatever was necessary to get there.
After that initial period of pogramming I haven't cared about it too much. I did whatever programming assignments we've got in school and later whatever work I needed to do to feed myself, but that was it. In the spare time I was mostly drinking with artists.
That changed in 2004. Back then I started to be involved in open source. The fact that I was delivering code, not a packaged product, sparked my interest in programming again. You see, with packaged product you provide people with a tool to do stuff. That's super useful and a noble endeavour but, at least for me, it is not very interesting. Delivering code, on the other hand, means putting an idea into other peoples' minds. And that kind of thing has an aura of magic that's hard to resist.
50,000 LoC
From 2007 to 2013 I've created ZeroMQ and later nanomsg. The idea I've tried to convey was that messaging patterns (request/reply, publish/subscribe etc.) aren't just some vague heuristics about how to make distributed systems but rather formally precise algorithms. Once you've understood what publish/subscribe means you knew exactly what kind of behaviour to expect from it and was able to use it as an atomic building block of your distributed application.
To pass that idea on I've created a library that encapsulated each of those patterns. As a user, you instantiated an publish/subscribe endpoint and that was it. It worked in publish/subscribe way. I hoped that people using the library will adopt those patterns and use them in their future work independent of whether they'll use ZeroMQ or not.
It took around 50,000 lines of code to get there.
5,000 LoC
In 2015 I've created a library called libmill. It's an easy to use coroutine library for C. Most of the code there is just a legwork, trying to rewrite Go's model of concurrency and make it so fast that the speed of coroutine creation or a context switch would be comparable to simple control constructs like 'if' or 'for'. The idea is that concurrency is literally just a bunch of control constructs. And the hope was that having a library which makes them equal performance-wise would shift the peoples' mental model of them.
In 2016 I've forked libmill and created libdill. The new idea here was that of structured concurrency. The idea that threads/coroutines can be cleanly nested in a similar way that we nest functions and objects. I've tried to examplify the concept by creating a new socket API that allows for fine-grained layering of network protocols.
In this case we are speaking about approximately 5,000 lines of code.
76 LoC
In 2017 I've created a tool called cartesian to deal with problem domains that are both highly repetitive and at the same time somewhat irregular. The idea is that the model of subclassing that we know from object-oriented programming is not the only possible. Yes, we can categorize animals to 'mammals' and 'fish', but those same animals can be as well categorized to 'land animals' and 'water animals'. In the subclassing model we have to decide which of those distinctions is more important and go with that. In cartesian, on the other hand, you treat both distinctions equally, as different dimensions of the same conceptual object.
The code to power it is very small. 76 lines of Javascript.
35 LoC
Last week I've written a small library called tiles. It comes from long experience with code generation. Your typical code generation product, like Jinja or Mako, or for that matter, my own Ribosome, are based on idea of a template code where you fill in some pieces dynamically. That makes sense if you want to generate a customized HTML page where all you want to change is say the username, the ID number and such. However once you try to generate an actual code, say a state machine, they become increasingly inconvenient. You have to mix the template code with the generator code which results in an unreadable mess.
Tiles, on the other hand, dispenses with the idea of the template and rather provides a way to manipulate and combine rectangular blocks of code in a simple fashion.
The module has 35 lines of code.
From Kaizen to Zen
You may have noticed a pattern. As the time goes by my code tends to be more and more concise. From 50,000 lines of code in 2009 to 35 lines of code in 2017.
One may consider that to be an improvement. As you get older and more experienced you can do more stuff with less code. What's there to object?
But let me ask a theoretical question: Is it possible to create a project with zero lines of code?
And yes, I can to imagine myself solving the last hurdle and finally deleting the last line of code. The project becomes perfect, yet, at the same time, incommunicable. Just try to imagine selling a library with zero lines of code. All that remains is mental pattern of how to solve the problem and there's no efficient way, short of telepathy, to instill that pattern into an other person's brain.
While it's totally reasonable for a person to use ZeroMQ (You don't want to write 50,000 lines of code yourself, do you?) why would they use Tiles, which is, after all, just a 35 lines long snippet of Python code?
But it's the act of using the library that establishes the idea behind it in your mind. If you don't use it you won't get the idea.
So, what appears to be an improvement in the terms of doing stuff, is actually a drawback in the terms of communicating an idea.
Kaizen, the process of continual improvement, have degraded to Zen, the act of solitary self-enlightment.
So here I sit, with no idea what to do.
Martin Sústrik, October 4th, 2017
Previous: Gift vs. Reputation in OSS
Next: Moral Dunning-Kruger
`tiles` is interesting. I wonder if you have here the minimal core of a browser layout engine. Not an existing engine, but something new and perhaps better, a tracking-free html replacement just for writing, not web apps. (https://news.ycombinator.com/item?id=11159532#11170697)
Back to ASCII web. Fun. However, I wonder how long would it take for ASCII graphic to kick back in, especially if different colors and font sizes are allowed.
Zero lines of code, genuinely useful, sold for five pounds a copy at the time:
https://web.archive.org/web/20100105021419/peetm.com/blog?p=55
Thinking about it some more, is tiles really helpful for code-generating anything but Python? (Or other indent-sensitive languages, like my Wart?) I'm starting to think its benefits with other languages would be mostly aesthetic, making the generated code look nicer.
For non-indent-sensitive languages it's mostly about reabability. This comes into play in at least two cases: a. you've written a generator and want to check whether it generates what you want it to generate 2. debugging the generated code.
Of course, if you have a tool like gofmt you don't need it. Just generate ugly, unintentionally-obfuscated code, then run it through gofmt and there you go.
Love nanomsg. Any chance you will take back maintainership and resolve existing bugs? Love to incorporate it and your coroutine library in my new lisp interpreter.
The lines of code are not important. My personal interest with metaprogramming was because it enabled to define a model that would describe the properties of the software and not to decrease the loc.
In a more advanced way , type systems and specifically dependendly typed ones enable you to define the logic of the program and then help the programmer write the implementation.
I believe python’s WSGI is exactly that. Zero lines of code, nothing to download/import/include, yet it’s pretty specific and very useful thing. There are web servers that implement WSGI, there are user programs that utilise it, but WSGI itself, as a glue between them, is reduced to exactly zero loc.
Yes, specifications and protocols are a good thing but I was rather talking about the implementations here. Once you drop the last line of code from an implementation there's no specification left. What remains is the ability solve that particular type of problem, a pattern stored in your brain. And it's not easy to communicate those.
The most orthogonal family of languages I know is the APL/J/K family. Functions like "average" or "maximum subarray sum" or "flatten" are usually 3-7 characters of orthogonal functionality combined to give the desired effect. The complete game of life in APL with display is a one liner, see e.g. https://www.youtube.com/watch?v=a9xAKttWgP4 or just google it.
If you find it interesting, I suspect you'll like the K language the best - more concise, more orthogonal, no special font.
Post preview:
Close preview