Image

yes I do. That draft was created just after I joined twitter, and in the details I had written that I had just passed 400 tweets. I’m now closing in on 13,000. I am, however, in the process of scaling back my twitter and Facebook usage – I identified last week that as I reduce my tweeting I might return to blogging for my creative output.

So. 15,500 hits and counting for my first real post in 3 years. That’s a pretty high bar to live up to ;)

I briefly considered adding my OCaml post to reddit. Since I neglected to, it was put up for me. And then Hackernews. 11000 views (and counting) later, I have some catching up to do

OCaml first hit my radar in November 2013. I had just learnt SML, a similar but older language, in the excellent Programming Languages Coursera course. Dan Grossman is one of the best lecturers I’ve ever seen, I found his explanations hit all the right notes and made learning easy. The simplicity of the SML syntax, and the power of the language while still producing code that is readable with minimal training immediately appealed to me.

Over the last 3 years I have tried, and failed, to learn Haskell. The combination of minimalist syntax, pure functional programming style and lazy evaluation is like a 3-hit sucker punch that is very hard to grasp all at once. Having now learnt SML and OCaml, which like Haskell are based on the ML language, that has changed. I have yet to put any more effort into learning Haskell, but it is now clear to me that the syntax is only a small leap from ML and the pure functional style has similarities to SML.

I still don’t want to write production code in Haskell, but the fact that I find it less scary than I used to indicates I have made a significant jump in my knowledge and, arguably, career in the last 6 months.

Dynamic typing

Before I go any further, I need fans of dynamic typing to exit the room. My 12 years in the industry have set my camp firmly on the static typing side of the fence, and discussions about static vs dynamic will not be productive or welcome here.

So, why OCaml?

Smarter people than me have written about this, but I’ll give it a shot.

I have found OCaml to be a refreshing change of pace. Most of my favourite things are derived from the ML base language; variants, records, and pattern matching combine to create elegantly powerful code that is still easy to follow (unlike most Haskell code I’ve seen).

Ocaml takes the expression-based ML style and incorporates enough imperative features to make it comfortable for someone learning Functional Programming. Don’t know how to use recursion to solve a problem? Drop into a for loop in the middle of your expression. Need some debug output? Add it right there with a semicolon to sequence expressions.

Throw in almost perfect static type inference, a compiler that gives useful error messages and immutable-by-default variables and I just can’t get enough. I won’t sit here and list every feature of the language, but hopefully that piques your interest as much as it did mine ;)

Industry acceptance

There is always an element of “I have a hammer, everything looks like a nail” when learning a new language but the evidence that OCaml is becoming more widely accepted is not hard to find.

In the middle of February, Thomas Leonard’s OCaml: what you gain post made waves; the reddit and hackernews discussions are fascinating. A lot of people using OCaml in the industry came out of the woodwork for that one. I’m still working my way through the series of 11 posts Thomas made, dating back to June 2013, about his process of converting a large Python codebase to OCaml.

Facebook have a fairly extensive OCaml codebase (more details below).

It doesn’t take much googling to find presentations by Skydeck in 2010 (they wrote ocamljs, the first ocaml to JS compiler) or a 2006 talk describing why OCaml is worth learning after Haskell.

OCamlPro appear to be seeing good business out of OCaml, and they have an excellent browser-based OCaml tutorial (developed using, of course, js_of_ocaml).

No list of OCaml developers would be complete without mentioning the immense amount of code at Jane Street.

There are plenty of other success stories.

The elephant in the room

The first question I usually get when I tell a Functional Programming guru that I’m learning OCaml is “Why not Haskell?”. It’s a fair enough question. Haskell can do a ton more than OCaml can, and there are only one or two things OCaml can do that Haskell can’t (I don’t know the details exactly, I would think it was zero). I see a lot of references to OCaml being a gateway drug for Haskell.

The answer is JavaScript. As much as I hate the language, JS is the only realistic way to write web apps. Included in the many and varied AltJS languages, both OCaml and Haskell can be compiled to JavaScript but the Haskell compilers aren’t mature enough yet (and I’m not convinced lazy evaluation in JavaScript will have good performance).

In fact, some study has revealed OCaml may be the most mature AltJS compiler of all by virtue of support for existing OCaml libraries.

JavaScript

Late last year I started hearing about OCaml at Facebook. Their pfff tool, which is a serious OCaml codebase all by itself, is already open source – but there was talk of an even larger project using js_of_ocaml (the link seems to be offline, try the video). That presentation by Julien Verlaguet is almost identical to the one he gave at YOW! 2013 and it really grabbed my attention. (Hopefully the YOW! video is online soon, as it’ll be better quality).

To cut a long story short, Facebook created a new language (Hack, a statically typed PHP variant) and wrote the compiler in OCaml. They then use js_of_ocaml to compile their entire type checker into JavaScript, as the basis of a web IDE (@19 minutes in the video) along the lines of cloud9. Due to the use of OCaml for everything, this IDE has client-side code completion and error checking. It’s pretty amazing.

Maturity of tools and js_of_ocaml

The more I dive into OCaml, and specifically js_of_ocaml, the more it amazes me how the maturity of the tools and information reached suitability for production use just as I need them.

  • The package manager OPAM is now a little over 12 months old and every library I’ve looked at is available on it. Wide community acceptance of a good package manager is a huge plus.

  • The Real World OCaml book was released in November and is an excellent read. The book is so close to the cutting edge they had features added to September’s 4.01.0 compiler release for them :)

  • OCaml Labs has been around for 12 months, and they’re helping to move the OCaml community forward into practical applications (see the 2013 summary).

  • Ocsigen are investing heavily in js_of_ocaml (among other things) with the next release including an improved optimiser (I can attest to the fact that it’s awesome) and support for FRP through the React library.

Moving forward

Is it perfect? No. Software development is not a one-size-fits-all industry. There are as many articles cursing the limitations of OCaml as there are singing its praises. But in the current market, and with the size of JavaScript applications we are starting to generate, I believe OCaml has a bright future.

There’s been a lot of talk about the iWatch, but I’ve never been convinced that a simple watch would be different enough for Apple to produce one. It would need to do more than the usual bluetooth features everyone is expecting.

Then an idea hit me on the way home today.

How could Apple make a watch that isn’t just a watch? How about if it’s also the control system for the TV that Steve Jobs claimed to have finally figured out before he died?

It could be a touch screen watch that replaces the tiny iPods. The iOS 7 icons do look good on a small device. But let’s really go out on a limb.

I’m picturing a watch face that detaches from the strap and slots into the remote control somehow. The remote doesn’t connect to the TV itself, it uses a bluetooth connection via the watch.

Now you’re charging the watch, using a familiar yet advanced TV control that leverages the added connectivity¬†and¬†identifying to the TV who you are for personalised functions.

That sounds like the future.

My information about using multiple Time Machine drives remains surprisingly popular, even 4 years after posting it. I missed this one in the massive list of features, but Apple appears to have added more robust support for multiple drives in Mountain Lion!

Thanks to Macworld for highlighting it, in an interesting list of Mountain Lion system changes.

Having bought one of the few modems on sale in Australia that support IPv6, and being on an awesome ISP that is running an IPv6 trial, I sat down tonight and upgraded to the v6 firmware. I nearly killed the poor thing by attempting to upgrade via wifi, but it worked in the end:

spyder@rei:~$ traceroute -6 http://www.google.com
traceroute to http://www.google.com (2404:6800:8004::68), 30 hops max, 80 byte packets
1 <snip> (<snip again>) 4.472 ms 4.460 ms 4.464 ms
2 loop0.lns6.syd7.internode.on.net (2001:44b8:b070::4) 43.598 ms 43.771 ms 44.941 ms
3 gi1-1.cor2.syd7.internode.on.net (2001:44b8:b070:5::1) 45.161 ms 46.352 ms 46.818 ms
4 gi6-0-0-144.bdr1.syd6.internode.on.net (2001:44b8:b060:144::1) 47.995 ms * *
5 te0-0-0.bdr1.syd4.internode.on.net (2001:44b8:b070:1::12) 49.397 ms * *
6 2001:4860:1:1:0:1283:0:8 (2001:4860:1:1:0:1283:0:8) 51.511 ms 42.576 ms 43.136 ms
7 2001:4860::1:0:9f7 (2001:4860::1:0:9f7) 49.014 ms 49.399 ms 49.635 ms
8 2001:4860:0:1::d7 (2001:4860:0:1::d7) 46.702 ms 46.886 ms 47.692 ms
9 2404:6800:8004::68 (2404:6800:8004::68) 47.922 ms 48.542 ms 48.984 ms

It has added a small amount of latency as I’m in Brisbane and the v6 trial runs everything via Sydney, but this is very cool.

(p.s. for the technically minded – no, I’m not silly enough to put my modem’s IPv6 address in this post. It’s probably globally routable, even if it is only temporary it’s static for the duration of the Internode trial :) )

The Brisbane flood of 2011 was big news all around the world, but for me it was entirely personal. Sitting here, now, a month after the flood as I settle into my new place, I think it’s time to talk about my flood experience.

If you watched enough of the news you’d recognize the suburb of Rosalie – it was a big talking point both during the floods and on the day after as cleanup began.

My place? It was right in the deepest point of Rosalie. So yeah, we got flooded.

Now while that sucks, we didn’t lose anything significant:

  • Two empty bookcases (one mine)
  • Tall white cabinet (mine)
  • Washing machine (mine, possibly salvageable but I had already planned to throw it out or sell it cheap)
  • Large fridge (mine, again possibly salvageable but I wanted to sell it)
  • Small bar fridge
  • Large cupboard with drawers
  • TV stand
  • Desk

I have Wivenhoe to thank for the comparatively small size of that list. Things could’ve been so much worse. Wivenhoe gave us the warning on Tuesday that a flood was coming the next day; this meant we could leave work early and spend the entire afternoon moving our gear upstairs. We had already been served notice to leave our rental property at the start of February (hence wanting to sell fridge/washing machine), so the bits of packing we’d done helped immensely to get everything we cared about upstairs long before the floods hit.

I left on Tuesday evening, but one brave flatmate stayed behind to see what the initial 3m flood looked like. He parked on a nearby hill and continued to move stuff we decided we didn’t care about, but would have been a little annoying to lose. Turns out 3m was just below our ground floor level thanks to building minimum height requirements, he stuck around moving the last few things until he was ankle deep in our downstairs floor on Tuesday morning (waist deep in the driveway). We both stayed about 23km away in Kuraby with friends.

My flatmate was told to go to work on Friday because they’re on the edge of the CBD, so I tried to work from our temporary accommodation. But there were so many volunteers on the news that my friends, and then finally Ephox, told me to take the afternoon off to clean up.

I turned up at about 2pm, saw a lot of cars (being kept out of Rosalie by police) but not a whole lot of people which had me a bit worried that I’d missed the cleanup crew. The high water line was over my head in the driveway; my key didn’t work in the front door. I eventually made it through the jungle that was our back yard and started recording as I walked in the front door:

What a mess! You can’t really see it (although I did try to show it near the end) but a lot of the walls are bulging. You can see most of the items I listed above, along with plates and stuff that we have since cleaned up and kept. Everything I mentioned was destroyed; the big white cabinet, for example, collapsed as soon as they tried to move it because the back was entirely chipboard.

After I took that video I was a little bit in shock. I shifted a few things around but wasn’t really sure what to do. I eventually walked out to the street and grabbed the first volunteer that walked past to help me shift the heavy stuff.

We moved a few small things but when it came time to tackle the fridges he wandered off to grab some more help; that’s when the whirlwind was unleashed. Word must’ve got out that there was someone in need of help, because an army descended on my home.

It’s all a bit of a blur. At a rough guess, I had as many as 10 people helping me but it could’ve easily been more.

I remember being in the driveway emptying our big fridge into a bin when someone said “I’ll do that” and sent me back inside after I made sure they would keep the pyrex containers. I remember having no idea how to unlock the electric roller door until someone finally found the release lever. I remember blindly walking into the garage as the volunteer behind me gingerly checked the area for snakes before following me.

I was debating whether to try keeping my fridge but I’d already told them to throw it, next time I went outside the massive dump truck had arrived and it was being loaded onto the back along with all the other rubbish piled up in the street.

We had someone in Army camo-type gear who turned out to be an ex-reservist and not actually in the Army anymore. I think one of the helpers might’ve even been a neighbor from our block of 3 units, I can’t really be sure. I was so busy directing people and responding to “should we keep this” questions that it was hard to keep track of it all.

Once everything had been taken outside they hosed out downstairs and asked me if I had any bleach. Most of it went on the floor for general disinfecting with another hosing, but some went into a bucket and was used to wipe the walls down for me – I never expected them to do that!

They even hosed out the garage for me, and asked nothing in return. One guy was eyeing off the miscellaneous beer and alcopops that had accumulated in the bar fridge, so I told him to take it. That’s all it cost me, and this is the result:

I don’t know any of their names – any I was told were forgotten in the madness – and they never asked mine, only learning it when I was looking for bleach and a neighbor (one I know I recognized) called up the stairs asking if we needed help. I was so blown away I didn’t think to take any photos – this is the only photo I have of them, the back of the guy who I gave the alcohol to:

I feel incredibly lucky to have survived as well as I have. My deepest thanks go to all those who volunteered for the cleanup, whether in Rosalie or elsewhere in Brisbane.

They were the Anonymous Army, and they will always be remembered.

Follow

Get every new post delivered to your Inbox.

Join 90 other followers