[Haskell-cafe] A heretic question
Derek Elkins
derek.a.elkins at gmail.com
Sun Oct 19 17:20:57 EDT 2008
On Sun, 2008-10-19 at 23:08 +0200, Achim Schneider wrote:
> What kind of things, barring coding on Haskell-less platforms and
> library interfaces would you choose to do in C++?
>
> I'm asking 'cos I'm learning C++ and can't get the proper motivation to
> do any program I can think of in it: If I need abstraction, I'm
> thinking Haskell or Scheme, and if I'm thinking performance, C itself
> more than suffices.
>
> Plus template programming makes me shudder because of its atrocities
> against clear and straightforward FP, but that's a different matter.
>
I tend to use C++ whenever I strongly care about data representation
(which is admittedly rarely.) You can use C for that; I just prefer C
to C++ for almost everything.
The only other thing that would almost certainly lead me to using C++ is
if I needed to use to a C++ library. C++ is extremely difficult to
interface to.
> Coming to think of it, a compiler from a clean syntax to C++ templates
> sounds like a fun project... which I'd do in Haskell.
This is actually one of the first things I wrote in Haskell. It's not
even much of a compiler but mostly just filling in the blanks of some
templates.
So I could write:
fac 0 = 1
fac n = n * fac (n - 1)
and get output akin to the example on wikipedia.
More information about the Haskell-Cafe
mailing list