enduro
5/15/2007 9:42:00 AM
Hello Brian,
Brian Candler wrote:
>On Tue, May 15, 2007 at 10:07:24AM +0900, enduro wrote:
>
>
>>- Symbols are fast as Hash keys,
>> but the "real-world" keys often are strings, or even can be both,
>> and then the current situation creates the well-known dilemma
>> to decide for a Symbol/String interface (and implement it).
>>
>>
>The programs for which it makes sense to convert strings (received from some
>external source, e.g. a database) to symbols for optimisation purposes, i.e.
>where the benefits are measurable, will be pretty few.
>
Yes, I agree.
(That's what I tried to address by the two lines after the quote above,
perhaps I should have put a smiley in there :-) )
>And you also open yourself to a symbol exhaustion denial-of-service.
>
>
Yes, of course.
But my point is: Let the system take care of that.
I want a Ruby that just works - crystal-clear, transparently, reliably.
:-)
And it already does in most cases. And there is a lot that can be improved.
And one such improvements could be a garbage collection for symbols. (I
think.)
>That is, as far as I know, the symbol table is never garbage collected. Once
>a symbol, always a symbol.
>
>
I'm not a core programmer, maybe i am asking to much,
but I think it should be possible without slowing anything down.
One very simple idea I can think of, is the following:
Set a limit to the number of symbols and if it is reached
the GC wil be invoked in a special symbol-mode, marking all symbols that are
still in use and completely re-generates the symbol-table from scratch.
>>Yes, I sometimes think of that separation of Symbol from String
>>as a tiny impurity in the Ruby crystal.
>>
>>
>
>I would disagree with you there, because Symbols are clean and easy to
>understand.
>
>
Yes, I really must admit, I also like the cleanness of current Symbols.
But then, my experience is that this clearness is not worth a lot,
because the border towards "dirty" strings must be crossed often.
(That's why I called sticking to the clearness "temping" in my last post.)
>There are other "impurities" I can think of - like the seven or so different
>flavours of Proc object which have subtle different semantics. This I find
>more difficult, because it's really hard to remember the rules for how they
>differ.
>
Fully agree! But that must be a different thread.
>But things like this are here to make the language "do the right
>thing" in most practical cases. And, once you've used Ruby for a while, you
>find that actually it does.
>
>
OK. But that can be said for most programming languages.
We are dealing with Ruby here,
and the appealing thing of Ruby is: the language!
I mean: concise syntax, flexiblity, expressiveness,
allowing to express things *naturally*.
Ruby is not yet good in many other aspects:
speed, threads, documentation.
But the runtime engine can be improved with time,
documentation can grow.
The language is the crystal. It must be good in the beginning,
it becomes more solid with every project written in that language.
So, I'd like to use the time we still have before Ruby 2 is born,
to contribute to a really good language.
>Do you think that hash['a'] and hash['A'] should be the same?
>
>
No, not for the builtin Hash#[].
So long
Sven