Wednesday, December 31, 2008

Music 2008, Part 2: Fresh Choices

Old farts weren’t the only ones making good music in 2008. The best of them was the debut by Vampire Weekend. This album took a little while to grow on me, but once it did it became a staple for me. I listen to it in the car, while working out, and while programming. Ten years ago I would have probably said it was the best of 2008, instead of Coldplay. Vampire Weekend was the best of the “young” artists, but hardly the only noteworthy album.

The Very Good
Attack & Release by The Black Keys is a very good album. These guys are both good songwriters and talented musicians. The album runs a little flat at times, but is thoroughly enjoyable. Definitely best listened to in the car, which for me means blaring loud.
For a more relaxing listen, try For Emma, Forever Ago by Bon Iver. The music is clever and enjoyable. The vocals can take some getting used to, but do not get in the way even if you are not a fan of the folk and falsetto.
Death Cab or Cutie has had a lot of success in recent years, and they only got better in 2008. Narrow Stairs is their best album to date. In fact “Cath...” was one of my favorite songs of 2008, but the album is full of beautiful songs.
The Seldom Seen Kid by Elbow received a lot of hype in 2008, and it deserved it. These guys really know how to create space in their music. “Grounds for Divorce” and “Weather to Fly” were personal favorites, but the whole album received a lot of playtime for me. It is a better headphones album, good for programming.
Back to Black by Amy Winehouse was a 2007 release that was discussed ad nauseum in the past. Personally I did not really get into the album until this year. She really does have a remarkable voice and the album is full of memorable music.

Merely Good
Metro Station’s self-titled album was technically released in 2007. I did not listen to it until 2008. It spawned a number of pop hits, but you should not hold that against them. It is a quality release. These guys are definitely know a good beat and good hook. They remind me a lot of a less polished Garbage.
Another heavily hyped album from across the pond was Fed by Plush. The songwriting and production is excellent, but a little indulgent at times. It did not live up to the hype to me, but is a good listen nonetheless. The adjective “lush” is often used to describe it, and with good reason.
If Plush puts you to sleep, then throw on Santogold’s debut album. It is a very fun and exciting album. This is probably not the kind of album that you will find yourself going back to in a year or two, but it is a pleasant treat for now. Of course I once thought the same thing about The Gorillaz...
Finally a year-end retrospective of music these days is obliged to mention the most popular showcase of music: American Idol. This year’s winner, David Cook, was the first “rocker” to win the event. However, former finalist Chris Daughtry has had as much success as any winner with the exception of the new Queen of Country, Carrie Underwood. So it was not surprising at all for Cook to win. His self-titled album is par for the course. It is not as good as Daughtry’s debut, but that probably won’t matter. It definitely reproduces the “emo” sound that was Cook’s signature and has quality songwriting. In other words, if you liked Cook on the show, you will like his album. This may not seem like a notable accomplishment, but actually there have been very few Idol winners who you could say this about.

Music 2008, Part 1: The Early Bird Special

It has been a remarkable year for new music. Not just because there has been some good new music released this year, but because of who has been releasing it. A lot of old dudes have rolled out of their pillow top beds and put down some good to great music this year: R.E.M., Nine Inch Nails, Metallica, The Cure, AC/DC, Q-Tip, and Guns n’ Roses. All of these guys released some of their best work more than 20 years ago, and they were all back this year releasing good music once again. You could argue that if any of these guys were new bands then what they released this year would have created huge hype. To some degree they are victims of their own success. None of these guys can ever release music that would be judged as being as good as what they did at their peaks.
R.E.M., AC/DC, and Metallica took a similar approach. They all tried to go back to their roots and resurrect the sound of their glory days. They all succeeded in my opinion. Each group released albums that were very enjoyable for long time fans. Neither really tried to reach new fans, but why bother? It was an election year, and playing to the base is a tried and true strategy.
NIN and The Cure both took their music in the direction they wanted. In both cases this was not a huge departure from where they had been in the past, but it was definitely distinct. The 21st century version of NIN has proven to have its own distinct sound from the 20th century NIN. Since 2005, NIN has released four albums: With Teeth, Ghosts, Year Zero, and 2008’s The Slip, plus the remix album Y34RZ3R0R3M1X3D. That’s a lot of music, especially compared to ye olde NIN that tended to take many years between releases. With more product, it has been a little more hit and miss for NIN. That is fine by me. The Slip contained several awesome tracks, and several so-so ones.
It is not uncommon to see rockers past the age of 30 continue to release music, even if it is usually not very good. It is more rare to see a hip-hop artist do this. This year saw an excellent album released by A Tribe Called Quest’s Q-Tip. Tribe and De La Soul once provided an excellent alternative to the misogynistic lyrics of “gangsta” rap. Of course today we have dropped the term gangsta, as it is the norm. Nearly every hip-hop artist is bound to make reference to dealing drugs, brandishing firearms, treating women as property, etc. Q-Tip still does things his own way and The Renaissance sounds as fresh in 2008 as Tribe did back in the late 80’s and 90’s. It was easily the best hip-hop album of 2008, far ahead of good but predictable albums by Kanye West, Lil Wayne, or T.I.
And then there was Guns n’ Roses... The long winding road of Chinese Democracy has been well chronicled. When you listen to Chinese Democracy, it is amusing to speculate about the evolution of the songs. However, I think you are best off to consider Chinese Democracy without its history and build-up. If you do that, it is an average album. It has some good moments, but nothing spectacular. It sounds modern, and that is noteworthy given the age of its creator (even more so if you speculate that many of the songs are 10+ years old, but I said I wouldn’t indulge in such speculation...)
The members of Coldplay are not quite the oldtimers as the above artists. They have been around for a while, and like the other artists, they are always compared to what they have done in the past. Maybe some fans may also think that Coldplay can never do anything that is as good as what they have done in the past. I definitely belonged to that camp -- I thought that Coldplay would never come up with anything as good as “Yellow”. I was wrong, because Viva la Vida is Coldplay’s best album of their career. It was one of my two favorites albums of the year, and I would give it the very subjective nod as the “best”.

Monday, December 29, 2008

Reality Check: SF 49ers

Yesterday I was driving home from Southern California, after spending the holidays with family. My wife was giving me updates on the Miami-New York game, and I was thrilled that the Dolphins won. Today I am back in the Bay Area and all anybody is talking about is Mike Singletary and the 49ers. In truth this has been going on for the last month, but I can take no more.

Now I can't really blame them. The 49ers seemed awful before Singletary took over, with a 2-5 record. A ten loss season looked like it was on the way. They finished 5-4 under Singletary, and now have given him a new contract. Many (including myself) were surprised when Singletary was named interim head coach. We weren't suprised that Mike Nolan was fired -- he should have been fired after last season because he behaved childishly and subsequently ruined the career of Alex Smith. Now the surprise was Singletary being named instead of Mike Martz. After all, Martz had coached both St. Louis (with great success) and Detroit (not so much.) Now with Singletary being given the reigns for next year, it is a foregone conclusion that Martz will be run out of town so new O-coordinator can be brought in to install a "power running game." Everyone in the Bay Area is giddy about all this -- but they won't be so happy 365 days from now. Let's take a look inside the numbers to see why.

Under Nolan, the 49ers were 2-5. As much as I disliked Nolan, that 2-5 mark was mostly a result of their schedule. The 5 losses were against teams with a combined 0.618 winning percentage. Three of the five teams made the playoffs, and the other two just missed. All five of those teams ranked in the 7 in the league in offense. Not surprisingly, the 49ers surrendered 339 yards per game. Their offense produced nearly 300 yards per game playing against defenses that were on average ranked 17th in the league -- right in the middle.

Under Singletary, the 49ers were 5-4. Again much of this was the product of their schedule. Their opponents had a combined winning percentage of 0.430. None of the teams that they beat made the playoffs. Actually they only played two playoff teams, and they lost to both. They played average offenses (19th ranked on average) and average defenses (18th ranked on average.) They produced 320 yards per game and gave up 315 yards per game. That is about a 20 yard swing on both offense and defense, but this is easily explained by their opponents. They were -6 turnovers under Nolan and -9 under Singletary.

In summary, it is hard to argue that Singletary made much of a difference. If Nolan had stayed on as head coach, the 49ers would have probably had similar "success". This is not a good reason to get excited about Singletary and offer him a multi-year contract. Worse, by making Singletary the permanent head coach, you guarantee that Mike Martz will be gone. Why is that a big deal? Keep reading.

The 49ers had a terrible passing offense last year, but this year they were ranked 13th in the NFL. That's not great, but it's a big improvement. Now maybe that is because of the opponents they played, but most of the really bad teams they played were division foes who were also very bad last year as well. So maybe some of that improvement is because of Mike Martz. Indeed, Martz's game planning ability was even more on display late in the season. He arguably exposed huge weaknesses in several defenses: Arizona, Dallas, and especially the New York Jets.

After beating the 49ers in week 10, the Arizona Cardinals went 3-4 the rest of the way. Before that game, they were giving up 23 points per game. Not great, but good enough when you have a top give offense. After that game, they gave up 31 points game. Martz's offense put up 275 yards passing against the Jets. After that game, the Jets faced the likes of JP Losman, Seneca Wallace, and of course Chad Pennington. The Jets defense was great against Losman, but Wallace and Pennington both posted 100+ QB Ratings against the Jets. In the previous 13 games, the Jets allowed a 100+ QB rating only three times (Philip Rivers, Matt Cassel, and Tyler Thigpen.)

You can argue that Singletary deserves credit for benching JT O'Sullivan and starting Shaun Hill. However, most of the credit for the 49ers "turnaround" goes to an improved offense engineered by Mike Martz. Next year, Martz will be gone. Instead we will see an offense that is more similar to what Nolan preferred last year, and we all saw how that turned out.

How 'Bout Them 'Fins!

This is the first of two NFL posts. This is the happy one. My childhood team, the Miami Dolphins, amazingly made the playoffs yesterday by beating the New York Jets. They went from 1-15 last year to 11-5 and this year, thus providing hope for Detroit Lions fans everywhere... Admittedly I did not get to watch too much Dolphin football this year (or last year for that matter) because I am in the Bay Area. Based on what I saw and what I have read over the last two years, there are a couple of major reasons for the turn around.

1.) Health. Last year Miami was plagued with injuries. Ronnie Brown started the year off on fire, making huge plays in both the running and passing game. I always joked that Brown would rack up 100 yards on the ground in the first half, while the game was close, and then another 100 yards through the air in the second half when Miami was trying to come back. It's not just Brown. The D-line was healthy all year. The O-line only had one missed game combined. The secondary is obviously the weak link of the defense, but at least there were a lot less games missed this year than last.

2.) Parcells and Sparano. The new brain trust certainly re-built the team beautifully. That healthy D-line? All new. The O-line returned several starters from last year, but was certainly improved by drafting Jake Long. Certainly the addition of Chad Pennington helped -- a lot. But don't forget about other subtle improvements like trading for Anthony Fasano.

3.) Brett Favre. I'm not putting him here because of the three picks he threw in the season finale against Miami, but because of his offseason drama. If Favre would have never retired, he would have stayed at Green Bay this year. I don't want to even try to speculate how that would have turned out -- Green Bay was bad this year because their defense could not stop the run -- but I know how it would have affected Miami. Favre in Green Bay, means no Favre in New York, and that means no Chad Pennington in Miami. Pennington is no messiah, but he was good. He posted a 97.4 QB rating! That was second in the NFL! He was obviously a huge improvement over the mess that Miami had last year. Here's a few more stats for you: Miami was 5th in offense in the AFC, 6th in run offense, 5th in pass offense, and had the fewest turnovers in the AFC. Thanks Favre!

With all of that being said, I shoudl expect Miami to roll to the Super Bowl, right? Well maybe not. I do think Miami has a good chance against Baltimore this weekend. Miami was 5th against the run, but only 12th against the pass in the AFC. Baltimore was only 13th in passing, and with Miami at home ... they have a chance! The early line has Baltimore as a 4.5 point favorite, so obviously some smart folks think Miami's fantastic run is about to end. Either way, it's been a great season for Miami.

Monday, December 22, 2008

Fun Things in January

Here are a few things I am attending/involved in that are coming up in January.
  • Macworld 2009, January 5-9, Moscone Center (San Francisco) -- Steve Jobs won't be there, but I will. Coincidence? I'll mostly be bugging iPhone developers. If that's you, then look out.
  • BCS Championship Game, January 8 -- Oh, I wish I could say that I was going to be in Miami for this game. Instead I will just be at my house in San Jose, watching the Gators triumph.
  • Java Community Process, 10th Birthday Party , January 13, Computer History Museum (Mountain View) -- Like other Silicon Valley JUG members, I got sent an invite for this little party. Democracy and Java, two killer ingredients for a party...
  • Introduction to Scala for Java Developers, January 20, San Francisco JUG -- I get to talk about Scala along with Lift creator David Pollak and the venerable Bill Venners. Bring your Scala book for Bill to sign it.

Thursday, December 18, 2008

Scala Golf

Recently I pointed out how Scala has Golf built into it, in the form of the _. So of course it is fun to solve a Golf problem using Scala:

val m=scala.collection.mutable.Map.empty[Char,String]
args(1).split('|').map(_.split(',')).foreach((s)=>m+=s(0)(0)->s(1))
println(args(0).map((s)=>m.getOrElse(s,s)).mkString)

Another Golf friendly feature at work here is the apply method in Scala. It is defined on RichString as an alias for Java's String#charAt method. Given my Golf comment, it is unfortunate that the _ can't be used more in the above problem. Two of the closures needed to refer to the bound variable twice. If you use two _ then the compiler assumes the closure is taking two input parameters. Seems like you could infer the number of input parameters and allow more flexible use of _ ... which could make Scala even more expressive and even more confusing!

Tuesday, December 16, 2008

Is Scala too hard or are you just stupid?

In case you missed it, Python's BDFL a.k.a. Guido van Rossum filed some major complaints about Scala. After you read that, read a good rebuttal and especially observe the ensuing debate. I especially liked Tony Morris's closing salvo. He brings some validity to the ad homenim response: Maybe you don't like Scala because you are too dumb to understand it. Please allow me to commit the most common fallacy of human thought and attempt to answer this question by only examining my own experience. In other words, if Scala seems too hard to me, then it is too hard. Period. If it seems simple enough to me, then anybody who finds it hard is just stupid.

Since I am going to make a statement of fact based entirely on my own experiences, maybe a little background would be relevant. I started programming 27 years ago when I was 7 years old. I programmed in BASIC, first on an Apple II at school and then on my very own Commodore 64. My first "real programming" was in Pascal when taking Advanced Placement Computer Science in high school. I probably still think in Pascal and translate everything into it first. I also learned FORTRAN and C while in high school.

In college, I learned a lot more C. For awhile I double-majored in math and computer science. Then I took the CS 10, the weed-out course for CS majors. For all of our programs in that class, we started with a predicate calculus definition of the problem, and then we had to logically derive the solution. We had a tool (I think the prof or somebody else in the department wrote) that we transform the problem statement to a computer program. But not just any program, a Lisp program. I hated everything about this, including Lisp. That class successfully weeded me out, and stuck to math.

In college I also learned Perl (for an economics class) and C++ (for a summer math research project.) After college, I programmed mostly in Java, with some C++, Perl, Ruby, and C# sprinkled in along the way. So in summary, I've programmed in a lot of language, but most of them are from the imperative cum OOP tree with C based syntax. I had one major experience with a functional language, and hated it so much that I change my major. So now on to my observations and emotions about Scala.

1.) Type inference sucks, but you (Java developers) gotta love it. I love having a statically typed language. I am definitely in that camp. However, I love not having to declare types very often. How often do you get to have your cake and eat it too? But this is, in my experience, the major source of pain in Scala. You are at the mercy of the cleverness of the compiler. In Java you are often at the mercy of the cleverness of the JVM, but it requires some esoteric Java (the kind that you only see in job interview problems or in books by Josh Bloch and Neal Gafter) to produce code that looks like it should compile, but will not. This is all too common in Scala. Here is an example.


// this compiles
object ItemMetaData extends Item with KeyedMetaMapper[Long, Item]{
override def dbTableName = "items"
// here is the problem line
override def fieldOrder = List(name, description, reserve, expiration)
}


class Item extends KeyedMapper[Long, Item]{
def getSingleton = ItemMetaData
def primaryKeyField = id

object id extends MappedLongIndex(this)
object reserve extends MappedInt(this)
object name extends MappedString(this, 100)
object description extends MappedText(this)
object expiration extends MappedDateTime(this)
}
// but this does not
object ItemMetaData extends Item with KeyedMetaMapper[Long, Item]{
override def dbTableName = "items"
// here is the problem line
override def fieldOrder = name :: description :: reserve :: expiration :: Nil
}


class Item extends KeyedMapper[Long, Item]{
def getSingleton = ItemMetaData
def primaryKeyField = id

object id extends MappedLongIndex(this)
object reserve extends MappedInt(this)
object name extends MappedString(this, 100)
object description extends MappedText(this)
object expiration extends MappedDateTime(this)
}

The two list expressions are equivalent, and yet one compiles and the other does not. Why? Is it a flaw in the compiler? Is it bad syntax? Is it a flaw in the language implementation (i.e. the List code and the :: code) ?

2.) Having no operators means that operators are everywhere! You can make the case that Scala's syntax is simpler than Java, C++, Ruby, or C++ for that matter. Why? Because it has no operators. There is no operator overloading, because there are no operators. The flip side of this is that it is easy to simulate operators and that everybody can do it. This is great for the wanna-be language designers in all of us, but can really suck. Why? It's like you are constantly encountering new operators. It can make Scala's syntax feel infinite is size, even though it is actually quite small and simple.

3.) Golf is built in and is known as _. Scala uses the underscore all over the place to allow for shorthand. Once you have become reasonably competent at Scala, you begin to like this. Until then, you hate it. In other words, it steepens the learning curve. It is a feature for power users, but it is prevalent. Thus you either become a power user, or you quit (insert snide comment about Guido or Cedric here.)

4.) Expressive is as expressive does. A lot of folks have thrown the term "readability" around. There are two aspects of readability. When you read code, do you know what it does? When you read code, do you know how it does it? The more expressive a language is, the easier it is for it to satisfy the first question. However, it may be harder for it to satisfy the second question. One could argue that if a language is better at both of these things than an alternative language, then you would probably rather program in that language. It is certainly easier to tell what idiomatic Scala will do than Java, for example. However, it is often harder to understand how it does it. You can substitute Python for Scala in the above two sentences and it is still true. But could you substitute Python for Java in those sentences? Probably not.

5.) Scala is not for creationists. Ok maybe that's a bad joke by an atheistic evolutionist. What I mean is that object creation can be confusing in Scala. Constructors are not obvious at first. Case classes add confusion, and then you throw in companion objects and you might start screaming "Make it stop!" Oh do I complain too much? Well in most of the other "mainstream" languages you need to learn exactly one thing to figure out object construction. Sure there may be other patterns (factories, singletons, builders, etc.) for augmenting this, but there is only "natural" way instantiate a class. In Scala you see standard stuff like val foo = new Foo("2ez") but also val foo = Foo("wtf"). The latter could be a case class, in which case the former won't compile. Or it could be a companion object, in which case both things compile.

So what is the conclusion? Well for all of my struggles, I have managed to find my way around Scala. So there, it must not be too hard. I am no smarter than any other programmer out there, so if I can learn it, they can too. Plus, my job did not even depend on it. Usually when a programmer has to learn a language, their job depends on it. A motivated programmer can definitely learn Scala is no time!

Saturday, December 06, 2008

Gameday

There are two games from this season that provide insight into today's Florida vs. Alabama game. First is Florida vs. Georgia. The Bulldogs have an offense with some significant similarities to Alabama's offense. They have a great, power running back (Knowshon Moreno) and a big play wide receiver (A.J. Green). Florida's strength is its pass defense, and they are good at both man-to-man and zone. They played a lot of man-to-man against Georgia to limit Moreno (17 carries, 65 yards.) Georgia was productive through the air (292 yards) but also produced three interceptions. Florida will try this same formula against Alabama.
Alabama's Glen Coffee might actually be a more explosive runner than Moreno, and their stellar freshman receiver, Julio Jones will definitely be playing on Sundays. However, I don't think Alabama has the confidence in John Parker Wilson to let him attack Florida's man-to-man play on the WRs. If they can make some big plays in the air earlier in the game, then they can win. If not, then it is hard to see Bama putting up enough points or controlling the clock enough.

The other important game is Alabama vs. LSU. LSU's running backs, Keiland Williams and Charles Scott, combined for 180 yards, 2 TDs on the ground against the vaunted Alabama defense. Alabama must do better against Florida's running backs. Look for Florida to use Rainey and/or Demps out of the ever-popular Wildcat formation. They have been experimenting with Percy Harvin out of that formation, but Harvin is out today. Everything has been pretty vanilla out of it, but you gotta figure Urban Meyer would save the more creative Wildcat plays for a game like this. Florida's rush attack is very similar to LSU's, so Alabama has to do better against it. They can't count on turnovers like they got against LSU. The thing that is going to be tough for them is that this game is on artificial turf, giving a boost to Florida's speedsters.

Friday, December 05, 2008

JavaFX: Some Frustrations...

Yesterday was the much ballyhooed release of JavaFX. I was excited about this for a few reasons. First, I started following JavaFX back when it was called F3. I remember last year planning on attending Chris Oliver's session at JavaOne on F3, when I read on his blog that F3 was now being called JavaFX. Second, a big part of my job is staying on top of RIA technologies and JavaFX certainly falls in that category. Lastly, it's a new programing language that runs on the JVM! How could I not want to learn it.

So I started playing around with JavaFX. Instead of going after lots of graphical goodness, I went for more mathematical stuff. I did a few problems with JavaFX, and then came across a problem that required finding the prime factors of a large integer. JavaFX has an Integer type that maps to java.lang.Integer. There is nothing in JavaFX specifically for large integers, but part of the beauty of JavaFX is that you can use classes from Java in it. In particular you can use java.math.BigInteger. So far so good.

In my solution, I wrote a prime sieve and then checked the modulus of the primes against the large integer. Now for normal 32-bit Integers, JavaFX has some nice syntax:

var remainder = n mod p;

It looks like math! Of course I love this. However, this does not work for BigIntegers. No problem, BigInteger has its own method for this:

var remainder = n.mod(p);

But this does not compile! Why? As you can infer from the first example, mod is a reserved word in JavaFX, so you can't use it as an identifier. Thus you can't use it as a method name. Of course you could surely use reflection to get around this, but who wants to do that?