raganwald
Sunday, November 27, 2005
  Torcamp
I went to TorCamp yesterday. Wow. First off, a message to David Crow: thanks!

It was good to hang out with people who are actually doing things. Everyone I met was running their business, advocating change in their organization, or contributing code to open source. Or whatever. The point is, everyone was in gear and moving.

(Tip: if you ever go to a networking/user group where everyone talks about such and such but they don't actually use it in their own projects or at their own workplace, you're among tourists, not users.)

I'd post a run-down of the event, but Kate did a fantastic job. Click on over there. She's awesome.

Image taken by Rob Hyndman; more of his images; more TorCamp images.
Some rights reserved.


I gave a presentation on "Web 2.0 beyond ajax." I posted the presentation here. I tried a very different style of presentation, and I give myself mixed reviews. At best.

Sutha Kamal had the best suggestion for improving the presentation: use Peter Norvig's example of statistical translation rather than search to stress the reason that a broad corpus is better than deep ontology for most "intelligent" applications.

(The most interesting flaw is the screen capture of del.icio.us I took on Friday night. For some reason I didn't get the "recommended tags" feature and I pointed this out. People in the audience were all mystified and quite sure that you should get popular tags at the bottom of the page. That's true, but you should get "recommended tags" just below the save button, and I didn't get either. I'm quite mystified as to where they were when I took the screen shot.)

Labels:

 

Wednesday, November 23, 2005
  Off Topic: RaganAdvertising
Disclaimer: I hate blogging about blogging. It's not bad enough that I'm blogging when I could be coding or talking to smart people, or thinking about how I should be coding, or planning what I'd like to learn from smart people, but I'm not even blogging about any of those things. Posts about blogging are the Ouroboros of blogging. They eat themselves.

Google's Adsense has shown its money grubbing, monetizing page views face on Raganwald. It's mostly about trying something new, especially since I haven't even cashed the cheque Google sent me from my last experiment where I placed some ads on my old personal home pages.

Ads will be shown if you navigate to a permalink page directly from a search engine. You should not see ads if you hit the Raganwald home page, or click through from an RSS feed, or bookmark a page, or follow a link from your feed reader (perhaps there will be ads if you follow a link from Google's feed reader. If so, send me an email and I'll play with the script.).

The ads are only shown once: if you click a link to read another post within Raganwald you won't see any more ads.

The intent is that people who find Raganwald through searches like "difference between marketing and selling" are actively looking for information and might be interested in what an ad has to offer.

I sincerely hope this is a positive service for the many anonymous visitors that seem to land on a page and then go about their merry way. Meanwhile, regular readers and subscribers shouldn't be bothered by the ads.

Thanks to my simplistic approach, you'll see an ad if you use Google as a memory amplifier. So if you google "raganwald prima donna" to find that recent article instead of bookmarking it or using del.icio.us, you'll see an ad.

If this bothers you, there are easy hacks to remove the ads, like ad blockers that can block JavaScripts. I use Adblock with Firefox and I never see Adsense ads. You could also do the really low tech thing and click on the Raganwald headline then drill back down to the post you were reading. The ads will not appear.
 

Monday, November 14, 2005
  Repost: Closures in Ruby

(I wrote the original version of this page in 2002. I've made a few minor edits and added a comparison with Java's anonymous inner classes)

I briefly worked with a team that used Perl to implement high availability web applications. When discussing the language with the team’s technical lead, I pointed out that I was impressed with the fact that Perl implemented closures. Having written a Scheme interpreter, I considered closures a fundamental component of modelling procedures.

This led to a discussion of what was a closure, and what was it good for?

A closure encapsulates the execution of a one or more operations for side effects and/or the return of a value in the environment of the function’s definition where the closure was created.
From this definition, all functions, procedures, and methods in languages such as Java and Visual Basic are closures. When a programmer refers to a language as implementing closures, (s)he is really saying that the language permits the creation of arbitrary closures at run time. Scheme aficionados would say that languages like Perl, Lisp, and Ruby support first class closures: closures can be arbitrarily created and assigned as values to variables or returned from functions.

Since contemporary programming languages are lexically scoped, the environment of the function refers to the variables in scope at the time the function is defined. This includes temporary variables, variables that are normally created on some sort of stack and discarded when they “go out of scope.” When a closure is created, variables in scope must be preserved until the closure itself ceases to exist.

Here’s a Ruby closure demonstrating the fact that it ‘captures’ a variable in the scope of its definition:

def makeCounter
var = 0
lambda do
var +=1
end
end

c1 = makeCounter
c1.call
c1.call
c1.call

c2 = makeCounter

puts "c1 = #{c1.call}, c2 = #{c2.call}"

The two important things from this example are:

  1. Although var is no longer in scope once makeCounter returns, Ruby saves it for use in the closure.

  2. Each invocation of makeCounter creates a different var. The two counters do not interfere with each other.

What can you do with closures? Here’s something a bit more useful, a call-by-need thunk factory:

def delay(&procToDelay)
value = nil
return lambda do
if value.nil?
value = procToDelay.call()
else
value
end
end
end

def force(thunk)
thunk.call()
end

foo = delay do
puts "thinking about foo"
"fu"
end

bar = delay do
puts "thinking about bar"
"british american racing"
end

puts force foo
puts force bar
puts force foo
puts force bar

In this example, you have a simple facility for memoizing closures: they can be called repeatedly, but they only evaluate their operations once (provided the retun value is not nil). Obviously, this should not be combined with the previous example: call-by-need thunks are useful when there are no side effects of their evaluation.

Why Java's Anonymous Inner Classes do not implement closures

At first glance, an anonymous inner class in Java looks like it captures an environment. It has access to its enclosing instance's members. That looks an awful lot like the way a closure captures its environment.

But an anonymous inner class cannot access method variables or parameters. This is a crippling limitation. Consider:

interface Transformer {
int transform (int what);
}

class TransformerConstructionKit {

public static Transformer makeMultiplier (int timesWhat) {
return new Transformer () {
public int transform (int what) {
return what * timesWhat;
}
};
}

}

This is illegal in Java for some reason. Ok, I know what the reason is. But I don't have to like it, do I?

Labels: ,

 

Sunday, November 13, 2005
  A few of my favourite things...
A few of my favourite things...
A few books I like to keep handy. Click the thumbnail for a bigger photo along with some notes.
 

Friday, November 11, 2005
  I remember
There's nothing I can write that could possibly capture how incredibly lucky I am to be able to live, love, and follow my dreams in the New World.

A generation of our youth poured over the trenches and into the gas in WWI, and then went back to fight and die and ultimately prevail in WWII so that you and I could live in a world where people of diverse colours, sexual orientations, religions, and political viewpoints could live without fear of extermination and genocide.

Thank you.
 

Thursday, November 10, 2005
  A quick word about prima donna hackers
Is every prima donna really one hundred times as productive as the middle of the Gaussian distribution who have a degree? Maybe, maybe not. But this post is about those prima donnas who really are from another planet, and the people who hire and manage them.
This is not a team. It's not a boat, not a machine that has a lot of parts of it that have to work together. The metaphors are all crap. This is a business - that's all it is.
Vogler in "House," Season One Episode Fifteen, "Mob Rules"
Read the sports section of the newspaper. Or do a Google News search for Terrell Owens. He's a superstar, one of the truly gifted who can change a football team dramatically. He's also incredibly high maintenance. And he's just been fired.

The bottom line? His team is losing. Here's the way it really works. Let's make things simple and say that Terrell is worth four wins to the team. If the team can make the playoffs without him, four extra wins makes the difference between making the playoffs and making it to the Superbowl.

When a team is losing, the same four wins are only the difference between just missing the playoffs and being out of it a month before the season ends. Although the difference in number of games won might be the same, the "utility" is far lower.

Now consider the cost. When the team is doing well, most of the players, fans, and management are basically happy. The distraction of a loose cannon is just that. A distraction. But when the team is losing and everyone is unhappy, a loose cannon is more like a bouncing hand grenade. Everyone is sore.

And even if a coach or manager is detached enough not to take a difference of opinion conveyed through the media personally, it's hard to turn a team's culture around and make changes when your authority is so visibly undermined. Basically, a prima donna provides less value to a losing team and costs more.

And yes, I'm going to say that the same thing applies to software development. If you're rocking and rolling in a growth environment where you're shooting the lights out, prima donnas provide value. They can make the difference between "just shipping" and hitting a liquidity event. They provide more value and cost less.

But if things aren't going well... a prima donna is going to be a distraction at a time when others have very little tolerance for a contrarian viewpoint.

And that's why you often see prima donnas flourishing in start ups but exiting when the company goes enterprise and development is no longer the value add.

Labels: ,

 

Reg Braithwaite


Recent Writing
Homoiconic

Share
rewrite_rails / andand / unfold.rb / string_to_proc.rb / dsl_and_let.rb / comprehension.rb / lazy_lists.rb

Beauty
IS-STRICTLY-EQUIVALENT-TO-A / Spaghetti-Western Coding / Golf is a good program spoiled / Programming conventions as signals / Not all functions should be object methods

The Not So Big Software Design / Writing programs for people to read / Why Why Functional Programming Matters Matters / But Y would I want to do a thing like this?

Work
The single most important thing you must do to improve your programming career / The Naïve Approach to Hiring People / No Disrespect / Take control of your interview / Three tips for getting a job through a recruiter / My favourite interview question

Buy Raganwald a Coffee
If you enjoy reading my weblog, please consider buying me a Darkhorse Double Espresso, for just $3.15 Thank you!

Management
Exception Handling in Software Development / What if powerful languages and idioms only work for small teams? / Bricks / Which theory fits the evidence? / Still failing, still learning / What I’ve learned from failure

Notation
The unary ampersand in Ruby / (1..100).inject(&:+) / The challenge of teaching yourself a programming language / The significance of the meta-circular interpreter / Block-Structured Javascript / Haskell, Ruby and Infinity / Closures and Higher-Order Functions

Opinion
Why Apple is more expensive than Amazon / Why we are the biggest obstacles to our own growth / Is software the documentation of business process mistakes? / We have lost control of the apparatus / What I’ve Learned From Sales I, II, III

Whimsey
The Narcissism of Small Code Differences / Billy Martin’s Technique for Managing his Manager / Three stories about The Tao / Programming Language Stories / Why You Need a Degree to Work For BigCo

History
06/04 / 07/04 / 08/04 / 09/04 / 10/04 / 11/04 / 12/04 / 01/05 / 02/05 / 03/05 / 04/05 / 06/05 / 07/05 / 08/05 / 09/05 / 10/05 / 11/05 / 01/06 / 02/06 / 03/06 / 04/06 / 05/06 / 06/06 / 07/06 / 08/06 / 09/06 / 10/06 / 11/06 / 12/06 / 01/07 / 02/07 / 03/07 / 04/07 / 05/07 / 06/07 / 07/07 / 08/07 / 09/07 / 10/07 / 11/07 / 12/07 / 01/08 / 02/08 / 03/08 / 04/08 / 05/08 / 06/08 / 07/08 /