Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Mongolian DeadBeef — April 24, 2012

Mongolian DeadBeef — April 24, 2012

Slides from my Mongolian DeadBeef talk at the MongoDB NYC Meetup on April 24th, 2012:
http://www.meetup.com/New-York-MongoDB-User-Group/events/58901662/

Marcello

April 25, 2012
Tweet

Other Decks in Programming

Transcript

  1. April 24, 2012 — Mongolian DeadBeef Who am I? ‣

    Programming since the crib ‣ Interested in digital creativity ‣ CompSci + Human Computer Interaction ‣ I run 2draw.net, online drawing tools + art community ‣ Current project: html5 sketching with websockets
  2. April 24, 2012 — Mongolian DeadBeef What is Mongolian? ‣

    Lightweight async node.js driver modeled after the mongo shell ‣ Features: replica sets, gridfs, db.auth, db.lastError, ... ‣ Open source (zlib license), 100% JavaScript ‣ On github: 6 contributors, 240 watchers, 27 forks ‣ On npm: 19 releases, depended on by 8 other modules
  3. April 24, 2012 — Mongolian DeadBeef Using Mongolian var Mongolian

    = require("mongolian") var server = new Mongolian var posts = server.db("awesome_blog").collection("posts") posts.insert({ pageId: "hallo", created: new Date, body: "Welcome to my new blog!" }) posts.findOne({ pageId:"hallo" }, function(error, post) { ... }) posts.find().limit(5).sort({ created:1 }).toArray(function (error, array) { ... })
  4. April 24, 2012 — Mongolian DeadBeef Why make Mongolian? ‣

    Moving from scala + mongodb + gridfs to node.js ‣ node.js is great; mongodb support, not so much
  5. April 24, 2012 — Mongolian DeadBeef node-mongodb-native, 2011 var mongodb

    = require("mongodb") var db = new mongodb.Db("awesome_blog", new mongodb.Server("127.0.0.1", 27017, {})) db.open(function(error, p_client) { if (error) throw error db.collection("posts", function(error, posts) { if (error) throw error posts.insert({ pageId: "hallo", created: new Date, body: "Welcome to my new blog!" }) posts.find({ pageId:"hallo" }, { limit:1 }).nextObject(function(error,post) { ... }) posts.find({}, {limit:5,sort:[['created','desc']]}).toArray(function(error,array){ ... }) }) })
  6. April 24, 2012 — Mongolian DeadBeef node-mongodb-native, 2011 ‣ Unhappy

    with nesting and code overhead ‣ Numerous differences from the mongo shell API ‣ Port of the ruby driver, not node.js-centric ‣ Not much documentation ‣ GridFS support clunky—didn’t use node.js IO streams
  7. April 24, 2012 — Mongolian DeadBeef Why make Mongolian? ‣

    Started by adding stream support to mongodb-native’s GridFS ‣ Wrapped mongodb-native with a mongo shell-style API ‣ In March 2011, the wrapper became Mongolian 0.1.0 ‣ Good excuse to learn node.js, modules, and mongodb’s intimates
  8. April 24, 2012 — Mongolian DeadBeef Mongolian Middle-ages ‣ Using

    mongodb-native’s internal APIs creates churn ‣ Bugs in mongodb-native look like bugs in Mongolian ‣ Mongolian no longer felt like a wrapper ‣ The dependency was becoming a burden...
  9. April 24, 2012 — Mongolian DeadBeef Modern Mongolian ‣ Built

    buffalo: pure node.js BSON serializer/parser ‣ https://github.com/marcello3d/node-buffalo ‣ Initially, 20~30% faster ‣ No longer depending on mongodb-native ‣ 4k LOC vs 14k LOC
  10. April 24, 2012 — Mongolian DeadBeef Learnings ‣ Don’t write

    a library: need a library ‣ Focus on the user experience ‣ Write for yourself, don’t over-generalize ‣ What is the minimal feature set? ‣ Start with the most important pieces, fill in the rest later (if needed) ‣ Be simple and consistent!
  11. April 24, 2012 — Mongolian DeadBeef How can you help?

    ‣ Use it! https://github.com/marcello3d/node-mongolian ‣ More mongo server command coverage ‣ Connection pooling, slave reads, tailable cursors ‣ Production testing ‣ Benchmarking, profiling, and optimization ‣ Fork and contribute!
  12. April 24, 2012 — Mongolian DeadBeef Cheers! ‣ https://github.com/marcello3d/node-mongolian ‣

    http://marcello.cellosoft.com/ ‣ http://2draw.net/ ‣ twitter: marcello3d / e-mail: [email protected]