chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] help please


From: Alex Shinn
Subject: Re: [Chicken-users] help please
Date: Wed, 14 Apr 2004 11:07:27 +0900
User-agent: Wanderlust/2.10.1 (Watching The Wheels) Emacs/21.3 Mule/5.0 (SAKAKI)

Yes, I'm stubborn and don't want to see Perl faster at this :)

At Tue, 13 Apr 2004 08:57:45 -0400, Linh Dang wrote:
> 
> I tried my script (with minor adjustments) with bigloo and it's even
> slower than chicken. the reason might be that bigloo's PREGEXP-SPLIT
> is slower than chicken's STRING-SPLIT. The fact remains that chicken's
> IO and bigloo's IO are both much slower than perlio.

string-split still creates a list every time.  If you've got a lot of
lines that don't match your format this is a loss.  You can replace the
initial test with

  (case (string-ref line 0)
    ((#\~ #\_ #\: #\a ... #\z #\A ... #\Z)
      (let ((tokens (string-split line "\t")))
        ;; ... rest of code w/o is-symbol-line test ...
        ))
    (else
      ;; do nothing
     ))

> The other thing I want to try is bigloo's REGULAR-GRAMMAR
> construct. Do you think it will help? Is there something equivalent to
> to REGULAR-GRAMMAR in chicken?

It may, but won't do anything you couldn't do with a manual parser
(instead of string-split and list-ref) except probably make the code
more readable :)

> 1. is there something like elisp's MAPC in scheme?

for-each

> 3. This is a blaspheming question. What's the best/most-efficient
>    scheme implementation for text processing? chicken? scsh? bigloo?
>    PLT?

Best and most efficient are two different questions...

It will be hard to beat Perl because this script does nothing but I/O
and simple regexp matches, which in Perl just translates directly to
highly optimized C.  Things still left to try are 1) using your own
presized hash-tables (that avoid checks for resizing) 2) using symbols
instead of strings 3) tuning I/O 4) tuning the parser.

Where Perl really falls apart is when little scripts like this grow, or
need to use external libraries, because OO and function calls are so
slow.  If you try hard you can write readable Perl (unless it's in the
functional style), and you can write well abstracted Perl, but as you
abstract it gets slower and slower at a much higher rate than other
languages.

Back to Scheme: anything w/ regexps and string-ports is good.  After
that don't think in terms of text processing but in terms of general
language features, and google for the answers on comp.lang.scheme :)

-- 
Alex




reply via email to

[Prev in Thread] Current Thread [Next in Thread]