The while-else-loop

Sometimes, „while“ and „if“ are interchangeable, for example while if you are „iterating“ over a collection that will only contain one or zero elements. In Java, both constructs have the same syntax, so I often find myself switching from one to the other.

Yesterday, I didn’t notice that my „if“ construct already had an „else“ branch, and so I created a while-else-loop. It took Eclipse like 10 seconds to realize that there’s something wrong, so when I saw my error after about 5 seconds, I instantly though „maybe that’s valid Java, and nobody ever noticed…“. Well it isn’t, but now I’m asking: why? And while I’m talking about the while-else-loop, what about for-else?

Often, you find yourself dealing with empty collections manually, like this:

Collection<Stuff> myStuff = getStuff();
    System.out.println("I've got no stuff.");
    for(Stuff s : myStuff)
        System.out.println("I've got " + s.getDescription());

Wouldn’t it be nice to have something like

Collection<Stuff> myStuff = getStuff();
for(Stuff s : myStuff)
    System.out.println("I've got " + s.getDescription());
    System.out.println("I've got no stuff.");

That would be pretty neat. But once you think about common loop idioms, there’s even more to invent.

And sometimes, you have to do something before the first and after the last line, but not if there are no lines. Or you have to do something between the lines, or just before the last one. Imagine your collections contains {socks,cups,dust,chocolate,nails} and you want to create an output like this:

I’ve got socks, cups, dust, chocolate and nails.

Normally, this involves heavy if-else action, and counting, like that:

Collection<Stuff> myStuff = getStuff();
if (myStuff.isEmpty()) {
	System.out.println("I've got no stuff.");
} else {
	int size = myStuff.size();
	int counter = 0;
	System.out.print("I've got ");
	for (Stuff s : myStuff) {
		if (counter < size - 1)
			System.out.print(", ");
			System.out.print(" and ");

Imagine writing it like that:

Collection<Stuff> myStuff = getStuff();
iterate(Stuff s : myStuff)
        System.out.print("I've got ");
        System.out.print(", ");
        System.out.print(" and ");
        System.out.print("I've got no stuff.n");

For While it may be overkill to put this into the Java language, I think it might be the right time for me to look into a language that has the degree of flexibility that allows me to introduce such constructs myself, without patching the compiler.

PS: Any ideas how to get syntax highlighting  into wordpress, given the fact that I want to use it for non-existing syntax constructs?

Random Malware Site – comes randomly, goes randomly

To reduce the risk of sending you to a malware site, I did not hyper-link the URLs which seemed unsafe to me. Thus, you can click any hyper-link in this blog post.

I just set out to read something about complexity. I used the google search box in Firefox to look for „law complexity simplicity“. The first result led me to – which is supposed to be the companion website to a famous book (that I once started reading but did not really like that much). After several redirects, one of which was

I ended up with a rather pretty made fake Windows Explorer, performing a virus scan, and warning me about an infected system. It automatically started downloading a setup.exe and somehow noticed each attempt to cancel that download. Many other popups appeared, some of which looked pretty realistic, and none of which were blocked by Firefox 3.5. It was hard to get out of it, because every killed message triggered two other ones. Whatever this site had to tell me about simplicity, my experience was anything but simple! Maybe I was right to dislike the book…

Luckily I’m on a Linux system and don’t get fooled that easy by some would-be-internet-explorer. Anyway, since I have wine on my computer, I’m not even save from windows malware on my Linux any more (if you don’t believe, click it). To help fighting such crap, I decided to report that site at – so I started filling out the form, and before submitting it, I decided to double check my findings. And on the second try (and the third and fourth and fifth…) the first site just loaded normally, no redirect at all, and even the click-go site seemed rather OK.

Now I’m wondering which of those is true:

  • I’m just too dumb to surf the web
  • A trustworthy site such as actively supports malware
  • just got hacked
  • The hackers are smart enough to trigger their stuff just once in a while to make it harder to detect and report
  • Or maybe there is something wrong with my local machine or the connection with the internet

If you’re feeling like willing to take a risk, you might try the URLs above for yourself and tell me if you experienced any weird stuff. If you do:

  • Consider filing a report to google (or other well known places to report malware)
  • Don’t blame me if that f***ed up your computer. I’ve warned you!


I just had a look at my browser history. I found out some of the URLs that I got redirected to, but it still seems incomplete. I’d rather not post those URLs in directly here, because I fear that my blog might be blacklisted as well, but if you are interested, you can download a text file that contains all those suspicious URLs.

Looking from the future onto now

When planing something, you normally focus on „what needs to be done first.“ I tried to take another perspective and imagine the project was already finished and I had to document it retrospectively. This way of thinking really helped me, so I want to explain the idea behind it and its outcome.

Given some well known branch of science or education, you will not only find a lot of talks, papers and articles, but also some sorts of compendium: A well structured, complete, assembled body of all relevant knowledge. Those compendia come as books, websites or lectures. If they are well made, their structure not only resembles the inherent structure of their universe of discourse, they also express the structural strengths and weaknesses thereof. Every complex system has weaknesses, because their inventors did not really know what their outcome after several years of hard work would be. If Brendan Eich would have known that people would do AJAX and mash ups (and evil Cross Site Exploits) with JavaScript, he probably would have done better when inventing it.

Now imagine that the developers of some system would have the chance to peek into the compendium about the system at hand before even creating it. They would have a clear vision of what lies ahead and of the possible complications that might arise, and would avoid many mistakes. Note that they need not read the whole thing cover to cover: A glimpse into the outline might be enough to boost their imagination.

Application to my project

Today, I sat back and had a look into the future: What would a compendium about Cubenet look like? At the bottom of this page, there is an outline of a possible book about it, and it serves several goals: It may give the reader (that’s you, for example) an overview of what’s inside Cubenet, but for myself and future developers it also is a map, showing what aspects need to be dealt with.

New scope to think about

Of course, this is not the first list of aspects of Cubenet. I had such outlines ever since, dealing with what needs to be build. But this one also has some bullet points for the aspects outside of Cubenet, which are closely related to it, in a way of what needs to be considered. This difference makes it much more exhaustive and thus more useful. On the other hand, there are even some details missing in this view. I spend the last weeks figuring out what language to write Cubenet in (C++) what interfaces to provide (C functions and stream over stdio, pipes and network) and how to build it (CMake). You won’t find any of those in my outline, and if this compendium was ever written, you probably wouldn’t find it in the full text neither.

And of course, this is only a fake, I did not really travel into another time to come back with this list, I just made up that future in my head so I could document it in some retrospective way of thinking. I’m currently fooling myself into believing that this _is_ the future, which is kind of ridiculous, but anyway, it kind of helps.

An example of a new insight

Just an example: Cubenet will be cool even without any special language. But at some time, you will want to have an expression language to dynamically evaluate properties. And you will want to have a scripting language to make those computations even more complex. And application developers will want something that integrates nicely with Cubenet. So I conclude that there might be a whole range of custom languages, but if I anticipate this, I could try to create a single language that fits all those cases, or I might find that this is impractical. I really found that out while creating this outline, because at first, those were separate bullet points on different ends of the list, but when sorting it into my fictional compendium, they eventually found each other and are now related.

Do I have to consider everything?

For some of the aspects of that outline, I already have a deep understanding and sometimes even a solution for each related problem I can think of. For other aspects, my mental model is more abstract, and on some of them, I’m completely clueless and only have a vague idea on why I put it on the list at all. I really need to handle those cases where I have no idea. Anyway, I could start to implement parts of Cubenet soon, without having everything laid out. As long as there is some coarse plan for each aspect, this is enough, and the details are on another page.

And of course, I can’t possibly know if my list is anywhere near completion, because I don’t know yet of what I currently don’t know. Ok, here’s the outline as it appeared somewhere in my head today, and I’m pretty surprised that I was able to write that down in about 20 minutes while listening to a lecture (which I had heard once before). Thinking about it for several years really pays of, and I remember that when I wrote my Bachelor thesis only a few months ago, I took several weeks to get to an outline that was as complete and well ordered as this one. This is because I wrote about portability of Java, a topic that was only on my mind since a few months (and which is actually not as trivial as it might sound!). So I did not expect that much of todays short brainstorming.


  • Purpose and characterization of digital information systems
  • Information Theory
    • Knowledge, Information, Data, Communication, Reality and Cognitive Science
    • Micro- and Macro-Theories, world knowledge
    • Logic, Contradictions, Reasoning, AI
  • Data Structures
    • Linear space, Symbols, Trees, Graphs, Relations, Sets, Tuples, Vectors, etc.
    • Categories and Inheritance
  • Common ways to implement information systems (the subsections of this one really need to be reordered. The way they relate to each other seems multidimensional to me, so how would I get them into a hierarchy?)
    • For personal use
      • offline
      • mobile devices / appliances
      • World wide web
    • For enterprise use
      • Middleware / SAP
    • Active research in KM and AI
      • RDF / OWL
      • Cyc
      • Multi agent systems
    • File systems
    • Database management systems
    • XML and related techniques
  • Problems of current approaches
  • Conclusions and overview of Cubenet


  • Domain models and data
  • Applications
  • Equivalent of Web Browsers


  • Identity and identification of real world entities
    • Merging and splitting of non-unique identifications
  • The Cubenet meta data model
    • Graph based view
    • Tuple based view
  • Standard serializations
    • Binary
    • Text based
  • Special data types and use cases
    • Measures and Dimensions
    • Spatial and Time based data
    • Table based
    • Mathematic structures
    • Natural language text and Documents
    • Graphical and geometric data
    • Native binary data


  • Collaborative, distributed data modeling and editing
  • Remote invocation, information vs. intent
  • Topology, roles and data flow in local and global networks, and within single machines
    • Peers, Repositories, Hubs
    • Emergent Structures, Neural and semantic associative networks
    • Push vs. Pull, Callbacks, Observers, Subscriptions
    • Routing
  • Standard network protocol and optional enhancements
  • Security, Cryptography and Web of Trust
  • Privacy, Copyright and Micro-payment

Application Development

  • Custom Syntax and Languages
    • Path, Filtering and Query
    • Expressions, dynamic evaluation and Scrips
    • Paradigms and languages for application development
  • User Interfaces
    • Guidelines
    • Libraries and system calls
  • Data access Library API, implementation and usage


  • Legacy systems (here you find some of the techniques from the first block. This duplication is on purpose.)
    • Data from legacy systems
    • Legacy systems for representation and interaction
    • Bidirectional updates with legacy systems
    • XML
    • RDF / OWL
    • Relational data bases
    • Object oriented systems
  • Subsets of Cubenet and interoperability
  • Random and Pseudo-random numbers
  • Efficiency, Optimization and Determinism
  • Future development
    • Known problems
    • Needed infrastructure and spin-off projects
    • Artificial intelligence

This outline will not be updated in-place. But there is a copy in the Cubenet redmine, which might eventually be kept up-to-date for some time.

Plain text, XML trees and graphs – and why reality takes more than this

Did you ever wonder why plain text files cannot contain structured data very well, for example, why the „good old“ ini files look so awful and chaotic in larger applications? Of course, it’s because plain text is plain. But not „plain“ as in „not colorful and with nice font variations“ but „plain“ as in „flat, linear“. It has lines, one after another, and each line has characters, one after another. And that’s basically all.

Ini files

Ini files, though never really specified, may have some more: headings in square brackets, and key value pairs. Maybe even comments. But still, complex data is hard to handle that way. (So is there are formal distinction between plain text files and ini files? Think about it, because the rest of the text has 11 other possibilities to ask a similar question, which I won’t do.)


This is where XML comes in. It is completely hierarchical, with a root element and any number of nested child elements. Then there are text nodes and attribute nodes, where text nodes can contain any text they like, and attributes consist of keys and values. This is a lot more structure than a plain text file, and is suited to represent almost every information you can think of. If you are used to XML, you just think in hierarchical structures, as if the whole world would consist of nodes with subnodes. And this seems only natural, since reality surely doesn’t consist of something linear like a plain text file. Sometimes, it’s not exactly clear what goes where: When you put statistics of what has been bought where and when into an XML file, is the <location> a child of <time>, or vice versa? Who cares, as long as it is a tree. If you really need it the other way round, you can always come up with some simple 143 line XSLT to transform it on-the-fly.


So let me tell you something important: The world is not a hierarchical thing, it’s not a tree. There is more than just linear structures and trees, for example there are graphs. To step up from XML to something graph based is like stepping up from plain text to XML. Some of the XML advocates would jump in yelling „But XML can represent graphs, like with RDF or OWL“. That’s true, because an RDF document is just a special form of XML document. Just as an XML document is just a special case of a plain text document. And because the is-a-relationship is transitive, an RDF document also is a plain text file, and as such, even plain text is capable to represent a graph.

Even more?

We’ve just seen three levels of structures and higher-order structures. So is an RDF-like graph the highest order of structure? No, because in RDF, you have triples of subject, predicate and object. You can express much with it, but there are lower level graphs, were connections are not directed, or higher level ones, where a connection can have more participants than just subject, predicate and object, like an adverb. Or you can bind the adverb to the triple, which needs reification (treating the relation as an entity, so it may be the endpoint of some other relation), but RDF has only very poor support for reification. Or you can have any number of objects bound by a single relation… the possibilities are endless.

Yet, when a programmer has to deal with information and thinks about graphs, it’s too easy to get stuck at what RDF gives you, just as it is too easy to take an RDF graph for its XML tree representation, and take this tree for the linearized plain text file. This is a mental issue, something each programmer has to overcome (and even I suffered from). Sometimes, it’s even wrong to think in documents, and you have to deal with the entities on another level, which my also be a mental problem.

Limiting technology

On the other hand, the technologies we use to manipulate that data is mostly web based, that means built on top of http, which is a protocol to request – guess what – plain text files. We do not have the technology to address actual entities or relations as nicely as we address plain text files. There are efforts to do this, but I call them „suboptimal“ at best.

Then there is tabular data, which is best kept in a relational database. Of course, you can always put it into texts, trees or graphs, but it does not really fit. Just as you can put any text, tree or graph into some database tables.


To summarize my key points:

  • XML is better than plain text, because trees are more advanced than linear structures
  • Graphs are even better than trees
  • There’s even something „above“ graphs, but this is too complex to be addressed here
  • RDF seems to be a nice representation of graphs, but it only models one special case of general graphs
  • It’s nice to be able to map graphs to trees and map them to linear plain text
  • Tables are just another way to store information, sometimes better than text, trees and graphs, sometimes worse
  • But we need protocols that work on another layer than just addressing plain text documents by their URL

These are some of the points that Cubenet aims to do better. I write this partly because I’m sure I already know how to do better, and partly because I must remind myself that some of this is still a great mystery to myself.

(Re-)starting a big project

In this post I want to look back on many projects I started, most of which were canceled in an early stage. Anyway, I think the time is right and the decision is clear to (re-)start Cubenet, my pet project since 2005, and assign it the priority it deserves.

I’ve always had my projects, mostly programming projects. If I don’t count all those small one page programs, I may have started about 300 of them, but only finished about 40. And it’s clear that no project is ever really finished, I just got them to a point where it’s close to completion. Most got canceled because I lost interest.

In 2005 I started Cubenet, a software concept for information handling, but right now, there’s nothing to show. You might count this as one of the 260 failed projects, but that’s not correct. I never lost interest, but I never had the time to work on it. Or maybe, I never took the time.


There’s an important invariant concerning time: You never have enough of it, there’s always much more to do than you ever could. So you do the most important things first, and the others afterwards. Cubenet never had the highest priority, so it never got the time it needed. I never had enough trust into this to assign a higher priority to it. So why is that?

First of all, as I said in the introduction, most of my projects „fail“. I used to think of this as a personal weakness, and so I was afraid to put large efforts into something that I would eventually cancel. Of course, this is exactly the wrong way round, but I didn’t recognize. If my projects fail because I’m not committed to them, then I won’t do any better if this leads me to even less commitment.

Child projects

Second, I used to start projects that I could never finish anyway. When I was 5, I insisted to file a patent for a chewing gum factory that I designed on paper. Age 6, I dug a hole in the ground because I wanted to build a subways station. My town only had buses, and I thought subways were much cooler than buses, so someone would have to start digging. Then, aged 9 or 10, I wanted to build the robot from the famous Johnny 5 movie.

None of this was feasible, but it’s no shame to talk about it, since I was a child. But when does this end? How do I know if I’m still a child with childish plans? When I was 13 or 14, when there were no MP3 players on the market, my father and I build one based on a do it your self kit, and I thought it would be cool to mass produce it, add a modem to it so it could connect to the Internet, and let people download music from a server, letting them pay for the music, and all this without a PC. This turned into a billion dollar marked some years later, but at that point, it seemed like another of my childish fantasies. I still mistrust my own ideas, especially when they are big and ambitious, which describes Cubenet very well.


Third, when I don’t consider my former projects, but just Cubenet on its own, there are so many reasons why it could fail. Failing is related to not getting finished, and the complexity of my concept clearly indicates that it is too big, that I could never finish every part of it on my own. So why even start?

While every project starts small, some aim for the small, and some for the big. Often I get the advise to aim for a small goal, along with some anecdotal stories about projects that tried to reach a small goal and evolved beyond that, to finally become something big. In my case, I’m bound to ignore that advise, because of my central belief about practical computer science: Programming has grown in complexity because the whole area of software development started out small, without the great picture in mind. Now, if you want to build a small thing, you have to deal with a dozen of layers, which evolved over 50 years. This could be done better if it was planned from the beginning. Cubenet is, in its core, an attempt to do it better, by aiming for the big goal and approaching it directly. So the project has a great goal by its very definition, and there are many who think it must therefor fail by definition.

Just doing it

I’ve finally come to my senses. Every project, no matter how big and how many persons it will take to complete, has to be started by someone. And now, that’s me, the crazy kid, grown up, old enough to make decisions, while not really wise enough to implement it all. But if you have a thousand crazy children like I was, digging in the ground, they will eventually build a subway station. Maybe they lack the skills at first, but after some years of work, they will have them. I don’t know the real source, because it’s been cited too often, but programming is a „wicked problem“, one that you only understand while you try to solve it. This is widely agreed upon, but opinions differ on whether this legitimates a restart from scratch, or if it must be tackled by incremental changes and refactoring. I’m not sure about it, but if there is a solution, I’m the one who sets out to find it, hoping someone might join along the way.

A scheduling trade-off

For Cubenet to succeed, I need not only overcome the many obstacles of software development, I also must overcome my intrinsic problem of time scheduling. That is, I must assign a priority to Cubenet, high enough to actually being worked on. With a classical scheduling, only the most important task is worked on, until it is finished, so the next important one may follow. For a long time project like Cubenet, this would be fatal: I would drop out of my university rather quickly, but eventually I would die of starvation because cooking meals has a lower priority. There has to be a compromise, like this one:

I’ll work on Cubenet as much as I can afford, and I think I must accept that other aspects might suffer, like my studies, free time, social life, etc. But if I define a limit on how much those may suffer, this gets manageable. This is the only way it can be done, and it might get easier with synergistic effects. Like integrating Cubenet into my studies. I failed at this at my former university, the Hochschule Harz, because I studied the wrong branch of computer science. Now at the Technische Universität Braunschweig, I’m at the right place, and there may be ways to bring it all together. If I’m forced to succeed, I will somehow succeed.

Linking it to people and obligations

There’s another advise to start a project, and not let it fall aside: Tell everyone about it. Tell about it, until they start asking about the progress, which somehow motivates. This is a common hint for people who want to stop smoking, but it applies elsewhere.

But sometimes motivation is not the problem, but justification: Is it right to spend time on Cubenet right now? Am I supposed to do something else instead? Yes, I am, but as soon as Cubenet is officially related to my studies, or science, or a job, I’m supposed to work on it, one problem solved. On the other hand, linking a pet project to a proper obligation bears the risk of control loss. Nobody will force me to do exactly what I already wanted to do, so if I need some force, it may come along with a shift of focus. I’m already afraid of it, but I have to face it. It’s no deal if Cubenet turns into the wrong direction at first, if I always keep enough control to change it afterwards. Licensing it under a copy left license enforces this, because everybody may develop it in any direction, which includes myself. Every study, research project or contract has an end, and with a copyleft license and version control, projects can evolve or stand still, but they can never fall back.

So now I’ve talked myself into taking this project serious, into writing about it and justifying my decisions. Now the actions must follow. To kick start this project, I’ve installed a Redmine workspace at and populated it with a huge mass of old notes, and a git repository for source code control. This is not only a place for old texts to get even older, it will be the central for cooperative working on the project itself.

If you feel like you want to be a part of my monster pet project, head over there and get yourself an account. Or just contact me with whatever you think about it.