Skip to main content

Posts

Showing posts from July, 2008

Finished Exercise #1 for Scala

I've just finished exercise #1 from: knowing.net. Please feel free to critique this code, I am serious about learning Scala and getting introduced to members of the community.
Calculator.scalapackage activeactive class Calculator { def main(args:Array[String]): Double = eval(args.toList) def eval(args:List[String]): Double = args match { case null => throw new IllegalArgumentException( "args cannot be null-valued") case Nil => throw new IllegalArgumentException( "You must provide a function name as the first argument") case "sum" :: rest => sum(convertList(rest)) case "prod" :: rest => product(convertList(rest)) case "mean" :: rest => mean(convertList(rest)) case "sqrt" :: rest => sqrt(convertList(rest)) case _ => throw new IllegalArgumentException( "invalid function name. Use 'sum', 'prod',…

Hibernate Bites...

...us in the butt Our team recently chose to use Hibernate for handling read-only access to data in our configuration and archive databases. Our primary decision for doing this was to use the baked-in caching provided by ehcache. Since then, we have had three major releases, the first two each containing a bit more hibernate than the previous, and the third, our architecture re-design, in which we spread Hibernate into all of the read-only data access classes. Our love affair with Hibernate was deep and passionate. Then disaster struck. During the verification of the installation of our new architecture to the disaster recovery environment, we found that many of our web-service responses were taking much longer than our service-level agreement allowed, significantly longer. One full week later, we have determined that most of the SessionFactory instances which we thought were caching, were in fact not caching. One particular request to our web service caused 43000 queries to be gen…

HelloWorld in Scala with the Eclipse Plug-in

The Eclipse plug-in for Scala makes you jump through two hoops before letting you run your application from the Run... menu: Your main object must extend Application.Since main is now overridden, you must use the override keyword on the method definition.package activeactive object Main extends Application { override def main(args:Array[String]) { println("Hello World!") } }

Learning Scala

I attended Stuart Halloway's dynamic language shoot-out presentation at NFJS last night. Ruby, Clojure, and Scala are the three languages in which he spent his time. Stuart claimed that each of these languages were made to run on the JVM in order to piggy-back on the penetration of the JVM in the enterprise. The choice of language you make is mostly unimportant, most of these interesting languages on the JVM provide the same general additions to Java running on the JVM. I intend to learn Scala this year. I feel that Ruby has a lot of penetration in the software development field, but that Scala is the up-and-coming language. I believe that the concepts and idioms in the languages are common enough to allow me to easily learn Ruby next year. My plan of attack for learning Scala: Install Eclipse 3.4.Install the Scala plug-in from: http://www.scala-lang.org/tools/eclipse/index.html.Create a working hello world program. Complete the exercises from: http://www.knowing.net/index.php/…