Tuesday, October 16, 2012

Modern product development motto


Don't launch if you aren't going to monitor
Don't monitor if you aren't going to improve
Don't improve if you don't know who to improve for

Sunday, October 14, 2012

Weird Clojure build-in function names

Clojure has a rich set of build-in functions for manipulating data structures. Library developers have to name each of them as concise as possible to make them convenient to use. Selecting a word that can describe the whole behavior of each function is a very important step and they did this very well.

But for non-native English speaker that coming from Java and Ruby world, I found that some of the
function names are hard to guess and remember what they do. These are an example list of them.
  • quot
  • assoc
  • dissoc
  • interleave
  • interpose
  • juxt
  • reductions
  • trampoline

Btw, I have a feeling that I remember them now after wrote this blog. :)

[VIM] + and * register don't work with clipboard on MacOSX

This problem is because VIM version that shipped with MacOSX doesn't enable xterm_clipboard. You can check this by run :version command in VIM. Enabled xterm_clipboard VIM must have +xterm_clipboard but the version shipped with MacOSX has -xterm_clipboard.
If you want it to be enabled, you need to compile VIM yourself with clipboard enabling flag.

Tuesday, October 9, 2012

Clojure Map function

I came across one of the quiz from 4clojure, it asks us to reimplement interleave.
=> (interleave [:a :b :c] [1 2 3])
(:a 1 :b 2 :c 3)
After I solve this quiz with a long solution, I looked at the other people solution. One of the solution that impressed me somewhat similar to this
=> (apply concat (map vector [:a :b :c] [1 2 3]))
(:a 1 :b 2 :c 3)
If we run only evaluate Map part, the result looks like this
=> (map vector [:a :b :c] [1 2 3])
([:a 1] [:b 2] [:c 3])
I had hard time to understand that. I got a question in my head. "Of what reason, why Map function take element of 2 vector (3th, 4th parameters) one by one?" It turns out that this is a Clojure Map function behavior.

Then I realized that the reason why I don't easily get that because all functional programming style syntaxes that I have played with, Map functional only takes 1 argument.

Look at Ruby code.
=> [1, 2, 3].map { |i| i + 1 }
[2, 3, 4]  
But for Clojure's Map function, it takes variable arguments and behave like what I explained earlier.
=> (map inc [1 2 3])
(2 3 4) 
=> (map + [1 2 3] [4 5 6])
(5 7 9)
Another question I had was "Can we archive the same variable arguments behavior with Object-Oriented style?"
The answer is No because we can only calling a method to 1 object. But of course, you can archive this with OO language but in functional way like this.
map(->x,y{ x+y }, [1,2,3], [4,5,6])
This examples might look trivial but if we look at it carefully it represents fundamental differences between OO languages and functional languages. For OO language, our method call is a mechanism of passing message to an object. But for functional language, it's just a function call.

Collectd PostgreSQL Plugin

I couldn't find this link when searching with google https://www.collectd.org/documentation/manpages/collectd.conf.html#plugin-postgresq...