

What Does Haskell Have to Do with C++? - VeXocide
http://bartoszmilewski.wordpress.com/2009/10/21/what-does-haskell-have-to-do-with-c/

======
dfox
I see (and it is certainly highly subjective) one large similarity between
Haskell and C++: Haskell and C++ code looks similar to me aesthetically, as in
indentation patterns being similar and so on, it's certainly weird :)

Also it is interesting to note, that both Haskell and C++ world is full of
discussions about how to do something remarkably complex to get nice syntax
for something. You don't see that in lisp world, where such problems are
simply solved by macros and nobody goes into great lengths to (ab)use some
random language feature to get nice syntax for his library.

~~~
jules
This happens in a ton of languages, e.g. Ruby (method call syntax and blocks),
Scala (idem), C# (LINQ syntax), etc.

------
DannoHung
This is why I hate C++

    
    
        template<template<class> class f1, template<class> class f2> struct or_combinator
    

Incidentally, his or_combinator example is more simply expressed thusly:

    
    
        or_combinator f1 f2 x = (f1 x) || (f2 x)
    

This has the same type signature. Anonymous functions are more useful in
Haskell when you have some lexical context which needs to be captured and
passed around. If partial application suffices, simply use partial
application.

I suppose he was trying to demonstrate that the evaluation does not occur
until the value is applied though, if the audience was more familiar with C++.

~~~
andymorris
When you get templates working, it does feel pretty good - you can get an
approximation of the power of functional languages, all the while knowing that
your code has been directly mapped to assembly.

I don't know if it's as good as writing some neat functional code, but for me
it's still fun!

~~~
eru
If you get a decent Haskell compiler working, say ghc, you get the same warm-
fuzzy assembly-feeling.

------
Zak
_The nice thing about single-paradigm languages like Haskell is that they have
very simple syntax (think of Lisp that does everything with just a bunch of
parentheses)._

This statement suggests the author has limited exposure to Common Lisp, which
supports the widest variety of programming paradigms in one language that I
can think of. Simplicity of syntax seems to be mostly orthogonal to allowing
the use of many paradigms, though it's probably hard to have a very complex
syntax with a semantically simple language.

~~~
mahmud
_Common Lisp, which supports the widest variety of programming paradigms in
one language that I can think of_

Allow me to introduce you to Mozart/Oz and AliceML. Seriously, those two twin
languages are the most epic out there.

You would have to hack CL extensively, and bundle various libraries to make it
on par with Oz or Alice. Maybe CL + Screamer + FSet + Heresy + pcall + cl-
store would be a pale, distant imitation.

For the last 50 years, PL research has been done with minimal kernel
languages, implementing few features. Don't know what mental mutation caused
the Oz team to go the opposite way and implement "everything imaginable" in a
tiny language, but I like it. The core of Oz is no larger than Scheme, btw.

~~~
dkersten
Oz is an interesting language. I only learned it because I was reading Peter
Van Roys excellent _Concepts, Techniques and Models of Computer Programming_ ,
but I'm glad I did.

Having said that, I've never actually used it for anything substantial.

~~~
mahmud
I couldn't either, til I discovered Alice, which is feature compatible but is
an SML.

I have "ported" my knowledge to Common Lisp and use it there; but I have been
actively re-learning ML for the past few months.

------
ben0x539
Clearly the rational thing to do is to create a Haskell DSL that compiles to
C++ template metaprograms.

~~~
prodigal_erik
That wouldn't fly. The IO monad makes Haskell too conceptually impure to
express well in the elegant functional language that is C++ template
specialization.

------
sgt
I'm loving Haskell more and more.

------
jaywalker
Great insight into the relationship between C++ MP and Haskell!

