Page 3 of 3
Re:Scheme in Short (Finished!)
Posted: Sun May 30, 2004 10:34 am
by chris
I was just recently thinking about Scheme again and I reread this tutorial. I was wondering if hygenic macro's cause alot of overhead.
Thanks.
Re:Scheme in Short (Finished!)
Posted: Sun Jul 11, 2004 7:38 pm
by Schol-R-LEA
I've just posted
Scheme in Short v.1.1 on my freeservers account. While the basic text hasn't been significantly changed, it has been reformatted and expanded somewhat. Comments and corrections are welcome.
Re:Scheme in Short (Finished!)
Posted: Fri Jul 16, 2004 5:34 pm
by mystran
Macros, hygienic or not, are always evaluated at compile time..
In purely interpreted code macros add overhead similar to that of normal functions, but with any code that does any kind of compilation (even syntax analyzis) before actually running the code, they add exactly zero overhead... except ofcourse some macros might need complex functions to be actually implemented but that's another story..
generally, avoiding macros because of performance reasons is like avoiding cars because horses are slower...
that said, don't bother with performance anyway, unless you actually see that your code is too slow..
Re:Scheme in Short (Finished!)
Posted: Sat Jul 17, 2004 6:34 am
by Schol-R-LEA
I agree with Mystran on that last point. As has been often quoted here, the first two
Rules for Optimization are
Rule 1: Don't
Rule 2 (for experts only): Don't - yet
(Yes, that linked page specifically discusses Perl, but the principles apply pretty much the same to any language.)
Concentrate on getting your code to work correctly, and only worry about optimization if the performance proves to be too serious a problem. Keep in mind that compiled Scheme can be an order of magnitude faster than interpreted Scheme, and that a highly optimizing compiler such as STALIN can improve on that even further.
If you do have to optimize, only optimize where it actually makes a difference. Use a profiler and timer to find where the time is being spent, and work on only those parts. Put your effort into things which have a measurable impact on the results; optimizing a function that runs once for less than a tenth of a second isn't worth the effort. Most Scheme interpreters come with excellent profilers, with the one in Dr Scheme being particularly easy to work with.
Re:Scheme in Short (Finished!)
Posted: Sun Jul 18, 2004 2:03 pm
by chris
Thanks.