Gustavo Duarte has a blog post that just showed up on proggit: New Languages Considered Harmful
His basic point, if I understand him correctly, is that we shouldn't bother learning new languages, because it's just a waste of time. It's well thought out, and he does support his point. But I completely disagree.
I'm a C++ programmer, which these days is apparently some horrible blight. Someone, not too long ago (I want to say it was Steve Yegge, but I can't find it in his archives), said that he would not seriously consider any interview candidate who "still wrote C++." Whatever. I honestly don't care -- until someone can show me a language that's as good or better at the things C++ is good at, I'm going to keep using C++ (not to mention that I can't exactly just decide to switch our projects over).
I'll save all the details about why I like C++ for another post (and it is coming). The most important aspect of C++ is that it is a multi-paradigm programming language. You can use it as a better C, as an object-oriented language, as a generic programming language, to some extent even as a functional language (I think C++0X will actually be an acceptable functional language). But how do you discover these paradigms, and how to use them effectively?
Early in college, I didn't like to think of myself as a C++ programmer, it seemed too restrictive. I wrote Perl, I wrote some Python and Ruby, I wrote C, I even wrote some Java. Then I took a class called Programming Language Design at UIC, taught by the wonderful Professor Barbara Di Eugenio. After the usuals of covering [static|dynamic] [typing|scoping], we were introduced to languages that otherwise were not generally taught in the CS curriculum at UIC. The first of these was Common Lisp. During my brief foray with emacs a few years back, I had tried to wrap my head around elisp using just the manual, but it didn't take, so I was excited to really learn Lisp for real. Something very fundamental happened -- I got it. It was a completely different way of thinking about programming, from my most basic assumptions -- Lisp was just math, functions were, well, functions. From there, we learned Haskell, which did a similar thing -- Haskell is just math, type calculus can solve any problem. We also learned Prolog, which I'll admit didn't click as well for me, I was never quite able to break through from "here's how you get sum of elements of a list" to "here's how you write programs." But I imagine there's something there, just under the surface, that I haven't yet found, that, if I ever do find it, will again change the way I think about programming.
I suppose this all goes back to Eric Raymond's choice quote about Lisp:
Lisp is worth learning for the profound enlightenment experience you will have when you finally get it; that experience will make you a better programmer for the rest of your days, even if you never actually use Lisp itself a lot.It doesn't just apply to Lisp. I don't really use Lisp on a regular basis, but there are patterns and techniques you learn in Lisp, because you have to, that can be applied to make your programs in other languages better. I don't use Smalltalk on a regular basis either, but learning Smalltalk helped me to understand OOP on a much deeper level than I had before. I don't much use Perl anymore, but it helped me understand regular expressions, scripting, weak typing, and much more. I used C and C++ in high school, but until I worked with the Z80 assembly language for my graphing calculator, I didn't really understand the machine. I've been using Python a lot recently, it's sort of my new de facto language when no other language is obviously better suited to the task. I'm not sure exactly what Python has taught me, other than perhaps the value of enforced readability. What I do know is that Python makes things that are hard in other languages easy, which is valuable in the pragmatic sense regardless of its implications outside the language.
There's a flip side, too. I recently decided to play with C#, half so that I could write the little GUI app I wanted, and half because I've heard so many great things about it. I honestly wasn't very impressed. The .NET framework is pretty great, except for the parts that are still very Win32 (BeginInvoke() anyone?). But the only feature I was really intrigued with in the language was delegate/event, and I was actually quite unimpressed. Here's a language feature that adds two keywords to the language, and all of it could be done in library code in C++ (and I imagine C# as well). C#'s generics are also nice, and in some ways better than C++ templates, but with concepts, C++'s templates will be leaps and bounds better in just about every way. Of course, it took me about 6 hours (including learning what I needed to know about the C#, .NET, and the Windows API) to write my little app, and the next time I need a Windows GUI app, I'll do it in C# again. But I can't see how the experience really changed the way I look at anything.
C++0x will be a very interesting language. Since the last "real" C++ standard, generic programming and template metaprogramming have become favorites in the C++ world, and C++0x will add features to make these easier. Concepts, along with auto and decltype will make TMP nearly as powerful as Haskell's type programming. And I'll know how to do it already. The addition of lambdas and closures to the language proper will make C++ areal functional programming language (assuming you're not one of those purists who claims that the only functional language is Haskell). And I'll know how to use it already. Regular expressions, based on Boost.Regex, are being added to the standard library, and I'll know how to use them already.
Duarte says in his blog post, "Scott Hanselman argues that learning a new language is sharpening your saw, but I see it as neglecting your half-sharpened saw while playing with the dull, new, shiny one." I agree that this analogy is appropriate in a way. But really, the point is that by learning a new language, you get a new saw which was built differently. You get to see why the new saw is better in certain situations, and you get to apply that to your sawing from now on, regardless of what saw you use. Languages are tools, but the best tool you have is up in that head of yours. Learning new languages makes sure that tool learns new tricks.
Plus, it's fun as shit.