Meta

Robert “Uncle Bob” Martin made similar comments about database separationin his keynote talk, and Nick Sutterer also stressed this idea. I believe there wasalso at least one other connection that I have forgotten.

It makes me think, now more than ever, that “database separation” is an idea whose time has come. And by that I mean, it was always a sold principle. but some of us have formed the habit in recent years of ignoring it.

Of course, there are multiple ways of implementing database separation. I dothink a new ORM might be necessary or at least appropriate. If people start moving in that direction, I will at least put in my 0.02 euros.

By the way: Who can tell me why I picked the title of this blog entry? Kudosto the real geek who knows or at least can figure it out.

In Ruby 1.4, they were basically fancy Fixnums. They were immutable and immediate,and their values didn’t really matter. (Back then, as I recall, you could actually do a putsof a symbol and get a numeric result. I don’t recall that there was a Symbol class, thoughthere may have been.)

Symbols are still immutable and immediate (though we don’t mentally associate them withintegers any more). Their semantics has changed little, except that in recent versions ofRuby I believe they are stored on the heap and thus can be garbage-collected (to avoid anexploit where an app might create an arbitrary number of symbols and force an out-of-memoryerror).

But it occurs to me now that much of their use is stringlike. I do find myself converting back andforth between symbols and strings fairly often (especially to strings — not so often the reverse).

Consider also mental “nearness” of strings and symbols. This has led many people to use theRails function with_indifferent_access — a practice I won’t support or decry here.

So I have a germ of an idea. A knowledgeable person may be able to shoot it down quickly —the likes of Matz himself, Dave Thomas, and a dozen others whom I consider giants. Others, despite lacking demigod status, may have useful points to make, or may have strongopinions. 😉

The idea is simply: Let Symbols be nothing more or less than immutable Strings. In fact, letSymbol inherit from String.

No more with_indifferent_access. No excessive to_s and to_sym scattered everywhere. Nomore asking: Does this return a Symbol or a String?

I’ve always believed that Ruby had open classes for a reason. People rail about
the consequences of misusing this feature; but my response is: Then don’tmisuse it.

Some things in life, such as spoons, are difficult to use in a dangerous way. Others,
such as automobiles and free speech, can be very dangerous. The degree of caution
must be appropriate to the risk; but that is not to say such things should never be
used.

If I’m writing code strictly for my own use, especially in a self-contained one-off script,
I reopen classes as I see fit.

For example – the other day I was writing something with RMagick, and I found myself
wanting to manipulate geometric points (and especially to represent constants simply)
without any hassle. So I did this:

This may or may not appeal to you. It enables me to initialize points very
simply, e.g. a = [3,5] and still access a.x and a.y as needed.

It’s far from bulletproof. An array of strings, for example, will be considered
to be a “point” up to the time we do an illegal operation and the code blows
up. But in this context, for my purposes, it felt just right.

Lately I’ve been studying all the details of how encodings work. I think on the average,
things work better than before. Of course, if you’ve always been a “plain ASCII in the
USA” type of programmer, you might find things a little more confusing.

For my part, I am wondering why the source encoding is separate from the IO object’s
internal encoding. Obviously the internal and external have to be different, but I
haven’t yet grasped the need to manipulate more than two encodings at a time…

Here we go again… You’d think that someone who loves to write as much as I do would be a prolific blogger. The problem is a lack of focus. I have my fingers in too many pies, and I have more pies than fingers.

But a friend has reminded me of the importance of blogging. So I am starting to do it again.