Friday, October 25, 2013

Bodega

Aaron wrote a number of blogs about Bodega. Our open market for digital content. Today I wanted to write a bit about the technology behind it. Plus my prose is unbeatable - it works out, a lot, and is ripped like Stallone during his "definitely not on steroids, just natural, inject-able supplements" years, so it should be appreciated more widely.

If you ever used a content distribution platform, like the Google Play or Apple's App store, I'm sure you noticed the terrible way in which they handle content discovery, rankings, communication with the publishers and the vetting process. To some extend Bodega solves all of those and every day it's closer to the vision that we had when we started it. And we weren't even high that day. Well, I wasn't, Aaron was high on life. And crack. Mostly crack. I apologize, crack isn't funny. Unless you're a plumber, in which case it's hilarious.

What wasn't very clear at the beginning was the technology that we would use it to write it. We started with PHP because Aaron had some code that we could reuse from another project. Testing became a nightmare. I'm not a huge fan of dynamically typed languages for server programming, they make it a lot harder to validate the code and avoid silly mistakes and without highly efficient testing setup they can make your life hell. So one weekend when I got sick of setting up Apache once again to test something, I just sat down and rewrote the code in Javascript using Node.js. I know, I know, "you don't like dynamically typed languages and you rewrote it in js?", keep reading...

Node.js was a great choice for Bodega. Testing became trivial (we're using Mocha). Between our unit tests and jshint support, I can live with the dynamic nature of the language.



What makes node.js great is npm and its extensive collection of packages. That tooling means that you can focus just on the code that you need to write to finish your project not the code that you need to start it. That's why I picked it.

If I didn't have a day job I'd pick either Go, Haskell or just do everything by hand in C++. I have to admit that I like Go a lot (even though the system level graphics hacker in me shakes his head at a language without native vector support) but it's hard to argue with the fact that node.js allows us to move very quickly. So Bodega is written in node.js and uses Posgresql to store all of its data and that combination works amazingly well.

It's a Free Software content distribution platform that actually works and it's just the start. In my obviously biased opinion it does a lot of really interesting things that make it a very important project, but that's a different topic.

5 comments:

David said...

I can really recommend using istanbuljs in combination with mocha to get some nice code coverage reports.

./node_modules/.bin/istanbul cover --print none ./node_modules/.bin/_mocha -- --recursive tests/ --reporter xuint > xunit.xml

Pau Garcia i Quiles said...

I admit to this day I cannot see the point of node.js,. I'd rather use Wt and just use C/C++ libraries (including Qt), no need to worry about bindings JavaScript-C++ bindings.

Arpad Borsos said...

Yup, with node and mocha, writing tests is actually fun, which means more are written and the quality is higher. Also npm is awesome, and you can get started in minutes instead to waste a whole day setting up your development environment.

But what has the graphics hacker been up to lately? 2 Years no blogging! I miss your posts that are a good mix of humor, narcissism and information :-D

Zack said...

@David: yea, we're using istanbul. it's great.

@Pau Garcia i Quiles: I'm not sure I understand, there's no js-c++ bindings to worry about with node.js. And Wt was never a choice, it's just not what we need. Like I said if I had to use c++ I'd just write a framework myself. Or work on the linux port of Microsoft's Casablanca.

Paul Gideon Dann said...

I have to say, I'm a little surprised noone's mentioned that Ruby would also have been a great choice: Rails or Sinatra, depending on the complexity of the project. I think Node.js has the appeal that JS seems more familiar to people who don't generally like dynamically-typed languages. Purely on a language level, though, I find Ruby much more elegant :)

Good work on Bodega, by the way; looks really promising!