Archive for May 5th, 2006

Date and Time libraries in various languages

Can a correct, or even sensible Date, Time and Calendar library be designed, for any programming language at all, ever, by anybody, genius, time expert, or not? Certainly Java’s Date API isn’t very inspiring, but some systems do manage to do better: here’s a quick survey of the state of Date/Time/Calendar libraries in a few different languages.

  • Scheme’s SRFI 19 is, overall, an excellent library at its core (i.e. the specification of Time objects), but suffers from a number of bugs in its reference implementation, some quite serious, and lacks support for the timezone database.

  • Things may be looking up for Time processing in Java: the Joda Time library looks like it’s designed around the key separation of Instants, Intervals, and Durations from Calendar-related notions such as Dates, Times, and human-readable representations of time. The evidence suggests it may even deal with timezones properly.

  • Even C’s venerable time implementation (it’s an int! Everything’s an int!) is better than that provided by many languages. At least it’s correct and reasonably simple. The main flaw in it is the way that the current timezone is not even a global variable - it’s an environment variable. Trying to treat it as a parameter is an exercise in frustration, making timezone calculations far, far more difficult than they need to be.

  • Squeak currently has two major libraries: Chronology, the incumbent, and the comprehensive-looking newcomer Chronos. I’ve only ever used Chronology, but I can definitely say it was a very pleasant experience compared to every other language and date/time library I’ve ever used. Chronology doesn’t really do timezones (or leap seconds), and from that point of view Chronos is a significant improvement. Chronos looks very promising, but loading it broke my image (timestamping doits broke during save and quit) so I’ve not explored it in any detail.

3 comments May 5th, 2006 tonyg

APL: Cooler than you think

A couple of weekends ago now I attended the first UK Smalltalk meeting. Stephen Taylor spoke about some of his experiences using XP in the financial industry, and touched on his development of a financial DSL based in APL (!). There were a couple of informal talks introducing the APL programming language - it’s got a lot going for it. Bryce Kampjes gave a demonstration of his Smalltalk compiler, Exupery, and after the main talk gave a demo of how he debugs the compiler and some of the basic-block visualisation and disassembly tools he’s built. Marcel Weiher gave a fascinating talk on Higher-Order Messaging, Objective Smalltalk (an inversion of Objective-C where the message-send syntax is the default, and escaping to C is done with a special construct), stsh, a Smalltalk shell based on his Objective Smalltalk implementation, and Arches, an experiment in multiparadigm language implementation with an interesting approach to metaprogramming and reflection.

Thanks to all who gave talks! I’m looking forward to the next meeting.

Add comment May 5th, 2006 tonyg

Calendar

May 2006
M T W T F S S
« Apr   Jun »
1234567
891011121314
15161718192021
22232425262728
293031  

Posts by Month

Posts by Category