Tag Archives: Scala

My schedule for CodeMash 2010

Or, more accurately, CodeMash 2.0.1.0.

This is the week that software development in many locations in the midwest takes a hiatus so that its developers can beef up on new skills and ultimately provide more benefit to their companies and customers. In its 4th year, CodeMash this year will attract nearly 700 developers to the Kalahari Resort and Indoor Waterpark in Sandusky, OH.  The conference kicks off with the "precompiler" sessions (fast-paced interactive tutorials) on Wednesday, and a panel discussion featuring the Java Posse on Wednesday night.  Thursday morning, the conference will be in full gear, with morning sessions by industry luminaries such as Joe O'Brien, Jesse Liberty, Jim Weaver, Jim Weirich, James Ward, Ken Sipe, and Jim Wooley.    Fortunately, due to "Best of CodeMash" repeat sessions, I can pass up the "Why is Ruby Different" talk during that session in hopes of catching it later and then only have to decide between the JavaFX talk by Jim Weaver and the Flex talk by James Ward.  The next session of the day pits the panel discussion "Lessons from the Rails Rumble" against the venerable Andres Almiray in "The Case for Griffon", not to mention Barry Hawkins' "User Stories: Closing the Agile Loop"  Hard choices: that's what CodeMash is all about.

Once I survive the struggle from my choices from the morning, and after a lunch keynote by Hank Janssen from Microsoft, I'll have to choose between Joe Nuxoll's "Photoshop for Engineers: Going from PSD to HTML" and Bill Venners' "GetHigher with ScalaTest". Then it's a hard choice between Leon Gershing's "Introduction to Cucumber",  Michael Slade's "Techniques for Programming Parallel Solutions", Catherine Devlin's "reStructuredText: Plain Text Gets Superpowers", and Barry Hawkins' "Domain Driven Design".  But I'll almost certainly choose Dick Wall's "Funky Java, Objective Scala", as I've been looking forward to this talk and its domain examples in bioinformatics.  Fortunately, Joe O'Brien's "Refactoring theProgrammer" has a repeat session!  And then there's one more session before dinner, where I'll have to choose between a more advanced Cucumber talk, Chris Adamson's "How do you do that on the iPhone", Andres Alimary's "Testing Java in the Fast Lane", and Carey Payette's "Enterprise Development with Prism".  I almost missed that Nick Sieger is talking about "Five Ways to Cure the Java Blues with JRuby" in this timeslot.  Again the "Best of CodeMash" repeat sessions come to the rescue and I can choose to see Joe Nuxoll's "Enginering vs. Design" talk later.

Thursday night is always fun at CodeMash.  This year, we're adding a concert (Enter the Haggis) to the cocktail party and jam session.  Every other year, I've headed out to the water park for a while on Thursday night.  Not sure I'll have time to do that this year!

Friday morning, there's no keynote (after that late night, probably a good thing!).  We'll start the day with Chris Adamson's "Oh Crap! I Forgot or Never Learned C!", "Going Dynamic with C#" by Bill Wagner, "Being an Evil Genius with F# and .NET", and "Software Design and Testability" with Jeremy Miller.  I really enjoy Chris Smith's banter, and so I'll probably head to the F# talk.  The next slot has several sessions that I'm really interested in: "RESTful Interfaces to Third Party websites with Python", "Come for the Phone Stay for the Mac" (by author Daniel Steinberg) and James Ward's "Agile Toolchain for Flex".

I'm REALLY REALLY excited about Friday's lunchtime keynote with Andy Hunt.  I heard Andy speak at the Philly Emerging Tech conference last year and was thrilled that we were able to get him to come to CodeMash.  And by "we", I mean Jason Gilmore.

SRT's Friday vendor session "MobiMash" should be interesting.  Jay Wren, Mike Woelmer, Dan Hibbits, and Patrick Steele worked together and independently to provide a mobile solution for CodeMash, incorporating scheduling, session rating, and favorites.  And they did it in the 4 major mobile platforms: iPhone, Windows Mobile, Android, and Blackberry.  The iPhone and Android apps are available for download in their respective stores.  The Blackberry and Windows Mobile apps should be available Real Soon Now.  They will discuss the development challenges (and rewards) on the various platforms, using the MobiMash app as a case study.  I'm looking forward to it!

After the vendor sessions, I'll have to choose between "Clojure" and "Tools in the Trenches".   That's a really hard choice, because I'm both really interested in Clojure and yet also intrigued with Carl Quinn's tools talk.  Maybe I can convince Carl to do a lightning talk version at the Java Posse Roundup 2010!

How I spent my software stimulus …

A few months ago, Bill Wagner (my business partner at SRT Solutions) and I were talking about how companies were really pulling together in this economy and doing what they could to help others. I was really impressed with the brillant marketing of Atlassian when they rolled out several of their enterprise tools for $5 for 5 days for 5 users.  Nice.  And so we started to think about what we could do, how we could contribute.  The result of that was the SRT Software Stimulus Lab, which we held last Monday at Automation Alley in Troy.  We held a low-cost, no-frills event.  We told people to bring bag lunches and their own coffee.  We made it cheap for employed developers ($50 early bird) and free for those who are unemployed.  And it was … fun, interesting, and productive.  During the registration process, we asked registrants what they wanted to learn and we found that C#, Silverlight, WPF, and Scala were high on the list, as were version control, unit testing, and functional testing.

We started out the day talking one of the most fundamental and, in my opinon, essential tools: version control.  While most people had used version control in one form or another, many of them had only used tools like Visual Source Safe (which, you will likely recall mainly led to annoyance with your coworkers for leaving files locked).  We talked about tools like subversion as today's tools and looked forward a bit toward distributed version control, like bazaar and mercurial.  We set up a repository for the attendees to access and made sure that everyone was able to do so.

After that, we broke into mainly 2 groups.  One attendee, who I know from the Detroit Java User Group, came to learn more about Scala.  He's a Java developer with a significant amount of experience in Groovy.  I enjoyed my time with him, ane he seemed to have fun too.  I don't think that I sold him on Scala (that wasn't my objective), but I believe he left knowing enough about it to decide if he wants to pursue it further or to determine if he wants to stick with Groovy.  We compared and contrasted some features of the languages, and it was fun for both of us (I think!). People from the other group filtered in and out.  One guy teaches C++ on the side, and he was interested,  Another was a PHP developer who was popping in periodically.  We spent some time looking at unit testing in Scala as well as at a lot of the language features, and the preview of what's to come.  Fun stuff!

The other group worked mainly on WPF and Silverlight. The attendees seemed to really appreciate Silverlight (as well as the demos and tutorials that they worked on with the SRT staff).  The attendees also wanted to delve into multithreaded programming a bit, so the SRT staff came up with some demos and an impromptu discussion on that topic.

All in all, the day was what a Jam session should be: a group of people self-organizing into groups to work on things that they enjoy, free to move on if they changed their minds. I really enjoyed spending time with the attendees and I think that we'll probably do the Lab again sometime.  I know that I won't always get to do Scala.  And that's just fine.  I wouldn't have minded learning more about Silverlight myself!

Another Java Posse Roundup comes to a close

Well, I've been here in Crested Butte since Sunday afternoon, for the 3rd Java Posse Roundup. It's been an amazing experience, as always.  I blogged earlier in the week about how this conference evolves to match the interests of the attendees. Of course, I should have anticipated that it was still changing.  The attendees really take charge of this conference, and that's part of why it's so great.

In addition to the new (optional) hackathon day, there were several other changes this year. First of all, the size has exceeded the capacity of the Posse House and so the evening events were held at the conference location.  This gave everyone a bit more breathing room and was just as fun.

The lightning talks offer a wide variety of topics, not all of which are Java-related. I enjoy the non-technical talks and tech talks alike.  Some of the more amusing sessions from this year include Barry Hawkins' "Introducing Change" and Andrew Harmel Law's "Zombies".  The lightning talks will make their way to YouTube at http://youtube.com/javaposse.

The sessions, as always, were fascinating. Ranging from the very specific to the very general, they were all great. Of course, they will be released on the Java Posse podcast channel, and it will be interesting to hear the reaction of those who didn't attend. But I did realize that if you're not here, you miss out on a lot.  Not only will you likely not get the jokes, but you also miss out on the opportunity for "free consulting".  People are very generous with their time and ideas.  I have met some amazing people here over the years, and I do keep in touch with them throughout the year.  We bounce ideas off of one another and I benefit immensely.  I hope that I offer at least a fraction in return. 

The afternoon activities were varied. Some people gathered at houses around town to hack together, while others "networked" (aka, skiied and snowmobiled).  I was thrilled yet again to leave my downhill gear packed because of the interest attendees had in learning how to cross-country ski.  We went out two days (so far; I suspect we will go tomorrow morning as well) and the groups were great! Some footage may make its way to the internet; we'll have to see.  Fewer people downhilled this year than in years past, and I suspect that was a combination of the weather (it was grayish without new snow) and the fact that Bruce had broken his leg a few weeks ago.  I think that his mishap may have spooked people.

The hacking groups had productive afternoons as well.  Dick was able to rewrite his JFlubber app in both JavaFX and Flex. With both Tor and James to work with, Dick seemed pretty happy.

Bill Venners was here as well, and he was able to find several willing participants to work on ScalaTest.  Rumor has it that he and Tor got the NetBeans build working for ScalaTest, which will certainly improve the developer experience "out of the box". We had a group at our house one afternoon, and most of us were having difficulty getting it to build.  I'm glad that they were able to make progress. Bill's done a great job with ScalaTest!

After lightning talks, groups formed.  I never went to bed early, always intrigued by some interesting conversation at my house or another one, that went well into the night.  As is consistent with the previous 2 Roundups, I found that I spent nearly ALL of my waking time with other attendees.  I had one brief shopping trip alone to buy souvenirs for my kids.  That's it.  So, if any employers doubt the "hard work" that we do at this conference, pass this information along.  Even while we were out cross-country skiing, we were talking about "things", either about Java things or business things or the conference.  It's truly an experience in conference immersion.

 

Oh, and just to dispel the myth that geeks don't socialize and can't cook, here's a story:

Since several of us had rented houses around town (5 or 6 in total) rather than renting hotel rooms, we got together and organized a progressive dinner.  While Wikipedia describes it as a complex process requiring a lot of organization, we didn't have that experience and it was awesome.  So, if you're going to do one, don't do it THAT way.  Try it OUR way … you might be surprised.  Here's the official (LOL) Java Posse/Open Spaces version of a progressive dinner:

  1. Write down addresses of houses that are interested in participating. Each house will prepare "some food" (we left that open).
  2. Pick a start time.
  3. Pick a house to start at.
  4. Pick the successive houses and write down the order on the paper.
  5. Go to first house, and migrate to the next in line until done.

We announced this on Tuesday afternoon, and simply reminded everyone on Wednesday at noon.  40 people traipsed from house to house!  It was a lot of fun.

Pretty simple. And FUN! Not only did it get everyone moving around, talking to different people, it was a great way to see the other rental houses and to learn who liked to cook. We didn't go to the trouble of telling people what to prepare, assigning a course, or even letting one another know our plans.  Our menu was varied and we had a blast. Try it.

The week was way too short.  There was a lot that I wanted to do.  But, as usual, I'll be returning home with my batteries charged and new friends. Can't ask for much more than that.

Alternative Languages on the JVM at the Java Posse Roundup

The Java Posse Roundup conference continues to evolve to meet the interests of the attendees. This year, the first day was an optional day,  with groups coding on alternate languages on the JVM.  Groups formed to share their collective knowledge and interest surrounding several languages. I chose to attend the Scala Hacking session, as did 13 other people.  In other locations around town, there was a similarly sized JavaFX group, and a smaller Groovy/Grails group.  Later in the day, Fan was added.

In the Scala session, we went through some code that we had developed for an evening session last year, implementing some functionality of LINQ (Language Integrated Query for .NET), in Scala.  We based our work on Bill Wagner's article from Visual Studio Magazine.  We didn't make much new progress, mainly because we were trying to dissect what we had dome both for our benefit as well as for those who had never seen the language.  We're hoping to get back to that later in the week.  You can read Joel Neely's blog that summarizes a lot of what we did along with some insight.

Later in the day at the Scala Dojo, Dick Wall demonstrated some of the work he's been doing with genomics, while another group moved over to another house, to work on ScalaTest with Bill Venners.  We spent some time getting our development environments set up, and started with some assignments.  Bill's talking about a release later this week, and is looking for help on the project.  Several people have expressed interest and working together was a good start.  I suspect that wasn't the last Scalatest hacking session either!

After a short break for dinner, we all got back together at the Posse House (as we affectionately call the house where the Java Posse stays during the conference) for a review of how we had all spent our day.  The Groovy/Grails team demonstrated their work on getting a simple CRUD app to work, and the JavaFX team demonstrated an application that they had built, which included a timer that counted down.  By adding some designer work in PhotoShop, they were able to get a styled app up and running, and even included sound.  It was an impressive demo. Joel Neely reviewed what our team had dome with Scala, and Fred Simon (who endured 48 hrs of travel and delays to get here) did a brief overview of Fan, which is a language that targets both the JVM and CLR.

We're all looking forward to the conference starting today, with open spaces sessions.  This year, we have exceeded the capacity of the Posse House for lightning talks (but not for gatherings), so the consensus is that the evening lightning talks will likely be held at the conference location as well.  It's not as cozy, but it will likely be more functional!  I'm sure that at some point today, people will head off to ski, and that's part of the experience as well.

So, off for another day in beautiful Crested Butte. First stop, Camp4Coffee.  Then, conference kickoff!

Practical Scala slides posted

My talk at CodeMash focused on a transition from Java to Scala, demonstrating the simplicity that Scala brings to ordinary Java tasks, like Swing code.  I believe that as programmers become familiar with the syntax of Scala, they will embrace its elegance.  With that, they will enjoy using it and the functional elements will be adopted over time.

Slides posted here.

Scala for Java Programmers talk

Last night, I presented a talk entitled "Scala for Java Programmers" at the Ann Arbor Java User Group.  I have posted the slides at http://srtsolutions.com/content/ScalaForJavaAAJUG.pdf.

This talk had its origin in a workshop that Joel Neely and I did at the Java Posse Roundup last March.  Joel presented this talk internally at FedEx, and I presented it at Chariot Solutions' Emerging Technologies for the Enterprise conference in Philadelphia.  I recently updated it for the AAJUG talk.

I didn't even touch on generics, traits, classes, and objects in this talk.  So I've posted my earlier talk (from CodeMash) which included information about these as well:

http://srtsolutions.com/content/ScalaCodeMash08.pdf

I’m speaking on Scala this week

So, this Tech Events in Ann Arbor post for the week of September 22 finds yours truly speaking at the Ann Arbor Java User Group on Tuesday, September 23 at 6:30.  The meeting will be held at Washtenaw Community College in room BE270.  I'll be talking about "Scala for Java Programmers".  What CAN you do with this language? And why do you care? Is it a Java replacement? We'll explore some of the corners of the functional aspects of Scala, but object-oriented programmers will feel quite at home in this talk. Please come.  I would love your feedback on the language (and on the talk).

On Friday join SRT for lightning talks, from 3:30-5. As always, lightning talks are open to all.  Come to do a 5 minute talk or to listen!

Next week, the Ann Arbor Computer Society meeting will feature Bill Heitzeg discussing JBoss and .NET.  AACS meetings are free and open to the public.  AACS sponsors pizza and soft drinks.  Members qualify for door prizes.

 

Tail recursion in Scala and Annotations for Software Defect Detection

The Java Posse interview with Brian Goetz and Bill Pugh cleared up how Scala supports tail recursion in spite of the JVM's lack of support.  Brian Goetz did a great job of explaining that currently compiler writers have to build in the support (which Scala does) because the language doesn't support it directly.  He went on to explain that while there is support in the CLR for tail recursion, the F# compiler writers chose not to use it in some cases because they found that they could write a more optimal version by converting to iteration.  

The conversation was about changes that can be expected in Java 7, including JSR 292 ("Enhancements for Other Languages", aka "Invoke Dynamic"), JSR 305 (Annotations for Software Defect Detection), and JSR 308 (Annotations on Java Types).  

The discussion of JSR 305 (and @NonNull) reminded me of the discussion of contracts in a podcast on Microsoft Spec# that I listened to a few weeks ago. Scott Hanselman did an accompanying blog post as well. The FindBugs (static analysis) tool that Bill Pugh did is definitely a "must-have", and can already support annotions such as described above.  The JSR would simply provide a naming convention so that all tool makers and programmers could agree.  I had to look up Bill's annotation to see if it was "NotNull" or "NonNull", for example!

Note: JSRs (Java Specification Requests) are formal requests through the JCP (Java Community Process) for changes or enhancements to Java and the Java Virtual Machine.  This is an open process and participation is encouraged. 

  

Lists and folding in Scala

James Iry pointed out that I could have used a fold left in my solution to the first ProjectEuler problem. Ah, now I remember reading about folds!  So, I went back and looked at it.  Right he is, of course.

Here's his solution:

val nums = 3 until 1000

val somenums = nums filter (x => (x % 3 == 0 || x % 5 ==0))

val sum = somenums reduceLeft {(x:Int,y:Int) => x + y}

println(sum)

Equivalently:

val sum = somenums.foldLeft(0)(_+_)

And more obscurely:

(0/:somenums)(_+_) 

I came across a great blog post describing all of this.   

I have to admit that I'm not enamoured with the last example above (the (0/:somenums)(_+_).  But, the (_+_) is at least fun to type since it's all done with the right hand while the shift key is depressed with the left!   

Anyhow, I'm encouraged to learn more about folding lists now!   Many thanks to both James Iry and Joel Neely for their suggestions and support (and to Ricky Clarkson for his fabulous blog post on folding).

 

 

Euler problems in Scala

SRT is abuzz with solving the Euler problems, in our collective spare time, and in different languages.

Bill Wagner has been solving the problems on euler.net in C#/LINQ.  Darrell Hawley is attacking them in Python.  Marina Fedner is giving us a flavor for Ruby.  And so I'll jump in, in Scala.   And no, we're not looking at each other's solutions before doing our own! 

Here's my Scala solution to problem 1, which is to sum the numbers between 0 and 1000 that are divisible by either 3 or 5.

    val nums = 3 until 1000
   
    val somenums = nums.filter(x => (x % 3 == 0 || x % 5 ==0))
   
    var sum = 0

    somenums.foreach(sum += _)
    println (sum)

I figured that there was no sense starting with a number less than 3 (not that it made much difference to the solution, but what the heck).  The filter function (on lists) in Scala provides a nice way to grab the appropriate values.  The foreach expression, when combined with the "_", which is a placeholder for the parameter. 

 Alternately, I could have defined a temporary variable x, like this:

for (x <- somenums)   sum += x
 

So, does the temporary variable "x" improve readability?  Perhaps somewhat, until you get used to the new syntax.  There are certainly times in Scala where I appreciate the more verbose syntax (and am grateful for its legality), but in this case, I prefer the more concise "foreach".

Sidenote: as Bill mentioned in his solution, the goal here is not necessarily to provide the most optimal, functional solution.  It's to provide one that works, and learn/expose information about how to use the language along the way.  And people who are interested in solving the problems themselves should probably avoid our posts on this subject.