Refinements in Ruby are going to be a BFD, but may drag 1.9 adoption out even longer
Magnus Holm has a SWEET rundown of refinements over at his blog. The original patch and commentary can be seen here.
Something about this smells like a pretty big fucking deal. This is going to drive a lot of innovation; people are going to be able to do a lot of really sweet things w/ refinements. No longer will horrible monkey patches be banished to the bowels of our applications. No longer will stack traces blame ThinkingSphinx when you incorrectly use a formtastic form helper. Monkey patches will soon be come easily testable first class citizens, and their undesired side effects will be greatly diminished.
As with any new functionality, it will create a portability issue. Once this drops into 1.9.3, anything using it won’t be backward compatible, and the incompatibility won’t be the kind of thing that will be fixable w/ a gem. But this isn’t that big of a deal; every new release of Ruby has things like this.
A bigger problem that refinements will introduce into Ruby is the further slowdown of Ruby 1.9 adoption. Ruby 1.9 adoption has not come on as fast as some would like, and I see refinements dragging that on even further. If you’re in a resource constrained environment, you may only get to change your Ruby version once or twice a year. Why would you upgrade from 1.8.6 to 1.9.2 when refinements are going to drastically change the Ruby landscape in 1.9.3?
I’m pretty excited for refinements, but I’m torn on when to pull the trigger on upgrading production apps away from from 1.8.x, and refinements just made that decision even more difficult.
Thoughts?
How can we accelerate a Ruby developer’s development?
My slides from Mongo Boston
“Open Source Software” isn’t about source code
While thinking about the slides for my upcoming talk at Mongo Boston, I had an interesting thought. It’s nothing earth shattering, but I wanted to write it down and see where it took me.
Lets take a look at the open source ecosystem surrounding MongoDB, and for this example we’ll focus on the Ruby space and some of the stuff I’ve played with at Punchbowl. You have MongoDB itself, which is written in C++. There’s MongoMapper, an ORM. There’s Rack-GridFS, a Rack middleware for directly accessing files stored in GridFS. There’s OpenIDAuthentication, a library for doing OpenID auth in MongoDB. There’s Roachclip, a plugin I wrote for MongoMapper which combines the fun of Thoughtbot’s Paperclip image processing with the ability to store all the assets in GridFS through Joint. There are literally hundreds of open source software projects out there that anyone can pick up and use in a hobby or in a business.
Some of this software has documentation. Some doesn’t. It’s all open source, though. So you can download it, crack it open in a text editor, and just go figure it out. See a problem or notice a lack in functionality? Most of this software is using version control (hi Github); just fork and fix it. What used to be:
http://github.com/original_author/sweet_repo
now becomes:
http://github.com/you/sweet_repo
Maybe your contributions will get pulled into the mainline, maybe your version will remain a fork and start to get used by others, or maybe nobody else will ever use it but you.
Such is the life of open source source code. In my opinion, it’s pretty damn cool. But this coolness is NOTHING compared to what open source is really about.
What I’ve started to realize over the past year is that “Open Source Software” isn’t about the last part of the Github URI: the repository name. Open Source Software is really about the second to last part: The Author.
Open Source Software is about the people. MongoDB isn’t just a C++ repository; it’s Kristina, Mike, Kyle, Dwight & Elliot (among others). MongoMapper, OpenIDAuthentication, Rack-GridFS, Roachclip & Paperclip aren’t just Ruby libraries; they are John Nunemaker, Brandon Keepers, Blake Carlson, yours truly & Jon Yurek (again, among others).
There is obviously value in the code: it does stuff. The code can also teach you stuff. The code can show you how to properly build shareable, modular and properly tested pieces of software. The code can teach you the black arts of meta-programming and the Ruby object model.
But I assure you that no matter how much awesomeness is in the code, there is at least 7 times more awesomeness in the brains of the people who built it. Those people who first had a need for it. The people who struggled through the bugs. The people who had a dozen false starts that might not get reflected by the current HEAD. That experience is PRICELESS. And it’s all available if you just ask.
So, ask. Say hi.
Every single one of those people, and countless more, are “Open Source”. You can get at them on mailing lists, IRC, and Github Issues. You can email them directly or tweet at them. Most of the time, they’ll answer (and don’t get pissed if they don’t answer — sometimes people get busy).
So if you are using Open Source Software just for the source code, you’re missing out. Use these people. Ask questions. Get a conversation going. That’s the real meaning of Open Source Software.
Check out my jockstrap
I’ve been working on a lot of gems lately. Got sick of writing the same stuff over, so I put it all in a repo up on github called Jockstrap (http://github.com/ryana/jockstrap). Use it if you want. Let me know if you got other useful stuff to throw in.
PS. Decided against the obvious opening image (NSFW) on this one. So instead you get a picture I took at a bar with my brand new iPhone4 this weekend. It’s incredible, by the way… too bad Tumblr keeps showing it upside down when I upload.

100.months.from_now.to_i works. 1000.months.from_now.to_i raises NoMethodError
Sigh….
ree-1.8.6-20090610 > 100.months.from_now
=> Wed, 17 Oct 2018 15:49:32 UTC +00:00
ree-1.8.6-20090610 > 1000.months.from_now
=> Sat, 17 Oct 2093 15:49:35 UTC +00:00
ree-1.8.6-20090610 > 100.months.from_now.class
=> ActiveSupport::TimeWithZone
ree-1.8.6-20090610 > 1000.months.from_now.class
=> ActiveSupport::TimeWithZone
ree-1.8.6-20090610 > 100.months.from_now.to_i
=> 1539791387
ree-1.8.6-20090610 > 1000.months.from_now.to_i
NoMethodError: undefined method `to_i' for Sat, 17 Oct 2093 15:49:51 +0000:DateTime
from /Users/ryan/punchbowl/vendors/vendor/rails/activesupport/lib/active_support/time_with_zone.rb:262:in `to_i'
from (irb):17
ree-1.8.6-20090610 > 100.months.from_now.to_yaml
=> "--- 2018-10-17 15:49:56.021813 Z\n"
ree-1.8.6-20090610 > 1000.months.from_now.to_yaml
=> "--- 2093-10-17T15:49:58+00:00\n"
ree-1.8.6-20090610 >
1000 months from now is beyond the 32bit limit of the epoch second counter. Rails does it’s best to hide this from you.
I want my 40 minutes back.
Ruby regex performance
Just checking to see what the performance difference is between evaluating three separate regular expressions versus a single composite in ruby:
ryan = /\ARyan/
blake = /\ABlake/
darren = /\ADarren/
vs:
composite_regex = /\A(Ryan|Blake|Darren)/
The composite takes ~ 34% of the time as doing the three regex matches/evaluations. Nothing earth shattering here, was just wondering.I’m speaking at MongoSF
I’m wicked excited to announce that I’m flying out to San Francisco at the end of the month to speak at MongoSF. The conference is a single day, multi-track conference that’s going to run the gammit: programming workshops, MongoDB internal discussions, the current state of the OSS ecosystem around MongoDB, and (the reason I’m going) several presentations on examples of production deployments.
To be honest, when I saw the rest of the people presenting at this conference I gulped a little bit. There are some giants presenting, and I’m psyched to hear about all the cool stuff that is going on at the cutting edge.
What I’m also psyched about is the wide range of production deployment talks. On the “this is how you use MongoDB like a Big Dog” end of things there is a talk I am very excited to hear by David Mytton, founder of Boxed Ice, entitled Humongous Data at Server Density: Approaching 1 Billion Documents in MongoDB which I’m sure will be a blast.
And at the other end: my talk :-)
Back in October, we made the decision at Punchbowl to use MongoDB alongside MySQL as part of a non-mission-critical new application we were building (since then it has become mission-critical). I’ll be discussing the decision process to use MongoDB, implementation details of how we got up and running, unexpected issues we ran into, and how they were resolved. I’ll also give some insight into how I feel the entire process has benefitted our engineering team and our company’s bottom line.
And because I’m opinionated, I might also throw in 5 minutes of “IMHO” with regards to some of the NoSQL vs. SQL “debate” that has been brewing in the blogosphere over the past six months.
There are two audiences I’ll be addressing in my talk. First and foremost, I’ll be speaking to developers who have never used MongoDB. Developers that think MongoDB looks cool from all the blog posts they’ve read, but are hesitant about “going through all the trouble.”
Second, I’ll be dropping in a few nuggets aimed at the business guys & gals: engineering managers, founders, CEOs, etc…. The people who guard their developer man-hours like hawks and who have even more hesitation, but without any of the romantic feelings about “how cool MongoDB sounds”. I’ll try to assuage your anxieties and show you that, in the end, giving developers the chance to experiment with this stuff will pay dividends down the road.
So sign up for MongoSF today if you haven’t already. I’m excited to see you there.
Easier debugging when refactoring Rails controllers
When refactoring a big controller with lots of before filters, it’s common (for me anyway) to get into a situation where tests start failing due to before filters redirecting. Today I made it a lot easier to debug these failing tests by adding this to my ApplicationController:
def redirect_to_with_logging(*args)
logger.debug "Redirect: #{args.inspect} from #{caller[0]}"
redirect_to_without_logging *args
end
alias_method_chain :redirect_to, :logging
This will log where the new redirect is coming from, and make it a lot easier to figure out what is breaking your tests. Enjoy.
