I’ve moved!

Posted in Uncategorized at 6:56 pm by JohnB

My blog has now moved to https://johnb.github.io/ (which actually started in November of 2010 but we’re not actually keeping score).


Small Changes in My Life

Posted in health at 12:33 pm by JohnB

The Alexander Method uses a set of simple phrases, something like a mantra, to help remind students of what they are trying to achieve (everyone studying the AM is called a “student” – even if they’ve been teaching it for years).

  • Let your neck be free
  • Let your head move forward and up
  • Let your back lengthen and widen

One might be tempted to shorten it to “free your neck; move your head forward and up; stretch your back” but that would be missing the most crucial, and hardest, part of AM – the part that says “Let your…“.  This is because you really don’t do anything in AM, you undo it – let your body return to its natural state: long, expansive and open. This sort of change is like not thinking about kangaroos – once you get the idea in your head, its really hard to not do it. So it is with your body – once you get in the habit of moving in certain ways, and of holding tension in particular places – it is very hard to change.

The Alexander teacher assists the process in two ways: first some movement therapy for about half an hour and then some massage-type therapy on a massage table. The movement therapy consists of mostly  just talking the student through a series of simple movements – with a few hands-on reminders of where the student is holding tension or habitually using their body in a less-than-optimal way. The simple movements tend to be the ones we do every day: standing up, sitting down, squatting and walking – but with more conscious intention and external feedback than we usually bring to our movements. All this mental work to rethink the core of our own movement takes its toll – it is hard work! But worth it.

I have a lesson scheduled today with my AM teacher, Amira, and expect it to be quietly intense. – like a hard workout that you don’t realize is hard until you feel it in your muscles the next day. I’m looking forward to it – no one ever said change would be easy…


Rails sites: consumer-facing vs. enterprise

Posted in ruby at 12:04 am by JohnB

At my current position and the previous one, I’ve worked on shrink-wrapped Rails application that are meant to be installed onto an enterprise-customer’s network. For want of a better name, I’ll call this an enterprise rails app. This is the dark matter of the Rails installations – we don’t know how many there are since they are only seen by the enterprise users.  But I think there are a lot of these enterprise applications and I’m beginning to see some differentiation from the customer-facing sites that we go to every day.

Release Cycle

At a consumer-facing site, you can push small updates on a daily basis. The users see a gradual evolution over time. Contrast this with the enterprise Rails site, where each version goes through months of development before any customers see it – and its a big jump when they do. Hopefully the big jump is in the right direction – an improvement – but its hard to guess right every time.

Development Cycle

The development process for the two types of sites reflects the developer’s needs. An enterprise app only needs to be perfect once or twice a year, when it is shipped out the door, whereas a consumer-focused site needs to be bug-free every single day for every single user. This leads to radically different development strategies.  For a consumer-facing site, the agile processes of making small fast changes with solid test coverage is about the only way to stay sane – lack of tests means unexpected late-night debugging while user’s stare at a fail-whale. Enterprise developers, while they may talk about TDD and agile, have no need to actually practice it since they have months to fix issues that creep in.

Death by a thousand Demos

The final area where this difference in process manifests is in how the business needs mesh (or don’t) with the development team. As a vendor to an enterprise-level company, we’re expected to periodically provide a “demo” version of the site to display at trade shows. This demo-ware needs to look like the final product and work, at a cursory level, like the final product – but it doesn’t need to actually work in a full and complete way. Smoke and mirrors is the name of the game when creating demos.

A consumer-facing site has no demos. What you see is what you get. It either works or it doesn’t – you can’t hide your failures from the user.

Developer Practices

Given the disparity in business requirements, its no wonder there is a huge difference in developer practices. When end-users are always using your site you have little choice but to use best-practices: test everything, keep all the tests passing, leave little development debt. When the end-users won’t see it for many months its easy to get lazy (I’ve done it): let the development debt pile up, rely on QA testing since you didn’t take the time to write automated tests, hope QA will catch all the bugs – but pay the price in rework and bug fixing long after you thought you were long done with with writing that code.

I’m curious to see whether this dichotomy will ever change. Maybe it already has somewhere. As one of my favorite authors says: “The future is already here, its just not evenly distributed”.



Posted in ruby at 11:55 am by JohnB

Update: Ignore all the great ideas below. @defunkt pointed me to jaml, which does a big chunk of what I was interested in.

I’ve followed the work of @hcatlin, @defunkt and @justinbmeyer on templating languages (haml, mustache and javascriptMVC) and have looked for something that met my needs. Here is an idea that seems simpler than javascriptMVC but has more power than haml or mustache – hopefully the sweet spot I’ve been looking for.

The initial idea, inspired by haml but not needing a text parser, was to represent markup as JSON:

Which would generate:

However, this provides no support for interaction with the markup. When considering generating a set of dialogs for user interaction I really wanted field validation built in, like this:

Eventually I realized that wrapping all the functionality as a filter, in essence creating a tiny scrap of functionality, was what I was looking for:

I could see wrapping a form scrap in a larger dialog-handling scrap that knew enough to validate its internal scraps before allowing the OK button to save the data. It should work – I just wish it could be as pretty as the others – but I don’t see that as possible, given the semantics of JSON.

The true test will be when I actually implement the code to support such a construct. Look for a johnb/scrappy project on Github. Until then, I’ll just assume it works! ;-)


RubyConf 2009

Posted in ruby at 11:05 am by JohnB

I was recently given the opportunity of attending Ruby Conf 2009. It was a lot of fun being with a few hundred of my Rubyist peers. You can now see for yourself via the recently-uploaded session videos or the RubyConf-in-22 minutes video. Or read other RubyConf wrap-ups. Due to the sheer amount of information, my personal wrap-up here is in the boring at-this-time-I-saw-this format. I’ll try to have links to each talk, but they aren’t all available at the time of writing this – I’ll try to update the list later.

Wednesday night I received my ticket via email from a nice guy in New York who couldn’t go at the last minute. Lucky for me!

Thursday 9am the conference started with a keynote from “Matz” (Yukihiro Matsumoto) the creator of Ruby. It was not the most interesting talk I’d heard, but everyone listened politely. Immediately after Matz’s talk I picked up my free Poken device to track the people I met. The Poken was kinda fun at the conference but not very useful unless you’re near a lot of new people who also have them. But at the conference it was kinda fun to touch someone’s Poken to capture a digital business card.

Thursday 10am I attended the BERT and ERNIE talk from one of the GitHub guys, which was fairly close to what I’d already read of the new GitHub server infrastructure. Its amazing what you can do with smart people and enough servers to effectively distribute your workload.

Thursday 11am to 4pm I listened to talks on Bits and Bytes, DSLs and Flying Robots – the quality of these talks was inconsistent and there was not much material I wasn’t already aware of, but I met some interesting people at each session.

At 4pm Thursday was a talk on MongoDB that cleared up some misconceptions I had. This dovetailed nicely with the Friday 9am “Not Only SQL” talk about other non-SQL database options. Unfortunately, I don’t see any obvious winner over my current use of PostgreSQL – there probably is a better one for our particular needs but the cost, in time, of trying the various options seems prohibitive.

Thursday 5pm was my last session of the day, with a presentation on Experiment Driven Development. The basic idea is that rather than relying on your best guess, or your Marketing guy’s best guess about a new feature, you just test both new ideas on actual users before committing to a definite plan of action. He hasn’t put up any slides for his talk (he has a 1 month old baby at home) so you’ll have to rely on my judgement that it was interesting. For me, it means that I’ll be looking for opportunities to capture metrics to measure user response to system changes. I expect the rest of the ConFreaks’ videos will be online in the next week or two.

Rather than stay for the 8pm Lightning Talks I went with my friend Dan and his friends to a yummy tapas restaurant in the Mission.

Friday I learned more than I wanted to know about ongoing improvements to the RubyGems system, partial evaluation of Ruby (pseudo JIT compilation) and an alpha-level persistence layer called Aqua.

At lunch on Friday (and again on Saturday), I watched a fun programming competition to see which team could refactor a chunk of code better and faster. It was all very subjective, but gave a real-world view into how pair programming actually works and other people’s ideas on what makes for a consistent test-driven process.

Friday 2pm was a talk on the latest in MacRuby, a very promising Ruby VM running on top of Objective-C using native objects and garbage collection. It looks promising but I won’t play with it until the 0.5 release is officially out (any day now).

Friday 3pm was Jim Weirich’s talk on SOLID Ruby that expanded on some ideas about Object Oriented Programming that were originally described by “Uncle Bob”. He is a good speaker who really knows his topic so my high expectations were happily met.

Friday 4pm was a fun talk by the always-interesting creator of GitHub, Chris Wanstrath, on what Rubyists can learn from Python.

Friday evening I attended the Startup Crawl, eating tasty food, drinking beer and meeting a few people. Scribd had the best food; Heroku had the best ambiance (and one of their guys solved a technical problem I had on one of my personal sites – nice bonus – instead of telling me to RTFM).

Saturday I woke a bit late but made it in time for the Clojure talk – it seems like a good language for concurrency, but not nearly as easy to write as Ruby. Tim Bray has a nice ongoing series of blog posts on various languages that focus on concurrency. He recently delved into Clojure and it looks somewhat promising (but there is no free lunch).

Saturday 11am I attended an interesting talk on scaling called  Synchronous Reads, Asynchronous Writes. Paul Dix went on at length on the various strategies his site has used to improve performance by off-loading work to services that allow eventual data consistency. It looks like a fairly standard infrastructure once you get to a large number of servers but it was good to hear the nitty gritty details discussed.

My last session was Gregg Pollack’s discussion of  a number of performance-related gems and plugins. It was essentially what he covers in his screencasts, but since I hadn’t seen them it was well worth hearing it in person. I’ve now subscribed to his Ruby5 podcast which I might finally listen to on the train.

All in all, it was a very good conference. I met, in person, a lot of interesting people that I’d been following in various ways (twitter, blogs, RSS feeds, etc.) and I’d love to go again next year – but I’ll try to get a ticket when they go on sale instead of the night before!


On Second Thought – The Avatar Will Stay

Posted in Uncategorized, musings at 10:04 pm by JohnB

I’ve now reconsidered my earlier plan to get rid of my avatar. Why? I’m so glad you asked. Three reasons:

I’m now identified with the avatar. I recently contacted a guy that I hadn’t corresponded with in a while and he said “Oh yeah – I remember you. The guy with the big rock man thing”. So if I get rid of the avatar, I might lose some of the people that would otherwise “recognize” me online.

The Games will blow over but the avatar is still, in my opinion, pretty darn cool. Ya don’t see huge multi-ton monoliths every day.

Time and inertia. I have very little “spare” time in my life and my plan for changing the avatar would likely have taken some time to get right (a series of ~10 images shifting from the rock man to my own smiling face). This is time that would take away from whatever projects I’d otherwise be working on.

So, I hope you like it – you’ll keep seeing it on twitter and other places.


The Avatar Must Die

Posted in Uncategorized, musings at 1:24 am by JohnB

A few years back, we took a trip from the Bay Area all the way to British Colombia. Near the apex of our journey we saw the most incredible sights. Orca whales, swimming at and under our boat. Brown-colored Black bears (yes, the distinction matters) by the side of the road. And on a mountain near Whistler – the place where I really learned to ski many years ago (such as a boy from San Diego can actually learn to ski) – we saw a huge totem called an Anukshuk. Built of huge Stonehenge-style rocks, it was perched  far up the mountain. I liked it so much that I started using it as my avatar on a number of sites.

Avatar used on twitter, chess.com and others

Yes, I know that it is one of the mascots of the 2010 Olympic games. I thought it would be so cool to make use it, long before the rest of the world associated it with anything other than me. But now, as the date (February 2010) approaches, I wonder when – or if – I should replace it. I’d like it to be a gradual process – but that is not usually the way these things work. You replace one image with another. Whoosh. Done.

And so I ponder. But as I ponder, the Games come closer. And with the date getting closer, it impacts The Locals more and more. To house and feed and transport that abrupt influx of humanity that is The Games, there must be changes. A streamlining of transport. A building of hotel rooms. A “regooding” of the now-deemed-blighted sections of the city. A streamlining of the food establishments, to cater to the oh-hey-theres-a-Starbucks-right-there crowd. Consistency is chosen, time and again, over flavorful melange.

But these Locals speak our language – by gosh they’re almost ‘mericans! Some, like the quirky observer William Gibson, use a delicate turn of phrase to create new words for the process that is unfolding. Others, like Tim Bray of the Urban Geek persuasion (no, I don’t know what that phrase means either) point us toward articles detailing the decline of the locals under an onslaught of progress and, later, of the fights and Pyrrhic victories. How soon until we see articles about the replacement of family owned businesses with multinational conglomerates? And do I want to be associated with all that through my avatar?

Stay tuned!



Posted in ruby at 12:25 pm by JohnB

Intending to direct a new Ruby-ist to rubyquiz.com, I hastily misread the Counting Toothpicks quiz as the reverse of what was intended.  So here is my quick code to solve the wrong problem: converting a string of toothpicks to its underlying equation and giving the answer. I was quite happy with my short solution until realizing that I had solved a much simpler problem. In any case, here it is:

# toothpicks.rb
def toothpicks str
  puts str
  str.gsub!(' ','')
  raise 'Wrong format' unless str =~ /^(x|\||\+|-)*$/
  count = str.length
  count += str.scan(/(x|\+)/).length
  str.length.downto(1) do |n|
    str.gsub!( '|'* n, n.to_s )
  puts str
  result = eval(str)
  puts "#{result} from #{count} toothpicks"

if ARGV[0]
  toothpicks ARGV[0].dup
  toothpicks '||| x || + ||||| - |||||||'

Running with no arguments tests the example equation:

||| x || + ||||| - |||||||
4 from 22 toothpicks

Note: syntax highlighting provided by this nice page.


Last of a Generation

Posted in Uncategorized at 10:02 pm by JohnB

My aunt Barbara passed away yesterday. We were never close, but she was the last of her siblings to pass on, even though she was the oldest. I know that was hard on her. Now its finally her turn. May she find rest.

She played a pivotal role in my life, long before I was even conceived. After her mother, my grandmother, had passed away, Barb took it upon herself to put my mother through college. I doubt she ever understood this nuclear engineering thing my mother studied, but she supported it. And eventually my mother met another engineer and here I am today.

It wasn’t unexpected – she had been declining for a while – but I’m surprised at how choked up I am about her passing. Outspoken, disapproving, warm and alive – often in the same sentence.

I remember a message she once left on our answering machine. Her voice sounded so similar to my dead mother’s voice, with the same Pennsylvania accent, that it sent chills up my spine.

Thanks Barb, for all you’ve done and all you were – you’ll be missed – and in the end, what more is there, than to be missed?


Self-Modifying Code? Or Self-Creating Code?

Posted in ruby at 12:49 pm by JohnB

[aside: Why write an email that will be read by just one or two people when you can instead write a blog post that will be seen by... uh... one or two people?]

I was recently discussing the problem of tracing program execution through code that doesn’t exist.  Sometimes, usually to understand and debug a program, you need to trace through it. If the code doesn’t exist, its hard to follow where it goes. Actually, the code exists, its just not in source control or otherwise easily searchable.  Let me explain.

In Ruby, whose source code is a lot like its executable format, its trivial to write code that writes code – so you, the programmer, don’t have to. The Rails web framework uses this a lot, for creating whatever form of ‘find’ strikes your fancy: find_by_firstname, find_by_firstname_and_gender, find_by_pet_species_and_viciousness, etc. – as long as your database table has the appropriately named columns then it will find what you’re looking for with no work on your part!  Actually, some work is required – you need to know that most any routine starting with ‘find’ is probably auto-generated by Rails and thus will be un-findable in the source tree.

A more complex example is the routing helpers – a shorthand way of saying “put a link here on this web page that will take the user to that web page over there.  Until you realize that most any method ending in ‘path’ is a URL helper then you’ll be confused by code that references user_edit_path or formatted_pet_list_path or formatted_pet_species_list_path.  The last one says that you want to get the path to a specially-formatted list of the various pet species represented by the system (e.g. “http://myPetSite.com/pet_species/list.csv”). Fairly clear once you know what it does, but fairly obtuse until you get to that point.  And it is, trust me on this, shorter, more maintainable and more clear than the alternative (after, of course, you learn to read it).

So this difficulty in finding the source to “formatted_pet_species_list_path” (or something like that) started a discussion that eventually got around to the idea that Ruby and Rails uses code to write code.

“Its the 11th commandment”, said one, ” – thou shalt not write self-modifying code!”

Yes and no. Call me irrationally exuberant or say that I drank some sugary flavored colored water – but I don’t think its as cut-and-dried as it used to be.  This commandment, when Moses brought it down from on high, was written for a compiled language, where the source was very very different from the executing code, and it actually did modify the code being executed.  This is bad bad bad – its hard to understand, it leads to intractable bugs, it’ll make you go blind, melt glaciers and other bad stuff.  No argument there.

But is this what Rails is doing with Ruby? I’d say its different.  Instead of modifying existing code it is merely creating code that did not exist before. Its more akin to a pre-processor that could, just before compiling a program, generate all the permutations of finding database rows from columns X, Y and Z (and any number of others).  Looked at this way, it appears to be similar to a C++ template – generic code that a programmer has written to simplify the writing of code that does similar things in similar ways.  The main difference is that with Ruby there is no pre-processor – the routine gets created at the time it is first used.

The “template” in this case is a routine called method_missing that gets handed the name and arguments of any routine that doesn’t exist.  It looks for a function name matching the form ‘find_by_X‘ where X makes sense for the database table in question (of course, if it doesn’t match the correct format then it just passes the name and arguments onward for some other routine to either make sense of or to burp up an error).  Once the routine is created it is available to be called again, with none of the overhead incurred when it was first created. More importantly, it was created with no additional overhead on the part of the programmer – to write it, test it, debug it or modify it. This, in my opinion, is a huge advantage – but I’m a lazy developer who doesn’t want to write or debug any code that I don’t have to.

Kool-aid anyone?

« Previous entries Next Page » Next Page »