Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

OCaml's type-checker is pretty awesome. You get the benefits of static typing, although you almost never have to declare types.

This also makes interfaces easier to understand. You can often understand what a function does without looking at the documentation or code. For example, let's say you've never heard of a map before, and you peek in the .mli file for the List module and see:

List.map : ('a -> 'b) -> 'a list -> 'b list.

This means that it takes a function (whose type signature is 'a -> 'b) and a list of 'a, and returns a list of 'b. Your first guess is that it produces the item-for-item image of a list under a function, e.g. f [a0; a1; ... an] -> [(f a0); (f a1); ... ; (f an)]... and you'd be right.

Pattern-matching is also a huge plus of the language, because it saves you from having to do a lot of ugly if/then kung fu and makes the code more readable.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: