Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1. Re:  Compiling C into Haskell (Hein Hundal)
   2. Re:  Compiling C into Haskell (Brent Yorgey)
   3.  Re: Compiling C into Haskell (Maciej Piechotka)


----------------------------------------------------------------------

Message: 1
Date: Tue, 13 Apr 2010 05:39:04 -0700 (PDT)
From: Hein Hundal <[email protected]>
Subject: Re: [Haskell-beginners] Compiling C into Haskell
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=iso-8859-1

Thanks Allan!
 
   I was hoping the C-Haskell mix would work.  I am glad to hear that you have 
good things to say about it.

   My main reason for thinking about the C-to-Haskell compiler was to address 
the question "Say you had a C program.  Can you always convert it to Haskell in 
such a way that the compiled Haskell is not too slow and does not need too much 
memory?"  Supposing that too slow means slower than 1/4 the speed of C and too 
much memory means twice the memory of C.  

   Do you know the answer to this question?

Cheers,
Hein



      


------------------------------

Message: 2
Date: Tue, 13 Apr 2010 10:42:04 -0400
From: Brent Yorgey <[email protected]>
Subject: Re: [Haskell-beginners] Compiling C into Haskell
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=iso-8859-1

On Tue, Apr 13, 2010 at 05:39:04AM -0700, Hein Hundal wrote:
> Thanks Allan!
>  
>    I was hoping the C-Haskell mix would work.  I am glad to hear that you 
> have good things to say about it.
> 
>    My main reason for thinking about the C-to-Haskell compiler was to address 
> the question "Say you had a C program.  Can you always convert it to Haskell 
> in such a way that the compiled Haskell is not too slow and does not need too 
> much memory?"  Supposing that too slow means slower than 1/4 the speed of C 
> and too much memory means twice the memory of C.  
> 
>    Do you know the answer to this question?

My guess is that the answer is technically "no".  If I recall
correctly, there are some imperative data structures where the best
known time complexity for a functional version is worse than the
imperative version by a factor of (log n), so in that case you
wouldn't be able to stay within a constant factor of C.

However, I think in practice the answer is usually "yes"; but it might
be hard to do it via a mechanical compilation. Idiomatic (and fast)
Haskell is often organized very differently than corresponding C code.

So if you want to know whether you will necessarily be taking a big
performance hit in moving from C to Haskell, the answer is usually no,
if the translation is sufficiently intelligent --- which a
straightforward C-to-Haskell compiler is (probably) not.

-Brent


------------------------------

Message: 3
Date: Tue, 13 Apr 2010 16:54:37 +0200
From: Maciej Piechotka <[email protected]>
Subject: [Haskell-beginners] Re: Compiling C into Haskell
To: [email protected]
Message-ID: <1271170477.13227.7.ca...@picard>
Content-Type: text/plain; charset="utf-8"

On Tue, 2010-04-13 at 05:39 -0700, Hein Hundal wrote:
> Thanks Allan!
>  
>    I was hoping the C-Haskell mix would work.  I am glad to hear
> that you have good things to say about it.
> 

Why would you like to compile C to Haskell as opposed to using FFI
(Foreign Function Interface) - i.e. calling C from Haskell or Haskell
from C?


>    My main reason for thinking about the C-to-Haskell compiler was to
> address the question "Say you had a C program. Can you always convert
> it to Haskell in such a way that the compiled Haskell is not too slow
> and does not need too much memory?"  Supposing that too slow means
> slower than 1/4 the speed of C and too much memory means twice the
> memory of C.  

I'd say that given optimal Haskell compiler (and possibly in IO) - yes.
However we don't have optimal Haskell compiler (neither optimal C
compiler BTW) so Haskell program might be slower. Or faster (like with
combination of sorting and taking first element).

>    Do you know the answer to this question?
> 
> Cheers,
> Hein
> 

Regards

PS. Could you limit length of line to 72-80 characters? Thank you in
advance.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
Url : 
http://www.haskell.org/pipermail/beginners/attachments/20100413/0de84e11/attachment-0001.bin

------------------------------

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 22, Issue 20
*****************************************

Reply via email to