Tuesday, October 31, 2006

Ruby and Continuations

I've been quietly observing the debate in the Ruby community over continuations being discontinued in 2.0. My stance is that the wrong debate is happening. It's not whether or not to include a feature. I think the debate should be "said feature should be possible". I want the power of being able to write continuations into Ruby if I want them. Why burden the language with extra features that only a few want? Make it possible for them to implement the feature themselves. If the features become popular, then include them in like you would a library. It's for this reason that I love Smalltalk and Lisp. There's no reason Ruby couldn't have the same power.

Monday, October 30, 2006

I didn't say it, honestly!

From Six Word Stories About Programming Languages
Smalltalk
All your concepts belong to us.

Lisp
(no ‘they all belong to (us))

MOHAHAHAHA! Ok, I'll stop the diabolical laughter now.

Saturday, October 28, 2006

Welcome To World, Duncan Manning

I would like to congratulate my great friend, Richard Manning, and his wife, Emily. They ushered in a new addition to their family, Duncan Manning, on Monday. A bouncing boy that will undoubtly be keeping them busy. I just got the news today and am so excited for them! How proud they must be. Welcome, Duncan!

Rebol in Omaha

We're doing something very special this month. We're doing a workshop on Rebol. Stan Silver will be our guide through the thickets of the Rebol programming language. if you think Rebol has something to do with Cobol, then you need to come to this meeting. Rebol is a cool dynamic language that has more in common with Self, Ruby, and Lisp. It's going to be interactive and a lot of fun. It will be November 7, 2006, 7pm-9pm. I hope to see everyone there!

Here's the location specifics:
Creighton University
2500 California Plaza
Omaha, NE 68178

Parking
Additional Information:
Enter the west end of the Old Gym.

Go up the elevator to the fourth floor.
You're there.
Restrooms are on the 2nd floor, unfortunately.
Vending machines are on the 1st floor, around the wall to the right of the elevator.
Anyone asks, you are attending the Omaha Dynamic Users Group meeting on the fourth floor of the Old Gym or ODUG.

PropertyDescriptor in JavaBeans

Does the JavaBeans framework have too many assumptions exposed? Does it suffer from a lack of encapsulation? I'm not talking about JavaBeans, but the framework that enables JavaBeans. Go take a quick look at PropertyDescriptor and what do you see? It knows a lot of things including read and write methods. What could be so wrong? For one, it's a dumb object (ala data structure), but that's not a bad thing given its name. But, I think it's powerless. It exposes all of its internals and has no encapsulation. But, this is a simple framework, why is that bad?

OK, it's time for an example. Spring is all of the rage (and rightfully so) and injects by the exposed writer methods in an object. But, wouldn't be nice not to expose them, but give Spring priviledged access to these fields and basically disallow ordinary access. What if I could have a custom PropertyDescriptor for just those fields. Well....

Right now, I could have a private writer and have a custom PropertyDecsriptor to grant access to it. But, what if I didn't want to add unnecessary noise to my class? Besides, it seems like a lot of trouble. Let's dream for a bit shall we?

What if instead of having getReaderMethod() and getWriterMethod(), we had getPropertyAccessor()? What would this new method return? How about this:
public interface PropertyAccessor {
Object get(Object receiver);
void set(Object receiver, Object newValue);
}

And this would be the default implementation:
public class MethodPropertyAccessor implements PropertyAccessor {
private Method reader;
private Method writer;

public MethodPropertyAccessor(Method reader, Method writer) {
this.reader=reader;
this.writer=writer;
}
public Object get(Object receiver) {
try {
return reader.invoke(object, null);
} catch(...PlethoraOfReflectionExceptions) {
throw new RuntimeException(reflectionException);
}
}
public void set(Object receiver, Object newValue) {
try {
writer.invoke(object, new Object[] {newValue});
} catch(...PlethoraOfReflectionExceptions...) {
throw new RuntimeException(reflectionException);
}
}
}

More of the knowledge in how to get/set properties in the object are known to the PropertyAccessor. We could then provide our own PropertyAccessors like we could have one built by giving it the Field itself. Like this:
public class DirectAccessPropertyAccessor implements PropertyAccessor {
private Field property;

public DirectAccessPropertyAccessor(Field property) {
this.property=property;
this.property.setAccessible(true);
}
public Object get(Object receiver) {
try {
return property.get(receiver);
} catch(...PlethoraOfReflectionExceptions...) {
throw new RuntimeException(reflectionException);
}
}
public void set(Object receiver, Object newValue) {
try {
property.set(receiver, newValue);
} catch(...PlethoraOfReflectionExceptions...) {
throw new RuntimeException(reflectionException);
}
}
}

Users of the PropertyAccessor would not have to know how the field is accessed (whether via methods or direct access or by going through other objects). By hard-wiring to always use methods, the JavaBeans framework has exposed too much of its internal implementation to the outside world. If they would have hidden more, it would have been more flexible. Of course, the examples need more fleshing out to handle things like primitives (but, you're not using those anymore are you since you have autoboxing, right?).

I wanted to show this as a simple example of why encapsulation is good. I've made the code more flexbile, simpler, and easier to test even. The PropertyAccessor is simply a facade around the business of accessing a field. Pretty simple stuff.

Just think if you had this with so many java frameworks that use JavaBeans. Wouldn't it be nice?

Monday, October 23, 2006

RubyConf 2006

I made it back from RubyConf in one piece. What fun! I drove up with Matt Secoske and the car decided to get sick while we were there. But, it was only minor. Anyway, I got to speak to a lot of people (and there's still people that I missed and didn't get a chance to chat with). It's nice sitting it at home relaxing now. It was a fun weekend of hacking Ruby and chatting about coder things. The funniest bit has to be that I wound up give a demo of Squeak and Seaside while I was there. I just can't help myself! It's hard for me not to get excited about dynamic languages and the one closest to my heart. I also got a chance to update my Lazy Collections implementation which I will post soon. It's also great to be back with internet. It's funny. This was the second coder conference I've been to with limited access. It was a great time and I enjoyed all of the festivities! See everyone next year! Ruby On!

The Gospel Of Closures

I gave my talk on closures at the Omaha Java User's Group and had a blast. It was great showing off the power of closures. I even got to to blow minds with the Y combinator. Don't worry I didn't scare them. I used it as an example of how you can take it and then showed them a simpler example to implement the same thing. Functional programming is becoming mainstream and that's a good thing in my book.

Saturday, October 14, 2006

Tour Updates

Just want to let everyone know that I will be speaking at this week's Omaha Java User Group meeting (October 17 @ 5:30pm). I'll be speaking alongside Matt Secoske, Kyle Dyer, and Scott Hickey. It will be a short talk, but it will be exciting. I promise! I hope to see everyone there.

Next up, I'll be attending this year's Ruby Conference in Denver October 20-22. I can't wait. It's going to be so much fun! New people to meet and exchange ideas with.

Wednesday, October 11, 2006

Eclipse Mylar

I'm in love. This is just too gorgeous. I spent the evening playing around with Mylar. I started using it with my work on TimeAndMoney and was quickly impressed. And I haven't even hooked it up to an issue tracking system yet.

Basically, it keeps the context of what you're working on. You create tasks and it pays attention to what you're editing. The cool thing is when you start switching tasks. It switches out the editors to exactly where you were and it creates a custom working set with only the files you were working on (you can also show everything and it greys out the least interesting items). I'm impressed and it works great with Eclipse 3.2. Finally, I have Squeak projects for Java and a whole lot more.

Now, I need to get Bugzilla installed...

Strings suck

All I have to say is, Amen, brother!" I see too many objects that are only comprised of primitive language types. Why not take it one step up further and make domain-specific primitives? A "Name" object might seem silly at first, but you soon find you can add validation logic and other behavior. Put down your procedures and data structures and grab an object. You'll be glad you did.

Saturday, October 07, 2006

What Makes Ruby Roll

Obie Fernandez reports from JAOO where he hosted the "What Makes Ruby Roll?" track. The following quotes are bitter pills to swallow though.
Kevlin Henney said...
Someone will have rewritten it by then. Yes, will succeed where Smalltalk failed because it's not bound up in the smalltalk environment (you can open up Ruby files in Notepad). Also, do not underestimate how important a 'normal' if statement is. The biggest problem with Smalltalk is Smalltalkers.

The first part of the quote is right. Smalltalk is too much change for most developers to accept. You have a new syntax to learn, a new environment to learn, and a completely different way of thinking. It's too much for a lot of developers. It's human nature. An image-less Smalltalk would have a nicer entry point since developers love their editors (you spend a lot of time there and well, when you learn one well, you don't want to leave it). The last part of the quote really hurt. I see myself as a lot of things. I see myself as rubyist, a smalltalker, a java programmer, and a bunch more. But, I can see where the arrogance of certain Smalltalkers can detract from the true message. It makes me sad. Smalltalk is a cool language to program in and I love talking about it. But, I know it has warts like anything else. I hope no one ever sees me as an arrogant Smalltalker. I want them to see me as passionate and thoughtful.

Dave Thomas said...
As long as the people who have big checks are running on the CLR and JVM Ruby will have to crossover to those platforms to succeed. Business and economics were the downfall of Smalltalk, not natural selection. The "arrogance of the smalltalk communities sealed the lid".

Another quote right on the money, but stings me in the heart. It's true. Marketing killed Smalltalk and the arrogance that their product was better. The sad fact was yes, Smalltalk was better than C++ and Java, but having a better product doesn't win. Java had a lower cost of entry (familiar syntax, could use any text editor, and a familiar work flow) and it was good enough. Maybe if Smalltalk had been marketed correctly, maybe the story would be different. And one more thing, yeah, the arrogance of some Smalltalkers didn't help our cause.

It's always interesting to see how the rest of the developer commounities see us. I feel like we get lumped in with the grumpy Lispers. We both have great languages with communities that can be intimidating. I hope that never happens with Ruby because right now their community is inviting.

Wednesday, October 04, 2006

Seaside Presentation

My Seaside presentation went well last night. I got to show off Squeak, Smalltalk, and Seaside to a bunch of folks. The code browser in the web browser always amazes along with the immediate updating of pages. I love showing how Seaside gives you not only a simpler framework, but also deals with common thorny issues like back button and multiple windows. I hope I got a lot of people excited about Smalltalk. My favorite part of the night though was the reaction I got when I shut down the image, restarted it, and was at the exact point that I left it instantly. The power of image-based development compels thee! I also got some shocked faces when I said that I NEVER shutdown my web server running in Squeak even while developing. Everything stays live. Feel the freedom NOW! Seaside and Smalltalk give such great demos. I really don't have to do much.

Sunday, October 01, 2006

Six Weird Things/Habits/Facts About Me

I found this on a blog of my friend, Derek Davis, and thought it was mad fun.
  1. I own lots of music (enough to fill an 80 gig MP3 if they made one), but I do not own a stereo. I prefer to listen to music on headphones.

  2. Territorial. I do not like anyone to be in my space when I'm not around. And I do not like it when neighbors park in front of my house.

  3. I loathe cigarette smoke even though I'm an ex-smoker.

  4. I love high fiber cereal. The higher the better.

  5. I carry Equal and a pen wherever I go. I'm freakishly prepared for anything.

  6. Encyclopedic knowledge of heavy metal that stems from being a rabid fan (I love a lot of other genres, but metal is my favorite). I can name not only the song, but the artist, album, side (remember records?), year, producer, and my first impression when I first heard it.

Seaside and Smalltalk in Omaha

I'll be giving my Seaside talk at this month's Dynamic Language User Group. I will probably spend sometime explaining why Smalltalk is so cool. Then, we'll go through continuations and why cheap closures are good. There's more to Seaside than just continuations and I will also touch on that. If you have ever been curious about Squeak, Seaside, or Smalltalk, then come on by. It's going to be explosive! It will be October 3,2006, 7pm-9pm. I hope to see everyone there!

Here's the location specifics:
Creighton University
2500 California Plaza
Omaha, NE 68178

Parking
Additional Information:
Enter the west end of the Old Gym.

Go up the elevator to the fourth floor.
You're there.
Restrooms are on the 2nd floor, unfortunately.
Vending machines are on the 1st floor, around the wall to the right of the elevator.
Anyone asks, you are attending the Omaha Dynamic Users Group meeting on the fourth floor of the Old Gym or ODUG.