I’ve lately been working with OCaml and Haskell. Both are functional languages, and I’ve enjoyed functional languages for some time. that’s one reason I used Python for so long — while imperitive, it has a number of features commonly found in functional languages, such as anonymous functions and certain types of list manipulations.
OCaml and Haskell are both appealing to me. OCaml can be compiled to byte code, native code, or interpreted. It is a blindingly fast language, often beating C++ for performance, and occasionally even beating straight C code. This is quite a feat for a functional language, and helped get me interested in OCaml to start with.
OCaml has a marvelous type system. It is strongly statically typed, but has type inference and polymorphism. In short, this means that the type system stays out of your way (unlike Java) while still catching type problems in advance (unlike Python or Perl).
OCaml also has an OOP system, which is powerful though a bit odd.
One annoying thing about OCaml is that you have different operators for integers than for floats, and for lists than for strings, and the list operators are more powerful.
Haskell is a lazy, pure language. Its typing system looks very similar to OCaml’s, but it extends it in several significant ways. One way is with the use of typeclasses, a great way around OCaml’s problem with different operators.
Haskell also has a nicer module hierarchy system, and has a stronger standard library in most respects.
Haskell is not as fast as OCaml, especially relating to string manipulation. On the other hand, it’s no slower than Python, and has some powerful ways to exploit its lazy lists. (Haskell lists are the same as OCaml queues, but are also used for strings.)
One thing OCaml has that Haskell seems to lack is camlp4. Haskell has template Haskell, but it doesn’t seem as versatile. Haskell also lacks overt OOP implementations, but the OOHaskell people would want you to believe otherwise. (I’m learning about that now.)
One thought on “Thoughts on Languages”