This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Scheme is too complicated


Jay Glascoe <jglascoe@jay.giss.nasa.gov> writes:

> I'd just settled down at my desk after some horrific meeting and I
> was in a bad mood.

I'm glad I didn't offend you.

> a while back I posted something like this:
> 
> hash->keys could be written in Scheme like this
> 
> (define entry->key cadr)
> 
> (define hash->keys
>   (lambda (mytab)
>     ;; maybe do some type-checking here
>     (let* ((vec (cdr mytab))
>            (vec-len (vector-length vec)))
>       (do ((keys '())
>            (i 0 (+ i 1))
>            (bucket (vector-ref vec 0) (vector-ref vec i)))
>           ((>= i vec-len) keys)
>         (do ((entry-list bucket (cdr entry-list)))
>             ((null? entry-list))
>           (let* ((entry (car entry-list))
>                  (key (entry->key entry)))
>             (set! keys (cons key keys))))))))
> 
> here's what I would call a functional version:
> 
> (define hash->keys
>   (lambda (mytab)
>     (let ((bucket->keys (lambda (bucket) (map entry->key bucket)))
>           (entry->key cadr))
>       (apply append (map bucket->keys (vector->list (cdr mytab)))))))
> 
> the functional guy is sleek and pretty, but those "vector->list" and
> "append" bits are performance killers. 

Now I think I understand what you are getting at.  It is true that
some functional operators have terrible performance implications.
'append' in particular is a garbage producing monster.

I was making a particular point about implementations of scheme being
different from one another in terms of performance, and the fact that
those differences are not part of the language.  Continuing the append
example, in a scheme system with an exact generational garbage
collector, append may not be a big problem, because the garbage
collector can quickly reclaim the storage, without scanning the whole
data space.

You see Perl doesn't suffer from this phenomena; there is only one
implementation.  So people compare guile and perl and say 'scheme
is slow!.'  This isn't fair; _guile_ is slow.

Am I making any sense at all?

-russ

--
Which is worse: ignorance or apathy?  Who knows? Who cares?