C++ – The “blub paradox” and c++

cprogramming-languages

I was reading the article here: http://www.paulgraham.com/avg.html and the part about the "blub paradox" was particularly interesting. As someone who mainly codes in c++ but has exposure to other languages (mostly Haskell) I'm aware of a few useful things in these languages that are hard to replicate in c++. The question is mainly to people who are proficient in both c++ and some other language, is there some powerful language feature or idiom that you make use of in a language that would be hard to conceptualize or implement if you were writing only in c++?

In particular this quote caught my attention:

By induction, the only programmers in
a position to see all the differences
in power between the various languages
are those who understand the most
powerful one. (This is probably what
Eric Raymond meant about Lisp making
you a better programmer.) You can't
trust the opinions of the others,
because of the Blub paradox: they're
satisfied with whatever language they
happen to use, because it dictates the
way they think about programs.

If it turns out that I am the equivalent of the "Blub" programmer by virtue of using c++ this raises the following question: Are there any useful concepts or techniques that you have encountered in other languages that you would have found difficult to conceptualize had you been writing or "thinking" in c++?

For example the logic programming paradigm seen in languages like Prolog and Mercury can be implemented in c++ using the castor library but ultimately I find that conceptually I am thinking in terms of Prolog code and translating to the c++ equivalent when using this. As a way of broadening my programming knowledge I'm trying to find out if there are other similar examples of useful/powerful idioms that are more efficiently expressed in other languages that I might not be aware of as a c++ developer. Another example that comes to mind is the macro system in lisp, generating the program code from within the program seems to have many benefits for some problems. This seems to be hard to implement and think about from within c++.

This question is not intended to be a "c++ vs lisp" debate or any sort of language-wars type debate. Asking a question like this is the only way I can see possible to find out about things that I don't know I don't know about.

Best Answer

Well, since you mentioned Haskell:

  1. Pattern Matching. I find pattern matching to be much easier to read and write. Consider the definition of map and think about how it would be implemented in a language without pattern matching.

    map :: (a -> b) -> [a] -> [b]
    map f [] = []
    map f (x:xs) = f x : map f xs
    
  2. The type system. It can be a pain sometimes but it is extremely helpful. You have to program with it to really understand it and how many bugs it catches. Also, referential transparency is wonderful. It only becomes apparent after programming in Haskell for a while how many bugs are caused by managing state in an imperative language.

  3. Functional programming in general. Using maps and folds instead of iteration. Recursion. It's about thinking at a higher level.

  4. Lazy evaluation. Again it's about thinking at a higher level and letting the system handle evaluation.

  5. Cabal, packages, and modules. Having Cabal download packages for me is much more convenient than finding source code, writing a makefile, etc. Being able to import only certain names is much better than essentially having all the source files dumped together then compiled.

Related Topic