About the author

Steven HarmanSteven Harman is a passionate developer who believes that writing great software isn't just a job, its a craft.

ASP.NET MVP

For recent posts and more about me, scroll to the bottom.

Subscribe

  • Subscribe to my feed. via RSS
  • Subscribe via email via email

News

devLINK Technical Conference

Jobs

Badges

  • Subtext Project
  • Support Subtext
  • HiddenNetwork.com Banner

Sharp Tools for Sharp People

Today at CodeMash I had the opportunity to sit on Joe O'Brien's What makes Rails possible, an introduction to the Ruby language session. Let me just say... despite all of the hype, I'm really starting to get excited about the power (and other cool stuff) that dynamic languages like Ruby have to offer.

Ruby Joe did a really great job of giving us noobs a quick intro to not only the Ruby language, but also to why dynamic languages are so powerful, and how useful they can be. Naturally some of the attendees started to raise questions about Ruby's lack of static type checking at compile time.

The concerns seemed to center around the idea that "compile time Type checking helps to ensure that your developers aren't doing anything to hurt themselves". Meaning that compile time Type checking helps protect a developer by letting them know immediately if they had done something wrong... because the code doesn't compile.

Predictably, the counter argument for dynamic languages is that having the code compile still doesn't mean that the code does the right thing. This is what unit tests, integration tests, etc... are for. That should sound very familiar to those of use who subscribe to the TDD methodology... Joe then made a rather surprising statement that went something like

I'm not going to lie to you... Ruby is like a loaded weapon. In the hands of the wrong person, it could be very dangerous, but in the hands of someone who knows what they're doing, it is a powerful and precise tool.

I was immediately reminded of a point that Jeremy Miller raised in his Programming Manifesto. (It's a pretty long read, but well worth it!) He makes the argument that you should use sharp tools, rather than coding with the kid gloves on. I think that an even better analogy (which Jeremy alludes to a little bit) is that of a sharp knife.

Sharp Knife A sharp knife can no doubt be dangerous in the hands of the wrong person. But in the hands of a trained and skillful chef, it becomes an efficient and indispensable tool. And don't forget, a novice cook can still cut themselves with a dull knife. Yikes!

The point is, we need to start worrying more about hiring smart people (who hopefully won't do dumb thing... too often) and less about how to protect Mort from hurting himself. We've spent far too much time indulging Mort.

Which is a nice segway into another, related, topic... walking that fine line between powerful tools and protecting developers from themselves. I'm going to have to agree with Jeremy again on this one... it all starts with the hiring process.

However, I realize that we don't live in utopia and as I mentioned on Jeremy's blog, sometimes we don't have the luxury of hiring the Rock Star developers that we all want.

So I believe that we also need to start helping Mort by teaching and mentoring him. Rather than just throw some tool at him, throw him a copy of Code Complete, The Pragmatic Programmer, Head First Design Patterns... or one of your favorites. Do it, give Mort hand. I bet you'll feel better about yourself and it might even remind you of another programmer you used to know... some guy you no longer work with.

Ha! You thought I was you going to "you".... didn't ya? OK, you're right - but I didn't want to be that cheesy.

Technorati Tags:  |

What others are saying.

# re: Sharp Tools for Sharp People
Gravatar cliff
Jan 19, 2007
I couldn't make it to CodeMash, unfortunately, but I'm glad to hear that you're enjoying it. I've got a bit of nitpicking to do about the above comment on typechecking. I would argue that the design goal of strongly-typed languages and typechecking is not necessarily to keep the developer from doing stupid things - at least not entirely. I think the more important goal is to provide a precise interface for each data type. This becomes particularly clear when considering overloaded operators. For example, if you have two variables - a and b - that hold the values "1" and 2, respectively, and you have an overloaded '+' operator (string concatenation, integer addition), what is the operation a + b supposed to do? Should it concatenate and return "12"? Or should it add the values and return 3? Is the developer an idiot if it does the wrong thing, despite the ambiguity introduced by a lack of typechecking? This is a trivial example, of course, but it illustrates the point I'm trying to make.

That said, I would probably never use Perl again if it were to become strongly-typed, and Lisp would likely be up for a "Most Useless Language Evar" award if it weren't for closures. Different tools for different jobs, I s'pose...
# re: Sharp Tools for Sharp People
Gravatar Scott
Jan 22, 2007
"Head First Design Patterns."

You mean Design Patterns for Mort? ;)
# re: Sharp Tools for Sharp People
Gravatar Steve Harman
Jan 22, 2007
@Scott: I realize that you're (probably) saying that a bit tongue-in-cheek... but I have an actual response just in case you weren't.

I know that some books like Head First Design Patterns are probably a bit heavy for Mort - but the point is to culture him. Take him under your wing and teach him. It may be a slow and painful process, but the end results worth it.

Now, I would never consider myself the teacher type - I lack the virtue of patience - but I always get a great feeling of accomplishment when I see the light go off in another developer's head once they finally grasp a concept.

At any rate, let's stop catering to Mort and start taking some responsibility for him.
# re: Sharp Tools for Sharp People
Gravatar Steve Harman
Feb 01, 2007
@Cliff: Sorry it took me so long to scrape together a reply...

To your point about overloaded operators - since you gave a contrived example, I'm going to take the easy road out and come back with a contrived reply. :)

If I took your two variables (string "1" and int 2) and applied the '+' operator in C# (which is a statically typed language) the result would be "12"... or "21" depending on the order in which the operator was applied. That happens b/c C# will implicitly call .ToString() on the int variable.

Obviously this is specific to C#, but the real lesson here is - you can't rely on type-checking to make sure you are doing the right thing.

However, you can write a unit test that will test the method that is doing the addition/concatenation to make sure it is doing what you expect. What's more, if you had been truly following the TDD methodology you would have written the test first, and then wrote the code to make it work.
# re: Sharp Tools for Sharp People
Gravatar Devender
Feb 06, 2007
I absolutely love working in Ruby, every time I am working in Java I can’t help but think how much better and beautiful the same code will be if done in Ruby.

That said being pragmatic, using test driven development and so on, these did not come to me the day I left college but through constant learning. Maybe I am a good Ruby developer today due to all the experience (paper cuts I got) working in other languages.

Should we have one language that can run in 2 modes? One in a more safe mode for new developers, so that they cannot hurt themselves and one more advanced mode so that experienced developers can remain sane ?

This is where I see the potential for Spring + JRuby , with Spring 2.0.2 you can have the interfaces defined in Java and have the implementation in Ruby.
Comments have been closed on this topic.