Sunday, April 20, 2008

Higher Order Messaging backgrounded

Piers Cawley talks about RSpec's use of HOM:
It is, however, encouraging to see initiatives like Rspec which, through judicious use of higher order messages enables a much more fluent environment for writing tests:
I think that's the first time I've seen HOM used to explain something else, rather than being the object of attention itself. So HOM is starting to be seen as simply a part of the computing landscape, at least by some. Cool. HOM was never conceived of as an interesting thing by itself but rather as a (meta-)building block for building more expressive computational forms. RSpec looks exactly like one of those cool things HOM enables that I would never have come up with myself. I look forward to seeing more.

Not just high performance Objective-C

Addendum to my article on implementing a high performance Postscript interpreter in Objective-C: not just is performance better, so is accuracy. Despite the fact that we are optimizing the heck out of the Objective-C objects we are using, they still give us encapsulation and polymorphism, allowing us to choose arbitrary representations. For example, most Postscript interpreters use a fixed-size value object (polymorphic in a C-union type of way) that constraints floating point precision to 32 bits. With Objective-C, we have no such constraints, so EGOS floats are actually 64 bit doubles, so running the modified benchmark below in PostView doesn't just yield the result 75% faster than Preview, it also produces it with 7 orders of magnitude less error. Not that that is necessarily important in Postscript, but it is a pleasant side effect and shows the power of combining performance with abstraction.
%!
  usertime
  1000 0 1 10000000 { pop 0.0001 sub  } bind for
  exch usertime exch sub dup ==
  20 20 moveto /Times-Roman 24 selectfont
  100 string cvs show ( ms) show ( error:  ) show 
  1000.0 div 100.0 mul abs  100 string cvs show ( %) show
  showpage