Tagged: lambdas

Leveraging message passing to do currying in ruby

I’m not much of a ruby guy, but I had the inkling to play with it this weekend. The first thing I do when I’m in a new language is try to map constructs that I’m familiar with, from basic stuff like object instantiation, singletons, inheritance, to more complicated paradigms like lambdas and currying.

I came across this blog post that shows that ruby has a way to auto curry lambdas, which is actually pretty awesome. However, I was a little confused by the syntax

a.send(fn, b)

I’m more used to ML style where you would do

fn a b 

So what is a.send doing?

Message passing

Ruby exposes its dynamic dispatch as a message passing mechanism (like objective c), so you can send “messages” to objects. It’s like being able to say “hey, execute this function (represented by a string) on this context”.

If you think of it that … Read more

Java lambdas

I’m not a java person. I’ve never used it in production, nor have I spent any real time with it outside of my professional work. However, when a language dawns upon lambdas I am drawn to try out their implementation. I’ve long since despised Java for the reasons of verbosity, lack of real closures or events, type erasure in generics, and an over obsession with anonymous classes, so I’ve shied away from doing anything in it.

Still, at least the Java world is trying. While I’d love to just ignore the fact that Java exists, I can’t. Lots of interesting projects are done in Java, and a lot of world class tools are written in Java, so from a professional standpoint it’d be good for me to know it.

In the past when I looked into how past Java utilities did “functional” it never felt natural to me. People have … Read more