[REBOL] Re: Rebol API to DyBASE
From: knizhnik:garret:ru at: 18-Dec-2003 14:37
Thank you very much to all who helps me to improve
Rebol API to DyBASE.
I am sorry that somebody treat my concerns about hash tables
in Rebol as criticism of this language.
I already understand that "make hash! 100000" is much more efficient
than "make hash! " and "loop N" is faster than "for 1 N 1".
Frankly speaking I do not think that it is my fault or dullness:
number of element which will be placed in hash table rarely can be
predicted and one of the rules of good language design is that
1. there should be no similar constructions doing the same thing
2. programmer should be able to predict complexity of one or another
operation. It is clear that function "power" is more expensive than
for example "*". But it is impossible to guess that "append" is less
efficient than "update tail" without having sources. Or that
is 10!!! times faster than "func[x][return x]"!
So excuse me once again for "criticism" of your favorite language.
Rebol is really interesting language. I could not say that I love
everything in it, but I have programmed in more than 10 programming
languages and invent two my own, and I could not said that some
of them is "the best language in the world" - even in its category
(I even not speaking about best universal programming language).
Each language has its pro- and contra- and designer of the language has
to solve a lot of compromises.
I have receive a number of hints how to improve code:
- replace "append" with "insert tail",
- "to-logic" with "to logic!"
- "(x = 'a) or (x = 'b)" with "find [a b] x"
- if (first x) = #"_" with if #"_" = first x
- "do cls" with "get cls"
- "for i 1 N 1" with "repeat i N"
- "to-string" with "form"
- "if x [ if y .... ]" with "if all [x y]..."
- "func[x][return x]" with "func[x][x]"
I have applied all of them. Updated version of DyBASE API is uploaded
to my site: http://www.garret.ru/dybase.html
But... performance of testindex.r is almost not changed.
That is why I decide to follow one of the fundamental principals of
software development - optimize only those code which needs to be
optimized (code in which program spends most of the time).
That is why I need to profile the execution of the program.
Unfortunately I had no profiler, because I have no professional
version of Rebol. I will be very pleased if somebody has Rebol profiler
and can profile execution of testindex.r and send profiler dump to me.
Thanks in advance