Interview with Ernie Miller, creator of great gems like Squeel, Valium and etc.
июля 17, 2012 | Published in Интервью
Перевод интервью на русский язык будет опубликован немного позже.
Today in our virtual studio we welcome a super guest. His name is , hi is an extremely productive programmer, Rails contributor, and maintainer of very useful projects such as MetaWhere, Squeel, Valium, etc.
Hi Ernie, please introduce yourself for RubyDev readers.
Hi Vladimir, thanks for the opportunity to “visit” with you. I’ve been a developer with for a bit over a month now, and I’ve been loving it. As for hobbies, I enjoy recreational coding, PC and console gaming (currently spending quality time with Diablo 3), reading, and spending time with my wife and stepdaughter. I also volunteer as a crisis counselor at my church.
Ernie, I want to thank you for your projects. I like MetaWhere and Valium and I have started to use Squeel in my new project. And all these three gems (or ActiveRecord extensions) are awesome and I recommend to all Rails developers to use these tools. Can you briefly describe these gems developed by you?
Sure.
and are very similar. They’re both attempts to expose more of the ARel awesomeness that underpins ActiveRecord 3.x to the developer. At its simplest, this means you can do more than equality and inclusion conditions in your where clauses without resorting to SQL snippets in strings. The primary difference between MetaWhere and its successor, Squeel, is that Squeel has an improved DSL, additional functionality, and cleaner internals. These gems really wouldn’t have been possible if it weren’t for the awesome work on ARel by Nick Kallen, Bryan Helmkamp, Emilio Tagua and of course, Aaron Patterson. Emilio and Aaron were always especially encouraging and helpful as I first began using, then contributing to ARel.
is much smaller, and much simpler. It’s just a gem that allows for improved performance when selecting only a few attributes from your AR models, because it avoids the overhead of instantiating ActiveRecord::Base objects for each returned row. The functionality is similar to “pluck” which has been added to Rails core more recently, though I think Valium is better. :D
Can you list some big projects which use your creations (MetaWhere, Squeel, Valium, etc.)?
(and before it, ) is part of SpreeCommerce. I have offered some support and had some interaction on Twitter with other companies who use it, but since those projects are closed source, I’m not sure they’d take very kindly to my name-dropping. :)
How other developer who like your gems can help you to do it better?
The most helpful thing you can do is to read the available documentation before submitting an issue. Once that’s done, if the issue is still present, provide as much detail as possible about the issue, and, if at all possible, submit a failing spec. That makes a huge impact on how quickly I can address your issues. Since my time is limited, I’ll sometimes tackle an issue that I know I can handle quickly before one that takes more detective work on my part.
What do you think about why ActiveRecord doesn’t contain all those features from MetaWhere / Squeel?
I really wish that some of the features of Squeel, particularly, were part of Rails core, but I can understand and respect the arguments against this, as well. Mostly, I’d like to see Squeel, or something like it, merged to core so that I’d have one less gem to maintain by myself. I have other ideas I’d like to experiment with, but I really hate leaving a trail of orphaned projects in my wake. Since “make my life easier” is a pretty selfish reason to wish for a merge, I’m inclined to say that I’m not a very good person to ask about this subject. :)
I have seen notes about some Rails vulnerabilities on which had been added by Aaron Patterson and there a have seen lists of security findings made by you. I also see you in Rails committers list. How much time do you spend working on Rails and your own projects? And is it difficult to commit to Rails?
First, the “committer” status. While I’d love to have access to commit to Rails core, as of now I’m just a committer to ARel. But it does come with that nifty Rails badge on my GitHub profile, so that’s nice. :)
I spend as much time as I can working on my own open source projects and contributing to Rails. As far as contributing to Rails goes, most of my contributions (including the security fixes) have been the result of personally encountering a bug (or missing feature). It’s not particularly hard to contribute to an open source project. The hardest part is getting past your own insecurity. When I post my code online, I still, to this day, feel a bit nervous about what others might think. The important thing to remember is that we were all beginners, once. If your code sparks discussion or criticism, there is knowledge to be gained from the discussion. Pick an issue you’ve encountered, and then dig in and try to fix it. Be sure to include tests! :)
Are hacking and security in your interests or you just help Rails to stand a better web framework? How do you find vulnerabilities and is it true that Rails is one of most secured web frameworks?
I performed some Information Security Officer duties for some of my past employers, and I tend to think like someone who is intent on breaking my code while I’m writing it. It’s just part of my thought process, really, and it evolved from some common security wisdom I took to heart a long time ago — namely, it is much harder to make an existing system secure than it is to build it securely from the ground up. In the sysadmin world, this means essentially starting with a system that isn’t open to the outside world at all, doesn’t have a compiler installed (yikes!) and so on, then installing only what you need to perform the desired function. In code, it means writing only what you need, and making sure that what you write is inherently distrustful of input received from outside of your code.
So I guess, to answer the question about how I find vulnerabilities, they just sort of pop out at me. I wouldn’t say I have directed tremendous effort at a security audit or anything. As such, I don’t think I’m qualified to make a statement regarding Rails’ security as it relates to other frameworks. Certainly there are things about the Ruby language, itself, however, that lead to making code more understandable, if applied correctly. And if code is easy to understand, it’s easier to spot problems, security or otherwise, and less likely that you’ll introduce them.
Ernie, what can you advice developers which want to start to commit to Ruby on Rails? What are your secrets of participation in open-source development?
I touched on this a bit, before — but my single largest obstacle to contributing to open source was my own insecurity. This sounds like an oversimplification, but really, my advice is this: Get over it! Send a pull request for a project you enjoy. It may or may not get accepted. Don’t let that discourage you. Pull requests get ignored for tons of reasons — I should know, I’ve ignored my fair share. Sometimes the maintainer is just busy. Sometimes the feature you’re trying to add is outside the scope of the maintainer’s vision for the project. There’s always the option of asking if a contribution would be appreciated ahead of time, as well. I’ll say it again, though — be sure anything you contribute has tests!
There are many Ruby/Rails developers in Ukraine and Russia who say that english-speaking community doesn’t respect them because they are not so active in open-source like developers from other communities. There are many reasons for that. Firstly, a salary of web developer in Ukraine or Russia are 3-4 times less than it is in USA, for example, and prices are the same or larger than they are in USA. So, we need to work harder and some developers don’t have time to work on open-source projects. They also say that not all colleagues want to visit Ruby/Rails conferences in Ukraine or Russia. Personally, I think that the main problem is not in open-source activity but in that not all Ukraine and Russian developers know English well. What do you think about this? Will you visit conference in Ukraine or Russia If someone invites you?
I think that you may be on to something with the language thing. I am, unfortunately, only fluent in English, and so if I were to speak at a conference in Ukraine or Russia, I’d be unable to speak the language of the attendees. Of course, when it comes to traveling, that is certainly a much greater distance than, say, my driving from Louisville, Kentucky in the USA to Nashville, Tennessee, to attend , for instance. That kind of travel can get expensive quickly, so conference-goers are often very selective about the conferences they attend.
As someone who has communicated with developers from all over the world, many of my software’s most enthusiastic supporters are non-native english speakers. I truly appreciate their contributions to the discussion, even though a language barrier may pose a problem, sometimes.
What tools do you use when you work on your own projects? Can you describe your workspace and your typical tools?
For my own personal projects, I currently prefer RSpec (I’ve been meaning to try switching to minitest/spec) and I love Travis CI. I work on a 15” MacBook Pro, and perhaps surprisingly, I don’t normally use an external display. I am pretty minimalist when it comes to tools, having recently made the switch back to MacVim from TextMate, with pathogen, ack.vim, ctrlp.vim, tabular, vim-markdown, vim-powerline, and of course, vim-rails. When I’m coding, I’m generally listening to some dance or trance music on my Audioengine A2s, which are easily the best recent purchase I’ve made for my home office. I also usually have a in the form of our Bengal named Esther.
Ernie, tell us when and why did you choose Ruby and Rails over other languages and platforms? What platforms/languages do you use except Ruby and Rails?
I came to Ruby (and Rails) via Perl, unlike many of my early peers, who were Java refugees. Since Ruby draws many influences from Perl, the transition was a mostly seamless one. I fell in love with the pervasive Object Oriented nature of Ruby. The whole “everything is an object” nature of Ruby really resonated with me, as did the ability to do really evil things like monkey-patch core classes to add new functionality. Not that I’m an advocate of doing that (usually), but just knowing that it can be done — that Ruby doesn’t wrap many artificial limitations around what you can do — that’s empowering, and exciting!
Besides Ruby, I of course write some Javascript (doesn’t everyone?), and occasionally do some Objective-C. I’ve previously worked (to varying degrees) with Ada, BASIC, Pascal, Java, C, and Perl. I’d very much like to play with Erlang sometime soon. It’s really quirky but has some very cool capabilities.
Ruby and Perl are very similar in some moments, but Ruby is less «esoteric» language than perl. I have no experience programming on perl, but I think that there are big conceptual differences. Can you explain me and RubyDev readers what are the main differences between Ruby and Perl?
Well, I wouldn’t say Ruby is less esoteric, but it’s esoteric in different ways. Ruby has OO as a first-class citizen, whereas you can write Perl in an OO way, but, partly because of history, and partly because of language features, a lot of “OO” Perl code is more about namespacing methods than development using OO patterns. That’s not the state of all Perl code, of course, and I can’t say that the same accusations about following OO best practices couldn’t be just as easily leveled at us in the Ruby community, at times. :)
Perl’s obviously big on sigils, as well, to indicate the type of a variable. So, if you’re referring to a hash, it’s written as %variable. An array is @variable, and a scalar value is $variable. The syntax is (by necessity) much more explicit about whether you’re dealing with an actual value or a reference to that value. Since Ruby is OO down to its core, you’re doing pass-by-reference everywhere. In Perl, you might have a hash that you’d like to return from your subroutine. But you can’t return the hash, you must return a reference to that hash. So your code might look like:
#!/usr/bin/perl -w use strict; sub return_a_hash() { my %hash = ( One => 1, Two => 2, Three => 3 ); return \%hash; } my $val = return_a_hash(); foreach my $key (sort keys %$val) { print "$key: $val->{$key}\n"; }
Note the barewords allowed on the left side of the hash (this is syntactic sugar, Perl converts them to string values), and the backslash on the return value. Perl does multi-assignment if you return an array (and has a wantarray function to check if that’s how a subroutine is being called), but otherwise you’re returning a scalar value, by using the backslash to return a reference to the hash, rather than the hash itself.
Dereferencing can be done by prefixing the $val with a “%” to indicate it should be dereferenced as a hash (as seen in the foreach) or via -> to access the members of the hash by name.
As you can see from this quick example (I’ll admit, I had to type and run it to make sure it worked — I’m rusty!) there is a good deal more procedural style to Perl code. with functions like “sort” and “keys” expecting array and hash parameters, accordingly.
Maybe this was more of an answer than you bargained for, so I’ll stop here. :)
What do you think about Node.js? Is EventMachine much better than Node.js and Node.js has only one benefit — it is just much faster than EventMachine?
I prefer to write Ruby vs Javascript (or CoffeScript), but I think that Node.js has its place, for the time being. The insane amount of effort that browser vendors have put into optimizing their Javascript VMs ensures it. I don’t know if I see Node.js as a long-term contender, but something inspired by it probably will be.
In past time JavaScript MVC frameworks were very popular. Developers use them even than they are not really needed. What JavaScript MVC do you use and what do you think about where they belong?
I’ll be honest, I play with them from time to time because I think they’re cool, but I really don’t find myself using them frequently in my day-to-day work, which tends to be more back-end heavy. I think that Dan Webb from Twitter made some pretty astute recently about where the client-side approach falls down a bit. Applying client-side MVC to render pages that are more or less static is a misapplication of the technology.
One thing I love about the client-side MVC trend, however, is that it forces developers to think about their APIs while they’re doing their development, instead of as an afterthought.
In past time there are many developers say that Javascript is the future. As for me it doesn’t. Javascript are very freaky language especially if developer isn’t a professional. What do you think about future of Javascript, Ruby, Rails and web development generally?
Javascript isn’t going anywhere, and as mentioned, the VMs designed to run it are super-optimized. I think that as far as web development goes, though, there are very few people who want to deal with the idiosyncrasies of the language itself, which is why things like CoffeeScript have taken off so well, despite causing so much drama in our Rails community.
Ernie, can you share your best development practices? How ruby/rails rockstar developer should organize his working environment, what techniques he should use and what do you think about these all *DD, like TDD or BDD or something else?
I don’t think I can really offer an answer there. What works for me might not work for you. Find a workflow that feels “right” to you, and go with it. Share it with the community — they’ll provide useful feedback, and if you’re open to it, you might just change your opinions.
Can you advice something for Ruby/Rails newbies? How they must organize their learning plan or learning plan is a stupid idea?
Find something you want to build, and start building. Research along the way, and find a mentor who is willing to work with you to answer questions and help you write more idiomatic Ruby.
Thanks you for interview, Ernie! As for me it is very interesting! I hope Rails merge Squeel and we will have all “super query power” out of the box with installing Rails. I also hope that you will start some new great projects and we create new interview about it. I wish you good luck and many-many awesome ideas and projects like that or much better that those you already realized in code! Thanks you for interview and for awesome gems that each developer should try!
Contact info
Blog:
Twitter:
Github: http:github.com/ernie
LinkedIn: