A Subtle Change to Mixin Semantics in Ruby 1.9

Posted by Rick DeNatale Mon, 09 Oct 2006 20:07:00 GMT

I’ve been working on a little tool to peek behind the curtain and see a bit of what’s going on behind the scenes in the standard Ruby implementation (i.e ‘ruby’ as opposed to ‘Ruby’)

While doing this I was looking at the code which ruby runs when you include a module in a class or another module. I noticed that ruby 1.8 was going to some pains not to move the proxy for an included module in the inheritance chain.

To verify what my eyes seemed to be telling me, I wrote a silly little test program which created a module with one method, and several classes.

This test verified my reading of the 1.8 code. I then tried the same test using the latest ruby 1.9 and found that module mixin semantics have changed.

Read on

Read more...

Posted in  | Tags , , ,  | 1 comment | no trackbacks

Simulee, Simula, Simulee, Simu-la-ah-ah-ah

Posted by Rick DeNatale Thu, 05 Oct 2006 15:48:00 GMT

Recently, a certain “gentle-reader” questioned my statement in my “mini-memoir” that Simula lacked classes and inheritance.

I stand by my guns. Simula (now known as Simula I) had neither. These were introduced by Simula-67 about five years later. It was Simula rather than Simula-67 which was one of the influences on Alan Kay’s early conception of Smalltalk.

For more details, see my reply to “gentle reader” in the comments to my mini-bio article.

Posted in  | Tags , , ,  | no comments | no trackbacks

Danger Will Robinson

Posted by Rick DeNatale Thu, 05 Oct 2006 15:23:00 GMT

Ruby has a nifty method in kernel called open. It’s quite powerful in the way it interprets its first argument, a string telling it what to open. It can open a file, or it can open a pipe to a sub-process it creates to run a command in that string. It takes quite a bit of open function has a similar interpretation of it’s first argument. Again it takes quite a bit of documentation to describe.

Which is a cause for concern. Most things that powerful can be misused.

I use an application called Awstats to get statistics on my websites. Awstats is a very popular application which is written in perl.

But I long ago disallowed access to Awstats from the outsite world after I found that my system had been compromised by a bad guy exploiting perl’s open function.

Read more...

Posted in  | Tags , ,  | no comments | no trackbacks

Performance Anxiety

Posted by Rick DeNatale Tue, 26 Sep 2006 19:17:00 GMT

I've been meaning to write about Ruby performance for a while, and a recent blog post by an old friend and colleague, got me off my proverbial.

The old friend is John Duimovich, who wrote about the relative performance of C++ and Smalltalk and what that could mean for ruby.

John's message is important for those who bemoan the performance of Ruby, and I plan to expand on that message in this and later posts to this blog, but first a few words about Mr. Duimovich.

Read more...

Posted in ,  | Tags , , , ,  | 10 comments | no trackbacks

Schrödinger's Duck

Posted by Rick DeNatale Thu, 21 Sep 2006 15:27:00 GMT

Once again there’s been a recent furore about the meaning of Ducktyping on the ruby-lang mailing list.

A nice young man from Sweden, by the name of Ola Bini, announced “ductator” a ruby-gem which allows type validation of ruby variables. Now I think that Ola is young based on the photo on his blog site, and I know that he’s nice because only nice people inhabit ruby-lang.

The real question is just what kind of a type system ductator represents. I’ve taken a brief look at it and it seems to allow one to describe, via a hash, a list of rules which are applied to a variable’s value at run-time. These rules are things like a list of methods the value must have, a class which the value must be an instance of, or an instance of a subclass of etc.

The Cat is Dead, Long Live the Cat

In 1935 Erwin Schrödinger, proposed his famous thought experiment, in which a cat, a a radioactive atomic nucleus, and a cannister of poison gas rigged ot open if the nucleus decayedare placed in a sealed box. The half-life of the neucleus is such that there is a probability of 1/2 of the nucleus decaying within one hour. Because quantum mechanics states that until a decay is observed, the nucleus really exists as a superposition of decayed and undecayed states, that the cat is both dead and alive until the box is open and the observation is made. Read more...

Posted in  | Tags ,  | 4 comments | no trackbacks

On Variables, Values, and Objects

Posted by Rick DeNatale Wed, 13 Sep 2006 19:47:00 GMT

I’ve recently observed some posts to ruby-talk which evidence some confusion on the part of the posters about the relationship between variables and objects in Ruby. One currently active thread concerns several participants who are upset that instances of the Matrix class in the Ruby standard library can’t be changed once created.

In Ruby, like in other uniformly object-oriented languages, the relationship between variables and their values is subtly different than in other languages, and this is a crucial paradigm shift, which must be crossed in order to understand Ruby.

In many languages a variable names an area in memory which holds a “bag-of-bits” representing the value of the variable. The size of that area depends on the type of the variable. A variable holding an integer might be 4-bytes long, while one holding a particular structure might be 325 (or whatever) bytes.

In a uniformly object-oriented language, all variables reference objects, and any variable can reference any object, or different objects over time. My good friend at IBM, the late David N. Smith, used to say that in such a language, “all variables are the same size,” when he wrote about or taught Smalltalk.

This distinction can trip up the unwary. Let’s try to clear some of the stumbling blocks out of the way.

Read more...

Posted in ,  | Tags , , , , ,  | no comments | no trackbacks

Humility and Advocacy

Posted by Rick DeNatale Wed, 13 Sep 2006 15:43:00 GMT

Two interesting web pages just came up on the ruby-talk list.

Humility – The Path to Learning

Paul Lutus, who recently posted something to the list, and later admitted that he was mistaken about a technical point. This was rightly called out as an unusual occurence on mailing lists, even the well-mannered ruby-talk.

He pointed out that he had a “vested interest” in admitting his mistakes. And pointed to His article on narcissism. Too many denizens of the “network” nation exhibit symptoms of believing that they are the smartest guy in the room.

As I’ve said here before, I believe in loosely holding strong opinions. That is when I find, or am presented with evidence which runs counter to one of my opinions, I have to reconsider, and if the evidence is compelling, change or drop the opinion in question. It’s a personal version of the scientific method.

Would that, more programmers, pundits, politicians, and folks in other walks of life follow this practice.

While I often state these strong opinions, well strongly, it’s always in the hope of stirring discussion, so as to continue learning.

Advocacy, vs. Open-Minds

Another good article is Mark-Jason Dominus’ essay about why he hates language advocacy.

Although this article is over 5 years old, and is written for an audience of Perl programmers, it’s a worthwhile read for fans of Ruby, or any other programming language.

His points are that we can learn from other communities, and that taking the stance that “my tribe is better!” shuts off that learning, and alienates those who get the impression that because an advocate of language L, say that idea I is unimportant because it’s outside of standard practice in L, that L is incapable of supporting idea I.

Far better to understand I, and how to either express or incorporate it into L, so that those ‘needing’ it, and the advocate both understand each other.

Tags , ,  | no comments | no trackbacks

I'm Ready For My Close-up, Mr. Demille

Posted by Rick DeNatale Tue, 22 Aug 2006 15:37:00 GMT

Back when I was younger, and object[-oriented] programming was fairly new, my colleagues and I seemed to spend a lot of time philosophizing about types and objects. Although I don’t remember talking about ducks, we did talk a lot about the theater. The most common word we used to use for what we now call a duck type was a role.

Another way of looking at this, is that duck typing is akin to the way a person is chosen to fill the role of the American President. An assessment is performed on the candidates,one is chosen, and then the country, and world adapt.

Contrast this to the way things are done in picking the next British monarch, or the type systems of C++ or Java. In both cases one has to be born into the role, having the right genes via inheritance. Of course in the first case, who gets the job doesn’t matter all that much anymore.

Recently a thread about patterns on the ruby-talk mailing list turned, as threads there are wont to do, to duck-typing.

Read more...

Posted in  | Tags ,  | no comments | no trackbacks

A Perl of Great Price

Posted by Rick DeNatale Wed, 16 Aug 2006 15:03:18 GMT

An old programming adage goes: “You can write Fortran in any language.”

Computer languages, like natural languages, tend to spawn their own cultures and religions. And it’s not unexpected that the groups associated with these have different slants on things.

One of Ruby’s strengths is that it stole from the best. When I look at the language, it feels like Matz took the best features from a variety of languages including Smalltalk, Lisp, and not the least, Perl.

Two great features which Ruby inherited from Perl are integral support for regular expressions, and Perl’s excellent statement modifiers which allow things like:
if test
   statement
end
to be replaced with the more succinct and usually clearer:
statement if test
However, IMHO, overuse of the Perl features in Ruby can make code too Perl-like.

I’ve seen my share of Ruby code which is hard-to read and understand, and a lot of that looks suspiciously like Perl code re-written in Ruby.

Read more...

Posted in  | Tags , , ,  | no comments | no trackbacks

First Encounter, Raleigh Ruby Brigade

Posted by Rick DeNatale Wed, 16 Aug 2006 11:57:00 GMT

Last night I got to attend my first meeting of the Raleigh Ruby brigade. It was an exciting meeting for several reasons. The first reason was the topic. Justin Gehtland Stuart Halloway of Relevance talked about and demonstrated Streamlined, a project which is doing for the UI of rails application development what ActiveRecord does for database access. The second reason was the attendance, 44 enthusiastic rubyists.

Near the top of the meeting, Larry Karnowski announced that he had set up a #raleigh.rb irc channel on freenode for the group. If this turns out to be popular it shouldbecome permanent.

The change came about as a result of last month’s BarCampRDU which was held at Redhat HQ. One of the attendees who is a member of the brigade suggested that the group move the meetings to Redhat, which meant that they couldn’t meet on the same night as TriLUG since it already meets there.

Nathaniel Talbott, who founded the brigade is thinking about a monthly ruby hack night at the old location. As long as they don’t make that conflict with TriLUG, I’ll be there!

Tags , , , ,  | no comments | no trackbacks

Older posts: 1 ... 8 9 10 11