Post Unix OS
The most interesting technical read of last week was undoubtedly Ars Technica’s review of Mac OS X 10.6 by John Siracusa. While for consumers the new feature set is very modest, having a software company release a new version of an operation system with mostly bug fixes and performance improvements is something very interesting. I wish others would follow this example. Most engineer know that I you give them enough time, they can improve the code tremendously, most very often this time is not given.
Besides optimizations, Snow Leopard introduces a set of new technologies related to performance. As single core performance is not improving much anymore, this means more parallelism. Grand Central Dispatch is a operating system level work-queue management framework. The C language and its variants have been extended to support closures. Those closures can then dispatched to various work-queues. Instead of using a lock to protect a given resource, a serial work queue is created and associated with the resource. Where this gets interesting is that the closures might not run on the CPU: closures are compiled to LLVM code, which might be dispatched on the GPU using Open CL.
Taken separately, none of these technologies is really innovative – there have been numerous projects and language that implemented them. The caveat is that they only solved part of the problem and never managed to gain much traction outside of specialized markets. Here we have an operating system that lets the programmer handle the machine as if it were a small cluster. Code is compiled into some virtual machine code and sent to various processing queues. The number of processors, and their precise instruction sets are irrelevant. While on OS X, the code is only dispatched on the CPU and the GPU, this architecture can be used for sending processing to other machines or add-on processing cards. The grand plan of the Cell processor, where processing could be sent from your mobile phone could sent processing tasks to your TV set might still be relevant. The coolest bit is that most of those technologies are free: Apple open-sourced GCD, LLVM is open source, Open CL is a standard handled by the same group as Open GL.
What is also interesting is that Apple is incrementally replacing traditional part of the operating system with more modern versions. In previous versions Launchd replaced the traditional dæmons, DTrace was used to replaced various system probes. Now Apple has started to replace the tool-chain: clang is a new C-compiler that generates LLVM code, it currently only support C and objective-C, but C++ is in the works. While gcc is the traditional compiler it has many problems, its error handling is horrible, the generated code is far from optimal, more importantly its code base is monolithic and old, this means it is difficult to improve it in any way. Finally gcc is not designed in part as a library (say for integration into an IDE), the GPL license is also a deterrent for such adoption. My hope is that clang will have the same effect on the compiler world that Webkit had on web browser: make things move forward.