Blog

In the Defense of Spaghetti Code

Have you ever seen a function that spans 1500 lines of code? At that point every semi-decent programmer curses spaghetti code in general and the author of the function in particular and embarks on the task of breaking it into managable chunks, trying to decompose the problem into orthogonal issues, layer the design properly, move the common functionality into base classes, create convenient and sufficiently generic extension points et c. If done properly, they'll end up with well-defined...

Comments: 22

Poor Man's Scientific Method

I've had the following conversation with my girlfriend lately: A: Let's vaccinate our kid. B: But I've heard that vaccination can cause autism! A: It's a hoax. There's no scientific evidence for the claim. Use scientific method. Read the related papers. B: But I've searched for the papers on the Internet and I've found one that claims that vaccination causes autism. A: You've got the wrong one. There are others that prove there's no correlation between vaccination and autism. B: How...

Comments: 16

The Second Step Towards Immortality

There have been some talk about achieving immortality via Internet. The idea was that if you store all your personal data, basically your stream of consciousness, in Facebook or Twitter (and, of course, NSA reconds), some of your identity, your memories, speach habits, sense of humour, survives even your death. While that seems to be a pretty diluted form of immortality, comparing it to the past reveals that it is actually a huge step forward. As for your great-grandparent born around 1900, you...

Comments: 8

Bitcoins & Deflation

Once again I've stumbled over an article today that suggests that the big problem with Bitcoin is deflation. The overall amount of Bitcoins is fixed, thus, there's no way to inflate the currency and the only possible outcome is ever increasing value of the coin Consider the following facts though: All the Bitcoins will be mined in approximately 100 years. The human population will reach its peak in 100 years and starts declining afterwards. Comment: Pt 2 is the official UN estimate. I've also...

Comments: 3

Fighting Efficiency

As tasks are getting automated and don't require much human intervention anymore we are heading to the world where 10% of population would be able to produce all the goods needed. While that sounds like a good news at first, there's a big question lurking in the background: How is the 90% going to make their living? They are not. If nothing changes they are going to die of hunger. And even worse, once that happens there will be only 10% of the population left, so the market shrinks to one tenth...

Comments: 9

The Pashalik Syndrome

Ottoman Emptire was composed of administrative units called pashaliks (in the west) or eyalets (in the empire itself). Each pashalik was headed by pasha, a dignitary with absolute power within the confines of the territory. Pasha was in charge of military as well as of finance, police and justice. In other words, he was a little sultan within the pashalik. The only drawback of being a pasha was that the position was temporary. Pashas were appointed by sultan or grand vezier and could be removed...

Comments: 0

Beyond Rational Idiotism

Yesterday, I've stumbled over an interesting article: Contracts Without Trust or Third Parties. It proposes a way to create contracts in such a way that they don't have to be enforced by third parties (legal system, police, bank etc.) The primary example is selling things over internet. The contract should ensure that neither party cheats and decides not to deliver goods or money as agreed beforehand. In short: I am selling you a book for $10. Each of us makes a deposit of $30, then we lock the...

Comments: 4

Tragedy of the Commons and Tragedy of the Privately Owned Land

Familiar with the parable called Tragedy of the Commons ? It goes like this: Villagers share grazing land. Instead of each one having their own fenced piece of it, they are all free to use the whole extent of the pasture. Every villager owns one cow and everything works great. One day a local idiot realises that he could get rich by having more cows. He buys ten cows and uses the common pasture to feed them. Other villagers get pissed off bacause: First, the idiot gets richer than them. Second,...

Comments: 9

Public Key Encryption for Kids

While everybody is using public key encryption, it's not at all obvious how it works. The whole idea is counter-intuitive. Everyone can encrypt a message but only one person can decrypt it? Really? Are you kidding me? However, when you try to gain some confidence in the system if for nothing else, just to make sure that it's not a hoax played on you by the cryptographers you are pointed to scientific papers: The system works like this: [complex math]. The system is secure because: [more...

Comments: 0

Backdoors in Encryption Standards and How To Fight Them

In the last week there a lot of discussion of malevolent parties putting backdoors into encryption standards and how to prevent it. There have been a long thread at IETF mailing list about the topic (starting here). NIST re-opened one of its standards due to worries that the backdoor was built in by NSA (see here). And so on. It may happen that security agency walks into a standards body and demands that the backdoor is built in. That is a rather trivial case and it can be handled by adjusting...

Comments: 0

nanomsg: Towards Full-Blown Configuration Management

There have been no administrative functionality in ZeroMQ, nor there is one in nanomsg. Adding such functionality is currently being discussed on nanomsg mailing list and I feel that it may prove confusing for those not directly involved in the discussion. This blog post thus tries to introduce the basic idea and the use cases without digging too deep into the implementation details. When you are connecting two components via nanomsg, you typically do it something like this: nn_connect (s, ...

Comments: 21

Event-driven architecture, state machines et al.

In my previous blog post I've described the problems with callback-based architectures and hinted that the solution may be replacing the callbacks by events and state machines. In this post I would like to discuss the proposed solution in more detail. Specifically, I am going to define what the events and state machines actually are and explain why they are useful. While the article may be used as an intro to nanomsg's internal architecture it can be also be though of as an opinion piece of...

Comments: 16

The Callback Hell

I've spent last month re-writing the code of nanomsg to use state machines internally, passing asynchronous events around instead of using random callbacks between the components. The change is complex, requires a lot of work and it is not visible to the end user, so the question is: Why do it at all? The time can be put to better use implementing sexy new features that would make the users happy. Instead, the progress on the library seems stalled and such major re-write may even result in...

Comments: 55

Getting Rid of ZeroMQ-style Contexts

I've argued several times (see for example here) that global state in a library should not be truly global, i.e. stored in C-style global variables, rather an instance of the global state should be created upon user request. The reason is that if the two modules within a process used the same low-level library, they would step on each other's toes: Imagine the library C has a global variable foo and setfoo() and getfoo() functions to access it. Now imagine the following sequence of events: ...

Comments: 8

TCP and heartbeats

Heartbeating is a common technique to check whether network connection is alive. The idea is that each end of the connection sends small packet od data called hearetbeat once in a while. If the peer doesn't receive a heartbeat for some time (typically a multiply of the interval between the heartbeats), the connection is considered broken. Interestingly, TCP protocol doesn't provide heartbeats (there are optional keep-alives that are operating on scale of hours, but these are not really useful...

Comments: 27

How to Write a Language Binding for nanomsg

FoldUnfold Table of Contents Reusing ZeroMQ bindings Forking ZeroMQ bindings Writing a new binding Plug-ins vs. native code Plug-ins Native code Run-time retrieval of constants Managing socket lifetime Sending and receiving messages Zero-copy Error codes Handling EINTR Polling Modularity Language bindings are pieces of infrastructure that allow nanomsg to be used from different programming languages. This article is meant to provide some hints that may be helpful for binding developers....

Comments: 0

Using Survey Protocol for High Availability

I've already wrote about survey scalability protocol in this blog. The article explained how the survey protocol can be used to collect information from a set of computers. This article, on the other hand, shows how to use survey protocol to combine high reliability with low latency. First, let's have a look how REQ/REP protocol handles reliability. The basic idea is that there are multiple instances of the service, so if one of them fails, others are still available for processing requests....

Comments: 0

Optimising Subscriptions in nanomsg

When I was writing ZeroMQ's subscription subsystem, my assumption was that there will be thousands or in the worst case tens of thousands subscriptions at any single time. The assumption reflected my background in financial services, where subscriptions are mostly used for subscribing for stock quotes. The topic you subscribe to is the name of the stock and there are, typically, some tens of thousands of those, even if you take into account derivatives like futures and options. However, it...

Comments: 6

Messaging & Multiplexing

I've originally written this article in September 2011. Given that I've had several discussions about multiplexing inside of messaging solutions in past few days, I've decided to re-publish a slightly improved version. Introduction Some messaging technologies (e.g. AMQP) allow for multiplexing several data streams on top of a single TCP connection. Distributed messaging systems such as ZeroMQ which assume lot of small independent services running on a single box or even inside a single process...

Comments: 0

Bus Messaging Pattern

The idea underlying bus messaging pattern is to provide the semantics similar to those of the hardware bus everyone connected to the bus gets any data sent to the bus just to do so on the higher layer. So, to use messaging terminology, everyone connected to the message bus gets any message sent to the bus. This pattern doesn't scale well at some point the number of applications connected to the bus will grow to the point where they will be overloaded by sheer amount of messages they...

Comments: 5

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