Patrick F. McGehearty writes: >All this "my language is best because it is all I know" discussion is not >very enlightening. Let's get back on the "language features which will >aid/hender future architectures generate fast applications" topic. Given my respect for David Chase, my awareness from the literature that the kinds of transformations he is talking about _are_ used and _do_ pay off (indeed, I have a student doing a minor thesis on neural nets trying to see if he can beat Sun's C compiler -- alas, he was unwilling to learn Fortran --), and also given my strong liking for functional programming languages like Haskell and Clean, I'm worried. People in the functional programming community have put a _lot_ of work into trying to implement functional languages really well. For example, on the pseudoknot benchmark, Clean-compiled code ran as fast as C. There are techniques like loop unrolling that can be applied in functional languages as well. Let's take the well-known `member' function: member :: a [a] -> Bool | == a /* This declaration means that member is a function that will accept homogeneous lists with any element type, as long as that element type has an equality operation, and returns a Boolean result. */ member x [e:es] = x == e || member x es member x [] = False Clean is a lazy language, but the Clean compiler is able to infer that this function is strict. In fact, in the context of the definition Start = member 3 [4,1,3,2,5] the Clean compiler will make an instance member (int) and infer, without any declarations at all member (int) :: Int ![Int] -> Bool where ! means strict. So the code that is generated is perfectly ordinary call-by-value stuff. In fact, it's pretty much the equivalent of template bool member(T const x, list es) { for (; es != NULL; es = es->tail) if (es->head == x) return true; return false; } This is precisely the kind of code that David Chase decries as intrinsically inefficient. There _are_ things that can be done here, and they can be done precisely because these languages have no mutable data structures and are fairly straightforward to analyse. One thing I'd like to discuss _has_ been implemented, but _not_ as far as I know in the Clean compiler. That is, loop unrolling. Instead of having :: list a = Nil | Cons a (list a) you unroll the type. Unrolling by 3 would give :: list3 a = Nil3 | Cons31 a | Cons32 a a | Cons33 a a a (list3 a) This would economise on space as well, taking an average of 4/3rds of a word per element instead of 2 words per element. A compiler can automatically rewrite the member function to member3 x Cons33 e1 e2 e3 es = x == e1 || x == e2 || x == e3 || member3 x es member3 x Cons32 e1 e2 = x == e1 || x == e2 member3 x Cons31 e1 = x == e1 member3 x Nil3 = False I must repeat, the Clean compiler does NOT do this transformation, but there has been published work on a compiler for another functional language that does. So this kind of loop unrolling _is_ something that can be applied to pointer chasing, *provided* the language is a high level one which makes it impossible for a program to notice any difference, except in performance. In pure functional languages, speculative loading in such loops ought to work very well. So that's another thing that should help. The thing that has me worried is that fantastic improvements have been made in compiler technology for functional languages, but the big money is in compilers for C, C++, Fortran, and Java, so those languages are always likely to enjoy a lead that relates to their popularity, not their potential. This in turn means that such languages will continue to predominate in benchmarks, which means that computer architects will continue to bias their designs towards such languages, which means that functional language implementors will have even more catching up to do. The reason this is sad is that lifecycle costs can be reduced when you have a language which is otherwise sufficiently expressive but in which a large proportion of common errors _can't_ be expressed. (Ericsson believe this. They have adopted a mostly-functional language of their own design called Erlang, sacrificing performance in the interests of time-to-market and reliability.) Once upon a time, people used to advocate specialised hardware for symbolic languages. The phenomenal price-performance improvements of commodity hardware have made that a thing of the past, and I expect that to remain true (although there were some seriously interesting ideas in the LMI K machine which might still be useful). These days systems like Clean and O'CAML and SISAL get _fine_ performance on stock hardware. My impression, which is not completely up to date (I'm trying to get through fifty papers this week, phew!), is that the limiting factor for functional languages is memory. (For example, Clean directly supports arrays of unboxed numbers.) What I'm wondering, and here I go way beyond any expertise I might possibly claim, is whether (a) there are patterns of memory use in functional languages that hardware designers might exploit, without adverse effect on more conventional languages? and (b) whether the hardware designers see any point in worrying about this? -- John �neas Byron O'Keefe; 1921/02/04-1997/09/27; TLG,TLTA,BBTNOTL. Richard A. O'Keefe; RMIT Comp.Sci; http://www.cs.rmit.edu.au/%7Eok