[Haskell-cafe] Picking an architecture for a Haskell web app

Andrew Coppin andrewcoppin at btinternet.com
Thu May 10 12:52:55 EDT 2007


>> I can see it's GHC-specific, what I was asking is does the computer 
>> than runs the final program need to have GHC installed. Presumably is 
>> does if it's going to compile files on the fly. What about if it only 
>> loads *.o files that are already compiled? Is GHC still required? 
>> (Not that the answer worries me greatly; I'm just curiose.)
>
> You would need the object files and archives comprising the Haskell 
> runtime, and you'd need to run a ghc link in verbose mode to figure 
> out how to use them and write a script to do the link.

Uh... right. So basically you need GHC. ;-)

>> Wait a sec... Are you trying to tell me that it is *faster* to take 
>> the source, type check it, convert it to Core, perform 25,000 
>> Core-to-Core transformations, convert Core to C, call GCC, link the 
>> result together, dynamically load it, execute it, extract the result 
>> and confirm that it type checks, and display it....... then it is to 
>> just directly execute an interpreted expression? I find that highly 
>> surprising.
>
> It's pretty fast, actually.  But your interactive expression still 
> needs to do most of that, except it compiles cmm to bytecode instead 
> of to C (old default; handed off to gcc afterward) or directly to asm 
> (modern ghc).  In particular, you are doing both core transformations 
> and type checking no matter what --- and they take *far* more time 
> than the compile and link.  Truly.

Interesting. On my system, the link stage typically takes far longer 
than compilation. (Compilation takes 4 - 5 seconds per module, linking 
takes another 15 seconds or so. Depending on how big the program is. Use 
-O2 to make the compilation stage take round about 30 seconds per module 
instead.)

> Plus, consider that people often throw extensions at lambdabot --- do 
> you support even simple stuff like forall in your interpreter?  Using 
> ghc means you can use most of the ghc extensions.

Ah, yes, well, I avoid everything that isn't in Haskell 98. ;-)

(Mainly because 1. most of it makes no semblence of sense, and 2. why do 
we need any of this stuff anyway?)

FWIW (again, I don't have the code any more) my interpreter had no type 
checker, but would gracefully handle runtime errors. (Typically if the 
code isn't well-typed, that means it hits some constructor the function 
isn't expecting, and dies that way.) Very useful and instructive for 
seeing how stuff works; I discovered first-hand why foldl' exists!



More information about the Haskell-Cafe mailing list