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 ruby, smalltalk | Tags implementation, performance, ruby, self, smalltalk | 10 comments | no trackbacks
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 ruby | Tags ducks, types | 4 comments | no trackbacks
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 ruby, smalltalk | Tags implementation, nubies, objectidentity, objects, semantics, variables | no comments | no trackbacks
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 advocacy, humility, strongopinions | no comments | no trackbacks
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 ruby | Tags ducks, roles | no comments | no trackbacks
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:
to be replaced with the more succinct and usually clearer:
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 ruby | Tags literateprogramming, peeves, perl, style | no comments | no trackbacks
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 durham, raleigh, raleighrubybrigade, rdu, rtp | no comments | no trackbacks
Posted by Rick DeNatale
Thu, 10 Aug 2006 15:09:00 GMT
One theory I’ve seen defines a “duck type” as a set of messages which an object bound to a parameter or value needs to understand. This leads some, who want to make type-checking happen a bit earler, to propose testing the values of such variables with oneor more respond_to? tests before using the object “in anger.”
But ducks can be subtle…
Read more...
Posted in ruby | Tags ducks, ruby, types | no comments | no trackbacks
Posted by Rick DeNatale
Tue, 01 Aug 2006 18:55:02 GMT
Programming in a dynamically typed language is sometimes like casting roles in a movie or play. Even if the screenwriter wrote a part with a particular actor in mind, theneed often arises for an understudy or stand-in.
One of the mantras of Duck Typing is that “Classes aren’t types”. Another, more subtle, aspect is that even if it walks and talks, an object needs to be tried out for a role.
In the Pickaxe, Dave Thomas gives, as his first example of duck typing, the usefulnessof of using a String or an Array as a lightweight substitute for a File.
Read more...
Posted in ruby | no comments | no trackbacks
Posted by Rick DeNatale
Sat, 29 Jul 2006 13:34:00 GMT
For those who don’t want to read a lot, or dont care too much, here’s the executive summary:
- I’m a long time object programmer.
- I worked for IBM for 31 years.
- I was one of the early adopters/advocates of Smalltalk in IBM.
- I’ve done a lot of Smalltalk.
- I’ve done a lot of standards work.
- I’ve done a lot of Java.
- I’m now free of IBM and Java, and I’m learning to love Ruby.
As a result of all of the above I’ve developed lots of strong opinions, weakly held, which I’d like to share.
Now for those with the stamina, some more details on my personal journey…
Read more...
Posted in ruby, smalltalk, war_stories | Tags memoirs, oop, smalltalk, types | 7 comments | no trackbacks