5 ms·
I know he said "All the code here should be translatable to OCaml if that’s more your taste" but I have read multiple examples about the power of ML modules and
by kuwze 9y ago
I know he said "All the code here should be translatable to OCaml if that’s more your taste" but I have read multiple examples about the power of ML modules and the code always seems to be in SML and not OCaml. Why is that?
- zeckalpha 9y agoOCaml has preferred OO over modules by convention.
- octachron 9y agoNo, OCaml has an object system, but it is an uncommonly used complement to the module system.
- zeckalpha 9y agoThat’s exactly what I mean. They find no need for modules when you have classical inheritance.
- ihm 9y agoUsing the object system in OCaml is super rare in my experience and using modules to structure code is way more common. They are also two somewhat orthogonal features of the type system: objects don't contain types, they are just values.
- zeckalpha 9y agoYikes, the OCaml I worked on must be pretty unusual then.
- jon_smark 9y agoQuite on the contrary: The OO part of OCaml is hardly used at all in the wild!
- vilhelm_s 9y agoI think a lot of the people who are enthusiastic about the ML module system are either faculty, students, or alumni from Carnegie Mellon University (including the author of this blogpost), and the same set of CMU people have also done a lot of work on defining and teaching Standard ML.
- willtim 9y agoPerhaps if it were taught to CompSci students elsewhere in the US, they'd be more advocacy?
- pjmlp 9y agoIn Europe, they are are taught at quite a few unis. We had classes about C++, Pascal, x86 and MIPS Assembly, Smalltalk, Caml Light (OCaml had just been released as Objective Caml), Lisp, Prolog, Java (on my last year there). Those that ventured into the optional compiler design classes, like I did, even had more languages to look at, like Algol, PL/I, Oberon and a few esoteric ones. So it always feels strange to me when universities don't take this approach to teach what is out there, or where we come from.
- hajile 9y agoBecause Ocaml is easily the ugliest of all the ML languages. I will never understand why Ocaml became the popular one. SML is much more elegant in my opinion (and even adding all the good Ocaml stuff to SML still leaves a much more elegant language). The further reason is that SML is very popular in Academia (perhaps that is its downfall). The same holds true for things like lisp where Common Lisp is undoubtedly the most used, but scheme is usually an example language because it is more elegant (and with fewer warts).
- xfer 9y agoCan you define what you mean by "the ugliest"? SML is used in academics because the language is very well-defined(both semantically and typing rules) and all the fundamentals of typed functional programming, so it is preferred for teaching. Ocaml is a moving goalpost, and the language has no formal specification, afaik.
- hajile 9y agoThe fact that the implementation is the spec is a large part of the issue. Someone feels like adding a feature, so they just tack it on somewhere until the language has a million syntactic features littered everywhere. The experimentation aspect is nice, but to me, the final product is an unwieldy Frankenstein (though still better than many more popular languages). http://adam.chlipala.net/mlcomp/ http://adam.chlipala.net/mlcomp/ SML is nice enough as is, but the progress with Successor ML to gradually add the best of Ocaml on top is a very appealing option. As a personal gripe, both languages need better Unicode support.
- pjmlp 9y agoSpeaking from European universities point of view, when I was there everyone was using Caml Light, so when its new version came out, Objective Caml, it was natural just to upgrade there. Then you have countries like France, INRIA's home, where schools are proud to teach their students about local tech. INRIA also tries to connect with the industry, instead of being stuck in Academic stuff.
- brmgb 9y agoMost likely because there is plenty of actual production code using modules written in Ocaml and modules are such a key part of modern idiomatic Ocaml no one seems to think that writing blog posts and exemples outside of teaching material is interesting. Ocaml users are generally more interested into writing software than promoting the language. You will find plenty of exemples in the Ocaml manual (the whole chapter 2 is on the module system [1]) and beginner focused books however (chapter 4, 9 and 10 of Real World Ocaml [2]). Functors (parametrized modules) are routinely used in production Ocaml code. Ocamlgraph [3] is a famous exemple (it's used by Frama-C and pff) because they wrote a paper on using functors to build generic library in 2007 [4] but they are literally everywhere : Janestreet Core, Facebook pff, Facebook infer, Frama-C. [1] http://caml.inria.fr/pub/docs/manual-ocaml/moduleexamples.html http://caml.inria.fr/pub/docs/manual-ocaml/moduleexamples.ht... [2] https://dev.realworldocaml.org/toc.html https://dev.realworldocaml.org/toc.html [3] http://ocamlgraph.lri.fr/index.en.html http://ocamlgraph.lri.fr/index.en.html [4] http://www.lri.fr/~filliatr/ftp/publis/ocamlgraph.ps http://www.lri.fr/~filliatr/ftp/publis/ocamlgraph.ps