
OCaml Resources (2006) - laex
http://www2.lib.uchicago.edu/keith/ocaml-class/home.html
======
implicit
OCaml/js_of_ocaml is presently my favourite AltJS stack.

OCaml syntax is super idiosyncratic and doesn't resemble anything, but, once
you retrain your eyes, the underlying semantics are terrific.

js_of_ocaml imposes very minimal code overhead (6k-ish). Sourcemaps work
great, and OCaml values are mapped into JS in a very straightforward way. You
can read them in a JS debugger.

Ocsigen's lwt library is also the best "callback hell" solution I've found.

~~~
lindig
Could you recommend a project to look at? I'm familiar with OCaml but found
Ocsigen as a whole impenetrable and would be interested in something more
library than framework.

~~~
mercurial
You have opium [1], which is considerably lighter and more traditional (no
Eliom stuff).

1: [https://github.com/rgrinberg/opium](https://github.com/rgrinberg/opium)

~~~
rgrinberg
I think the GP wanted something with js_of_ocaml. Nevertheless, as the author
of Opium, I am grateful for your recommendation :)

------
eatonphil
I started writing OCaml in college after hearing a talk by Jane Street [0],
one of the most outspoken corporate supporters of OCaml.

After getting past the steep learning curve (about a weekend of pedal-to-the-
metal debugging), I really got a feel for how beautiful OCaml semantics really
are.

If you're looking for a solid and familiar OCaml stack, check out OWebl [0].
Always looking for helping hands or other support.

[0] - [https://www.janestreet.com/](https://www.janestreet.com/)

[1] - [http://meetowebl.com](http://meetowebl.com)

------
pron
There's a very good (and multithreaded!) implementation of OCaml for the JVM:
[http://www.ocamljava.org/](http://www.ocamljava.org/)

~~~
616c
Well, if you are the quasar/pulsar guy I think you are, I will take you up on
your praise then.

And because of my guess, what do you think of the performance?

~~~
pron
I am, and thanks :)

I haven't got to the point of doing any benchmarks, but according to the
author, it is slower than plain OCaml. I've only written a couple of toy
programs (a Swing GUI in OCaml!)

I am, however, very impressed by the implementation. The author wrote an OCaml
library that emits Java bytecode, and then modified the OCaml compiler to emit
bytecode. He then ran the compiler on itself, and got an OCaml implementation
on the JVM written completely in OCaml (plus some runtime classes in Java).

The author, who used to work at INRIA told me he's now working on a startup
using OCaml-Java.

~~~
616c
I also think it is interesting, once I put 2+2 together, you pointed out the
OCaml Java runtime from Xavier is not open source ... yet. It will be, but it
is binary only at this point.[1]

I want to make a joke about the F/L/OSS spirit of this guy, but the whole QPL
thing has been repeated a la Shen in circles where I read and seems to have
left a sour taste in the mouth of some, like this guy.[2]

Still, I am in place to judge OCaml devs or the community around them, as they
seem increasingly awesome. I am a novice, but a CS undergrad in my hood
specifically said check out OCaml when we discussed functional langs because
of the Jane Street videos. And before that, my only expsoure to what OCaml
was, let alone is or even coding it, was the eMule software package.

Anyway, good to see you on the field. If you are paying attention to this, I
certainly will! [1]
[https://github.com/xclerc/ocamljava/issues/22](https://github.com/xclerc/ocamljava/issues/22)

[2]
[http://programmers.stackexchange.com/a/62704](http://programmers.stackexchange.com/a/62704)

------
jaegerpicker
OCaml is a hard sell for me. I want to really like it but everytime I start to
play with it, I drift back to F#, .net core, service stack, and all the other
open source projects are really hard to compete with. The Syntax is similar to
OCaml (really really close IMO) and other then it's ties to Microsoft it's
seems to be all upside with F#. Is there a compelling lib or advantage of
OCaml over f#?

~~~
tel
Functors tend to be the big thing that's missing, right? F# just had to drop
the feature because of compatibility with .Net packages, as I understand, but
it severely cripples the module system.

MLs are such that the value-level stuff and the module-level stuff are more or
less independent. So you can go a long way just liking the value-level stuff
without really caring about the status of the module-level stuff. But it's
also a pretty big motivator for the design of ML. F# is at least weirdly
missing out here.

~~~
cwyers
Can you provide an example of how functors make Ocaml code different from F#
code in practice?

~~~
tel
Sure. I'm not super familiar with F#, but I can state things which depend upon
functors.

A good example is the Set.Make functor in the OCaml stdlib. Elements in a Set
must be orderable for efficiency's sake, so to construct a Set you
parameterize it over a module specifying not only the type but also its
ordering.

    
    
        module type Set = sig
          module type OrderedType = 
            sig 
              type t 
              val compare : t -> t -> int 
            end
          module type S =
            sig
              type elt
              type t
              val empty : t
              (* ... *)
            end
          module Make :
            functor (Ord : OrderedType) -> S 
              with type elt = Ord.t
        end
    

Here the OrderedType module signature represents any type that also has an
ordering. The S signature represents the result signature of calling the Make
functor which is passed any OrderedType-substantiating module and uses it to
construct the (Set.S with type elt = Ord.t) module.

------
more_original
This page is from 2006!

I guess the official homepage [http://ocaml.org](http://ocaml.org) would be
better for up-to-date information.

------
locokoko
I recently looked at OCaml and quite liked it, but I was wondering if there is
any SLIME/Geiser (these are the lisp and scheme IDEs for emacs) equivalent for
it? I know there is tuareg-mode, but as far as I can tell it is not nearly as
convenient as SLIME. Any ideas?

~~~
ufo
I don't know what you are looking for when you compare things to SLIME but I
was quite satisfied with the setup they suggest in realworldocaml:

[https://github.com/realworldocaml/book/wiki/Installation-
Ins...](https://github.com/realworldocaml/book/wiki/Installation-Instructions)

* OPAM for package management * Utop for a REPL * merlin for autocomplete and type queries * ocp-indent for aotomatic indentation

~~~
unhammer
[https://github.com/OCamlPro/opam-user-
setup](https://github.com/OCamlPro/opam-user-setup) tries to make the setup
even easier

------
ricccardo
I've been developing in Haskell for a while and I recently had to learn OCaml
to help TA for a course in my university.

I couldn't shake the feel that I was learning "Haskell Light". No pure/impure
code (I/O, mutable references, exceptions), no monad syntax sugar, less syntax
sugar for pattern matching, much smaller base library, plus surely other
differences that my current level of expertise of Haskell is hiding.

Perhaps the simpler semantics make it easier to translate to js (I know
haskell->js transpilers are very complex and I'm sure lazy evaluation has a
lot to do with it), but in terms of language features, what am I missing in
Haskell that makes you more productive/helps you write clearer code in OCaml?

~~~
ihm
OCaml's module system (and conventions associated with it) give a few
advantages over Haskell.

\- There are good conventions for naming and argument order (and named
arguments!) so I don't have to memorize a bunch of different APIs. This is
made possible by the module system. It could probably be solved in Haskell
with better tooling.

\- Modules allow you to, for lack of a better word, make your code more
modular. Modules are essentially the same thing as what people use objects for
in Java. They let you abstract implementation and program against a particular
interface (i.e., a collection of types and values) easily in a way you can't
really in Haskell.

~~~
ricccardo
Can you give a specific example? If you need abstract interfaces, what's wrong
with Haskell's type classes?

~~~
creichert
OCaml modules have many similar characteristics to Haskell type class[0]. One
of the primary differences being that the Haskell type classes handle
dictionary passing automatically and support ad-hoc polymorphism. This can be
achieved with ML modules but requires bit more labor.

Haskell type classes can make it a bit easier to encode (and infer) interfaces
but assume a single implementation per data type. ML modules do not make this
assumption and support a higher degree of modularity as a result.

Robert Harper has some extremely good writing out there on this topic (and
many more): [https://existentialtype.wordpress.com/2011/04/16/modules-
mat...](https://existentialtype.wordpress.com/2011/04/16/modules-matter-most/)

[0] - [http://www.mpi-sws.org/~dreyer/papers/mtc/main-
long.pdf](http://www.mpi-sws.org/~dreyer/papers/mtc/main-long.pdf)

------
tejinderss
How does Ocaml compare with F#? Now that .net is open source and supports
multi platforms, is it fair to compare these 2 languages?

~~~
mercurial
OCaml has no corporate support and a limited standard library. It does not
benefit from the larger MS ecosystem. It does not have multicore support (not
until the end of the year if all goes well). On the other hand, it is really
fast, it has some great features (functors, mostly) not found in F#, a really
good package management story, and some great libraries (eg, lwt). It can also
boast of having one of the most developed unikernels out there (mirage) and
can generate sane Javascript via js_of_ocaml.

That said, it's definitely an even harder sell than F# in the corporate space.

------
melling
I can't find the time to learn a language for fun. I need to find a way to
incorporate it into my daily routine. There just aren't enough hours in the
day to play.

Anyway, I've got a couple side projects, one of which is website in Go. How's
OCaml for web development?

I also saw oCaml for iOS but it didn't seem to be up to date:
[http://psellos.com/ocaml/compile-to-
iphone.html](http://psellos.com/ocaml/compile-to-iphone.html)

~~~
programLyrique
There are ocsigen ([http://ocsigen.org/](http://ocsigen.org/)) and opium
([http://rgrinberg.com/blog/2014/04/04/introducing-
opium/](http://rgrinberg.com/blog/2014/04/04/introducing-opium/)), OWebl
([http://meetowebl.com/](http://meetowebl.com/)), xbreed
([https://github.com/mk270/xbreed](https://github.com/mk270/xbreed)) and maybe
others... See also:
[https://news.ycombinator.com/item?id=2235204](https://news.ycombinator.com/item?id=2235204)

~~~
melling
Yeah, I'm sure there are lots of small projects. Are any widely used that have
matured? I don't want to play with someone's part time project.

~~~
programLyrique
ocsigen is used in production (by Facebook for an internal project, for
instance). There is a more complete list on the website.

------
fithisux
My only skeptikism with OCaml is that OPAM (latest packages) does not work on
windows and does not cooperate with msys2 (lates libraries) or another port
solution like winbuilds.

I have to install msys2 and keep compiling by hand.

Even if a source solution that kept updating even if I had to compile
regularly, would be preferable.

This is my only hesitation.

~~~
avsm
The wg-windows@lists.ocaml.org working group has just started this week to
sort this out properly. Now that OPAM itself is fairly mature on
Linux/BSD/MacOSX, we can tackle this properly.

Please do feel free to join the group and give your 2 cents about the
direction that this should take: [http://lists.ocaml.org/listinfo/wg-
windows](http://lists.ocaml.org/listinfo/wg-windows)

------
dlandis
I did a couple small projects in OCaml and I loved the syntax and style of
programming, but I think there would pretty much always be a better language
choice for a serious project, regardless of what type of program you are
writing. Also, the standard library leaves a lot to be desired and parts of
the ecosystem (e.g. docs, and OPAM) are pretty rough. The standard library has
a lot of gaps so you end up implementing a lot of low-level functions that
will seem tedious and inefficient if you are coming from a more mainstream
language with a rich ecosystem. Using the Jane Street's Core library helps a
little bit but still leaves a lot of gaps. It's still a fun language though,
but I don't think there would be a compelling reason to choose it nowadays for
a new project.

~~~
mwcampbell
> there would pretty much always be a better language choice for a serious
> project

The Mirage library OS is a pretty serious project. Facebook also uses OCaml
for Flow and the Hack type checker. And of course, Jane Street Capital uses
OCaml.

But I'm guessing what you mean is that OCaml is a very non-mainstream
language, so it will be rejected for most corporate projects just because it's
so foreign.

~~~
dlandis
> But I'm guessing what you mean is that OCaml is a very non-mainstream
> language, so it will be rejected for most corporate projects just because
> it's so foreign.

Rather than snidely guessing what I meant, why not just read the rest of my
comment or ask for clarification like an adult? Also, I'm not denying there
are a few odd projects here and there that use it successfully -- as well as
Jane Street, of course, who are almost synonymous with OCaml. But like I said,
although it is a very nice (and educational) language, I just don't feel like
it is "best of breed" in any particular area. Not sure what that has to do
"corporate projects", etc.

~~~
mwcampbell
> Rather than snidely guessing what I meant, why not just read the rest of my
> comment or ask for clarification like an adult?

You're right; I'm sorry.

------
lesterpig
I'm studying this language right now at a french school, with INRIA
researcher.

And, well... I'm not really satisfied with it. OCaml produces a small amount
of code, but is really slow and hard to understand. Sometimes, it looks like
obfuscated code!

Documentation and libraries are not polished, and I would recommend Haskell
instead of OCaml. Good for research and some algorithms, bad for applications.

And... God... "This page was last updated on 17 June 2006."

~~~
superboum
Same feeling, and why are they ignoring EVERY programming convention ? One
more thing I really hate is there are many way to the same basic thing, ie.
declaring a new function or doing a pattern matching. Finally, standard
libraries are not well named (List.split will not do what you think) nor easy
to use (List.last ? Nope !).

~~~
implicit
This is very consistently my biggest problem with OCaml: it just doesn't
follow conventions set in other ecosystems. I predict this is the sole reason
it could never be "the next Java."

It's worth noting, however, that I've had very, very few problems with the
semantic properties of the language. I think the slog is worth it for that
reason.

~~~
rbehrends
> This is very consistently my biggest problem with OCaml: it just doesn't
> follow conventions set in other ecosystems.

Well, the reason is that Caml predates those ecosystems; the original Caml was
released nearly a decade before Java [1], and ML itself dates back to the
1970s.

[1]
[http://caml.inria.fr/about/history.en.html](http://caml.inria.fr/about/history.en.html)

~~~
implicit
Right. I mean only to say that OCaml's superficial strangeness is regrettably
offputting.

Talk of syntax is almost always history and religion, not science.

------
jarcane
I was as recently as today quite curious to find that there was an
implementation of Ocaml 2.00 for RISC OS, but alas, it seems to have been lost
to the internet.

------
pjmlp
Caml Light was my introduction to the FP world back in the day. Very nice
experience.

------
m0skit0
404 on some links

------
zak_mc_kracken
This is just a list of resources to learn OCaml, there is nothing about
convincing skeptical people here.

Also, this page is almost ten years old.

Not sure how this kind of post ever makes it to the front page.

~~~
amirmc
Useful/interesting discussions are sometimes reason enough to upvote.

~~~
r0naa
Very good point, most of the time when a post with a "sensationalistic" title
makes it to the front page I immediately go to the comments section first.

