Friday, June 11, 2010

just use this one if you need per-thread smart(produces ints if can) parsing of json numbers:

trait SmartJsonNumberParsing {
  val doubleRe = """.*\..*""".r
  scala.util.parsing.json.JSON.perThreadNumberParser = { n : String => n match { case doubleRe() => BigDecimal(n) case int => BigInt(n) }}
}

Thursday, June 10, 2010

functional programming

Meanwhile "folding" is awesome. If you're from the non-functional-programming background, like me - learn one. Really blows mind as OO used to in the good ol' days.

blogging is about complaining isnt'it?

And here I come, ma.
Scala is a beautiful language which compiles to JVM's or CLR's byte code. Cool? Cool. But it also means that it inherits all the ... little things from those VMs. And Java's biggest thingy I know so far is type erasure.
Compatibility with old code? Great. Support code for win3.1 apps in XP? Perfect idea for marketing dept.
Before getting out of home, check your winkdoodle, because 400 years ago someone didn't and got bitten by the dog. It was huge.
Well, they run XP code in VM on Vista-shmista these days, okay, an option. What do we have in java these days?

scala> List[Pair[String, Any]]("a" -> 2) match { case (h :: t) if h.isInstanceOf[Pair[Int, Any]] => "match!" case emp => "nada" }  :6: warning: non variable type-argument Int in type (Int, Any) is unchecked since it is eliminated by erasure
List[Pair[String, Any]]("a" -> 2) match { case (h :: t) if h.isInstanceOf[Pair[Int, Any]] => "match!" case emp => "nada" }
^
res1: java.lang.String = match!
And those people disallow me picking in nose and call that language type safe? Yeah! Way to go for the backward compatibility!

Saturday, June 5, 2010

even though results seem to look same, refactoring is joy of getting things right, migration is pure pain in the ass of just making it work.