Sunday, April 30, 2006

What I Love About The Ruby Community

Chris Petrilli writes about one of the things that I love about the Ruby community:
Spiffy. In some ways they’re juts rediscovering what the Smalltalk world has had for a long time, but there’s a lot of new stuff happening too, and the “spirit” of the community is what attracts me. There is a certain unwillingness to accept wrote answers and look for new solutions. They also seem, unlike so many others, to not have forgotten where so many of the ideas come from.

The youthfulness and excitement of the Ruby community attracted me to the language even before Rails. It was the knowing your past, but looking at the future that got me. I love it. It makes me look past a few shortcomings in the language (like & and that blocks are not first class objects). But, it's going to be a fun journey with so many passionate people.

Learning To Like iTunes

When I won my iShuffle last year, I was very angry with Apple after installing iTunes. It installed itself itself between my computer and the CD-ROM (which I found out when I uninstalled it and my CD-ROM disappeared). And let's not forget that it tried to rearrange my existing MP3s after I told it NOT to. It was a frustrating experience and it cooled my desire for a Mac real fast. So, I uninstalled it; set my computer back to its initial before-iTunes state; and downloaded a Python script to add MP3s to my iShuffle. I love my iShuffle.

Fast forward another year and I have won another Apple product: the Nano iPod. I have talked to several people who think of me as crazy for my rants against iTunes. They told me that iTunes is wonderful and what is my problem? Well, I told them that I hate the "by song" view. I listen to albums gosh darn it! They assured me that they too have big collections and iTunes is awesome. Maybe I'm missing something here, no? I install it; try in earnest to use it; and go as far as to download Podcasts.

To cut a long story short, I've spent the weekend with iTunes. I learned how to get around what I thought were deficiencies. The path to liking iTunes is underway. My real complaints were really that it was a different way to work on my MP3s. It's already forcing me to tag all of my MP3s in my iRiver so that they can be easily imported into iTunes. I even learned how to sync both of my iPods.

My lust for a Mac is increasing.

Saturday, April 29, 2006

Cool Pictures

Adriaan van Os has posted some great pictures of Smalltalk Solutions 2006. I especially liked this one:

Hold on one minute while I channel the gods of Smalltalk past

I never thought I looked silly but, this proves it! The pictures are fabulous. They are pure fun!

Friday, April 28, 2006

Smalltalk Solutions 2006

I've been spending most of the day recovering from the massive idea exchanges at Smalltalk Solutions 2006. I had so much fun talking with everyone. I'm starting to feel comfortable giving presentations and I think it shows. As given by this review by James Robertson:
Blaine gave a good talk. He was funny, self deprecating, and well prepared.

If he only knew how many times I practiced and the amount of time I used for research. I'm glad it showed. I enjoyed giving it and I can't wait to unleash it on Java and Ruby crowds! So, what were my favorite presentations? Bar none, it had to be Brian Foote's keynote and Lukas Renggli's talk on Pier. But, I must admit I got private sessions where Colin Putney showed his design for Monticello2 (WOW). Andres's thoughts on the coding contest, and Hans-Martin Mosner showed me some "Behavior" magic. I will soon be taking over the universe with the information given to me.

I learned so much during the conference. Everyone I talked to gave me fresh perspectives on a wide range of topics. I'm still busy writing in my journal all of the great conversations I had. I can't decide if my brain is hurting from caffeine withdrawal or all of the possibilities. I think it's the latter.

My only real complaint is that we didn't have a space to have a Camp Smalltalk. I would have loved to paired with some folks. Maybe next year, we can find a spot in one of the coffee shops and take it over.

I can't wait till next year!

Thursday, April 27, 2006

Number Two In The World!

I became the number two Smalltalker in the world this past week. It feels great. The coding contest this year was so much fun. Michael Lucas-Smith came up with such a great puzzle to solve. I loved every minute of it. I used Dolphin 6 for my player and it was an absolute pleasure to program in. My brain hurts.

My great friend, Andres Valloud is number one and for good reason. I knew I was beat when we compared designs after the contest. Andres's design was just gorgeous I hope he blogs about it. I learn so much from him. I wish he would blog more about what goes on inside of his head. It's refreshing how he thinks and he's the type of person that makes you push yourself harder to do better work (or shall I say art?).

Great design won the contest. I hope Andres blogs about his design and decisions in the contest. It would be a lot of fun to read.

We're talking about doing the coding contest next year and we're batting around a lot of ideas. Now, we'll get to think about the contest from the reverse direction. I'm excited about working with him on that.

Saturday, April 22, 2006

Smalltalk Solutions Cometh

I'm leaving for Toronto tomorrow to attend Smalltalk Solutions. I'm so excited! I will be presenting as well as you all know. Nervous doesn't even being to describe my anxiety. Let's hope I don't get booed off the stage when I present "Controlling Pain: Augmenting Unit Testing". I've been practicing to reduce my twitches and it should be an incredible experience. To give everyone an extra incentive to show up, my talk is all in Squeak (No PowerPoint here, buddy).

After Smalltalk Solutions, I will be focusing on presenting the talk in Java and Ruby versions. I'm dubbing it "Reflective Testing" and it should make for more fun presentations!

I can't wait to see everyone! See you guys at the pub tomorrow night!

May Omaha Dynamic User's Group

April showers bring May flowers or shall I say another awesome Dynamic Language User Group Meeting. This month we are honoured to have Scott Hickey presenting Groovy. His presentation will cover an overview of the language highlighting Groovy's dynamic programming features. He will also show some common Java programming idioms and show how we can replace Java with Groovy to make our application code more readable. I simply can't wait! As always bring everyone you can.





WhenMay 2, 2006, 7pm-9pm
WhereCafe Gelato

156th & Dodge

445-4460

Friday, April 14, 2006

Playing With Procs And Objects

One of the things that I love about Ruby is the ability to treat methods and blocks as the same:
def square(number)
number * number
end
method = method(:square)
block = lambda {|number| number*number}
numbers = [1, 2, 3]

#prepare to get the same answer
p numbers.collect(&method)
#result: [1, 4, 9]
p numbers.collect(&block)
#result: [1, 4, 9]

At first glance, you might think this happens because of method and block having a common method in :call. But, you would be wrong. Try this code and watch it fail:
#This fails
class Symbol
def call(*all)
method(self).call(*all)
end
end
p numbers.collect(&:square)
#result: ERROR!

Well, the first clue is the weird "&" in front in all calls. This converts a Proc object to a block to be passed into the call. The interpreter expects an object to be a Proc after the "&" or it complains you didn't give it one. What are we to do? Well, thankfully, the interpreter tries to do the conversion by calling :to_proc. Let's try it:
class Symbol
def to_proc
method(self).to_proc
end

end
p numbers.collect(&:square)
#result: [1, 4, 9]

This works like a charm! Now, by simply implementing :to_proc we can use any object to a call that expects block.
class MyComplicatedCalculation
#lots of instance variables..too heavy for a mere Proc
def to_proc
#calculations that could end world hunger go here
#For now, simply return a simple answer
lambda { | number | 42 }
end
end

p numbers.collect(&MyComplicatedCalculation.new)
#result: [42, 42, 42]

I do wish Ruby just allowed me to implement :call and be done with it, but implementing :to_proc isn't much more work. Have fun!

Moved

I moved my blog to a bright new location and you can access the feed right here. It's been a long time coming. If anyone runs into any problems, let me know!

Thursday, April 13, 2006

Nintendo and Casual Gamers

James Robertson talks about the market that Nintendo is after and it's the causal gamer. I must admit they get all of my gaming money (which isn't much). I'm probably what they consider a casual gamer. I don't play that much and when I do it's just to have some mad fun to clear the mind. Nintendo has the best "fun" games. Bar none, my favorite games ever are the Mario and Donkey Kong off-shoots (Donkey Kong Country, Mario Kart, Mario Bros, Wario, Yoshi, etc). Plus, I like carrying my games with me. The PSP peeked my interest when it came out, but I really don't enjoy racing real cars, shooting people, or robbing people. I want escape. Nintendo gives me that and fun in spades. Besides, the DS touch screen and on-line play is awesome. I dare anyone not to get addicted to Mario Kart.

Wednesday, April 12, 2006

Mini-Fight

From Blabbermouth comes this funny bit of news about MiniKiss vs. TinyKiss. It does't get much stranger:
Robert W. Welkos of the Los Angeles Times is reporting that Joey Fatale, the 4-foot, 4-inch New Yorker who heads the all-dwarf KISS tribute band MINIKISS, is denying published reports that he tried to sneak past security last month at the Hard Rock Hotel and Casino in Las Vegas to confront a rival band leader, 4-foot "Little" Tim Loomis of TINY KISS, for allegedly ripping off his idea for such a group.

Loomis, a former drummer for MINIKISS, was performing with TINY KISS, which includes three little people and a 350-pound woman, on St. Patrick's Day at Beacher's Madhouse, a Las Vegas variety show, when the incident occurred.

Show host Jeff Beacher told The Times on Monday that Fatale "tried to sneak in saying he was TINY KISS" and had to be escorted from the premises. According to the New York Post, Fatale's lawyers sent a legal cease-and-desist letter to the show trying to shut down the act.

Loomis told the Post: "[Fatale] came out here [to Las Vegas] and tried to cause trouble, so I had him 86'd from the Hard Rock. The impression I got was that he was looking for a fight. He'd been threatening me over the phone."

But Fatale disputed the accusation, telling The Times: "This whole thing about me going to the Hard Rock with my gang — that didn't happen. What happened was, I went there because somebody told me [TINY KISS was] doing the show that night…. Nobody escorted me out of there. I went there by myself to approach them as a gentleman."

Fatale says he has "nothing to say" about Loomis, except, "He's a nice guy." And, he added, "This is all a big publicity act for the guy at Beacher's."

Sunday, April 02, 2006

Revisiting Old Code And Private

I've been looking through old code as of late and well, it's...it's...EMBARASSING! There I said it. Does anyone else do this? I was looking at my Thesaurus project (my Squeak version and soon-to-be Java version) and was appalled at a lot of the code. So, I spent sometime refactoring and getting the code back into shape. My Thesaurus project in Squeak was a quick excursion into writing Morphs and that code was fine. What made me crinch was my parsing code! For one thing, I put all of the code for parsing into one class. It was doing all sorts of stuff with the HTML elements that it had no business doing. The first order of business was to move all of the low-level HTML traversal code into a new class. This made the parser much more readable and took away the noise inside of it. The next order of business was the actual traversal code. I made some huge blunders in my implementation of the depth-first/breadth-first algorithm. I knew the first problem was when I couldn't even understand what I was doing!

Here's the original code:
elementsIn: anElement do: aOneArgBlock depthFirst: aBoolean
| left children |
left := OrderedCollection with: anElement.
[left isEmpty]
whileFalse:
[| next |
next := aBoolean ifTrue: [left removeLast] ifFalse: [left removeFirst].
(aOneArgBlock value: next) == false
ifFalse: [children := OrderedCollection new.
next elementsDo: [:each | aBoolean ifTrue: [children addFirst: each] ifFalse: [children addLast: each]].
left addAll: children]]

YUCK! What was I thinking with two checks for depthFirst or not? Here's the new code (which is a new class by the way!):
pvtDo: doBlock depthFirst: isDepthFirst 
| searchQueue dyadic |
dyadic := self pvtCurryForContinue: doBlock.
searchQueue := OrderedCollection withAll: self pvtChildren.
[searchQueue isEmpty] whileFalse:
[| next continue |
next := self class on: searchQueue removeFirst.
continue := [next addChildrenTo: searchQueue depthFirst: isDepthFirst].
dyadic value: next value: continue]

Now, you might notice some weirdness like the #pvtCurryForContinue:. All it does is to call the continue block by default if the block only accepts one argument. Otherwise, it let's the block continue through. Here's it's implementation:
pvtCurryForContinue: doBlock 
^doBlock numArgs == 1
ifTrue:
[[:each :continue |
doBlock value: each.
continue value]]
ifFalse: [doBlock]

This is my functional programming training shining through. This code is much cleaner and easier to read than the one before.

This was just one simple example. I used the Thesaurus project to refactor to see how enforcing private members in Smalltalk would feel. So far, I found a lot of breaches of encapsulation that I had not noticed in the heat of development. Even with categorizing methods as private and with comments, I still broke the boundaries. The pvt at the beginning makes it obvious and Squeak's compiler tells me immediately when I have done something wrong.

After the refactoring, I felt my design was much cleaner overall. So far, I'm enjoying using pvt at the beginning of my private methods. It makes me get into the habit of "telling" my objects instead of "asking" which I generally do well. But, it helps when I'm weak in the rush to get something done or simply not as focused as I should be. The public protocol is obvious and minimal. Plus, if I have too many pvt methods, I start looking through my methods to break the object down further.