5 ms·
> IO is reflected in the type signature of Haskell functions. What you mean is, "effects are reflected". Haskell has a monadic effect system (IO is very rough-
by mercurial 11y ago
> IO is reflected in the type signature of Haskell functions.
What you mean is, "effects are reflected". Haskell has a monadic effect system (IO is very rough-grained part of it), which can be combined via monadic transformers.
Situations where you don't want to use OCaml:
- you need good parallelism and using multiple processes are not enough (concurrency is fine, though)
- you want a large pool of developers (also applies to Haskell, but less so)
- you like monadic effect systems
- you need a number of libraries which are not present in the OCaml ecosystem
- you want a build system that doesn't suck
- you want a good standard library
- you want typeclasses
Why you'd want to use OCaml over Haskell:
- fast compilation (especially if you compile to bytecode)
- no monadic effect system
- no awful, ridiculous record field name collisions (OCaml lets you have two distinct types with an "id" field, imagine that)
- best-in-class package manager
- faster than Haskell (I think?)
- eagerly evaluated (Haskell's informal motto is "if it compiles it works", complemented by "until you get a memory leak") and therefore makes it much easier to reason about performance
- high-quality ecosystem (though not always very well documented)
- labeled arguments (many Haskell libraries have these functions with lots of arguments which are quite confusing in the absence of labeled arguments)
- great support for Vim/Emacs (IMHO, the Haskell equivalent to Merlin/ocp-indent are not nearly as good, or at least were not as a few years ago)
- great REPL via utop (just don't use the standard one, it's terrible)
- an object system if you really need one
- functors
- pleasant "printf debugging" option, with a possibility of using a real debugger if you need
- fsloth 11y ago"- you want a build system that doesn't suck" This is a very surprising claim. Do you have any examples how Ocaml specifically induces systems built on it to suck?
- samwgoldman 11y agoI don't think that's what was meant, but rather that ocamlbuild sucks. It's not the best.
- 12121091872 11y agoI'm curious: The configuration file syntax is odd, but otherwise it tends to work. What are the additional problems?
- LeonidasXIV 11y agoThe others are even worse. I tried using OMake and apart from having some neat features like watching files and automatically recompiling it was an incredible pain of setting it up - mainly due to the strange programming language used in its build files. Also, it has seen 0 updates in the last years. It already starts with the compiler, calling them manually is quite a pain, especially if you want include any kind of library, which is why ocamlfind is such a huge win.
- nv-vn 11y agoOasis isn't that bad apart from a few options that are tricky to get (or the fact that, as far as I know, there's no sane way to make it install executables to your ocamlfind directory, which makes it fairly unsuitable for PPX extensions). For the most part, it's about as easy/intuitive as using Cabal.
- LeonidasXIV 11y agoYes, I am using it too, but too bad it is basically unmaintained since its author moved to work for Google. I had hoped it could generate many more files like config for Merlin or Makefiles for build systems than ocamlbuild.
- mercurial 11y agoYou may be interested in https://github.com/OCamlPro/opam-user-setup https://github.com/OCamlPro/opam-user-setup
- fsloth 11y agoAh, yes, I parsed it wrong.
- catnaroek 11y agoWhat if I want some hybrid? From OCaml, I want the awesome module system and strictness by default. (I'm not dismissing laziness or any other evaluation strategy - just saying strictness is a better default.) From Haskell, I want effects tracked in types, higher-kinded types and painless parallelism.
- thinkpad20 11y agoThere's one language I know that gives nearly all of those things, which is Ur (of the ur/web framework fame). Modules, type classes, eager evaluation, HKTs. It even adds features that aren't in either language such as first-class records and row polymorphism, type-level programming, macros and probably more. It's apparently very high performance, and even has a nice C FFI. The major downside is that it's only meant to be used for writing web servers, and for whatever reason, despite the huge number of features it supports, there seems to be little demand (or effort) to broaden its usage beyond this role. It also suffers from poor documentation, both from a language manual perspective as well as the compiler itself, which quite frankly has some of the sparsest comments I've ever seen in a code base of its size (when I was perusing before, there were practically zero comments across tens of thousands of lines of code). So yeah, probably not headed for the mainstream in its current state. Also I don't think there's much in regards to parallism in the language, although this might be able to be put in a library ¯\_(ツ)_/¯
- catnaroek 11y agoI've played with Ur/Web before, and I'm very impressed with its type system, but unfortunately I don't have much use for it, because, as you mentioned, it can only be used to make Web applications, which I don't find terribly interesting. I even remember telling Adam Chlipala on Freenode at some point in time, that it would be very nice if Ur could be used for more general-purpose programming.
- thinkpad20 11y agoYes, I asked him a similar question a while back when I was investigating the language. I recall the response was something along the lines of that he wrote the language primarily for research into type-safe web APIs, and the language's features were a means to that end rather than an end in themselves. This is unfortunate because as a language it's one of the most exciting that I know of, but like you I have little interest in web apps. In fact with its current compiler (AFAIK) it can only be run as a web server, which means it's not even possible to write a program which just writes Hello World to stdout and exits. This was frustrating enough to me that I soon gave up on the language. :(
- seagreen 11y ago> What you mean is, "effects are reflected". Haskell has a monadic effect system (IO is very rough-grained part of it), which can be combined via monadic transformers. Technically I'm on solid ground, IO _is_ reflected in the type system and not all effects are (memory use being the big omission, which we both mention). Saying "effects are reflected" is probably more helpful though. > monadic transformers There are ways combine capabilities without using monad transformers. For instance with typeclasses (if any non-haskellers are reading this here's an example: https://github.com/commercialhaskell/stack/blob/8b010060b0d79f8455562a2716c68b72796f25b6/src/Stack/Build/Cache.hs#L66 https://github.com/commercialhaskell/stack/blob/8b010060b0d7...). > IMHO, the Haskell equivalent to Merlin/ocp-indent are not nearly as good, or at least were not as a few years ago Editor tooling is still a big weakness of haskell:( A lot has been done on it though and progress is starting to pick up. I agree 100% with your other points.