Website of Martin Sústrik, creator of ZeroMQ, nanomsg, libmill and ribosome.

Feuilletons about software design, economics, complex systems and psychology of programming.

Be just or be data-driven?

There was some Amazon-bashing going on at Hacker News lately and one of the commenters came up with a story about a guy whose business used Amazon for sales and advertising. One day Amazon permanently revoked his account, no explanation given. The comment describes the consequences: This person lost everything they built over four years of hard work and had to file for bankruptcy when the commitments made by the business to support a multi-million-dollar-per-year supply pipeline caught-up with...

Comments: 3

OO languages spend most effort addressing a minority use case

Programming language design must take many aspects into consideration. Fitting it's target domain, performance, style and so on. One aspect I am personally most interested in is expressivity. Specifically: If I take a diagram from my sketchbook, is there a way to express it in the language? If I draw two boxes connected by an arrow, is there any way to capture the relationship in the language itself or do I have to resort to comments? For example, SQL is good at expressing cardinality: For one...

Comments: 13

Documentation at scale: The principles

I've been thinking about documentation a lot recently. Namely, how to maintain internal documentation in a large-scale project where multiple teams are involved and whose lifetime is measured in decades rather than years. The challenges in such environment are very different from what you experience when writing the documentation for your personal hobby project. In the latter case it's just a question of writing the document. In the former case, though, there's a whole bunch of different...

Comments: 10

Document intent not algorithm: A use case

It's often said that when writing comments you should document intent rather than algorithm. However, I think lot of programmers haven't really grasped the maxim. Therefore, I was trying to come up with a minimal use case, an example that would illustrate, in very simple and easy to remember way, why that is the case. Imagine you are debugging an application written by someone else. You have little understanding of how it works, what are the data structures or algorithms and so on. When you look...

Comments: 9

Advanced metaprogramming in C

Metaprogramming in C is the art of creating new language constructs, typically using macros. Great introduction to C metaprogramming by Simon Tatham can be found here: Metaprogramming custom control structures in C Recently, however, I've faced a problem that could not be solved by the means outlined in the article. I was implementing a control structure with variable number of clauses, similar to C's 'switch' statement. To be more concrete, I was trying to implement an equivalent of golang's...

Comments: 2

Let's stop kidding ourselves about APIs

I've browsed resources about API design on the web lately and I was rather surprised that I haven't seen a single mention of the most important thing to know about APIs. And by most important I don't mean covers 20% of the topic but rather solve it and the rest of it can be done by a monkey sort of thing. Here it is: API is a POLITICAL concept, not a technical one. Arguing that API is a technical problem is like arguing that state borders are a geographical phenomenon. Yes, boundaries...

Comments: 11

The Second Use Case for Literate Programming

Everyone have heard that Donald Knuth have invented something called literate programming . Everybody thinks that it's something like commenting your code very heavily, but maybe not maybe it's different in some way. Wikipedia isn't of much help. Nobody is quite sure. To understand what's going on, you have to remember what Mr. Knuth does for living: He's an academic. He writes papers and textbooks. And how does a paper about computer science look like? It's nicely formated text, with...

Comments: 10

A case for unstructured programming

Let me say few words about unstructured programming. First of all, almost nobody can do it any more. You don't believe me? Just try writing you next project in unstructured way, Instead of: if(x) { do_stuff1(); do_stuff2(); } write: if(!x) goto stuffed; do_stuff1(); do_stuff2(); stuffed: Very soon you'll feel that creeping sense of insecurity: Am I doing it right? If this thing going to be maintainable? And what are the best practices anyway? To be fair, the above doesn't apply to...

Comments: 12

Where are Python macros?

Everyone believes that macros (as in C preprocessor and assembly macros) are the Bad Thing and no modern language with any self-respect has them. Yes, UNIX philosophy explicitly says Avoid hand-hacking; write programs to write programs when you can but without a decent macro language, code generation has to be done by an external tool, which makes it obscure and unreadable for anyone beyond the author of the code. (We've actually seen this. OpenAMQ project was havily code generated which then...

Comments: 12

Dissecting Software Component's Reproductive System

After writing reusability trap blog post where I played with evolutionary concepts in the area of sofware engineering I was pointed to the Selfish Class essay, which explores similar landscape. The article is fine although a bit naive. It makes it sound like programmers were in control of the evolution of software. Whereas, in fact, they are just a useful source of random mutation in the self-driven evolutionary process. That is, I guess, both bad news (The horror! We are not in charge!) and...

Comments: 0

Finish your stuff

If there is one principle that should be added to the UNIX philosophy, it is: Finish your project. It's the most simple, yet the most disregarded software engineering princinple I can think of. I dare you to list three finished software projects. Having hard time, eh? Except for some basic UNIX tools, like grep or make, it's almost impossible to find anyting that's truly finished, not simply abandoned. Imagine the carpenters were like programmers. You bought a chair. You bought it because...

Comments: 22

Reusability Trap

Truly reusable components are clearly separated from the code that uses them. That makes it easy to use the component in a different project. It also makes it easy to rip the component out and replace it by a different one. Non-reusable components cannot be used in different projects. At the same time, they tend to be hairy and almost impossible to rip out of their native project. They are interconnected with the rest of the codebase in subtle ways. Replacing them can break the functionality in...

Comments: 10

Coroutines in C with Arbitrary Arguments

There are many C coroutine implementations out there. However, they usually allow only a single predefined type of function to be exected as a coroutine. For example, both libtask and libcoro require that the coroutine has the following prototype: void foo(void *arg); The following toy implementation of coroutines shows how to execute an arbitrary function as a coroutine. The idea is that if the coroutine invocation performs the context switch to the new coroutine straight away, it can use C...

Comments: 0

A cryptopuzzle. Ready, steady, go!

I've solved a nice cryptopuzzle yesterday and solving it was so much fun that it would be a shame not to share it. The background is simple: Elections. There's a lot of clever crypto being devised to help with elections (see e.g. E2E audiatable voting systems , also nice talk here), but, as you might notice, there's always an assumption that the voter will come to the polling place to cast the ballot. Half a minute or so of the enforced privacy in the booth is necessary for the voter to do their...

Comments: 19

Non-interactive zero knowledge proofs for fun and profit

Intuitive explanations of the zero knowledge proofs on the web have been rare. There is the classic Alibaba's cave parable, but while it is generally comprehensible it's too simplistic, in my opinion, to explain the topic fully. Luckily, recent article by Matthew Green does a great job at providing an intuitive introduction to the topic: http://blog.cryptographyengineering.com/2014/11/zero-knowledge-proofs-illustrated-primer.html But while good explanations of zero knowledge proofs have been...

Comments: 2

The Clockwork inside Game of Thrones

When Ned Stark got executed by the end of first season of the TV series everyone went like: Ugh! Not possible! He's the protagonist! He just cannot die like this in the middle of the story! Ridiculous! What's the next season going to be about? The deep sense of confusion that the event causes is he result of a completely new story-telling device invented G.R.R. Martin. And when I say completely new I don't mean it in the sense of the best one this season but rather as I cannot think of such...

Comments: 3

Bullshit jobs

There have been a nice article by anthropologist David Graeber about what he calls bullshit jobs. I recommend to read it in full, however, in case you don't, here's a short summary: In 1930's Keynes, reflecting on the improving productivity, predicted that by the turn of century we should be working only few hours a day. The productivity did in fact improve but, surprisingly, the working hours are longer today than they've used to be back then. So what's happening here? Mr. Graeber attributes...

Comments: 16

Magic numbers in C

I was asked today why I often use magic numbers in my code. It's a small issue, but I feel passionately about it as the current trend of replacing every constant by a symbolic name is extremely annoying. And insistence of some code analysis tools on treating all magic numbers as coding style errors drives me crazy. Just the give you the context, here's an example of magic number: i = i + 4; And here's a fixed version of the code: #define FOO 4 ... i = i + FOO; There are certainly cases...

Comments: 9

Are you a programmer-mathematician or a programmer-handyman?

I always assumed that programmers hate complex tools and, if given the option, choose simple tools that get the task done over complex multi-purpose ones. (And that complexity we encounter in the tools these days is mainly because develops are paid by hour rather than by delivery. If dealing with a complex tool meant you'll miss your kid's baseball game rather than just the project schedule slipping slightly, there would immediately be an enourmous pressure on tool developers to keep the tools...

Comments: 40

Idiot's Guide to ABI Versioning

Libtool ABI versioning is used in both nanomsg and ZeroMQ, so I've been dealing with it for a long time now. However, for some not completely obvious reason it seems almost impossible to remember how it works. I've observed myself as well as other people forgetting the rules over and over again. This short article is my attempt to formulate libtool ABI versioning rules in such a way that they can be actually remembered. First of all, don't think of the ABI version major/minor/patch version, e.g....

Comments: 0

page 1 of 3123next »

Website powered by Wikidot.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License