Re: [Haskell-cafe] Compilers: Why do we need a core language?

What would be the point in doing so?
Well, I don't know. Would it save some time? Why bother with a core language?

Le Tue, 20 Nov 2012 10:49:01 -0500 (EST), citb@lavabit.com a écrit :
What would be the point in doing so?
Well, I don't know. Would it save some time? Why bother with a core language?
The compilation process might be slightly faster, but I guess it wouldn't be much noticeable. Also I guess having a core language eases porting to new architectures, you "just" have to port a simple core language rather than porting a complex language. The semantics of the core language is also rather simple, so you can use it to explain and understand how it works, then for the high level part, you can give a semantics by compilation to the core language. Finally, adding a new feature seems easier and less error prone if you have to translate it into the core language rather than compiling it directly. I never studied the Haskell compiler so I do not know the details, but I think that having a core language is a good idea. It is also good to have some VM to porting purposes. If you have N source languages and M target machines, by providing N+M stuff, you get N×M compilers !
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On 21/11/2012, at 4:49 AM,
What would be the point in doing so?
Well, I don't know. Would it save some time? Why bother with a core language?
For a high level language (and for this purpose, even Fortran 66 counts as "high level") you really don't _want_ a direct translation from source code to object code. You want to eliminate unused code and you want to do all sorts of analyses and improvements. It is *much* easier to do all that to a small core language than to the full source language.

On 20/11/2012 6:08 PM, Richard O'Keefe wrote:
On 21/11/2012, at 4:49 AM,
wrote: Well, I don't know. Would it save some time? Why bother with a core language? For a high level language (and for this purpose, even Fortran 66 counts as "high level") you really don't _want_ a direct translation from source code to object code. You want to eliminate unused code and you want to do all sorts of analyses and improvements. It is *much* easier to do all that to a small core language than to the full source language.
Actually, here I disagree. It might be much 'easier' for the programmers to do it for a small core language, but it may turn out to be much, much less effective. I 'discovered' this when (co-)writing a partial evaluator for Maple: we actually made our internal language *larger*, so that we could encode more invariants syntactically. This ended up making our jobs considerably easier, because we did not have to work so hard on doing fancy analyses to recover information that would otherwise have been completely obvious. Yes, there were a lot more cases, but each case was relatively easy; the alternative was a small number of extremely difficult cases. Jacques

On Thu, Nov 22, 2012 at 7:56 AM, Jacques Carette
On 20/11/2012 6:08 PM, Richard O'Keefe wrote:
On 21/11/2012, at 4:49 AM,
wrote: Well, I don't know. Would it save some time? Why bother with a core
language?
For a high level language (and for this purpose, even Fortran 66 counts as "high level") you really don't _want_ a direct translation from source code to object code. You want to eliminate unused code and you want to do all sorts of analyses and improvements. It is *much* easier to do all that to a small core language than to the full source language.
Actually, here I disagree. It might be much 'easier' for the programmers to do it for a small core language, but it may turn out to be much, much less effective. I 'discovered' this when (co-)writing a partial evaluator for Maple:
You're still using a core language, though; just with a slightly different focus than Haskell's. I already mentioned gcc's internal language, which similarly is larger (semantically; syntactically it's sexprs). What combination is more appropriate depends on the language and the compiler implementation. -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix/linux, openafs, kerberos, infrastructure http://sinenomine.net

On 22/11/2012 11:52 AM, Brandon Allbery wrote:
On Thu, Nov 22, 2012 at 7:56 AM, Jacques Carette
mailto:carette@mcmaster.ca> wrote: On 20/11/2012 6:08 PM, Richard O'Keefe wrote:
On 21/11/2012, at 4:49 AM,
mailto:citb@lavabit.com> wrote: Well, I don't know. Would it save some time? Why bother with a core language?
For a high level language (and for this purpose, even Fortran 66 counts as "high level") you really don't _want_ a direct translation from source code to object code. You want to eliminate unused code and you want to do all sorts of analyses and improvements. It is *much* easier to do all that to a small core language than to the full source language.
Actually, here I disagree. It might be much 'easier' for the programmers to do it for a small core language, but it may turn out to be much, much less effective. I 'discovered' this when (co-)writing a partial evaluator for Maple:
You're still using a core language, though; just with a slightly different focus than Haskell's. I already mentioned gcc's internal language, which similarly is larger (semantically; syntactically it's sexprs). What combination is more appropriate depends on the language and the compiler implementation.
Right, we agree: it is not 'core language' I disagreed with, it is 'smaller core language'. And we also agree that smaller/larger depends on the eventual application. But 'smaller core language' is so ingrained as "conventional wisdom" that I felt compelled to offer evidence against this bit of folklore. Jacques

Jacques Carette
On 22/11/2012 11:52 AM, Brandon Allbery wrote:
On Thu, Nov 22, 2012 at 7:56 AM, Jacques Carette
mailto:carette@mcmaster.ca> wrote:
On 20/11/2012 6:08 PM, Richard O'Keefe wrote:
On 21/11/2012, at 4:49 AM,
mailto:citb@lavabit.com> wrote: Well, I don't know. Would it save some time? Why bother with a core language?
For a high level language (and for this purpose, even Fortran 66 counts as "high level") you really don't _want_ a direct translation from source code to object code. You want to eliminate unused code and you want to do all sorts of analyses and improvements. It is *much* easier to do all that to a small core language than to the full source language.
Actually, here I disagree. It might be much 'easier' for the programmers to do it for a small core language, but it may turn out to be much, much less effective. I 'discovered' this when (co-)writing a partial evaluator for Maple:
You're still using a core language, though; just with a slightly different focus than Haskell's. I already mentioned gcc's internal language, which similarly is larger (semantically; syntactically it's
sexprs). What combination is more appropriate depends on the language and the compiler implementation.
Right, we agree: it is not 'core language' I disagreed with, it is 'smaller core language'. And we also agree that smaller/larger depends on the eventual application. But 'smaller core language' is so ingrained as "conventional wisdom" that I felt compelled to offer evidence against this bit of folklore.
I don't think you're evidence contacts that bit of folklore. But as stated it's vague. In particular, is "smaller" relative to the full source language, or is it absolute (in which case you should compile to a RISC architecture and optimize that :-)? Since the latter seems silly, I have to ask if your core language for Maple was larger than Maple? -- Sent from my Android tablet with K-9 Mail. Please excuse my swyping.

On Fri, Nov 23, 2012 at 9:59 AM, Mike Meyer
I have to ask if your core language for Maple was larger than Maple?
I can think of several reasons why it would make sense, especially if the core language is much harder for a human to write for but much easier to optimize and/or generate machine code for. -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix/linux, openafs, kerberos, infrastructure http://sinenomine.net

On 23/11/2012 9:59 AM, Mike Meyer wrote:
[...] I have to ask if your core language for Maple was larger than Maple?
Yes. Maple 10 had 62 cases in its AST, we had 75 (p.13 of [1]) Jacques [1] http://www.cas.mcmaster.ca/~carette/publications/scp_MaplePE.pdf
participants (6)
-
AUGER Cédric
-
Brandon Allbery
-
citb@lavabit.com
-
Jacques Carette
-
Mike Meyer
-
Richard O'Keefe