read


read
or learn more

The Nothingness Metric

Oct 19, 2010

I’ve been thinking of a code metric designed to measure how much code it takes any given language to write a program that does nothing. Don’t misunderstand me and think that I mean a Hello World program with 64K exclamation points tacked onto the end. What I mean is finding that critical point where a program crosses from ‘doing nothing’ to ‘doing something useful’. I tried to express this idea in my CUFP talk, but I failed miserably and it came off as a joke. Sadly I ran out of time before expanding on it. I have no idea if this is worth exploring further, but I’ll probably keep thinking about it nonetheless.

3 Comments, Comment or Ping

  1. F_D

    I’m intrigued. Trying not to misunderstand you here. I.e., a “Hello World” program doesn’t do nothing; esp. not if it outputs the text back to the user.

    I’ll lapse into my native tongue here:

    ; // does nothing but terminate the previous statement, even if there is no previous statement

    And/or:

    function(){} // perfectly call-able empty function, albeit arguably a syntax error w/o a name, nor being assigned to a variable

  2. That’s kind of interesting. So to rephrase what I think you’re saying, what’s the minimum amount of code you need to write to create a program that will be accepted without error by the compiler/interpreter, that does not do anything.

    I think in most languages that would reduce to the minimal set of comment delimiters for that language, so the next question would be what’s the minimal amount of code you need to write to produce a valid program that does nothing and has no comments. Like perhaps:

    JavaScript: a=a

    PHP/perl: $a=$a;

    Clojure: (def a)

    C: void function a() {}

    Java: public static void function main() {}

    Ok, I’m really rusty on my Java, but you get the idea.

  3. On re-reading your post, I’m thinking that those are the wrong questions. It sounds more like how much code you need to write to obtain a program that almost does something useful. That’s even more intriguing, but I’d better go get my morning coffee before I try and think any more deeply about it.

Reply to “The Nothingness Metric”