Category ArchiveSoftware



Humor &Philosophy &Software 16 Nov 2007 01:06 pm

Rands In Repose: The Nerd Handbook

Rands In Repose: The Nerd Handbook is funny, though not completely accurate. Still, it’s funny and this bit is scary funny:

“Your nerd has built an annoyingly efficient relevancy engine in his head. It’s the end of the day and you and your nerd are hanging out on the couch. The TV is off. There isn’t a computer anywhere nearby and you’re giving your nerd the daily debrief. “Spent an hour at the post office trying to ship that package to your mom, and then I went down to that bistro — you know — the one next the flower shop, and it’s closed. Can you believe that?”

And your nerd says, “Cool”.

Cool? What’s cool? The business closing? The package? How is any of it cool? None of it’s cool. Actually, all of it might be cool, but your nerd doesn’t believe any of what you’re saying is relevant. This is what he heard, “Spent an hour at the post office blah blah blah…”

You can be rightfully pissed off by this behavior — it’s simply rude — but seriously, I’m trying to help here. Your nerd’s insatiable quest for information and The High has tweaked his brain in an interesting way. For any given piece of incoming information, your nerd is making a lightning fast assessment: relevant or not relevant? Relevance means that the incoming information fits into the system of things your nerd currently cares about. Expect active involvement from your nerd when you trip the relevance flag. If you trip the irrelevance flag, look for verbal punctuation announcing his judgment of irrelevance. It’s the word your nerd says when he’s not listening and it’s always the same. My word is “Cool”, and when you hear “Cool”, I’m not listening.”

And the real question: “what is your trip word?”

(Via Ranchero.)

Language &Philosophy &Programming Languages &Software 12 Nov 2007 11:35 am

Document the Difficult Stuff, not the Easy: Rails Tutorials

I found Rails Tutorials pretty handy. They are short and sweet focusing on only one particularly problem per tutorial. I also found some good discussion in the comments of each tutorial. With their help, I finally got my head around how to deal with creating complex relationships of objects and dependent objects so that they are put in the database atomically, and so that they are available for error correction on the form if there were validation errors.

A big part of the problem I was having is that there are a million tutorials on the simple stuff in Rails and ActiveRecord, but very few on doing real work. There are many features of the Rails framework that I have just happened across accidentally, or that I had to scour the net and books looking for examples.

The one particular bug, err… feature, that has been haunting me is how to create an object that has a complex join model, and have all the other objects in that model get created automatically.

It is obvious enough for me to do it by hand. For example, creating a Registration for multiple People for multiple Courses, with other related information like Payment choices and related details to the Registration. When I get back a form, I could pick out each parameter set in my form fields. I could then create each object, Registration, People objects, Payment details, etc.. and then set them on the Registration object.

@registration = Registration.new(params[:registration])
new_payment = Payment.new(params[:payment])
@registration.payment = new_payment;
@registration.people = params[:people].collect { |[], person| Person.new(person) }
@registration.save

But rails should be able to do all this automatically since I already specified the relationships in the model objects. Well, turns out it can. You can use the build method on the model objects.

params[:people].each {|person| @registration.people.build(person) }

However, this doesn’t work for has_one or belongs_to objects, for those you have to call

@registration.build_payment(params[:payment])

Notice that this seems to be some sort of method_missing magic. I haven’t hunted down where this gets handled, but more troubling to me is that I never knew it even existed. I am glad I found it of course, but it is the first time in Ruby I have had the feeling that dynamic features could be bad.

I know the horror stories of dynamic languages and the claims for static typing and so on, but by and large I have not had this problem with Ruby, and I have probably written about 15-20kloc of Ruby now. Not a great amount, but not a trivial amount either given the expressiveness of the language.

Maybe I should have learned Rails by looking at the test suites. Perhaps within that code I would’ve found examples of build_x and that would have clued me in. I don’t know if those tests exist, but still I think that tutorials can be more efficient communication than test suites.

Of course that depends on what tutorials get written. My Request:

When writing tutorials for programmers, just write the tutorials for the hard stuff.

This should be the priority. Assume that programmers can figure out the obvious stuff, and spend your time on explaining the hard, hidden parts of the framework.

Programming Languages &Software 12 Nov 2007 10:29 am

LLVM Tutorials

LLVM Tutorials shows how to build your own language targeting the LLVM. The LLVM is a cross-platform low-level virtual machine that already comes with tools for bytecode analysis and optimization.

I’ll be curious to see how flexible it is for creating dynamic languages in comparison to the JVM.

Programming Languages &Software 16 Oct 2007 05:04 pm

More New Rails Screencasts from RailsCasts.com

Reference for myself mostly.

More New Rails Screencasts from RailsCasts.com: “Ryan Bates is being a total champ in rolling out more and more consistently good Rails related screencasts for free at RailsCasts.com. Some of the latest include:”

(Via Ruby Inside.)

Humor &Software 12 Oct 2007 11:50 pm

StupidFilter

The StupidFilter project has high goals.

“The solution we’re creating is simple: an open-source filter software that can detect rampant stupidity in written English. This will be accomplished with weighted Bayesian analysis and some rules-based processing, similar to spam detection engines. The primary challenge inherent in our task is that stupidity is not a binary distinction, but rather a matter of degree. To this end, we’re collecting a ranked corpus of stupid text, gleaned from user comments on public websites and ranked on a five-point scale.”

(Via Anarchaia.)

Humor &Software 10 Oct 2007 12:39 pm

Exploits of a Mom

Her daughter is named Help I'm trapped in a driver's license factory.

(Via xkcd.com.)

Miscellaneous &Software 09 Oct 2007 12:02 pm

Cool Tool: Goog(le) 411

Cool Tools mentioned Goog(le) 411 today. It’s a free phone information service that also connects you to the number. It also doesn’t have the obnoxious 20 second ad up front like the other free 411 services.

Sweet!

Art &Math &Science &Software 07 Oct 2007 03:34 pm

Turing Machine in Conway’s Life

Vadim Bultiko site has a cool paper by Paul Rendell on creating a Turing Machine in Life. I didn’t get to read it all in detail yet, but this looks pretty clever.

There is a lot more, including the data and patterns, on Paul Rendell’s site.

Programming Languages &Science &Software 06 Oct 2007 05:29 pm

Mark Guzdial’s Amazon Blog: Software Engineering and the Cause of the CS Enrollment Crisis, Part 2 Permalink

Mark Guzdial’s Amazon Blog: Software Engineering and the Cause of the CS Enrollment Crisis, Part 2:

The fact that we still primarily use an edit-compile-link-execute cycle 50 years after the first commercial release of Fortran is an indication of how little programming language designers and software engineers talk to HCI designers and cognitive scientists. That’s not how people best work, so why are we still doing it that way?

Miscellaneous &Software 10 Apr 2007 12:20 pm

Moon Lander using the CANVAS tag

What was old is new again 🙂

Moon Lander using the CANVAS tag

« Previous PageNext Page »