views:

156

answers:

1

I'm looking for something akin to JodaTime or JSR 310 for Scala that leverages nice Scala features such as operator overloading and doesn't rely on implicit conversions (I have an irrational fear of implicit conversions).

I'm aware of http://github.com/jorgeortiz85/scala-time, but it just pimps JodaTime with implicits.

A: 

There's nothing wrong with implicit conversions. Even if a Java library wasn't used for the underlying logic, any sensibly designed pure Scala library would still use implicits, allowing you to write expressions such as 5.days + 3.minutes.

Not all implicits are created equal either, an implicit converting to a very specific type that you have full control over is almost certainly safe .

As others have already stated, such conversions will be optimised away in most cases, especially with escape analysis turned on, so don't let them worry you!

Until JSR 310 is finalised, joda-time is the best you're going to get.

Other than the need to follow Java naming conventions and a lack of operator overloading, joda-time is already a very good fit for idiomatic Scala. The design is very functional in nature, especially the way it embraces immutablity, so scalaj-time is actually only a very thin wrapper around the library.

You also get the benefit that scalaj-time can be easily upgraded to use JSR 310 when it's available, so it'll be much less painful to migrate your code at that time.

Since 2.8, scala-time has been renamed scalaj-time: http://github.com/scalaj/scalaj-time

Kevin Wright
I can imagine that moving from Scala's JodaTime wrapper to Scala's JSR310 wrapper will be much less pain than using those things directly (or in Java). Would be fun if changing the export and fixing some class names would be enough :-)
soc
Implicit conversions add a semi-hidden layer of indirection above what wrapping does. This adds both complexity and runtime overhead. There is nothing wrong with them as a feature, but occasionally they are used in gratuitous ways.
Erik Engbrecht
Is it gratuitous to convert a naked integer to a number of minutes?
Kevin Wright