A heretic question

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
31 messages Options
12
Reply | Threaded
Open this post in threaded view
|

A heretic question

Achim Schneider
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.

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.

--
(c) this sig last receiving data processing entity. Inspect headers
for copyright history. All rights reserved. Copying, hiring, renting,
performance and/or quoting of this signature prohibited.

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: A heretic question

John Van Enk
C++ is nicer to work with, when you have the option, on embedded microprocessors. Dealing with C all the time can be a little cumbersome.

Actually, I've parroted this over and over, if I *could* use Haskell on an embedded micro, I would. There needs to be more work in that area.

/jve


On Sun, Oct 19, 2008 at 5:08 PM, Achim Schneider <[hidden email]> 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.

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.

--
(c) this sig last receiving data processing entity. Inspect headers
for copyright history. All rights reserved. Copying, hiring, renting,
performance and/or quoting of this signature prohibited.

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe


_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: A heretic question

MigMit
In reply to this post by Achim Schneider

On 20 Oct 2008, at 01:08, Achim Schneider wrote:

> 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.

Seems like you've just explained why C++ isn't good for anything.
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: A heretic question

Derek Elkins
In reply to this post by Achim Schneider
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.

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: A heretic question

Erik de Castro Lopo-29
In reply to this post by Achim Schneider
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 realatively new to Haskell but I've been coding pretty intensively
in Ocaml for a number of years.

For new code, there is stuff I would do in C over Haskell/Ocaml; low
level libraries, realtime audio DSP (digital signal processing) and
device drivers. For all of these I would choose C over C++ because C
is a cleaner less cluttered language. As soon as I want to do something
more high level, then I choose a real high level languague like Ocaml
and maybe some day even Haskell.

Erik
--
-----------------------------------------------------------------
Erik de Castro Lopo
-----------------------------------------------------------------
"A task always takes longer than you expect, even when you take into
account Hofstadter's Law." -- Douglas Hofstadter
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: A heretic question

Jason Dagit-2
In reply to this post by Achim Schneider


On Sun, Oct 19, 2008 at 2:08 PM, Achim Schneider <[hidden email]> 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

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: A heretic question

Luke Palmer-2
In reply to this post by Achim Schneider
On Sun, Oct 19, 2008 at 3:08 PM, Achim Schneider <[hidden email]> wrote:
> What kind of things, barring coding on Haskell-less platforms and
> library interfaces would you choose to do in C++?

I would recommend programming a simple game using SDL.  That is
currently not that much easier in Haskell than it is in C++  (only a
couple orders of magnitude ;-).

As for what would actually be strictly *easier* or *better* to use C++
for... well let me just say that I used to be a C++ guru, and now I
haven't used it for two years.

Luke
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: A heretic question

Bulat Ziganshin-2
In reply to this post by Achim Schneider
Hello Achim,

Monday, October 20, 2008, 1:08:06 AM, you wrote:

> thinking Haskell or Scheme, and if I'm thinking performance, C itself
> more than suffices.

... and machine code too :D  C++ is the highest level language that
provide asm-like speed, so it's hard to find reasons to use C instead.
and templates may be used to generates lots of efficient code
automatically


--
Best regards,
 Bulat                            mailto:[hidden email]

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: A heretic question

ajb@spamcop.net
In reply to this post by Derek Elkins
G'day all.

On Sun, 2008-10-19 at 23:08 +0200, Achim Schneider wrote:

>> 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.

Unless I'm working on a platform where memory is so tight that I
can't afford the cost of vtables, EH, RTTI and extra stack usage,
I always prefer C++ to C.  Always.  On the sorts of CPUs you find
on desktops and servers, and even most embedded platforms these
days, there is no advantage in using C over C++, and significant
advantages in using C++ over C.

The trouble is that C++ is a tool that's hard to use well.  But that's
why they pay us the big bucks, right?

Quoting Derek Elkins <[hidden email]>:

> I tend to use C++ whenever I strongly care about data representation
> (which is admittedly rarely.)

Indeed.  Having said that, type families mean that Haskell now gives
you much finer control over data representation, though still not fine
enough for many applications.

The more general thing is that C++ gives you fine control over
resources.  Resources appear and disappear at predictable times, which
in some applications is important.

My last point is that C++ has a lot more tool support: compilers,
libraries, frameworks, refactoring browsers and so on.

Cheers,
Andrew Bromage
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re[2]: A heretic question

Bulat Ziganshin-2
Hello ajb,

Monday, October 20, 2008, 4:50:45 AM, you wrote:

> The trouble is that C++ is a tool that's hard to use well.  But that's
> why they pay us the big bucks, right?

i think that one day we will hear that ML was too easy language and
they invented Haskell in order to keep future salaries high LOL

--
Best regards,
 Bulat                            mailto:[hidden email]

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Re[2]: A heretic question

Brandon S Allbery KF8NH
On 2008 Oct 19, at 21:07, Bulat Ziganshin wrote:
> Monday, October 20, 2008, 4:50:45 AM, you wrote:
>> The trouble is that C++ is a tool that's hard to use well.  But  
>> that's
>> why they pay us the big bucks, right?
>
> i think that one day we will hear that ML was too easy language and
> they invented Haskell in order to keep future salaries high LOL


I thought that was what Agda was for.  :)

--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [hidden email]
system administrator [openafs,heimdal,too many hats] [hidden email]
electrical and computer engineering, carnegie mellon university    KF8NH


_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: A heretic question

Colin Paul Adams
In reply to this post by Achim Schneider
>>>>> "Achim" == Achim Schneider <[hidden email]> writes:

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

Nothing.
Eiffel every time.
--
Colin Adams
Preston Lancashire
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: A heretic question

Maurí­cio
In reply to this post by Achim Schneider
What kind of things do you prefer? Databases, science,
math, web?

At first, make sure you have Bjarne Stroustrup book
(very important: last edition). If there's anything good
in C++, it's there. Look also at his homepage:

http://www.research.att.com/~bs/homepage.html

Bjarne is the guy who first started C++, and in a certain
way still leads its development.

> 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.
>
> 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.
>

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: A heretic question

Benjamin L. Russell
In reply to this post by Achim Schneider
On Sun, 19 Oct 2008 23:08:06 +0200, Achim Schneider <[hidden email]>
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.
>
>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.

Read the following uncensored interview with Bjarne Stroustrup, the
designer of C++, and then tell me what you think:

An Interview with Bjarne Stroustrup
http://www.ariel.com.au/jokes/An_Interview_with_Bjarne_Stroustrup.html

-- Benjamin L. Russell

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: A heretic question

Benjamin L. Russell
In reply to this post by ajb@spamcop.net
On Sun, 19 Oct 2008 20:50:45 -0400, [hidden email] wrote:

>The trouble is that C++ is a tool that's hard to use well.  But that's
>why they pay us the big bucks, right?

Interesting argument.  At first I thought that the following
uncensored interview with Bjarne Stroustrup was a joke, but your
argument makes it seem all the more plausible:

An Interview with Bjarne Stroustrup
http://www.ariel.com.au/jokes/An_Interview_with_Bjarne_Stroustrup.html

Some say that C++ was intentionally designed to be extremely difficult
to use specifically in order for C++ programmers to earn those "big
bucks."

Maybe this is just me, but if I had to choose a tool, I'd choose one
that would be easy to use well.

-- Benjamin L. Russell

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Re: A heretic question

ajb@spamcop.net
G'day aoll.

Quoting "Benjamin L.Russell" <[hidden email]>:

> Interesting argument.  At first I thought that the following
> uncensored interview with Bjarne Stroustrup was a joke, but your
> argument makes it seem all the more plausible:

That's not quite what I meant.  What I meant is that Visual Basic script
kiddie-ing may well be easy, real software development is hard.  C++ is
a hard tool to use well, but that's because it is doing a hard job.

> Some say that C++ was intentionally designed to be extremely difficult
> to use specifically in order for C++ programmers to earn those "big
> bucks."
>
> Maybe this is just me, but if I had to choose a tool, I'd choose one
> that would be easy to use well.

A paintbrush is easy to use, but hard to use well.

Cheers,
Andrew Bromage
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: A heretic question

Benjamin L. Russell
On Tue, 21 Oct 2008 01:46:00 -0400, [hidden email] wrote:

>A paintbrush is easy to use, but hard to use well.

An interesting analogy.  Then, in the style of a verbal analogy exam
question:

C++ : paintbrush :: Haskell : ?

Is C++ really easy to use?

-- Benjamin L. Russell

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Re: A heretic question

Bulat Ziganshin-2
In reply to this post by Benjamin L. Russell
Hello Benjamin,

Tuesday, October 21, 2008, 8:13:55 AM, you wrote:

> Maybe this is just me, but if I had to choose a tool, I'd choose one
> that would be easy to use well.

and what tool you choose in 80's? :)


--
Best regards,
 Bulat                            mailto:[hidden email]

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Re: A heretic question

Colin Paul Adams
>>>>> "Bulat" == Bulat Ziganshin <[hidden email]> writes:

    Bulat> Hello Benjamin,
    Bulat> Tuesday, October 21, 2008, 8:13:55 AM, you wrote:

> Maybe this is just me, but if I had to choose a tool, I'd choose one
    >> that would be easy to use well.

    Bulat> and what tool you choose in 80's? :)

A TARDIS.
--
Colin Adams
Preston Lancashire
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re[2]: Re: A heretic question

Bulat Ziganshin-2
Hello Colin,

Tuesday, October 21, 2008, 12:56:30 PM, you wrote:

>     Bulat> and what tool you choose in 80's? :)

> A TARDIS.

and why it not ruled the world? :)


--
Best regards,
 Bulat                            mailto:[hidden email]

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
12