Meetu Maltiar's Weblogs

Meetu's thoughts on technology and software development

Archive for July 2011

Getting Started With Scala

leave a comment »

I and Vikas presented on “Getting Started With Scala” few years back. It was presented at OSS camp 2009 in New Delhi. I still remember the interest it created at the conference.

Today I happened to have a look at it on Slideshare. Looking at the number of views it seems to be doing good. Out of my previous employer presentations its having highest hits. Scala is really doing good in terms of popularity.

Presentation is still old. To get started concepts are still the same. Enjoy the presentation…

Written by Meetu Maltiar

July 7, 2011 at 20:46

Posted in Scala

Tagged with

Experiences at Cloud Computing Conference Pune 2011

leave a comment »

I was one of the speaker of the second IndicThreads conference held at Pune on 3-4th June 2011.

Sessions at the conference dealt with key topics like Cloud Security, Amazon Elastic Beanstalk, Legal Issues in Cloud Computing, OpenStack, Xen Cloud Platform, Rails and CouchDB on the cloud, CloudFoundry, Gigapaces PAAS, Monitoring Cloud Applications, ORM with Objectify-Appengine, Scalable Architecture on Amazon AWS Cloud, Cloud Lock-in, Cloud Interoperability, Apache Hadoop, Map Reduce and Predictive Analysis.

My talk focussed on managing persistence on GAE. It dealt with choices available to a developer and then focussed on doing it with Objectify-Appengine.



Demo application is present here for download. For the instructions on how to run it please read the wiki.

Written by Meetu Maltiar

July 2, 2011 at 11:51

Posted in Architecture, Cloud, Java

Tagged with ,

Working With Scala Collections

leave a comment »

We have a monthly iBAT (Inphina Beer and Technology Sessions). We look forward to this day and it was Scala day this time. I presented on Scala collections.

Scala collection is elegant and concise. Scala Collections like java is object-oriented and we can work with generic types. It is optionally persistent i.e can be mutable and immutable. It provides higher order methods like foreach, map and filter.

Scala collections follow uniform return type principle. Which basically means that when you perform an operation on a collection they return a collection of the same type.

The root Trait in Scala collections is Traversable. It may take some time to get used to it as Scala collections root Traits like Traversable have a big bunch of methods.

The for notation is more readable. It is basically like a for loop with a return type. Look for yourself how readable it is compared to the original code.

This code listing is without a for notation

scala> val listOfNumbers = List(1, 2, 3)
listOfNumbers: List[Int] = List(1, 2, 3)

scala> val flattenedListOfNumbers = listOfNumbers flatMap (0 to _)
flattenedListOfNumbers: List[Int] = List(0, 1, 0, 1, 2, 0, 1, 2, 3)

After using for notation

scala> val listOfNumbers = List(1, 2, 3)
listOfNumbers: List[Int] = List(1, 2, 3)

scala> val flattenedList = for(number <- listOfNumbers; range <- 0 to number) yield range
flattenedList: List[Int] = List(0, 1, 0, 1, 2, 0, 1, 2, 3)

One more interesting thing we can do with a Map is that we can reverse key and value with the following code

scala> val aMap = Map("India" -> "Delhi", "France" -> "Paris", "Italy" -> "Rome")
aMap: scala.collection.immutable.Map[java.lang.String,java.lang.String] = Map(India -> Delhi, France -> Paris, Italy -> Rome)

scala> val reverseMap = aMap map{case(k, v) => (v, k)}
reverseMap: scala.collection.immutable.Map[java.lang.String,java.lang.String] = Map(Delhi -> India, Paris -> France, Rome -> Italy)

scala> val alsoReverseMap = for((k, v) <- aMap) yield (v -> k) 
alsoReverseMap: scala.collection.immutable.Map[java.lang.String,java.lang.String] = Map(Delhi -> India, Paris -> France, Rome -> Italy)

Reference were from Martin’s Odersky talk on Future Proofing Collections and Scala Collections API documentation. Enjoy the presentation …

Written by Meetu Maltiar

July 2, 2011 at 11:29

Posted in Scala

Tagged with

Follow

Get every new post delivered to your Inbox.

Join 42 other followers