Recently, Facebook announced Flow, a static type checker for JavaScript, which is implemented mainly in OCaml (https://code.facebook.com/posts/1505962329687926/flow-a-new-static-type-checker-for-javascript/).
Hacklang (PHP with static type checker) is also mainly written in OCaml. So, I wonder that what are the distinctive benefits of OCaml for making a static type checker?
Object-oriented programming: OCaml allows for writing programs in an object-oriented style. In keeping with the language's philosophy, the object-oriented layer obeys the "strong typing" paradigm, which makes it impossible to send a message to an object that cannot answer it.
Hack is a programming language for the HipHop Virtual Machine (HHVM), created by Meta as a dialect of PHP. The language implementation is open-source, licensed under the MIT License. Hack allows programmers to use both dynamic typing and static typing.
OCaml unifies functional, imperative, and object-oriented programming under an ML-like type system. Thus, programmers need not be highly familiar with the pure functional language paradigm to use OCaml.
OCaml is a functional (applicative) programming language, but also an imperative language, and also an object-oriented language. This means you can mix and match paradigms at will.
"What are the benefits of OCaml as a programming language" is indeed an opinion-based question, and one that I'm not going to tackle here. However, I work on the Hack team at Facebook, and have worked closely with the Flow team, so I can answer the question I think you intended to ask: "Why did Facebook pick OCaml to build Hack and Flow?"
fold_left
over the statements it contains.mmap
'd region shared between different fork
'd processes, containing a shared, lockless hash table. That's the sort of thing I wouldn't want to express in any language except C -- and that's exactly what we do. The OCaml code can call a couple magic functions without being any the wiser that it's actually C under the hood. (As an aside, I'm going to do a tech talk in January about how exactly our multithreading works, along with some other bits of Hack implementation details -- it's really cool, but hard to grasp without an intro, even if the code is open source!)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With