What makes a developer ecosystem robust?
Here’s one factor: empathy. Parse founder James Yu wrote in a post about idea generation:
Empathy is defined as “the capacity to recognize and, to some extent, share feelings that are being experienced by another semi-sentient being.” So, empathetic product discovery is simply learning through other people’s experiences* in order to discover potential solutions to their problems.
* emphasis mine
When creating a product for other developers, their experiences include:
get("/"){"hello"})For a project to really click, you need to take most, if not all, of these factors into account. The following is a (semi) fictional account of how good empathy by project creators leads to libraries that just make sense to a (semi) fictional developer, and ultimately a community and ecosystem we should all be proud of.
This is where it begins. Maybe you’re completely new to programming or web development. Maybe you’re a refugee from spaghetti php ;) or ancient CGI scripts. You’ve heard the buzz around the “15 minute blog”. The coolness of this code is undeniable:
rails new MyApp
cd MyApp
rails g scaffold Post title:string author:string body:text
rake db:migrate
rails s
Once the novelty of scaffolding wears off, and it’s time to build the actual app, you continue to thank yourself for choosing Rails when you can write your model like this:
class Post < ActiveRecord::Base
has_many :comments
belongs_to :author
end
The best code is the code you don’t have to write. You’re not here for an ORM flame war, but there’s plenty of boilerplate avoided here. It’s awesome.
Now you want a custom db query. Query chaining ftw:
@posts = Post.where(:published => true).where(:category => "code").all
Time to deploy MyApp. Instead of thinking about servers, you smile and do this:
gem install heroku
git init
git add .
git commit -m "initial commit"
heroku create --stack cedar
git push heroku master
Now your project is too cool to keep to yourself, so you want to use GitHub. When you create a repo called “MyApp”, you’re greeted with this:
Existing Git Repo?
cd existing_git_repo
git remote add origin git@github.com:foousername/MyApp.git
git push -u origin master
Looks easy enough! Just skip the first line, and copy+paste the next two lines. Boom.
Note: Pretend IndexTank didn’t get hire-acquired
Now you want to make my posts searchable:
class Post < ActiveRecord::Base
#...existing code
include Tanker
tankit 'my_index' do
indexes :title
indexes :body
end
end
Five lines!
Alright, it’s been a few years since Rails first impressed you. Objective-C is the new cool kid on the block, it’s time to build a mobile app. After reading Dear business people, an iOS app actually takes a lot of work! along with Parse founder James Yu’s take on the post, you realize you’d be a fool not to try Parse. Here’s the iOS beauty:
PFObject *testObject = [PFObject objectWithClassName:@"TestObject"];
[testObject setObject:@"bar" forKey:@"foo"];
[testObject save];
PFQuery *query = [PFQuery queryWithClassName:@"GameScore"];
[query whereKey:@"playerName" notEqualTo:@"Michael Yabuti"];
[query whereKey:@"playerAge" greaterThan:[NSNumber numberWithInt:18]];
NSArray* scoreArray = [query findObjects];
You barely know Objective-C, and you know exactly what’s going on here since you’re already familiar with query chaining from the ActiveRecord example above. Many months pass…
Now that you’re knee-deep in garbage collection and XCode is giving you nightmares, you yearn for the good old days of web app development. Luckily, you have a good excuse, as your hot new iOS app really needs a web presence.
You want data from the native app be the same data on the web app. parse_resource to the rescue! It’s a Ruby wrapper to Parse’s REST API, and coincidentally my first open source project and Ruby gem. Here’s parse_resource’s simplicity:
class Post < ParseResource::Base
has_many :comments
belongs_to :author
fields :published, :category, :title, :author
#TODO replace IndexTank
end
That’s it.
Your scaffold-generated controllers still work.
Post#comments and Post#author still works.
Post.where(:published => true).where(:category => "code").all still works.
You sit back and smile.
The best APIs implement the most accessible patterns. Sometimes it means inventing something new (Rails’ scaffolding), or it means standing on the shoulders of giants and implementing something tried and true like Git (GitHub, Heroku) or ActiveRecord (um, ActiveRecord/Rails, Parse, parse_resource).
Good developer empathy has far-reaching effects when we all practice it. First, it increases the chances of success for your project. Second, if your project becomes successful, other devs might “build around” it (ex. I built parse_resource “around” Parse).
When developers create projects that act in harmony with other projects, the community gains strength.
The result is a robust ecosystem where a “15 minute blog” can be hosted, version controlled, search engine indexed, and converted to work with a mobile app in hours and not days, by noobs and not neckbeards.
Alan 09 February 2012