"What We Wrote" Posts

Writing Ruby Extensions in C the Highgroove Way

Posted in Open Source, What We Wrote, Presentations Comments Comments

Matt todd
Matt Todd
10
Jul

Trying to handle image manipulation, creating PDFs, or in-memory caching in pure Ruby is like trying to win the Tour de France on your hipster single-speed bike. The single-speed works 90% of the time, but when you have demanding performance requirements, it’s not good enough. Many popular Ruby libraries, such as MySQL/PostgreSQL, RMagick, and most of the webservers Ruby applications are deployed on (like Passenger, Mongrel, and Thin), harness the blazing speed of the C language and libraries to handle the heavy lifting and performance-intensive business that Ruby can’t keep up with on its own.

In some of my recent work, I had the opportunity to delve into and expand on a Ruby extension written in C for looking up geographic information based on IPs. This library was vital to one of our client’s projects that has immense performance requirements without the possibility of full request caching. By utilizing the existing GeoIP C library for accessing their special in-memory binary database, we were able to keep up with the demand the application would be seeing.

As is common at Highgroove Studios, along with making sure our contributions to the library were open sourced, I took the lessons and experience gained from this unusual endeavor and presented them to our local Ruby User Group here in Atlanta. I focused more on exposing the bridge between the Ruby and the C environments and understanding the internals of the Ruby language from a C standpoint. However, armed with this knowledge, any Rubyist is able to open up most any Ruby extension or even the Ruby language implementation itself and understand what’s going on. My goal was to get the developers over the initial hurdle of being able to read the code and understand it enough to investigate further.

Personally, I gained from this experience a better appreciation for the real beauty of the Ruby language and the effort required to make it as fluid and dynamic as it is as well as having a more thorough understanding of the internal workings of the language. Working this close to the language core has also made a difference on my Ruby style, both in trying to fight the language less but to also use it more efficiently and effectively.

For more information, check out the presentation slides1 and some of the C examples I wrote for the presentation2. Also check out the GeoIP I contributed to which inspired this whole adventure3.

1 http://www.slideshare.net/maraby/writing-ruby-extensions

2 http://github.com/mtodd/ruby-c

3 http://github.com/mtodd/geoip

Capistrano Takes the HighLine, I Mean Road

Posted in Open Source, What We Wrote Comments Comments

James
James
14
May

If you are following the Capistrano preview releases, you may have noticed a new dependency. Capistrano now depends on HighLine, an open source input library by yours truly.

The reason for the switch is that Capistrano needed a reliable way to grab passwords in a cross-platform way. That turns out to be a lot harder than you might guess. On Unix, termios can make short work of such challenges, but that’s an extra C extension install and it doesn’t work on Windows.

HighLine combines the knowledge of several platform gurus to use the right solutions in the right place. Even with all that knowledge as an advantage Capistrano’s maintainer, Jamis Buck, still had concerns. termios can’t be made a HighLine dependency, since we want to stay cross-platform and when defaulting to stty HighLine was a little flaky for the way Capistrano users might need it. Jamis and I discussed these concerns and HighLine was patched with better support for Capistrano’s needs. Jamis later added the dependency and HighLine benefited from another round of expert knowledge.

It still impresses me how much we can accomplish with the super friendly open source model of development. Thanks for the input Jamis!

The TextMate Book is Shipping

Posted in What We Wrote, Ruby on Rails Comments Comments

James
James
23
Feb

If all you Rails programmers love TextMate as much as I do, you will want to know that my TextMate book is now shipping. Amazon has it in stock already.

If you been a casual TextMate user until now, I promise this is the best excuse you’ve ever had to put an end to that. Allan Odgaard, the creator of TextMate, actually read through the book as I worked fixing my errors and adding a terrific collection of helpful tips. You just can’t beat having that kind of knowledge. That’s why I’ve already been using the book as my personal TextMate reference for months now.

Pick up a copy. You won’t regret it.

Look What's Coming...

Posted in What We Wrote, HowTo Comments Comments

James
James
28
Aug

Just wanted to make sure HighGroove customers and fans are the first to know, my new book is official:

James’s Book on TextMate

If you’re living under a rock, TextMate is the wildly popular text editor for Mac OS X shown off in most Rails screencasts. It even won the covetted Apple Design Award for Best Developer Tool just a few weeks back.

I’ve been heavily involved with TextMate development for some time now and am excited about the opportunity to show you how to really get the most out of it. The book will cover beginning to advanced editing techniques, built-in automations and how to create your own, even how to teach TextMate new languages. I promise, there’s something for everyone in here.

Some time ago I read a “10 Best Things You Can Do as a Programmer” list and one of the points on that list was: Learn one text editor very well and use it for everything you can. I believe that’s great advice and TextMate was my pick. I’m now ready to pass that knowledge on to all of you!

You’ll be seeing even more news about this book very soon now. (Weeks, not months!) Stay tuned…

The "Everything Ruby" Book

Posted in What We Wrote Comments Comments

James
James
08
Aug

I’ll be fair with you and tell you right out that I am biased in this matter, but I still have to say:

GO BUY THE RUBY COOKBOOK RIGHT NOW!!!

Yes, I wrote six of the bazillion recipies in the book (on DRb and Rinda), but I do not make money when they sell copies, so you can trust what I am saying here.

Basically we are talking about nearly 1,000 pages of EVERYTHING on Ruby. I don’t care who you are or what you do with Ruby these guys wrote something about your problems. How cool is that?

These recipes are just loaded with code, tips, links to related resources, etc. They even manage to be funny in places. (You will laugh at the dinosaur ad.)

Why are you still reading this?! Get up. Go outside. Hail a cab. Get yourself to a bookstore and pick this up! GO!

(If you have back problems you shoudn’t be carrying books this big, trust me. Instead you can grab the PDF version O’Reilly just made available.)