I surrender — Lisp really is better than C++

I’ve been using C and C++ for over twenty years now, and I’m very fluent in both of them. C++ has been my preferred language for pretty much any programming task for most of that time, and I haven’t seen any point to learning other programming languages because some of them are at best equivalent in power to C++, and most are noticeably poorer.

However, as I described a few days ago, I decided to learn Lisp, primarily because Paul Graham insists that it’s the most powerful language out there. I couldn’t see that it was any more powerful than C++, but enough smart people seemed to agree with Paul that I had to admit that I could be wrong on that score.

Well, I just finished chapter nine of Practical Common Lisp, and I’m finally convinced.

Up until now, everything that I’d seen done in Lisp could easily be done in C++ too. The only real difference was a little more verbosity. But the unit-testing framework that was developed in that chapter… while I think I could do the same thing in C++ with the Boost library, template functions, function pointers, and a C-style macro, it still wouldn’t be nearly as elegant as the Lisp version, and it would be noticeably more verbose. And it would require some fairly esoteric C and C++ features, things that even I — a fluent user with decades of experience behind me — would have to delve into reference works to figure out, whereas it uses only standard features of the Lisp language. It would also take me about the same amount of coding time in both languages, which considering my very different levels of expertise in them, is another big win for Lisp.

I’m still planning to use C++ for most of my professional work — I worked long and hard for the kind of expertise that I have in it, and all of my professional tools are geared toward it as well. But Lisp is definitely going to play a big part in my personal programming from now on, and likely in the prototyping stages of my professional code as well.

20 Comments

  1. Hmm, “Lisp is better than C++”, “Linux is better than Windows”… The world is coming to an end, you’re agreeing with me! (After years of nagging. 😉 )

  2. I have a reading-knowledge of Perl, and an in-depth knowledge of x86 (and several obsolete systems) assembly already, but I was never tempted to use them for anything. 😉

    And in response to the Reddit crowd’s comments, by “better” I’m specifically referring to both “more powerful” and “more productive.” That makes it better in my book. 🙂

  3. I had a very bad experience with C++ and the MFC for Windows GUI programming. I’ve been open to try everything else since then. I’ve tried python and ruby, and looking forward to check out Lisp (now that On Lisp is available as free ebook).

    Just one note….a little more verbosity?? Maan…check Ruby/Python syntax for a sane amount of verbosity in source code. Even Java is better than C++.

    Besides, Bjarne himself said that he made C++ sintaxis difficult on purpose.

  4. MFC is horrible. I wrote my own C++ library for Windows GUI programming; before that, I used the raw API functions or the ones defined in windowsx.h — it’s not too bad for the more basic stuff, but it quickly gets to be too much detail for things like tree-views.

  5. > I have a reading-knowledge of Perl

    Wow, that’s impressive, I’m not at that level yet. I only have a writing knowledge of Perl… 🙂

  6. > Prolog, Haskell, Erlang, Smalltalk and Perl I completely agree with this list.

    Prolog => bare bones LP / CLP without any fluff. Haskell => extremely pure lazy-FP, an explosive academic playground. Erlang => lean, clean strict-FP, lean message-based concurrency, failover. Smalltalk => OOP done right, the first time. Perl => imperative programming made expressive, powerful.

    All those languages should be standard tools in a real programmer’s toolbox.

    PS: to those that bash perl, you may continue to waste valuable time.

  7. … and I feel like I could keep learning more about lisp for the rest of my life.

  8. I am sorry but I must admit (while I myself love ruby) both ruby and python have a sane count of verbosity without sacrificing readability.

    When I look at Lisp, or even worse C++, the level of extra verbosity just scares me. (In lisp the needless use of () )

    Am I the only one who thinks C++ templates are DAMN ugly? It feels like satisfying a parser …

  9. “PS: to those that bash perl, you may continue to waste valuable time.”

    Perl is very practical. I know many old C programmers that use it to “get things done quickly”. They get their job done faster than writing it in C, so thats fine for me.

    But perl syntax is extremely 1980ish. Perl never bothered to make itself prettier, if you are fine with that – thats cool. But it has got good competition in Ruby and Python, and I can understand everyone who will choose these over perl – the ugliness of the ancient UNIX legacy is the main problem. (Shell scripts are also very ugly, but a perl script quickly gets more complex than a shell script)

  10. Power isn’t just “how easily you can do it” but also “would it ever have occurred to you to do it”. If you only know C, it likely wouldn’t occur to you to develop automated unit tests in that way. Lisp’s powerful metaprogramming facilities open up new ways about thinking about problems, and make ‘normal’ things seem like problems. (“Why is most of my time spent writing the exact same code?”) Sapir-Whorf may not be very true in terms of natural languages, but in terms of programming languages it is all too relevant.

  11. she, if you count the number of parentheses in (my-function) and myFunction() they are the same. Uniform syntax is a feature!

  12. Here’s my opinion.

    The big problem with Perl is that it’s easy to learn, but difficult to learn right. It has a tough learning curve and it can take years to master, even if you already know many other programming languages.

    However, I’ve never met a person that uses the advanced features of Perl (closures in an OO context, hash dispatchers, higher-order methods, super general functions, and so on) that didn’t write beautiful, concise, fast, and bug-free code. People that really get Perl (and there are precious few of those because of the learning curve) don’t bash Perl.

    The only relative advantage that I see in Python or Ruby is the learning curve. It’s much easier to become a good Ruby or Python programmer than it is to become a good Perl programmer. But aside from that, on a language-feature by language-feature comparison, Perl does almost everything better than those other languages. If everyone that wrote Perl code grokked the language, there wouldn’t even be any readability issues.

    As for Lisp… I think it is much better than Perl or pretty much any other language I’ve tried. I can say that even though I am not a good Lisp programmer. Learning a little Lisp made me a much better Perl, C++, C#, and even PHP programmer. When I program in any of those languages now, I see where they try to be a little like Lisp and I feel the pain of having to work around the limitations of the language. Working around limitations always means more work and more time.

  13. I have to agree with Chris Barts: learning Lisp has shown me ways to do interesting things that just wouldn’t have occurred to me before.

    And I found the parentheses pretty daunting at first too, until I really dug into the language and realized that they aren’t superfluous. They’re there for a reason, and it’s a good one. A lot of them look rather alien if you’re not used to the syntax, but when you consider that they replace both parentheses and curly-braces in C/C++, it’s not nearly as bad as it looks at first. A good editor deals with most of them for you.

  14. I’m closing the comments on this entry, it’s getting nothing but comment spam now.

Comments are closed.