Subj : Re: OO compilers and efficiency To : comp.programming From : Jon Harrop Date : Tue Jul 26 2005 01:12 am Scott Moore wrote: > Jon Harrop wrote: >> The poor performance of Java relative to OCaml just goes to show that >> having hundreds of compiler-writers in big business is not as good as >> having a single good language designer. > > You all have been giving OCaml a lot of press here. Whats good about it? A > look at Wakypedia shows that it needs lots of odd puncuation and "let", > which I thought went out with Basic. Plus the example is clearly for an > interpreter (it has a shell specifier at the top). Why don't you tell us > what makes OCaml so much better, instead of just repeating it like a > mantra ? Sure. I have already published quite a bit of information on this for free on the web. For hackers familiar with other languages, it is instructive to start with some interesting programs written in OCaml in order to see how concise OCaml code is. I wrote a little maze generation program in OCaml which renders its result using OpenGL and outputs PostScript: http://www.ffconsultancy.com/free/maze/index.html The following web page describes a simple OCaml ray tracer of mine which visualises the result using OpenGL: http://www.ffconsultancy.com/free/ray_tracer/ I cut this ray tracer down to a 57-line OCaml program which implements the main parts (e.g. hierarchical spherical bounding volumes) in order to compare equivalent implementations in different languages. The following pages discuss four progressively more optimised implementations in C++, Java, OCaml and SML: http://www.ffconsultancy.com/free/ray_tracer/comparison.html http://www.ffconsultancy.com/free/ray_tracer/comparison_cpp_vs_sml.html http://www.ffconsultancy.com/free/ray_tracer/languages.html I have written a book called "Objective CAML for Scientists" which discusses the benefits of OCaml in the context of scientific computing: http://www.ffconsultancy.com/products/ocaml_for_scientists/ Several parts of the book are freely available on-line including the whole of the first chapter, OpenGL examples: http://www.ffconsultancy.com/products/ocaml_for_scientists/visualisation and complete example programs: http://www.ffconsultancy.com/products/ocaml_for_scientists/complete Another useful source of OCaml code is the shootout: http://shootout.alioth.debian.org From the shootout, OCaml is clearly an unusually concise, high-performance language. In summary, I'd list the following positive attributes of OCaml code: 1. Robustness (particularly static type checking) 2. Brevity (particularly type inference) 3. Speed 4. Portability 5. Simplicity 6. Compatible byte-code and native-code compilers 7. Functional or imperative 8. Easy-to-use lexing and parsing tools If you'd like to select which of those benefit you the most then I can go into more detail. For example, do you already know what functional programming is and why it is useful? -- Dr Jon D Harrop, Flying Frog Consultancy http://www.ffconsultancy.com .