My deck for the @Betabeers Cádiz on Practical Scala - Higher Order Functions and some practical Scala one liners
Play2 Scala, Mongo Capped Collections & Iteratees
Today I was honored to be part of the XII Betabeers Cádiz to show some API’s around Scala Play2 Iteratees and Mongo Capped Collections. I put together a quick and dirty app to show how you can stream from the Twitter Streaming API into Mongo and back to the browser in real time thanks to Play2 Iteratees and Enumerators. I also spoke about how we use Heroku in 47 Degrees and how easy it is to deploy Play2 apps on Heroku. It was exciting to see the audience interest in Scala and many developers approaching afterwards telling me how they are switching or getting interested in Scala. Definitely a growing community and exciting technologies for new folks joining.
Scala Resources & Community links for the newcomer
During the last couple of months I have been asked a few times among colleagues and friends hot to get started with Scala. People come to Scala from diverse backgrounds such as… - Java folks looking for a better Java or just tired of waiting for Java features other modern languages such as C# already offer. - Ruby, PHP, and programmers that come from a scripting background looking for type safety. - People trying to bridge the best of both OOP and Functional paradigms. Scala is a vast language full of features with a very technical community. Don’t let your first step discourage you as you don’t need to know everything about Scala to become productive quickly. People in the mailing list will often talk about some crazy shit you don’t need to know just yet. Monads, Monoids, Combinators, Macros and things you may not even know how to pronounce,… Seriously guys as you start to learn about it it’s gonna blow your mind. It’s gonna take some time to digest all the info but it sure it’s worth it. Here is a few resources / steps may help you get started focused on its community and not so much on the technical details of downloading and running your first scala “hello world”
Take the Coursera Progfun Course
The first thing I’d recommend based on my experience is that you take the Coursera Progfun Course. This course sure is a great learning experience folks not used to functional programming that come from an imperative lang such as Java. Martin Odersky guides you through very interesting concepts regarding functional programming, immutability, collections, tail recursion, the Scala programming language principles. It is a great source of knowledge even for the most experienced Java programmers.
Subscribe to the scala-user mailing listA very active mailing list with topics ranging from newbie stuff all the way to hardcore discussions about new lang features. People are friendly and eager to help.
Join the G+ Scala Community
Complementary to the scala-user mailing list there is also other social resources like the G+ community. You can find people sharing here articles, questions and all things Scala.
Browse available books see which one fits your style better.
There are dozens of Books by now about Scala and other related scala frameworks and libraries such as Play, Akka, Lift…
Subscribe to RSS feeds to find interesting articles about Scala.
- Cake Solutions Team Blog
- Kotan Code
- Lambda the Ultimate
- Reddit for Scala
- DZone Scala Search
- Scala and typesafe stack in Stack Overflow
- Algorithmically Challenged (Awesome posts by D. Sobral)
- Artima Scala Buzz
- Blog of Adam Warski
- Code Commit
- Daily Scala
- Foursquare Engineering Blog
- James Strachan’s Blog
- Jim McBeath
- Planet Scala
- Ruminations of a programmer
- Scala-lang.org feed
- The Typesafe Blog (Scala + Akka + Play framework)
Swing by SpeakerDeck presentations and Github project lists
Discover what the community is building with Scala. There are tons of great OS projects being currently developed on Github.
Attend live events and meet the community in person
- Scala Days - Major Scala Event
- Scala Tribes - Communities Worldwide
- Scala Meetups
Other resources and links of interest to newcomers
If you are around for #ScalaDays and want to meet the guys at @47deg and @47deg_es, ping us and we’ll get together to discuss #scala and #apps over beers! cheers!
Scala vs Java manipulating collections
One of the nicest scala features is for comprehension loops. They allow you to express the expected outcome of the loop and manipulate Seq, List and other collections in a way that saves time and removes clutter from its Java counterpart.
Consider the following…
- Go for the yield style where as you iterate over a collection with a for comprehension and a guard the yield sends new elements to the resulting List.
- Use the map and filter FP style approach where you map the collection to a new collection of Ints that is then filtered and yields a new collection of even ints.
- Check out some other ways to do the same task more efficiently in scala as well contributed by some members on the G+ Scala community
Sending Email with Scala and Akka Actors
How many apps have you built where you have to send out emails for any variety of reasons?
As I make my way learning about Akka Actors I decided to use them in one scala app I’m working on.
I decided to used them for this task not just because of the scalability and easy concurrent model but also for 3 main reasons.
- The builtin configurable supervisor strategy allows you to monitor child workers and decide what policy applies should there be an exception.
- I could easily reschedule email delivery attempts on common email exception often times thrown by SMTP servers.
- Actor routers allow you to dispatch messages to a pool of actors in an intelligent way. In this case we use the SmallestMailboxRouter which sends messages to actors in the pool with a smaller workload.
The code is dependent on apache commons-email and some built in play! framework 2 stuff but getting rid of it would be trivial for anyone wanting to reuse it on a different context.