[Haskell-cafe] Very silly

Andrew Coppin andrewcoppin at btinternet.com
Thu Oct 16 13:09:14 EDT 2008


Juan Carlos Arevalo Baeza wrote:
> Andrew Coppin wrote:
>> Some guy told me that templates are "the best feature in the 
>> language", and proceeded to show me a huge chunk of highly 
>> complex-looking code which is approximately equivilent to
>>
>>  join :: Array x -> Array x -> Array x
>>
>> I was unimpressed.
>
>   Now I'm curious to know what chunk of code he showed you. FWIW, that 
> declaration you put there is done in C++ like so:
>
> template < typename X >
> Array<X> join(Array<X> const&, Array<X> const&);
>
>   Nothing more. I like both languages for very different reasons. C++ 
> for its insane amount of flexibility, and Haskell for its 
> expressiveness. And I've encountered equally harsh roadblocks in both 
> whenever I try to get "too crazy" while using them.

Well no, he included the implementation as well as just the signature.

>> Actually, that's a lie. I was impressed that such a low-level 
>> language could manage even that much abstraction. But I still prefer 
>> the Haskell way...
>
>   The dynamic range of the C++ language is probably unparalleled. In 
> particular, templates enable implementing high level abstractions in a 
> way such that we're still discovering how far it can go. But of 
> course, it's not just templates: it's templates when united to all 
> other language features like overloading.

C++ has some interesting ideas. I haven't learned how to use templates 
yet, but what I do find interesting is that there is no automatic memory 
management, and yet you can still do fairly dynamic programming. I've 
never seen any other language that allows this. (I had assumed it's 
impossible...) This makes me wonder just now necessary GC really is, and 
whether there is some way to avoid it...



More information about the Haskell-Cafe mailing list