Live data from Hacker News

Comparing OCaml and Standard ML

adam.chlipala.net

41–50 of 71 posts

Re: Comparing OCaml and Standard ML

#41
post #32

Earlier quoted context omitted.

I agree completely with your library statements. > I think one of the biggest mistakes in the life cycle of SML was premature specification. I disagree. There were some earlier Successor ML efforts ~10 years ago (see: http://successor-ml.org/index.php?title=Main_Page ), but as I understand it, there was agreement on many of the small issues but larger challenges reaching consensus on bigger changes. You can see some…

That's certainly a pretty exciting presentation! Looks like a huge effort though... how much progress has there been since?

We did the first part and very recently put http://www.sml-family.org/ online and announced the opening of the definition (whew!).

I'm primarily concerned with the parallelism and concurrency-related features, which we're trying to first clean up a bit more in the context of Manticore before trying to do something like proposing standardization for those features.

Also (IMO) you should take those slides more as a research direction for years of research investigating alternatives that eventually get standardized, not a 2015 implementation plan :-) Each of those topics casually mentions non-trivial extensions to problems that already have each had researcher-decades of investigation.

Re: Comparing OCaml and Standard ML

#42
post #3

Small update: recent versions of OCaml have immutable strings too. It also miss mention of package manager (OCaml has Opam, which is awesome, I don't know about SML). And ocamlbuild is missing from the build tools section.

Out of curiosity, why do you think Opam is awesome? I recently had to install a few OCaml projects and I had a hard time dealing with opam and ocamlfind (both on mac os and a linux VM). I suppose it's fine once everything is properly set up. I have the impression that the OCaml world has seen a lot of changes recently with a lot of complexity added.

> I have the impression that the OCaml world has seen a lot of changes recently with a lot of complexity added.

The first part of that is very true but the second part feels completely and utterly false to me. Where is this added complexity?

OCaml and OPAM were ridiculously trivial to set up on my system (via homebrew on a Mac) and OPAM 1.2, with many improvements, is due for release in the next few days [1]. Decent instructions are in the RWO wiki page [2]. The OPAM devs are responsive to bug reports and do a lot to maintain the health of the package ecosystem too.

If you're installing everything from sources then you're choosing to take on that burden and I wish you well but don't claim that more complexity is being added.

[1] beta announcement: https://opam.ocaml.org/blog/opam-1-2-0-beta4/

[2] https://github.com/realworldocaml/book/wiki/Installation-Ins...

Re: Comparing OCaml and Standard ML

#43
post #2

Purity is almost used in a pejorative sense throughout the page. If it wasn't for poor library support, I would prefer using SML to OCaml. SML is syntactically simpler and both SML/NJ and MLton have a lot to offer that I haven't yet found with OCaml. I think one of the biggest mistakes in the life cycle of SML was premature specification. As a result of the language definition, SML has stagnated for almost 20 years.…

I really liked SML and wanted to use it in anger after reading "ML for the working programmer" and "Purely functional data structures" (excellent functional programming books by the way) but just couldn't due to the lack of libraries as you say. For me the object system on Ocaml was just too much. Tis a pity.

I remember reading that book on my crossings over the tagus river in Lisbon, after we got introduced to Caml Light.

Time flies!

Re: Comparing OCaml and Standard ML

#44
post #36
post #20

Earlier quoted context omitted.

It's not just the match syntax; it's also the `;` expression separator. > Any decent programming editor will be able to indent that properly and you will see the problem. This seems like a weak excuse. In particular, I could turn it around and say, "any decent programming language should be writable without an editor". Also, the issue isn't just reading, it's writing too - it's much harder to foresee/plan all the `be…

> This seems like a weak excuse. (…) Fair enough, but for the ';', as others explained meanwhile, I think it's pretty simple to understand, it's just that we are not used to it because of C syntax. EDIT: actually, you are right about ';', it is confusing when I think about it: it does not have the same behavior in a branch of a `match` and in the branch of an `if`… I wonder how I never had problem with that before.

It depends on the learning path of each one.

In the Pascal family of languages, ';' is a separator as well.

Re: Comparing OCaml and Standard ML

#45
post #6

Wow, ML syntax is actually better than OCaml. It's a shame the former was used as a base for F#.

One thing I think F# got right is that it removed some of the "flexibility" in OCaml's syntax. For example, it uses significant whitespace to define scoping, which removed (in nearly all cases) the need for the 'in' keyword and lots of parentheses and semicolons. That may not sound like a huge deal, but it does greatly improve the readability of F# code (all other things being equal).

Actually when F# was introduced, you could switch between both modes.

After voting the #light "on" became the default behaviour.

You can get the more compatible OCaml one with #light "off".

Re: Comparing OCaml and Standard ML

#46
post #2

Purity is almost used in a pejorative sense throughout the page. If it wasn't for poor library support, I would prefer using SML to OCaml. SML is syntactically simpler and both SML/NJ and MLton have a lot to offer that I haven't yet found with OCaml. I think one of the biggest mistakes in the life cycle of SML was premature specification. As a result of the language definition, SML has stagnated for almost 20 years.…

Given the goal of implementing proof systems, whose semantics you obviously need to be really clear, I don't think that specification was premature. But you're right that it has inhibited the use of the language in a more general setting.

Re: Comparing OCaml and Standard ML

#47

Earlier quoted context omitted.

I really liked SML and wanted to use it in anger after reading "ML for the working programmer" and "Purely functional data structures" (excellent functional programming books by the way) but just couldn't due to the lack of libraries as you say. For me the object system on Ocaml was just too much. Tis a pity.

> For me the object system on Ocaml was just too much What do you mean by that ? The current consensus about the object system in OCaml is "don't use it", even if there might be cases where it will describe your system better. The standard library (both the real stdlib and Jane Street's Core library) don't use objects so you can pretty much ignore this part of the language if you want to.

There's nothing wrong with objects or classes in OCaml -- it's just that most problems can be expressed using a simplest abstraction technique such as modules. OCaml has steadily improved in every recent release to further reduce the set of problems that need objects (open types, GADTs, first class modules, destructive substitution in module types).

For problems where objects and classes are a good fit (e.g. something requiring open recursion), then OCaml objects are fine and sound. They are used quite nicely in CIL for implementing the visitor pattern, and I like them in the Lablgtk OCaml bindings as well. They also provide a nice bridge to foreign code in OCamlJava and js_of_ocaml when compiling to platforms that make more use of objects.

It's worth noting that class types and object types are distinct in OCaml, so you can often use objects without involving classes at all. This is explained in Real World OCaml: https://realworldocaml.org/v1/en/html/objects.html

Not using OCaml because it possesses an optional object and class extension is a little strange. It never really gets in the way...

Re: Comparing OCaml and Standard ML

#48
post #34

Earlier quoted context omitted.

My only reservation with Ocaml is that there does not exist a package management system for windows or even cygwin. I cannot understand why OPAM takes so much to work on Cygwin. I like SML but it still does not have a good set of libraries. I understand that these projects are sort of resources but supporting cygwin well should be easier than mingw or VS.

That was my biggest disapointment with "Real World OCaml", as the book requires OPAM to follow along. Apparently it works with WOBI, an OCaml distribution for Windows. I haven't tried it though. When on Windows I just go for F#.

WODI (not WOBI) didn't exist when we started Real World OCaml, and we developed OPAM along the way.

We've also started putting Windows support in place via Appveyor: https://github.com/ocaml/opam/blob/master/appveyor.yml

It just can't be activated by default since GitHub doesn't support multiple commit updates yet, so we have to chose between Travis and Appveyor. When GitHub sorts that out, we can have Linux, OSX and Windows tests for all new packages. In general, help porting packages to Windows is very welcome from interested parties.

Re: Comparing OCaml and Standard ML

#49
post #2

Purity is almost used in a pejorative sense throughout the page. If it wasn't for poor library support, I would prefer using SML to OCaml. SML is syntactically simpler and both SML/NJ and MLton have a lot to offer that I haven't yet found with OCaml. I think one of the biggest mistakes in the life cycle of SML was premature specification. As a result of the language definition, SML has stagnated for almost 20 years.…

> SML has stagnated for almost 20 years

I'm still waiting for OCaml to get decent multicore support, decent Windows support and an FFI that doesn't suck donkey brains through a straw (which is why so many OCaml libraries, like OpenGL bindings, suck beyond belief). Multicore became ubiquitous 10 years ago. Last I looked the vestigial OCaml community still hadn't noticed.

Re: Comparing OCaml and Standard ML

#50
post #16

Earlier quoted context omitted.

I'm curious about what you find particularly confusing about OCaml. I'm a (relative) newcomer to the language, but I find it extremely readable, even if it's a bit clunky at times.

What does this code do? if a > 0 then print_endline "a > 0" ; match a with | 0 -> print_endline "impossible" | 2 -> match b with | 0 -> print_endline "2, 0" | _ -> print_endline "2, not 0" | 3 -> print_endline "3, something" | _ -> print_endline "something, something" ; print_endline "done"

OCaml will give you compiler warnings on the incomplete and redundant match cases. F# will silently execute a semantically different version of your code. I prefer OCaml. Indentation sensitivity was one of F#'s design flaws.
Post reply on HN