|WikiProject Computing / Software / CompSci||(Rated C-class, Mid-importance)|
- 1 Neutrality contested
- 2 Too complicated examples
- 3 Bottles of beer
- 4 Website
- 5 "Ocaml" to "O'Caml programming language" move
- 6 Requested moves
- 7 On Commercials in this article
- 8 Reorganization
- 9 Links to books
- 10 Thanks
- 11 Checked exceptions
- 12 Libraries
- 13 Case
- 14 Move to Objective Caml
- 15 On example code and OOP
- 16 Applications
- 17 Errors when trying the Examples
- 18 Link spam
- 19 Functors
- 20 eagerness
- 21 Pronounce?
- 22 Killer apps?
- 23 Stuff removed from Boolean data type article
- 24 Benchmark data
- 25 Name: OCaml
- 26 Opa Language
- 27 Higher-order functions and type inference
- 28 Facebook and hack usage
A fair portion of this page reads a lot like an advert, between the "colorful" descriptions, performance quotes from one of its developers, and thinly veiled trash talk about other languages... there's a lot of good information in here, but reading this article left me with a pretty bad taste. I notice some of the other discussion bits talking about what the "C/java/perl/python passerby" would think, so here you have it. Sorry if this comes off badly, but a lot of this article looks like a sales pitch to me- the programming examples section, however, is quite good; nice work there. -Sovereign —Preceding unsigned comment added by 22.214.171.124 (talk) 04:16, 7 September 2009 (UTC)
- I just took a quick look at the intro and opening sections of the article and I'm not sure I see what you're talking about. In particular, I think the references to other languages are purely factual and not at all "trash talk" (e.g., Java does require explicit type annotations, dynamic language do suffer a performance penalty from runtime safety checks). Could you cite specific POV passages? If the performance quote is problematic, we could cite the performance measurements reported here. There's also some benchmark numbers ("Ray tracer language comparison") reported by Flying Frog Consultancy, but their site is blacklisted by Wikipedia for some reason. Clconway (talk) 01:16, 8 September 2009 (UTC)
- I don't see the problem either. I can't immediately see anything in the article that isn't objectively correct. OCaml is a pretty well-designed language, so the article does come across as quite positive -- and what's wrong with that? Unless more support can be provided for the assertion of non-neutrality, I'll remove the tag in a few days. --David-Sarah Hopwood ⚥ (talk) 04:22, 25 September 2009 (UTC)
- Here comes number three... There is NOT a problem with the neutrality of this article. Personally, I don't much like the OCaml language (I'm a Java/Scala developer) but I do not have a problem with this particular DESCRIPTION of OCaml. It seems fair and unbiased to me. It would be nice to add a small "Drawbacks of OCaml" section, written by someone who uses OCaml extensively AND uses at least two other common languages (ex: C/C++/Java/Perl/Python/Objective-C/Ruby/Erlang/Haskell/Scala) -- I suggest this issue be resolved at this time, as the vote now stands 3 to 1 in support of sufficient neutrality. _ _ - Brymancer (talk) 20:25, 8 November 2009 (UTC)
- A good place to start for drawbacks might be Brian Hurt's blog post "How OCaml Can Be Improved" (née "Why OCaml Sucks"), which is a constructive critique of the language from an experienced OCaml programmer. There's also OCaml Language Sucks by Sam Steingold, which is a bit less measured. Probably the biggest drawback—one that is recognized by the language designers—is that OCaml has poor support for multiprocessing. Jon Harrop has written a lot on this subject, but his website seems to be on the WP blacklist. Clconway (talk) 17:03, 9 November 2009 (UTC)
Too complicated examples
I don't think it is very pedagogical to start off the examples with the quicksort algorithm. To get a feel of the language the first example should be extremly simple. I suggest a small program that sums the numbers 1 to 10.
Bottles of beer
Um, isn't x bottles of beers wrong? Shouldn't it be x bottles of beer?
- -- thanks gmarceau
The new version of bottle-of-beer uses the "and" keyword, as well as extra indentation. I fell this make the code unnecessarily intimidating to a passer by, who, we assume, doesn't already know Ocaml. In languages other than Ocaml "and" is usualy a boolean operator, and indentation is usually used to indicate flow of control, rather than to indicate lexical scope. Avoiding these two constructs make the meaning of the rest of the code easier to guess (don't you think?). -- gmarceau 03:07, 14 Sep 2004 (UTC)
- I like my bottles of beer example better, it is shorter and much more obvious, and also demonstrates tail recursion. Is there any consensus on which is clearer? I we keep the new one we should probably explain it better, especially the ^ operator. --Nick Nolan 04:59, Sep 14, 2004 (UTC)
- Again, I am thinking of this in term of a passer-by who doesn't know Ocaml, and who is more likely to be familliar with one of C/Java/Perl/Python. The new version might be longer, but it showcases some idioms done in Ocaml, such as string slicing, pattern matching and procedure invocation. Hopefully, it's all guessable. I fell that (^) is guessable simply because 3 of the 4 popular languages each have a different symbol for string concats.
- By using a tail recursion in place where a simple for-loop would do, the cannonical passer-by could reasonably guess that Ocaml is an twisted academic language which shy away from mundane "normal" loops. The for-loop is simply make Ocaml look less intimidating.
- On the other hand, I agree that tail recursion deserves a demonstration, with a link to its wikipedia article. Can we think of a third example? -- gmarceau 15:38, 14 Sep 2004 (UTC)
Unless we mention that Haskell was derived from ML, the see-also link to Haskell doesn't appear relevent to the reader. How about "Haskell is a non-strict member of the ML-familly"?
- The Inria people went to great length to support Posix functions and the associated coding style. I think the ocaml reimplementation of printf is the best example of that effort, particularly because many high-level programming languages miss it. The technical discussion of the distinction between a system call, a C library call or an Ocaml reimplementation should not detract from the main point, which is that Ocaml support a standart-Posix coding style. Maybe some rewording is warranted? --gmarceau 14:07, 24 Jun 2004 (UTC)
- Regarding POSIX, I've just done some rewording in which one of the changes was from "POSIX functions" to "familiar functions". I think this captures the essential fact (OCaml provides features which will be familiar to C programmers as well as all the neat functional stuff), without making the incorrect claim that OCaml's Printf.printf is the same as the POSIX function of the same name.
- In that case, why does the introduction say "Like all descendants of ML, OCaml is ... strictly evaluated ... ."? 126.96.36.199 04:27, 10 January 2006 (UTC)
- Is belonging to the ML family same as being a descendant of ML, I don't know. The page on Haskell programming language says: "The direct predecessor of Haskell was Miranda from 1985." And the page on Miranda programming language says: "Miranda is a non-strict purely functional programming language developed by Professor David Turner as a successor to his earlier programming languages SASL and KRC, using some concepts from ML and Hope." Perhaps Miranda and Haskell belong to the ML family in law. At least the syntax and the type system are similar. --TuukkaH 05:39, 10 January 2006 (UTC)
As far as I know, Ocaml is not used as an introductory language in Pisa University. Could you please cite your source for this information?
- I am not the author of the phrase but I can say that in Pisa Ocaml has been used in the very first (theoretical) course on programming for a couple of years some time ago - then they switched to java. Ocaml is still used as a meta-language for an advanced - but obligatory for one of the two second-level degrees - course on programming languages held by prof. Levi: http://www.di.unipi.it/~levi/corsoLP/pagina.html
- The first non mathematical course I took on my first year at Pisa University was "Programmazione 1" where OCaml was used to give a first explanation of type systems, grammars, automata and operational semantics. This is a preliminary version of the program for that very course for the year 2009/2010 http://compass2.di.unipi.it/didattica/inf/share/corsi/corso.asp?id=3041&cds=INF31&anno=2009
I don't see why we label ocaml.org as the "unofficial" website, and caml.inria.fr as the "official" website -- the former site says nothing about its unofficial status. Also, caml.inria.fr describes the CAML language family -- I think www.ocaml.org, which is specifically about Ocaml, should be listed first. Neilc 07:28, 11 Jul 2004 (UTC)
- The reason ocaml.org is labelled "unofficial" is that it is unofficial. This is a simple and straightforward fact. It is also very outdated (the most recent news item is the release of 3.07!). Do you really think we should be giving prominence to a site that is not being actively maintained, over one which contains the up-to-date information straight from the horse's mouth?
- (FWIW, as of March 2005 this no longer the case; ocaml.org now redirects to the official site.)
The ocaml.org website has been completely redesigned (2013) and has far more up to date content than the old caml.inria site. As such, I propose to re-order the links on the right sidebar to put ocaml.org *before* caml.inria.fr. Would anyone object to this? Eventually the caml.inria site will be marked as deprecated, at which time, I'll propose that we remove that link (but not yet). AmirMC (talk) 17:36, 6 February 2014 (UTC)
"Ocaml" to "O'Caml programming language" move
Why was this page moved? I can think of nothing else called "Ocaml" which might potentially warrant disambiguation, and policy dictates that pages reside where they'd most commonly be looked for; cf. Fortran. Moreover, the language is Objective Caml, OCaml, or Ocaml; it is pronounced "O'Caml," but never spelled as such in text (barring one appearance at the head of this article, which should really be clarified). I am moving it back for the time being; feel free to make your case here. Austin Hair 01:35, Aug 16, 2004 (UTC)
- Agreed. Unless somebody points out to a good reason for the move, the page should be repatriated. David.Monniaux 08:08, 16 Aug 2004 (UTC)
- I don't agree that "it is never spelled as [O'Caml]". Look at http://www.ocaml.org/, for example: the title of the page is "Welcome to the O'Caml language". Admittedly the <title> is "The OCaml Language", but it seems either spelling is acceptable. However, the "Ocaml" form seems significantly less common -- IMHO it should not be the title of the article. Neilc 08:21, 16 Aug 2004 (UTC)
- Granted, that blanket statement was (as most are) inexcusably inaccurate; nonetheless, "O'Caml" is probably the least common form, and certainly not the preferred one. I do agree that OCaml is where this article should rightfully lie, but as that page has a four-edit history, I chose to simply repatriate (to borrow David's term) the article and wait for consensus to be reached before asking for admin intervention. Austin Hair 12:16, Aug 16, 2004 (UTC)
- What ocaml.org says is irrelevant, because that is not the official site. The form used on the official site is OCaml. A better choice for this article, IMO, would be the full name, "Objective Caml".
How about the following:
- Move Ocaml to Objective Caml programming language.
- Move Talk:O'Caml programming language to Talk:Objective Caml programming language.
- Fix redirects etc.
This would avoid debate over the spelling of "OCaml" vs. "Ocaml" vs. "O'Caml". Whether "...programming language" should be part of the title is a matter of discussion; we should go with whatever is the standard for programming language articles. --MarkSweep 02:33, 29 Apr 2005 (UTC)
- Actually there's no need for a debate over the spelling: it's OCaml, as mentionned in the FAQ on the language's site: We write Caml and OCaml.
- !/usr/bin/env ocaml
is more generic than #!/usr/bin/ocamlrun ocaml
On Commercials in this article
Looking at the article in its present state, there are 16 external (non-wikipedia) OCaml-related links in it. Seven of them point to http:// www.ffconsultancy.com, and all of them seem to have been made by a user from the IP 188.8.131.52, which resolves to jdh30.plus.com.
Doing a bit of research, this is the machine of the owner of ffconsultancy.com, Dr. Jon Harrop. This brings up the question whether we actually see here a violation of Wikipedia:What_Wikipedia_is_not rules, as this article might be abused for self-promotion and advertising issues. Doubly so, as there is quite some consensus of Jon Harrop showing quite undue behaviour on the usenet as well as some mailing lists, alienating large parts of the functional community.
I therefore strongly suggest deleting all references to ffconsultancy.com from the article.
- Motion seconded, carried, and implemented. --MarkSweep (call me collect) 22:58, 26 October 2005 (UTC)
I just re-added many of the links before I read this. I am happy to have the direct links to commercial products removed (the OCaml book and Presenta) if this is against Wikipedia policy (note that Wikipedia references many other books though - perhaps we should add a references section?). However, I see no sense in removing links to free software written in OCaml that happen to be available from the same site, particularly the maze generator, ray tracers and example programs from scientific computing. I have also added some links to other OCaml-related pages. If I can provide any useful information, please contact me (the objection was made by Thomas Fischbacher). - Jon Harrop <email@example.com>.
I just updated the page a little more, replacing the link to an OCaml book with a link to INRIA's page of OCaml books (that includes my own). I have also added links to other Wikipedia pages about companies that use OCaml (not including Flying Frog Consultancy ;-). MarkSweep, can you explain the logic behind keeping many relatively-unknown OCaml programs like DrGeoCaml but removing what is possibly the most famous OCaml program, FFTW? It seems like a great shame to omit a link to this fantastic piece of software! - Jon Harrop
I've reintroduced the reference to FFTW. Many people don't realise this program is written in OCaml because it generates C and Fortran, this is probably why it was deleted first time. To anyone who wants to confirm this the FFTW website mentions it in the FAQ section. - Jrthorpe
Jon Harrop recently reorganized most of the features and "philosophy" text in this article into a list form. I don't think this is a good way to present the article; an encyclopedia is supposed to explain things, but a bullet-list of features just presents a collection of facts. A lot of work is needed on this article, but I think our model should be the excellent Python article.
I remerged the improvements to links and other small things that were included, but let's think through the main body of the article a little more. --Mike Lin 08:11, 31 October 2005 (UTC)
I agree that the article needs a lot of work but I think undoing my alterations is another step in the wrong direction. The old text that is at best misleading and at worst factually incorrect. I'll go through some of it:
"ML-derived languages are most well known for their strict type systems" - conventional nomenclature is static type systems, not "strict", and it should link to the Wikipedia page on static typing (as mine did). If you need more information on conventional nomenclature then I suggest my book on OCaml (proof read by Xavier Leroy, the lead developer of OCaml).
"Like Python and Perl" - I think OCaml should be discussed in its own right with links to relevant Wikipedia articles on its features (i.e. it should not include yet another subjective discussion of topics that already have dedicated pages with more detail). Many languages (e.g. SML, Lisp, BASIC) provide a top-level, why liken OCaml to Python and Perl?
"Many high-level programming languages, even when compiled to native code, achieve slower performance than might be possible with C/C++ because of runtime type and safety checks" - this discussion of the performance hindrance of dynamic typing does not belong on the OCaml page.
"OCaml's strict type system renders runtime type mismatches impossible" - Strong typing checks for type mismatches. Static typing checks for them at compile time. It may be worth noting that not all OCaml programs are type safe.
"OCaml's strict type system eliminates a large class of programmer errors that may cause problems at runtime" - Static typing!
"the OCaml compiler can infer types, greatly reducing the need for manual type annotation" - you can always have your types inferred in OCaml, so I had replaced "greatly reducing" with "eliminating".
"as they do in Java" - again, I dislike random references like this. Type inference has already been discussed more thoroughly elsewhere, so we should reference that page and not cut and paste it or write a worse version here.
"A preprocessor and macro language named Camlp4 which permits syntactical extensions" - camlp4 can also be used incrementally in a top-level. I have a nice camlp4 example that perhaps I should post in the Code Examples section.
"Applications..." - if we are not allowed to cite what is possibly the most famous piece of software written in OCaml (FFTW), I see no point in having the "Applications" and "Programs written in OCaml" sections. Perhaps these should be removed and replaced with a practical discussion on applications which stand to benefit the most from the use of OCaml. However, that is likely to be a biased and subjective view which (AFAIK) is against Wikipedia policy.
"Natural science..." - now that my links have been removed (not by Mike Lin, AFAIK), this subsection conveys no useful information. It should either be removed or the links replaced with more appropriate ones.
Finally, I had added a discussed of some of the most important points in the context of OCaml (e.g. safety, brevity, modules, pattern matching, separate compilation) but these have all been removed by Mike. Although I think a list is easier to digest that paragraphs of text, I wouldn't have minded so much if my list had been replaced with paragraphs of text. However, I see no merit in Mike having removed my corrections and additions. - Jon Harrop
- Valid points mostly. I just think your thoughts should be reorganized in an expository paragraph form; no one wants to or will read bullet points of unrelated technical facts. Consider my revert an invitation to add your changes back in a better way. --Mike Lin 18:28, 31 October 2005 (UTC)
- Well, bullet points are much easier to read than paragraphs of texts. I see it as a chance when it is possible to do so. It is always possible to expand them as dedicated sections with a title, without having to rewrite the whole paragraph or the whole article. That's not because most scientific articles are written in a way which makes them more difficult to read in order to make them look deeper that it's a good thing to do. Even better than bullet points are diagrams, with colors, but that's even more work. --Martin.jambon 19:03, 3 November 2005 (UTC)
- I have to concur with Jon and Martin here. Sometimes a list is the best way to describe things. I find Jon's bullet-points much easier to follow than a dense paragraph of text, and splitting the feature list into bullet points makes it much, much easier to explain individual features. — Haeleth Talk 19:22, 3 November 2005 (UTC)
- Jon's list is very easy to read and understand as long as you already know everything that's on it, as I think each of us do. But approach this from someone without much PL background just trying to obtain general knowledge about OCaml: you are presented with a bullet list of technical terms with terse, one-sentence quasi-explanations.
- Let me stress that by no means is the current paragraph-form content of this article satisfactory. But we do need prose explanations that don't assume mastery of PL jargon (see WP:manual of style and WP:guide to layout). Again I refer to the excellent articles on Python and Java as models. --Mike Lin 20:40, 3 November 2005 (UTC)
Thanks for joining in, guys. So we all agree that a bullet point list is better for us language-heads. I agree with Mike that prose is the best way to give a fuller explanation, especially for people not so familiar with different languages. So I suggest that we replace the current "Philosophy" with a bullet point list giving links to the full, generic explanations of each feature/property of the language and we can then elaborate in an OCaml-specific way on particular features (e.g. ways to leverage OCaml's static type checker) in prose. The Wikipedia guidelines do say that articles should be unbiased, so I think it would be better for us to be completely objective and, particularly, avoid subjective discussion of the philosophy behind OCaml, at least to begin with. - Jon Harrop
- I think that sounds like a reasonable compromise; let's see how it looks. As for the "Philosophy" section, I think something of the sort belongs; for example, I liked Gerd Stolpmann's ideas about the basic motivations underlying the language, which I'm reproducing here for reference (obviously not saying we should use this literal text).
In the first place, O'Caml is a research language where scientists enhance ML in a sound way, and implement it such that it is practically usable. The article mentions the "strict type system" several times, but that remains mysterious and somehow ensures that there are no runtime errors. Actually, there is a lot of theoretical work behind that. The type system is actually a calculus that has some properties (e.g. there is always a principal type if you don't use subtyping - which explains something, in particular that the compiler can always deduce a type if possible at all). At least, I would expect that such an article lists the most important properties of type checking and evaluation (the article does not even mention that O'Caml is an eager language).
If O'Caml has a revolutionary aspect, this can only be that the developers do not allow that practical benefits destroy theoretical soundness, and that O'Caml is nevertheless extremely well-suited for practical problems at the same time. If that was the motto of the article this would have my consent.
- --Mike Lin 20:15, 4 November 2005 (UTC)
Links to books
I just added links to four different books on OCaml. In order to prevent "link spam" I removed the one remaining link to freely-available code and information about OCaml (the ray tracer) from our company site. - Jon Harrop
I just wanted to say thanks to everyone who's contributed since my request, especially Mike Lin for his recent overhaul. The page is vastly better now! One small point, the page says "Code generated by OCaml's native code compiler can, in fact, approach the performance of C/C++ on algorithmic tasks". Actually, for many non-trivial programs, OCaml is often much faster than C++, e.g. it can be faster for set union. - Jon Harrop
- tr1::auto_ptr solves any reasonable worry over copying, and you really should check with more than one implementation of std::set_union, you know. There are probably even (non-standard) functions for calcuating set unions that are significantly faster than OCaml. Referential transparancy is nice, but not a pancea. I have no argument about the prettyness of the code though :) 184.108.40.206 04:23, 10 January 2006 (UTC)
Immutable sets could be implemented in C++, of course. They would probably be much more complicated to implement but should be at least as fast as OCaml's built-in Set module (this would be an interesting exercise). However, it is interesting to compare the provided functionality, namely OCaml's Set module and the STL. Finally, auto_ptr is a long way from garbage collection. - Jon Harrop
The article on exception handling on one hand describes how there are external checkers to see that all exceptions are handled in OCaml, and on the other hand says that OCaml has checked exceptions. I don't know OCaml, but my guess is that the language as it is doesn't have checked exceptions. You could clarify the situation in both articles. Thanks. --TuukkaH 22:14, 15 December 2005 (UTC)
I just made a minor edit to the "wide variety of libraries" line. It sounded a little odd to me, considering the breadth of other stdlibs available with, say, Java. Was this warranted? Scotto 20:55, 13 January 2006 (UTC)
Firstly, I think we should either say "wide variety" or just "variety", there is no point in saying "moderate variety". In this specific context, I believe OCaml provides strictly more functionality than Java (and C, C++ etc.) in terms of arbitrary precision arithmetic (i.e. rationals). OCaml's stdlib also provides a lot of other functionality not found in the standard libraries of other languages (e.g. immutable sets, lazy evaluation, streams, lexing, parsing, unix calls). Ultimately, we should probably enumerate the features provided by OCaml's stdlib and give links to other external libraries rather than argue about whether or not to use the word "moderate". -- Jon Harrop
- With perl4caml, OCaml's libraries are a strict superset of Perl's libs, which I'd say makes them pretty extensive. Richard W.M. Jones 09:21, 6 March 2006 (UTC)
I just made a minor edit to the Triangle (graphics) example, "simple.ml". At least on Unix systems it is important to get the case right: +lablGL instead of +lablgl. Cragwolf 02:26, 7 June 2006 (UTC)
Agreed. I'm using Debian, which installs both lablgl and lablGL. Presumably other distros don't? Jon Harrop
- I installed from source, and that process installs lablGL as default, although I suppose you could configure it to install lablgl. Cragwolf 00:53, 9 June 2006 (UTC)
Move to Objective Caml
- Add *Support or *Oppose followed by an optional one-sentence explanation, then sign your opinion with ~~~~
- Add any additional comments
On example code and OOP
The article is just plain great for introducing anyone to this wonderful language. I myself used it as a launch point three months ago and I just completed an 3000-line compiler as a term essay using ocaml. A big thanks to all contributors!
Now, what I am writing here about is the example code snippets in the text. To my understanding, the major difference between OCaml and the previous camels is that big 'O' at the beginning of the name. However, code snippets in the article do not show any of ocaml's object oriented features. After writing my compiler and using absolutely none of the OOP features of OCaml, I do wonder how they are so important to make Caml into OCaml. If I knew how the OO paradigm is used in ocaml I'd go write an example myself, but I don't, so I ask of someone more knowledgeable than me to do so. Again, thanks guys for a great article! --Michalis Famelis (talk) 16:04, 29 July 2006 (UTC)
Thanks! Most of the examples came from my book, although I see that Qwertyus has deleted half of them (was that deliberate?). Perhaps we should add an interpreter as an example? PS: I also do not know when and where OOP is useful in OCaml. -- Jon Harrop
- I moved all non-Objective Caml-specific examples to Categorical Abstract Machine Language. Qwertyus 21:23, 30 July 2006 (UTC)
- I think that was a bad idea. Caml is a dead language. Those examples were written and tested in OCaml. Objects are not the only difference between Caml and OCaml. -- Jon Harrop
- It appears to me that there is no object-oriented code at the moment. (The OpenGL examples don't show the paradigm.) Could someone add an example? 220.127.116.11 07:51, 28 September 2007 (UTC)
The languages used in Classes Préparatoires in France are many, and depend on the type of Classes Préparatoires considered. However, Objective Caml is not used in any significant way: speciality Computer Science courses are taught in Caml Light (official requirement, as far as I know), non-speciality Computer Science courses in scientific Classes Préparatoires are given in a mix of Maple and Java (no official requirements there), while Computer Science in commercial Classes Préparatoires is done in Pascal. --ToohrVyk 13:53, 14 October 2006 (UTC)
Errors when trying the Examples
In the example it state "compile to byte code" Should that really state byte code and not machine code?
- "Byte code" is correct.
ocamlcis the byte code compiler;
ocamloptis the native code compiler. It makes no difference which you use for this example. Clconway 21:27, 3 September 2007 (UTC)
I don't know enough OCaml to be 100% sure, but shouldn't the last line in the Birthday Paradx Example end with two semi-colons?
birthday_paradox 1.0 1 ;;
Also, the factorial example gives an error when I try it:
# let rec fact n =
if n =/ Int 0 then Int 1 else n */ fact(n -/ Int 1);;
Unbound value =/
BioGeek 22:46, 29 January 2007 (UTC)
The birthday paradox snippet is a script designed to be run from file. My factorial example requires you to load the Num module, the details of which are given in the section I wrote. -- User:jdh30
Quicksort implementation in article is not proper: slow and runs out of stack space really fast. The proper way to implement quicksort would be something like
let rec qsort ?(acc=) = function |  -> acc | [h] -> h :: acc | h :: tl -> let part1, part2 = List.partition ( (<) h) tl in qsort ~acc:(h :: qsort ~acc:acc part1) part2
The rotation matrix should be reset before drawing each frame, otherwise errors accumulate. See http://caml.inria.fr/pub/ml-archives/caml-list/2007/04/c8c30ba5b7e7f446cbb789cd50c052eb.en.html. I fixed it. --Martin 20:39, 12 April 2007 (UTC)
This example still suffers from a worse problem: the animation is a function of the CPU time elapsed rather than the real time, so the speed of the animation is dictated by the load on the computer. Given the current climate of people deleting my contributions from Wikipedia, I'm just going to refer anyone wanting good code to the original source, the visualization chapter from [http:// www.ffconsultancy.com/products/ocaml_for_scientists/visualisation/ OCaml for Scientists] which is (C) Flying Frog Consultancy Ltd. 2005. Jon Harrop 21:20, 13 April 2007 (UTC)
I've been trying to add my OCaml book to the "books" section of this page but Wikipedia are threatening to blacklist me and ban me from editing. If anyone knows how to fix this then I'd appreciate it... -- User:jdh30
- This is fixed easy enough: don't advertise yourself.
- Regarding your cite: First, please demonstrate why this particular facts need citation, and how your own (self-published?) book as a source meets WP:A. Femto 12:02, 9 April 2007 (UTC)
- The same reason that my PhD thesis warrants citation for work relating to my research, these are the only sources for this information. To the best of my knowledge, there are no other resources detailing optimization in OCaml to the extent that my book does. Jon Harrop 12:59, 9 April 2007 (UTC)
- The point is that what you write in your thesis or your books provides no encyclopedic verifiability beyond what you can write here as a common editor, the same person. Leave it to independent editors to determine whether your work warrants citation, per Wikipedia's neutrality policy, it's not yours to decide. Besides, if there are no other resources, your work might be original research on which Wikipedia's content should not rely at all. Who publishes your work, who reviewed, who confirms that you're a well-known, professional researcher in your field? Until this is established, you should refrain from attributing content to yourself, especially since you earlier added links that may be considered blatant advertising. Femto 14:48, 9 April 2007 (UTC)
- Yes. I am not contesting the fact that I added too many links from Wikipedia to our site (I won't do it again). I am contesting the fact that I was reverting Requestion's vandalism (that was directed specifically at my work and not at links to books in general). I doubt a revert warrants the editorial process.
- As for my personal credibility, all the information you want is available on our company site. Our company publishes my books. OCaml for Scientists was proof read by Xavier Leroy (the lead developer of OCaml) and testimonials from many other readers are on the book's web page. The internal examiner for my PhD was Professor Alan Windle, who described my work as "scholarly". The whole thesis is freely available on-line at the URL that Requestion deleted. Jon Harrop 15:26, 9 April 2007 (UTC)
I noticed that the link to the "Books about OCaml" page on the official OCaml site no longer works (it now just leads to the home page). That's unfortunate, as linking only to that page seemed to be a reasonable solution to me. In the absence of that I agree with parts of both sides of this argument, in that we need to link to all of the books or none of them. But is there such an index to OCaml books page on ocaml-tutorial.org? Say, that's a wiki...hint, hint. --Mike Lin 13:37, 9 April 2007 (UTC)
- Yes. I'm much happier to see equal treatment of external links. I've deleted the broken link BTW. I think this article already has too many miscellaneous links at the bottom so I'm not going to add another one to a books page. Readers can Google for them. Jon Harrop 15:26, 9 April 2007 (UTC)
- Would this be a replacement link? http://caml.inria.fr/about/books.en.html Since it's not WP's purpose to be such a directory, an external link to the official page would be clearly preferable to a listing in the article. Femto 15:01, 9 April 2007 (UTC)
- That book list is out of date: it lacks Practical OCaml and OCaml for Scientists. Probably better to not even refer to a list of books. People can find them easily enough using Google or the OCaml-specific Wiki that Mike cited. What if I put an up-to-date book list on ffconsultancy.com? ;-) Jon Harrop 15:26, 9 April 2007 (UTC)
Why does Functors link to function object in the article? As stated in the parens a functor in ocaml is a parametric module and not some kind of function object like a closure. —Preceding unsigned comment added by 18.104.22.168 (talk) 22:49, 16 October 2007 (UTC)
- OCaml is strict/eager/call-by-value, which makes it completely unremarkable, as this is by far the most common choice in mainstream programming languages. The standard support for laziness through lazy/force may be notable. Clconway (talk) 01:29, 24 November 2007 (UTC)
- The pronunciation is "oh-Camel". Clconway (talk) 01:39, 12 November 2008 (UTC)
- Added a note to the beginning of the article. Clconway (talk) 13:10, 12 November 2008 (UTC)
- I think the notion of "killer app" isn't applicable here: a "killer app" is usually an application that drives users towards a platform/OS. The only programming language I can think of that really has a "killer app" is Ruby and Rails: people use Ruby (whatever its advantages/disadvantages) in order to gain access to the Rails framework. The most well-known open source applications written in OCaml are probably Coq, Ocsigen, and Hevea. None of them are "killer" in this sense. In my little corner of the world CIL is close to being a "killer app"—it is far and away the nicest, easiest way to write analyses for C programs and you have to use OCaml to take advantage of it. (But, of course, my little corner of the world is very, very little. Not very "killer".) Clconway (talk) 17:31, 2 January 2009 (UTC)
Stuff removed from Boolean data type article
The following section was removed from the article Boolean data type:
begin removed text
Ocaml has a
bool type that has
# 1 = 1 ;; - : bool = true
Like other enumerated types, a value of this type uses a word of memory.
Adrianwn recently changed
- Xavier Leroy has cautiously stated that "OCaml delivers at least 50% of the performance of a decent C compiler", and benchmarks have shown that this is generally the case. (Cite: Computer Language Benchmarks Game)
- ... but at least some benchmarks have disproven this claim.
Indeed, it seems the results at the linked page show slowdowns between 2x and 325x (with most slowdowns being 7x or less). I believe the results of the Computer Language Benchmarks Game are dynamic and subject to change. I assume the original wording was correct when it was first inserted and in the meantime somebody uploaded some very clever C implementations.
I think the current wording is too strong, since the benchmarks are, by their own admission, a flawed comparison. I'm going to leave a link to the benchmarks in the "See Also" section, but refrain from characterizing the results in the body of the article. Clconway (talk) 17:32, 13 April 2010 (UTC)
- If I understand Xavier's claim correctly, what he really means is more like: if you take a C program in the subset of C that is comparable to OCaml (e.g., no nasty pointer casting/arithmetic) and transliterate it into OCaml, then the overhead you'll pay (e.g., in array bounds checks, etc.) is about 50%. Understood this way, it's a fairly weak claim. Clconway (talk) 17:41, 13 April 2010 (UTC)
- I agree with you that those microbenchmarks don't provide any real evidence for such a general claim as made by Xavier, and the weaker claim is even more difficult to prove. In fact, I propose that the complete paragraph is removed:
- the benchmark part: see above
- "Some functions in the OCaml standard library are implemented with faster algorithms than equivalent functions in the standard libraries of other languages." – this statement is rather dubious and vague: some functions in some implementation are faster then the same functions in some implementation of some other language
- the implementation of set union: at the very least, this needs references and more detailed description of the parameters (e.g. what standard library implementation, what version number)
- I thought about improving it when I edited the benchmark part, but I wasn't sure how, so I left it the way it is. – Adrianwn (talk) 06:27, 14 April 2010 (UTC)
- I agree with you that those microbenchmarks don't provide any real evidence for such a general claim as made by Xavier, and the weaker claim is even more difficult to prove. In fact, I propose that the complete paragraph is removed:
- Unfortunately, this is even harder to verify than just comparing it with the performance of C, because a representative selection of high-level languages would have to be compared to OCaml. Now try to find non-OR sources for that ;-) But I see your point. We could write that the language has been designed with performance in mind, and give examples for design aspects that facilitate efficiency and how those aspects were exploited in certain implementations. After all, in the end it depends on the implementation in question, not just on the language itself. Adrianwn (talk) 06:14, 16 April 2010 (UTC)
Opa was recently added then removed from the "Derived Languages". I think Opa is notable and legitimately related (see, []), but I'm not sure it's really "derived". AFAICT, it the compiler was implemented in OCaml, the developers come from the OCaml community, and language extensions can be written in OCaml. Clconway (talk) 17:56, 10 October 2011 (UTC)
- I think there are two questions there:
- Is OCaml important to Opa (programming langauge)?
- Is Opa important to OCaml?
- Given the chronology, I expect that the second depends essentially on the first. If the first holds, then the Opa article probably wants a link to OCaml. I don't see that compiler implementation in OCaml is sufficient to demonstrate this - compilers do after all have to be implemented in 'something. Is there a reason why OCaml was chosen for this? Are the principles of Opa similar to those of OCaml? Is the technical implementation close between them, such that they're a natural fit? Are their languages as seen by application developers close to each other? If OCaml "is just good at writing compilers" though, that wouldn't be enough.
- The second constraint is harder - such relations should not be assumed to be commutative, as they often aren't. Is its use to implement Opa a significant aspect of OCaml itself? Is Opa "OCaml for web apps"? Is OCaml application syntax close to Opa syntax?
- Andy Dingley (talk) 19:34, 10 October 2011 (UTC)
Higher-order functions and type inference
When testing OCaml example code for the newly-added section OCaml#Higher-order_functions, I obtained answers from my Linux OCaml 3.12.1 interpreter that seemed counter-intuitive to me.
# let inc (x : int) : int = x + 1 ;; (* some toy int->int function to be operated on by higher-order fcts. *) val inc : int -> int = <fun> # let twice (f : 'a -> 'a) = fun (x : 'a) -> f (f x) ;; (* 1st higher-order function *) val twice : ('a -> 'a) -> 'a -> 'a = <fun> # let add2 = twice inc ;; (* apply it to (inc) *) val add2 : int -> int = <fun> # twice;; (* demonstrate that type of (twice) didn't get instatiated by applying it to (inc), as expected *) - : ('a -> 'a) -> 'a -> 'a = <fun> # let fourtimes = twice twice;; (* apply (twice) to itself to obtain 2nd higher-order function *) val fourtimes : ('_a -> '_a) -> '_a -> '_a = <fun> # let add4 = fourtimes inc;; (* apply that to (inc) *) val add4 : int -> int = <fun> # fourtimes;; (* demonstrate that type of (fourtimes) does get instatiated by applying it to (inc), why is that?! *) - : (int -> int) -> int -> int = <fun> # twice;; (* type of (twice) still uninstantiated, as expected *) - : ('a -> 'a) -> 'a -> 'a = <fun>
I wonder if it is ok that the type of fourtime changes after it has been applied to inc (3rd line from below). Could any OCaml expert check whether this is coherent with the language definition, and if yes, explain in the higher-order fct section, why? Jochen Burghardt (talk) 11:19, 14 June 2013 (UTC)
- For ulterior references, the problem was the value restriction: with the previous definition of "fourtimes", "fourtimes" was not polymorphic but had type "('_a -> '_a) -> '_a -> '_a". The underscore prefix in the type "'_a" indicates that this type is weakly polymorphic. In other words, "'_a" is not a polymorphic type variable but a temporary placeholder for an unknown at this time type. Applying "fourtimes" to "inc" told the compiler that this unknown type "'_a" was in fact "int". To fix this problem, a classical solution is to rewrite the definition of fourtimes to "let fourtimes f = (twice twice) f" in order to let the type system know that "fourtimes" is a function with no hidden mutable state. Octachron (talk) 14:58, 15 July 2016 (UTC)