[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: functional languages ill-suited for large programs?




On Oct 31, 2003, at 2:31 PM, Perry E. Metzger wrote:

>
> Jim Blandy <jimb@redhat.com> writes:
>> I can think of one case where pure functional languages make nice
>> interfaces difficult.
>>
>> Suppose you've got a function that takes some time to compute, but you
>> know that once you've applied it to one value, you're likely to apply
>> it to that same value again soon.  In a stateful language, you can
>> wrap a cache around your function without changing its type.  But in a
>> pure functional language, each call to the cached version of the
>> function must take the cache (or something containing the cache) as an
>> explicit parameter, and return an updated version; the caller must
>> thread these values along from each call to the next.
>
> That's not necessarily the case. The optimizer for a pure functional
> language will know that a function is pure and can handle
> memoization/caching behind your back. That requires more work on the
> part of the compiler, but there is no reason that it can't be done.

In fact, every lazy language I know of does this. Lazyness is one of 
the side benefits of being purely functional, in fact.

Robby