Monday, February 15, 2010

I require a ... subtle Scala

C++ is complex in part because it is multi-paradigm. That is, C++ supports many styles of programming. It is a rabbit hole, but a necessary one—no one likes to hear "sorry, you can't do that".

Scala is so exciting a follow-on to Java in part because it too is multi-paradigm. Witness Jesse Eichar on self-annotation:

  1. class Base {
  2.   def magic = "bibbity bobbity boo!!"
  3. }
  4. trait Extender extends Base {
  5.   def myMethod = "I can "+magic
  6. }
  7. trait SelfTyper {
  8.   self : Base => 
  9.   
  10.   def myMethod = "I can "+magic
  11. }

But the two are completely different. Extender can be mixed in with any class and adds both the "magic" and "myMethod" to the class it is mixed with. SelfType can only be mixed in with a class that extends Base and SelfTyper only adds the method "myMethod" NOT "magic".

Why is the "self annotations" useful? Because it allows several provides a way of declaring dependencies. One can think of the self annotation declaration as the phrase "I am useable with" or "I require a".

Java is my daily bread and butter (and puts food on the table). There is no easy way in Java to express this subtle point of inheritance—delegation is the closest you come.

In C++ the template system lets you parameterize your base class which you cannot of course do in Java:

template<class T>
class template_base_class : public T
{
};

Saturday, February 13, 2010

Billions and billions

Lambda the Ultimate brings me A Few Billion Lines of Code Later: Using Static Analysis to Find Bugs in the Real World. These fellows have a wicked dry sense of humor. Typically:

We thought this approach was bulletproof. Unfortunately, as the astute reader has noted, it requires a command prompt. Soon after implementing it we went to a large company, so large it had a hyperspecialized build engineer, who engaged in the following dialogue:

"How do I run your tool?"

"Oh, it's easy. Just type 'cov-build' before your build command."

"Build command? I just push this [GUI] button..."

Hilarity ensues. Unfortunately the article generated only one comment:

I hugely enjoyed this article. I can't think when I last read an article that made so many important points. Thanks for not sugar-coating the description of real-world problems and real solutions. And thanks for not drowning those points in jargon.

   — Bjarne Stroustrup, January 29, 2010

Happy President's Day.

Tuesday, February 09, 2010

Scala is Java, or how to grow to love the bomb

Twitter's Nick Kallen posts Why I love everything you hate about Java, a satisfying read about Scala, scaling and design patterns in the real world. More authors (including myself) should post like this.

That he dispenses with explanation why a Java article is really about Scala evidences this fact: Scala is Java, or what Java could have become in a better universe.

UPDATE: Why I love the blogosphere, also entitled Why I hate everything you love about Java courtesy of Roman Roelofsen.

Wednesday, February 03, 2010

Monday, February 01, 2010