[Haskell-cafe] A heretic question

Jason Dagit dagit at codersbase.com
Sun Oct 19 17:55:26 EDT 2008


On Sun, Oct 19, 2008 at 2:08 PM, Achim Schneider <barsoap at web.de> wrote:

> What kind of things, barring coding on Haskell-less platforms and
> library interfaces would you choose to do in C++?


You're asking a crowd that is heavily biased towards Haskell, what they
would use C++ for?  You should expect many answers to be of the form, "Well,
if Haskell doesn't work, I'll try generating C or C++ from Haskell."  :)

Which means, people here often see other languages as target languages for
code generators.  Which is something I think is pretty cool.  But, getting
back to your question...

If I were considering writing something in C++ here are some of my
considerations:
1) Is the thing I'm writing known to be easy to solve in C++?
2) Will writing it in C++ instead of, say, Haskell give me access to a
developer pool that is superior for the task?
3) Will dealing with the very few drawbacks of laziness, in particular lazy
IO or space leaks from laziness, end up dominating the development effort?
4) Is it a work related project?
5) Am I just making a prototype or executable specification?

I put (2) and (4) up there because I think it's important to consider who
you'll be working with.  I can't really get way with using Haskell much at
my day job because I'm the only one there that wants to use it.  The company
has to deal with the code I create even if I move on.  Also, programming is
hard regardless of how cool your language is.  So it always seems wise to
work with the sharpest set of programmers that you can.  Sometimes that
means picking a particular language.

It's also important to think about the merits of the languages themselves,
such as (1), (3) and (5) point out.  If you're prototyping, Haskell is light
years ahead of C++.  Then again, optimizing C++ programs, while tedious and
error prone, is understood by far more people than optimizing Haskell
programs.  Laziness can be unpredictable.

I like Haskell a lot and I'd bias all my answers to the above 5 towards it,
but C++ is also a very cool language.  It's just cool for very different
reasons than Haskell is cool.

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.


Heh.  Yeah, it can be ugly, but it's also very powerful.  The template
system is Turing complete as you may know.  Boost and Loki are two good
examples of some of the cool things you can do with C++ if you really work
the template system.

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.


Ah yes, even you're thinking about code generators.  It's a very common way
to think in this community it would seem.

Jason
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081019/850a9bff/attachment.htm


More information about the Haskell-Cafe mailing list