RubyConf Summary Day 2

Ah, another day of RubyConf has passed.  Here’s a brief overview of the talks I attended and my thoughts on them.  The theme for today was definitely Threading and Concurrency.  And the conclusion in many (if not all) of the cases was:  Ruby sucks at it, how can we make it better?  I hope that Matz, et al takes these issues to heart and prioritizes some improvements in this area.  Native threads are a start, but the GIL kills us.  We need more!

Aristotle and the Art of Software Development – Jonathan Dahl

What a way to start the morning!  Jonathan gave an overview of several great philosophers and how to apply their ideals to programming.  He likened Perl, Java, and PHP to the school of Utilitarianism, where the ends justify the (very) nasty means of getting there.  His basic theme throughout the presentation was that hard rules (from any school of thought) must be tempered with common sense.  He gave the example of DRY versus clean & understandable code in ‘database.yml’.  While the clean version has a lot of redundancy in the settings, DRYing it makes it impossible to read.  Overall, a great way to start the morning.

Ruby Arduino Development – Greg Borenstein

I caught a Ruby electronics talk last year that was pretty cool, and got an even better one this year!  Greg presented a number of cool arduino projects, including drumming with servos, a temperature reader using a big red arrow on a servo, and a drink mixer that could make screwdrivers using windshield washer pumps!  It was a terrific overview of RAD and I can’t wait to buy an Arduino when I get home.

Better Ruby through Functional Programming – Dean Wampler

Dean did a nice talk about using functional paradigms in Ruby.  He gave examples of makign sure your functions don’t modify state, pattern matching, using functions as first class objects, etc.  He gave a good comparison that showed that DSLs are very similar to functional languages because they are very declarative instead of imperative.  What I think he missed is that, under the hood, DSLs are very state-heavy in order to implement that declarative model.  It was great to delve into these ideas, but I was left feeling that if you go through the trouble of following functional programming in Ruby, you don’t really get any benefits.  Ruby isn’t optimized for concurrency like Erlang or Haskel and your code will really just be more difficult to trace.  Maybe I’m missing something, but I didn’t see the benefits (except making it easier to switch to a functional language).

What Every Rubyist Should Known About Threads – Jim Weirich

When I see Jim’s name on a talk, it is guaranteed I will attend.  I don’t care about the subject.  Jim is an amazing speaker with always interesting topics.  He gave a fairly basic overview of concurrency and why we need it (the failure of Moore’s law).  For Java programmers and the ilk, this would be concurrency 101, but probably had some new information for a lot of Ruby developers.  He provided some great code-heavy examples of race conditions and deadlock and how to work around them.  He also hammered home his message of ‘Concurrency is HARD’, but it must be done.  However, I felt there was a kind of elephant in the room with the fact that concurrency in Ruby is rather fruitless, thanks to green threads, GIL, etc.  Jim did, however, give some great examples of ways to make it easier:  Erlang & Clojure.

Using Metrics to Take a Hard Look at Your Code – Jake Scruggs

Jake gave a terrific presentation on how use metrics appropriately to help improve and maintain your code.  He talked about code coverage, testing, Flog, Saikuro, and more.  Jake also had a great example of applying these tools to target improvements with a real-life example of refactoring a Dameau-Levenshtein distance function.  He also had great example of how inject has a tendency to muddy your code significantly, increase complexity, and decrease understandability, a sentiment I whole heartedly agree with.  Best of all, Jake introduced Metric-Fu: .  Metric-Fu combines, code coverage, flog, saikuro, and more into an easy to use interface that integrates with CC.rb.  Looks awesome and I’ll be trying it out soon!

Components are not a Dirty Word – Mike Pence & Nick Sutterer

One of the few Rails talks at the conference (as it should be).  Mike introduced us briefly to ‘Cells’, a new type of Component more similar to what Merb has now.  The Nick came up to demo Apotomo, a plugin that provides wholey-contained stateful widgets.  These widgets are persistant and handle updating their own appearance.  They also have event triggers, observers, and caching.  I will definitely be giving Apotomo a try, at least to play with, although it may not be ready for production use yet.

Ruby Kata and Sparring – Micah Martin

Micah talked about his experiences with martial arts and how it can be applied to programming.  His message was “To be a master, you must use disciplined practice outside of work”.  This is the purpose of Kata, or Forms.  He gave many reasons for a similar approach in development: peer feedback, definite goals, performance, etc.  He even performed a Kata of developing Langton’s Ant right on stage.  The best part was his introduction of a new tournament: battleship.  All Ruby developers are invited to participate by building a battleship AI.  The tourney info is available at: .   Awesome indeed, you can be sure I’ll participate.

Ruby Heavy-Lifting: Lazy load it, Event it, Defer it, and then Optimize it – Ilya Grigorik

Ilya gave a great talk on how to break down a task into something where you can use multiple processes.  This is the good stuff.  Forget threads and concurrency problems.  If you truly isolate the tasks (share-nothing? hello?), you begin to produce a system that can massively scale very easily.  He demonstrated using his real-world example of scaling  They split off the different tasks: network-bound, IO-bound, CPU-bound.  The different processes communicate with message and job queues (he mentioned starling, beanstalked, and SQS) and they used EventMachine to prevent blocking-IO.  In the end, they could load each EC2 instance with basically one task of each: saturating network, IO, and CPU simultaneously to get the best bang for the dollar.  Overall, the talk was great, but I may be biased since I feel it basically validated all my experience and convictions about the RIGHT way to scale.

Keynote – Dave Thomas

To round out the evening was Dave with a literally breathtaking talk.  He gave an example of Ruby’s biggest problem (at least I think so): slow development.  Ruby had 48 months between 1.6 and 1.8 and it’s already been 52 months waiting for 1.9.  (I guess Matz has really taken to heart his goal of being ‘enterprisey’)  This causes INCREDIBLE problems for migrating to a new version, not to mention learning or using the new features.  It also leads to slower adoption, wheich means less usage of the new version, which makes even LONGER releases.  Dave’s solution is to Fork Ruby.  He proposed four forks, all VERY good ideas.

RubyLite – A version of Ruby where we strip out a lot of the unnessessary stuff.  Dave projects Ruby’s codebase to be 100MB when 2.0 is finally release (in 2011!).  Pulling out a ton of unneeded syntax, libraries, and redundant methods could significantly improve size and performance.  I’m all in!!

Parallel Ruby – Dave proposes a ruby that will automatically parallelize certain operations.  A new operator: //= would perform something similiar to:  a,b=b,a using passed procs simultaneously.  Basically distributed map automatically.  Awesome idea.  Have no clue where to begin with this one though.

Typed Ruby – Ruby with typing.  Charles Nutter has been workign on something very very similar to this with Duby.  Cool idea, but I love duck-typing too much.

Closure-based Ruby – Dave offers a new syntax for hashes that will free up braces (not a bad idea, if there’s an =>, you already know it’s a hash, the braces aren’t really needed, just like with implicit arrays right now).  The braces can be used to element all the Lambda, proc,, block madness.  Make ONE first-class proc object, that can be passed and used all over the place.  A GREAT idea!!!  I think he took it a little far when he suggests making class and method definitions using it.  The code at the very end looked like Lisp with braces all over the place, you couldn’t tell what was what.  But otherwise, I whole-heartedly support a simplified proc system in Ruby.

Dave closed by saying that he hopes that he inspired us to go out and impliment these ideas, or any others we may come up with.  Try out new things and maybe they’ll get merged into MRI.  I sure hope RubyLite and the closure system Dave proposed eventually get taken into MRI.  I may even take a crack at implementing them myself!

RubyConf Day 1

During RailsConf this spring, I provided thrice daily (or more) posts on the talks and events.  While they were very popular, I didn’t really get to enjoy the conference much.  This time, I’m limiting myself to shorter notes once per day.  Here is a brief recap of Thursday, Day 1 at RubyConf.

The theme for RubyConfat RubyConf so far is DSLs.  While DSLs are always a promenant topic, so far every talk has included a pretty extensive coverage of them (or how they are used in a project).  This isn’t at all a bad thing, as I believe DSLs are very powerful, produce clean code, and are of great benefit to Rubyists.  That said, I don’t get to write many of them, so I’m a bit rusty and looking forward to beefing up my skills at Neal Ford’s ‘Advanced DSLs’ tomorrow.

Matz’s Keynote
Matz was his usual comedic self.  The talk was quite good and very sentimental.  As he notes, he doesn’t like a lot of technical content in his keynote.  Instead, this was more about how great the community is and he provided a lot of encouragement to keep that up, no matter how much we grow.  He asked for raised hands on “Who started with Ruby because of Rails”.  I’d say about 30% of the room raised their hands.  Then he asked about “Who stuck around because of Ruby” and it was clear that Ruby is why everyone stays.
A oft repeated quote from the keynote:  “Rubinius, yea – Good try”

Scaling Ruby (Without Rails) by Gregg Pollack
Gregg (of RailsEnvy) did a nice talk about what you should keep an eye on when developing in Ruby and trying to maintain decent speed.  He noted that Design Patterns in Ruby has many great examples, but they are necessarily slow.  Matter of fact, in general, making method calls are much slower than the alternatives.  I think this was great to hear as it reinforces my coding style of avoiding things like ‘.nil?’ or ‘.zero?’ that are expounded by other Rubyists.  I believe the more traditional routes are just as understandable without being so expensive.

Gregg also talked about threading (also a popular topic at RubyConf this year), Neverblock, Mongrel vs. Evented Mongrel, Deferred requests, Rind, DBSlayer, Halcyon, and Ruby-prof.  Overall, not bad, but a little light on content, examples and details.

Using Git in Ruby Applications – Scott Chacon
Scott gave a nice talk that included a brief overview of git itself followed by explaining some unusual things that git could be used for, including a ticketing system, wiki backend, and more.  His major goal was to introduce Grit, a Ruby library that allows you to interact with a git repo through Ruby.  It was pretty neat, but also quite complicated, even for git veterans.  There were quite a few code examples, but I didn’t really see any ‘start-to-finish here is how you do this’, and I think it was just a bit too much for the talk.  Overall though, it looks like a nice library and I hope to try it out more later (possibly for some interesting Rails/Capistrano tasks)

Recovering from Enterprise – Jamis Buck
I actually debated whether to attend this talk or go to another because it looked to be a bit beginner.  Boy, am I glad I stayed.  Jamis gave a terrific talk about his experiences writing and re-writing dependency injection libraries Copland & Needle.  After a nice, fairly technical walkthrough, we get to the meat of the conclusion:  Ruby-style dependency injection doesn’t require a dependency injection library at all:  Pass the class name or overwrite a helper method and go!  He left us all with some great quotes and nuggets of knowledge:

“I was riding the Dependency Injection horse for all it was worth”
“If you were turning every ten lines into a component, then you just wind up with component soup.  And I hope you’re hungry”
“Just in time.  Not just-in-case”

Unfactoring From Patterns: Job Security Through Code Obscurity – Rein Henrichs

Rein gave a pretty funny talk that went through the procedure for turning good code into bad.  It was funny with a lot of audience suggestions.  I attended hoping for some ‘glimmer of divine knowledge’ from the advertised ‘1% of truth’ to be presented, but there was none.  It was just a good time laughing at poor coding practices.

Peer Aware Desktop Application Development – Preston Lee
Preston presented on a library called ‘Journeta’ that provides a server-less broadcast-based peer-to-peer discovery and communication platform for clients on a LAN.  It’s a pretty fun and interesting topic, although I can’t think of any application of it right now.  Once again, the subject of the inadequecy of Ruby’s green threads came to the forefront.  It provides a severe bottleneck for the kind of asynchronous communication that Journeta does.  As we know (and was pointed out by Gregg earlier), the Global Interpreter Lock in Ruby 1.9 means that we still don’t have an appropriate solution.  I pray that a real solution comes to light soon because Ruby is severely suffering because of it.

Preston noted that Journeta didn’t work for Windows (mostly because he hadn’t tried).  I took that as a bit of a challenge and hacked on it during his talk.  After delving into some interesting internals of the Windows UDP Socket handling, Multicast, etc, I managed to get Journeta working on my Windows machine.  A fun chellenge for sure.  This is definitely what RubyConf is about.

Testing Herasies – Francis Hwang
Another talk I was considering missing, but I’m glad I didn’t.  I would say Francis gave probably the best talk of day.  It was chock full of technical content, examples, and a rather controversial topic: the right way to test.  Francis started with an overview of Mocks, Stubs, Dummies, Fakes, etc.  Then he started in with a great list of testing ‘dogma’ that people are told is the ‘One-Right-Way’.  He provided some excellent examples for why these bits of dogma aren’t necessarily true.  For example, he argued very effectively against Mocks (and the general ideal of seperating your testing from side-effects of external applications).  I hope he posts his slides for later reference, and if I find them, I will be sure to add a link here.

To end out the day, I attended the evening’s lightning talks.  There were a lot, but I’ll note a few:

Ryan Davis (ZenSpider) – Provided an overview of his new gem: Flay.  It’s a tool to find duplicate code, even if the code uses different variable names.
Yossef Mendel – Talked about what is and is not true (Truthiness) in Ruby.  A good reminder that only ‘false’ and ‘nil’ are evaluate to false in Ruby.  Everything else is true.  Yossef provides a funny little tool to see the truthiness of something (but hopefully after his talk, you don’t need it):
Bruce Williams was quite popular at RubyConf today as he was selected on Monday by the Obama campaign to attend the acceptance speak in IL as ‘Front Row to History’.  Bruce built a neat site prior to leaving (in one day) that provided updates on his tweets and snaptweets: Way to go Bruce, I’m jealous!