To ref count or not

A ‘Stop-The-World’ garbage collector makes it almost impossible to get performance estimates right. Given the vast combination of parameters that will influence actual deployments, we can’t predict when the collector will run. A reference counted real-time collector is simpler to implement and provides room for making better runtime estimates. But the VM should still keep track of allocated objects for two reasons. One is for doing a full sweep to break cyclic references. (Memory exhaustion caused by cyclic references are extremely rare. So in actual practice this collector will almost never run and memory management could be considered ‘real-time’). A record of allocated objects is also needed for providing data required by profilers. The Limbo programming language implements this scheme.

Pop culture

In this interview, Alan Kay laments about the ‘pop culture’ in computer science. Came across an article that shares a similar idea. Reading these brought to mind a prophecy that I read in an ancient scroll:

The required techniques of effective reasoning are pretty formal, but as long as programming is done by people that don’t master them, the software crisis will remain with us and will be considered an incurable disease. And you know what incurable diseases do: they invite the quacks and charlatans in, who in this case take the form of Software Engineering gurus.

Though superficially different, the three links above are, in fact, beads on a single thread.

invokedynamic

JDK 7 features. The most notable one is the new invokedynamic instruction, which will give dynamic languages first class status on the JVM. People are patching up things here. A VM for an Object Oriented language should be built around dynamic typing and true message passing. Dynamic typing is important because good software engineering means exploratory programming and prototyping. Message passing should be preferred over method calls because it melds well with dynamic typing, concurrency and component distribution. Smalltalk and Erlang got these right from the very beginning.

JDK 7 also features automatic resource management. If you have programmed in Common Lisp, you know what that means:

(with-open-file (file "some.data" :direction :output)
      (format file "whew!!"))

Now you can do the same stuff in Java:

try (file = new FileOutputStream("some.dat")) {
       file.write(buf, 0, len);
} // file is automatically closed here.

The last great idea in language design is probably (at least) 35 years old. Glad to see the world’s leading ‘enterprise language’ catching up – slowly!

PS: Static type checking, if required, can be implemented in the language being implemented itself. EOPL contains the best explanation (I have seen) on this topic.

Principles of design

Donald Norman’s key principles of design:

  1. Make it easy to determine what actions are possible at a particular moment.
  2. Make things visible – the conceptual model of the system, the alternative actions and the results of actions.
  3. Make it easy to evaluate the current state of the system.
  4. Follow natural mappings between intentions and the required actions; between actions and the resulting effect; and between the information that is visible and the interpretation of the system state.

In other words, the user should be able to figure out what to do without much instruction. He should also be able to tell what is going on. The reason for the design should be a simple explanation, even if that is required. If the explanation leaves the user confused, the design has failed. The interesting observation that Don Norman makes is this: when we are not able to figure out how to make a call from the latest smartphone or cannot locate a simple formatting command in a word processor, it is not because we are dumb, it is just another case of bad product design.