# 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).

# Event for businesswomen in Ann Arbor area

Over the past few months, I have been involved in organzing an event geared toward the professional women in the Ann Arbor area.  I think that it offers a unique opportunity for women to learn about what other women are doing, and to gauge the prominence of women in our community.

So, you might ask the question, "WHY is this a gender-specific group?".  That's a rational question, and being in a male-dominated profession, I have spent a lot of time thinking about gender-specific groups. The truth is that the number of women who are active in the business community in Ann Arbor is substantial, but not well publicized.  I've been honored to be working with many of them on the committee putting together this event.  I have a lot to learn, and I feel that bringing together women for an event will go a long way toward an understanding of what is being accomplished in our area by some top-notch women.  I learn a great every day from the men that I'm surrounded by in my field.  I'm happy to stretch that a bit and see what I can learn, or what I can offer, to the business community that is comprised of women.  In truth, we all benefit from diversity, and having access to both male and female perspectives is critical.

The Women's Exchange of Washtenaw (WXW) is not a membership organization.  Rather, its purpose is to organize, encourage, support, educate and strengthen the businesswomen of our region by providing a venue for business connections, skill-building, professional support, and growth.  There are several membership organizations in the area (Association for Women in Computing, National Association of Women Business Owners, etc.) that serve a different purpose.  I'm interested to see how this group grows and distinguishes itself.

The event is being held on Wednesday, May 7th. The event begins at 1:00 pm and includes a thought-provoking panel discussion (with the best line up of panelists you've seen in a long time), breakout sessions where all attendees participate, and a happy hour (and a half) beginning at 4:30 p.m.

In addition to the panelists (check out the bios on www.wxwbusiness.com), the afternoon will be filled with roundtable discussions on issues decided by the participants.  We will include the following breakout sessions:

• Managing Growth
• Learning to Lead and Creating Culture
• Relationship Building
• Visioning: Creating a Path for your Company

The event will be held at Kensington Court Ann Arbor, 610 Hilton Blvd, Ann Arbor, MI.  The cost to attend is \$50 and includes refreshments and one drink ticket.

Register at http://www.wxwbusiness.com.

I hope that the 5 women who read this blog will join us. <grin/>

# Ann Arbor area events this week: JRuby and lightning talks

On Tuesday April 22, Joe O'Brien, famed Ruby developer and Columbus area business owner, will be speaking at the Ann Arbor Java User Group.  He will be discussing JRuby, Ruby that runs on the Java Virtual Machine (JVM).  Sun is putting a lot of resources toward dynamic languages on the JVM.  First, they hired 2 JRuby developers.  Just recently, they hired 2 Jython developers.  Microsoft is similarly loading up, for IronPython and IronRuby.

Anyhow, come out on Tuesday and hear Joe talk about JRuby.  The meeting starts at 7:30 pm at Washtenaw Community College (room BE260), but come early for the networking at 7:00.  Pizza and soft drinks will be provided.

And, on Friday April 25, SRT is continuing with the bi-weekly lightning talks.  We're mixing up the format a bit, going to a more traditional lightning talk length of 5 minutes (we had previously allowed 10, but we've babied everyone long enough!).  Instead of starting at 3, we're going to start at 3:30.  But we have an open door policy, so if you break free at 4 and want to stop by, just DO!  This week, we'll have snacks.  It's Nate's last day of working as our intern.  We're sad that he's leaving, but we know that he will do GREAT in Manhattan.

# What message are we sending to students?

This week, I was at Michigan Technological University.  I graduated from MTU in 1986, and returned 4 years later for a masters degree in Computer Science.  It's a great computer science program and I also love the area.  I really enjoyed both experiences in Houghton, taking full advantage of the natural beauty of the area for hiking, mountain biking, cross country skiing, or just hanging out on the fresh air. The coursework was difficult, but the very laid back atmosphere of the Keweenaw peninsula often offered some perspective.  A drive up to Copper Harbor and back (45 miles of twisting, windy roads) often cleared my mind, putting me in a better place for studying or understanding the subject matter of my classes.

My purpose in being here was for a meeting of the Presidential Council of Alumnae.  This is a group of women who have been selected by their departments and approved by the council. The group advises the President of the university on a wide variety of topics about the student experience, not limited to simply diversity on campus, but that certainly is a big component.   One of the activities for the meeting was to meet with some of the women who are students here.

I was amazed by the apparent "stress level" in the students I spoke with this week. Many of these students expressed apprehension about … everything. A junior was concerned that she wouldn't find a job (next year!).  Others expressed concern that they don't know what they want to do.  One student mentioned that it's hard to find time to enjoy the area because she's so involved in committees and volunteer work.  Others expressed that they didn't feel that they had time to do small things for themselves, even getting a haircut. It occurred to me that these students are feeling all of the same stresses that those of us in the professional world feel throughout our careers, but they are experiencing them now, along with the traditional stresses of college. That alarmed me.  I went back to grad school full time because I didn't feel like I could devote enough time to my studies alongside the stresses of a full time job (and vice versa). But these students have essentially assumed a load similar to mine at the time.  And they're still in college!

I've been thinking about the message that we (in industry and academia) might be sending to them about the importance of their college experience.  I'm concerned that when those of us in the business community talk about the importance of "community involvement", the students are hearing "the more activities I'm involved with, the better".  I don't really think that this is the message that we want students to hear.  What I want to see, both for the students' wellbeing and in employees is someone who has perspective.  There's a time to work and a time to play.  The "activities" and "community involvement", in my opinion, need to give way for some "down" time.

Granted, what I encountered was a small sample of students.  Those that I met may not be representative of college life in general.  They were selected by their departments specifically, I assume using this flawed selection criteria of the best grades and loads of activities.  The intent of this selection was to choose those who might ultimately qualify to sit on this Presidential Council, after they have some professional experience and success in their fields.  Yet, most of us didn't recognize ourselves in these students. Yes, we were "overachievers", and we were "stressed".  And maybe 20 years of time has faded my views of what was going on in college.  I didn't participate in any regular organized activiites in college (sure, a Bocce Ball club meeting now and again, or a statue for winter carnival, but not an ongoing commitment).  Many of my colleagues on the committee expressed the same.

I'm left wondering that if the departments had sent a random sample of students, or those who they might have considered "second tier", perhaps more of us would have recognized ourselves in these students.  Maybe these students were always on college campuses, and I didn't really run into them.  I don't know.  But I do think that college is a time for exploration, for figuring out what you want to do for a career.  You don't need to have all of the answers, going in, and you certainly don't need to feel constrained by the choices that you make. I advise professionals to regularly re-evaluate what they are doing.  The same definitely goes for students. My advice to them would be: when in doubt, broaden your horizons.  Take "different" classes, outside of your requirements.  If cost is a factor, take something at a community college in the summer.  You might find something that really engages you (and, you might learn something too).  Take time to relax.  Your brain really does do a better job of retaining information when you have some time to absorb things, some time when you're simply relaxing.  I also think that we, in industry, need to ensure that we're not leading these kids down a path that we didn't intend.  We need to talk to people at universities to make sure that they know that when we say "outside involvement", we don't mean a boatload of activities that crush the spirit of the students under their weight.

# Society of Women Engineers at Michigan Tech: Panel Discussion

I'm in Houghton, Michigan this week, for a meeting of the Michigan Technological University Presidential Council of Alumnae.  To kick off the meeting, we had a panel discussion, where student SWE members could ask questions. Turnout was good, higher than I had expected.  About 50 students showed up, nearly all of them women, from a wide range of fields.  Questions ranged from work/life balance questions (always interesting to me, since I'm still trying to figure those out), to questions about getting a job and how to build community after moving to a new town.  After the meeting, there was a "social hour" where the students could talk individually with the almunae.

Most of the panelists were from big companies.  Perhaps a few of them had worked for small companies at some point in their careers, but the vast majority were from big companies now … companies like Intel, Ford, FedEx.  I think that I was the only small business owner on the panel.  Unfortunately, I think that college recruiting tends to give students the opinions that most of the jobs ARE with big companies.  I'm happy to be here to provide information about small companies, and why students should consider them.

Today, I'm doing a talk in the Computer Science department, for students. I'll be talking about Staying Current in Technology, both the why's and the how.  I'll blog my talk later, mainly because I don't want students to feel like they should take notes. Rather, I want this to be an interactive discussion.  Another alum will be joining me for the talk, one that I have never met.  She works for 3M and will be adding input about soft skills.  I hope that the students enjoy it.

# 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.

# PyCon 2008: An Overview

I attended my first PyCon this year.  It was in Chicago, and I was able to take Amtrak from Ann Arbor to Chicago (for only \$27!).  The trip was quite pleasant, and I will say that I am definitely going to take Amtrak to Chicago again in the future.  My kids are already looking forward to it (to wit: do not tell a 2 year old that we will take the choo choo train "someday"; that's way too similar to "Sunday").

Anyhow, I arrived in time for tutorials.  I had signed up for 3, and they ran from about 9 am until 9 pm.  I was wiped out by the end of the day.  Two tutorials would have been plenty!

The conference was interesting. I met up with some of the devchix, who I had previously only been acquainted with online.  We decided to arrange a Birds of a Feather session and invite all of the women who were in attendance.  I was surprised to notice that a lot more women seem to attend Python conferences than Java or .NET conferences.  Interesting ….  In any case, we had our meetup.  About a dozen people showed up, and we had conversations that ranged from computer science education to how people felt about the bathroom on the lower level being redesignated for "men".  On the latter, it didn't really bother me (there were a LOT more men there than women, and time between sessions was short).  OTOH, it would have made sense just to have made the bathroom gender-neutral, I suppose (which is what we did at the Java Posse Roundup).

I went to a variety of talks, including some open spaces sessions.  I also went to lightning talks.  These were noted by others as a huge bonus of the conference in years past, but as Bruce Eckel noted, they were a bust this year, dominated by vendor talks.  Fortunately, the conference organizers are open-minded and DO listen to attendees.  They have already said that they will not open lightning talks to vendors in the future, and that responsiveness is what I have learned is pretty common in the Python Community (and in community-based conferences in general).

Conference sessions are starting to be put online. You can access them at http://www.youtube.com/user/pycon08

# Upcoming Tech Events in the Ann Arbor area (and Ohio!)

Yes, it's the first week of the month again.  The Ann Arbor Computer Society meeting is tomorrow night, April 2, at 6 pm.  Jay Wren will be speaking on the Boo Programming Language and DSLs (Domain Specific Languages).  Boo is a statically typed language that runs on the CLR.  It has Python-inspired syntax.

AACS meetings are free and open to the public.  Pizza will be provided.   Meeting will be held at SRT Solutions' offices, at 206 S. Fifth Ave, Suite 200.  That's at the corner of Fifth Ave and Liberty, just above the Linux Box.  Take the elevator to 2R or come up the stairs and wind around to the right side of the elevator.

On Thursday April 3 at 7:00 pm, the Michigan Python User Group will meet to discuss EasyExtend, which allows you to extend Python syntax.  New documentation tools may be discussed as well.  Like AACS, the MichiPUG meetings are free and open to the public, and held at SRT Solutions.  Pizza will NOT be served, but people often go out after the meeting.

Next week, on Monday, April 7, there is a Flex Camp in Cleveland, Ohio.  Go to http://flexcampcleveland.com/ for registration and more information.  Looks like a fun and interesting event.

On Wednesday, April 9, the Ann Arbor Dot Net Developer Group will meet, at SRT Solutions. Bill Wagner will be talking about how to make good use of the new releases in Visual Studio 2008.  Meeting is free, starts at 6, is at SRT, and yes, there will be pizza.

# Technical Sessions at the Java Posse Roundup

I'm a month late in posting this, but better late than never.

The Java Posse Roundup was an Open Spaces conference in Crested Butte, CO.  It was held March 4-8, and this was the second (hopefully annual) conference.  The non-technical sessions, about which I already posted, were great, and the technical sessions were great too.  I didn't keep really great notes, because it's hard to take notes and participate at the same time, but here is my re-creation, from my chicken scratch.

The night before the conference started, most of the conference attendees were in town, so we got together at Bruce's house.  We badgered Dick Wall about Android, and he spent some time walking us through his application (WikiNotes), which has been (recently) open-sourced.

Joe Nuxoll, of the Java Posse, convened a session on Component Based Systems.  Many different systems and libraries were discussed, including Swing, Flex, Boxley, and Thermo.  The consensus was (pretty much) reached that Swing is a library and is not component based.  Flex is component based.  Boxley is an AOL component based application development environment whose lead architect was hired by Adobe to work on Flex.  And Thermo is a design-oriented tool that provides the missing link between FlexBuilder and PhotoShop, allowing designers to build an application that a developer can drop into the production app.

Barry Hawkins convened a session on "Why is Agile Hard?" (note: audio released this week on the Java Posse podcast).  Barry is an agile coach, from Atlanta, and I always enjoy his sessions.  He always seems to come up with some good one-liners, that stick with me.  Like "Agile exposes the dysfunction endemic in software development, whereas other approaches mask it".  He also pointed at some great sources for future "research", including Scott Ambler and Kevlin Henney's podcasts at Parleys.com.  Also Alistair Cockburn's podcast on IT Conversations: Agile Software Development, and of course  Mike Cohn's blog "Succeeding with Agile". A few people who participated in the discussion were looking for answers about how to bring agile into an environment which is hostile to it.  The consensus of the discussion is that until the business respects agile, you're giving up a lot of the benefits, but there are some benefits that can be gained by heading in that direction.  Another reference that came out of the discussion was the book "Waltzing with Bears: Managing Risks on Software Projects".

I think that it was Ophir Radnitz who convened a session on "What does Scala Need".  Many people were interested in Scala at the Roundup (myself included), and this was a lively discussion.   It ranged from how to leverage what we already know (about Java) for Scala to what it will take for the language to be successful.  Toward that end, the group determined that books, community, and tools were important to success.  The books are getting there, with Martin Odersky's Programming in Scala book and others likely on their way.  Community is building both at artima.com and scalax.scalaforge.org. The plugins in development for Eclipse, NetBeans, and IntelliJ's IDEA will help a lot with adoption.  It's hard, these days, to learn a language without code completion. Sounds silly, but I doubt that I'm the only one who has started to depend on that support.  During the session, Carl Quinn and Tor Norbye came to an agreement to work together to help advance the NetBeans Scala plugin.

One nice thing about Open Spaces conferences is the ability to mold them to fit the needs of the actual attendees, at the event.  Last year, there was a discussion about how cool lightning talks are in other environments, and so we added lightning talks to the Roundup.  This year, people wanted to go a bit more in depth on some issues, so we added some very informal workshops.  A few people were worried that the workshops didn't fit the model of Open Spaces, which are interactive, but there really wasn't a conflict.  People who were interested in the workshop format showed up!  Others did not.  Joel Neely and I did a workshop on Scala for Java Programmers, followed by a several hour Scala hacking session the next evening, where we worked on a functional implementation of a problem that we had come across.  You can read more about how far Joel has taken this on Joel's blogChet Haase did a really cool lightning talk where he demonstrated how he was able to implement some of the examples from his Filthy Rich Clients, but in Flex.  We wanted to know MORE so we recruited Chet to do a workshop to do a deeper dive on this.  It was fantastic.  I think that his blog will serve as great reference material for building apps in Flex.

I think that we will see an increase in workshop time at future Roundups, if the attendees want them.  We slid these into the dinner time, after the ski hill closed and before the lightning talks started.  It was time that people were using to socialize anyhow, and it fit well into many schedules.

Once again, the Java Posse Roundup is over for another year. I had a blast, and learned a lot.  I met some really great people, and also enjoyed seeing some familiar faces.  I'm already looking forward to Roundup '09.