Wednesday, August 28, 2013

Datomicity

I just got back from a FP-Syd (that's Functional Programming Sydney user group) meeting where one of the speakers talked about Datomic. It's basically, in the speaker's own words, "a NoSQL database with a rewind button". Datomic shines where other NoSQL databases have failed:

1. It's fully ACID compliant, which means you can have transactions. What I'm not sure about is whether it does distributed transactions as well. But regardless, I don't know of any other NoSQL database that supports ACID transactions, be they local or distributed.

2. Unlike most NoSQL databases, it actually has a first-class query language based on Datalog which is  itself based on Prolog. Some say it's even more expressive than SQL.

3. Unlike most NoSQL databases, it lets you store data hierarchically and do joins.

4. Out of the box it uses what I believe to be HSQLDB (think SQLite for Java), which allows data to be in memory or on disk. If that doesn't cut it, you can hook it up to a relational database, Riak, CouchBase or Dynamo DB.

5. Clojure is somewhat native to Datomic as it understands Clojure data structures. If you do functional programming in Clojure (or understand Lisp), Datomic is perfect for you as it minimizes if not completely eliminates impedance mismatch.

6. Data is stored as time-based facts, which means that it's append-only. The fact that data is immutable enables things like event sourcing (and with it all the wonderful business scenarios), not to mention avoids a host of concurrency issues that typically plague database systems.

The downsides:

1. It's closed source

2. It costs money if you want to hook it up to other data storages or integrate with memcached

Saturday, June 29, 2013

First GitHub pull request

Tonight while twiddling with a new pet project, I made my first GitHub pull request ever. To add icing on the cake, it's for an Elixir project, and I'm a complete Elixir noob!

Here's to hoping the original author will accept my pull request and doesn't think that I'm way out of my depth.

Sunday, June 23, 2013

Farewell mocks and stubs, here comes JavaScript

This isn't exactly a revelation to many developers out there, but I finally got my head around unit testing JavaScript code! I knew that the dynamic nature of JavaScript would help a great deal, but it wasn't until I actually wrote the tests that I realized how easy stubbing was.

There are a couple of key things to note though:

  1. Dependency injection (a fancy schmancy term for passing arguments) improves testability, even in JavaScript. Being able to just stub arguments negates the need to use a faking framework like Sinon.
  2. While it's not absolutely necessary to use a faking framework, one has to be wary of not changing the behavior of the module being tested across multiple tests. A naive way of getting around this is to cache the actual function that is being faked in setup and assigning it back in teardown. A safer, albeit more convoluted way is to use libraries like NodeUnit and Sinon which provide sandboxing capabilities.

Tuesday, June 18, 2013

Let's Kinect!

My company's upcoming hackathon presents a perfect opportunity to finally do something useful with that Kinect unit that I bought more than a year ago. We're planning to spend a couple of days building a game. The only requirement is it's not supposed to be work-related. How cool is that?

Time to dust off that Kinect. Hot or Not game with motion capture and voice recognition, anyone?

Saturday, June 15, 2013

Where art thou, expm packages?

I had a second look at how the expm package collection is going, and boy progress has been rather slow. Popular frameworks such as Cowboy, MochiWeb and WebMachine are evidently missing.

Although I don't mind using rebar to 'git pull' the dependencies and compile them with a single 'make deps', I still think it'd be more handy to be able to just do an 'expm spec webmachine' or some such.

Note to self: add more packages while grokking Elixir.

Good riddance, parameterized modules!

After previous attempts at upgrading FilmoMeter to rid itself of the ungodly shackles of parameterized modules, I finally managed to pull it off today! WebMachine 1.10.1 and MochiWeb 1.5(?) finally fix this issue by removing all traces of parameterized modules. All hail functional gods!

Now I can finally upgrade to Erlang R16B and Elixir 0.9.2 in peace.

To Elixir or not to Elixir, that's the question

Elixir has been gaining a lot of attention of late. Even the venerable Joe Armstrong himself has taken it for a spin and is impressed by some of its features.

I myself have been mildly frustrated by the lack of 'proper' macros and monads in Erlang. Maybe it's time to succumb to temptation and take the plunge?