Slashdot Mirror


Developing Applications With Objective Caml

Fahrenheit 450 (William D. Neumann) writes "Developing Applications With Objective Caml was originally published in French by O'Reilly, and later translated into English by a group of volunteers (note that the reviewer was a volunteer proofreader during the translation effort), and graciously made available online as HTML or PDF at the Caml website. For those not familiar with Objective Caml (or OCaml, as it is commonly called), it is a strongly, statically typed (but don't be thinking about Pascal-style typing), eagerly evaluated language with a functional core that also offers many imperative programming features. OCaml also has full support for object-oriented programming that fits in completely with OCaml's strong type system. On top of that, OCaml code can be interpreted for simple scripting, compiled to bytecode for portability, or compiled to native code for speed and resource utilization that rival even that of Intel's C++ compiler. Intrigued?" If so, read on for the rest of Neumann's review. Developing Applications With Objective Caml author Emmanuel Challoux, Pascal Manoury, and Bruno Pagano pages 742 publisher O'Reilly France rating 8/10 reviewer William D. Neumann ISBN 2841771210 summary A comprehensive book on Objective Caml, covering not only the core language, but also modules, objects and classes, threads and systems programming, and interoperability with C.

The Book The book itself is quite comprehensive, clocking in at over 700 pages and covering material ranging from an introduction to the language to concurrent and distributed programming. To organize all of this material, the book is broken into four main sections that build upon each other. Each section has a set of chapters that present some related concepts, followed by an "Applications" chapter that uses those concepts to create a few small applications such as a minesweeper game, a graphical interface library, a couple of different two-player games, a distributed robot simulation, and a basic HTTP servlet. These four sections are as follows:

I. Language Core
This section serves primarily as an introduction to the OCaml language, with chapters on the functional core and imperative aspects of the language, a chapter on the differences between the two styles that shows how the two can be melded, and a chapter on the OCaml Graphics module. The introduction to OCaml is complete enough that anyone with a background in programming should be able to achieve a good understanding of the basics of the language. Especially when combined with other freely available resources, like Jason Hickey's Introduction to Objective Caml , and Richard Jones' Learning OCaml for C, C++, Perl and Java programmers, one should be able to obtain a strong OCaml foundation to use while reading the rest of this book.

II. Development Tools
The second section covers, as the title states, the OCaml development tools. The chapters in this section provide information on the OCaml compilers, interpreter, and interactive toplevel environment; some of the libraries included with the standard distribution; OCaml's garbage collection mechanism; Ocaml's debugging and profiling tools; OCaml's versions of lex and yacc; and interfacing OCaml with C. This is perhaps the most valuable section of the book, as it provides good coverage of some important topics that are covered a bit too briefly in the OCaml manual.

III. Application Structure
This section covers the OCaml Module system, and its interface and functor (parameterized module) facilities. Also included in this section is a well written chapter on object oriented programming in OCaml, and a chapter comparing the two models of program organization, offering a brief look at how the two systems can be combined to reap the benefits of both.

IV. Concurrency and Distribution
The final section covers the topics that many folks might consider to be the "real world" programming topics: File I/O, process management and communication, concurrent programming using threads, and distributed programming. The coverage in this section is, again, well done, but perhaps a bit light, and it would have been nice to see more time spent on this subject matter. However, the book is already quite hefty, and the services provided by OCaml's Unix module should look familiar enough to most programmers that the material that is presented should be sufficient to get a competent programmer up and running.

The Upshot For the most part, Developing Applications With Objective Caml does a very good job at presenting the OCaml language in more of a "practical" light than other books on languages in the ML family (and functional languages in general). And while the applications that are constructed throughout this book aren't anything particularly great or interesting in and of themselves (a simple BASIC interpreter, a rudimentary database, a client-server toolbox, etc.), they aren't the primary purpose of the book. What the applications are used for is to illustrate how the concepts presented earlier in the book are used in within the framework of an application, and not just as isolated examples. This is especially important, as most people who might read the book will be unfamiliar not just with Objective Caml, but with the entire functional programming paradigm. Repeated exposure to working OCaml code helps to familiarize the reader with functional programming and OCaml idioms while reinforcing the book's material.

There are, of course, some problems with the book. For one thing, Developing Applications is nearly five years old, half a lifetime when dealing with most computer related topics. This issue is first brought to light in the introduction where it's mentioned that chapter one tells how to install version 2.04 (OCaml is currently at version 3.08), and then in chapter one, when the reader is warned that, "Objective Caml only works under recent versions of Windows : Windows 95, 98 and NT." Fortunately, the information presented about the language remains valid (and Appendix B presents some of the features added to the language by version 3.04, the release that was current at the time of the translation). There are also a few spots where the code in the book contains minor errors, but both of these issues can easily be overcome with the help of the resources listed earlier in this review, or with the help of the OCaml community. Other minor issues crop up as a result of the translation, with the occasional odd sounding phrase popping up in the text and examples. These problems are, however, few and far between and do little to detract from the material or the presentation. And so this book still remains one of the best resources for learning Objective Caml. I used it when I was learning the language, and I still turn to it from time to time as a useful resource.

Will the book turn you into an OCaml guru, or teach you all sorts of advanced type system trickery? No, of course not. But it can teach you enough about the language to start you writing real apps in it. And it will allow you to add a fast, flexible, and powerful language to your toolbox.

Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

243 comments

  1. MLDonkey by Megaslow · · Score: 3, Informative

    Possibly the most widely used app written in Objective Caml -- MLDonkey

    1. Re:MLDonkey by mordors9 · · Score: 0, Troll

      Well then, shouldn't the RIAA file suit on OCaml also. After all it is being used to write an application that is being used illegally by some people. Certainly they should have foreseen this.

    2. Re:MLDonkey by Anonymous Coward · · Score: 0

      Ocaml! The reason I gave up on compiling mldonkey and installed amule from rpm's. Yes I know it's inferior but I had 1 day to use up 1Gig and no time to play with compile errors.

    3. Re:MLDonkey by bcrowell · · Score: 2, Informative

      Also unison, which is a great app.

    4. Re:MLDonkey by Taladar · · Score: 1

      Then they should start suing at the source: C is used to write all P2P apps directly or indirectly (the compiler/interpreter/VM for the language used to write the P2P app is written in C).

    5. Re:MLDonkey by Anonymous Coward · · Score: 2, Funny

      You're obviously kidding, the true fault clearly lies in the x86 instruction set and assemblers. If they had only stopped to think about how end users would take those innocent MOV's and POP's and pervert them into Peer2Peer thought-stealing technology. How many billions in "lost" content revenue would have been saved? What about the children?

    6. Re:MLDonkey by mordors9 · · Score: 1

      Modded down as a troll. You have to be kidding. It is obvious that I was spoofing the RIAA. It is spelled sarcasm.

    7. Re:MLDonkey by Anonymous Coward · · Score: 0

      Yeah, you can't be too subtle with some of the moderators. It goes right over their head.

  2. Muchly needed by Tibor+the+Hun · · Score: 5, Funny

    Why just last week I was developing applications with an Opinionated Camel, and it was hell.

    Hell, I tell ya.

    --
    If you don't know what AltaVista is (was), get off my lawn.
    1. Re:Muchly needed by Anonymous Coward · · Score: 0

      Were the Twins there? Good, Wicked and Evil?

  3. Intrigued? by hobuddy · · Score: 5, Insightful

    Yes, I've been intrigued by OCaml for a long time.

    OCaml's major problem is that, like every other functional language available today, the breadth of its standard library and third-party libraries is totally pathetic in comparison to the likes of Java and Python. The same limitation applies to Lisp, Scheme, Haskell, Erlang, etc.

    These languages face a Catch-22: until they're more popular, they won't attract enough developers to ameliorate the library situation, yet until they offer better libraries, they won't attract developers. Historically, this barrier has been surmounted in one of two ways: either a deep-pocketed corporation subsidizes library development until the language gains momentum (see Java, C#) or the languages are sufficiently "charming"/"hip" that the library support appears as a result of a grass-roots effort (see Perl, Python).

    Is there any realistic prospect that one of the functional languages I mentioned will strike it rich in either of those ways? It doesn't seem likely to me.

    --
    Erlang.org: wow
    1. Re:Intrigued? by Anonymous+Brave+Guy · · Score: 5, Interesting

      I totally agree with your comments about the need for a standard library. But, as you observe yourself, such things can be developed by the community: CPAN for Perl, CTAN for TeX, and Boost for C++ are all very high quality libraries that are pretty much entirely community-developed.

      I think the most obvious missing thing is a figurehead for functional programming. A fair few of programming language geeks seem to be fans, but as someone posted here once before (sorry, can't remember who), functional programming has yet to find its Larry Wall. I'd like to think that the first time someone steps up and takes on that role, that will get the geeks going, and the snowball will start to form. All we need is someone qualified who wants to put in the effort, but of course there are going to be very few such people around in a relatively small corner of the programming world -- catch 22, indeed.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    2. Re:Intrigued? by Anonymous Coward · · Score: 5, Informative

      Well, that may have been true five or ten years ago, but have you checked the Caml humps http://caml.inria.fr/humps/ recently ?

      For GUI you have Tk, GTK, GTK2 ; some people have written interfaces to the Win32 API. Concerning data structures, the standard library has lots (lists, hashtables, queues, sets, maps), and if that's not enough, you name it, you have it (from splay trees to bitvectors), and not only esoteric data structures available only in functional languages. With Bigarray you can MMap huge arrays of whatever you want (bytes, floats). With the built-in lazy streams you can easily hack a LL parser, and if that's not enough you can run ocamlyacc. There are interfaces for Postgresql, mysql. Unix support is very complete (and portable). There is a good crypto library. For number-crunching you have the built-in number library, GMP bindings or numerix. Interfacing to C is excellent. I mean, come on, Perl and Java have, today, more in their libraries, but you really can't call Ocaml's library support "pathetic". Ocaml can and is really used for real apps (Coq, MLDonkey, etc.) with real GUIs. You can't say the same for Scheme. Plus, Ocaml compiles to machine code on i386, PowerPC and a few other architectures, and that runs damn fast even if you don't spend the afternoon optimizing your code.

    3. Re:Intrigued? by srussell · · Score: 4, Informative
      OCaml's major problem is that, like every other functional language available today, the breadth of its standard library and third-party libraries is totally pathetic in comparison to the likes of Java and Python. The same limitation applies to Lisp, Scheme, Haskell, Erlang, etc.

      I don't know; I've always been able to find libraries that I needed for Haskell; there are quite a few listed on the Haskell libraries page. It seemed to me, when I was evaluating OCaml, that a lack of libraries bindings or bindings to other language's libraries was not a problem. They've got quite a decent database of extensions at The Camel Humps

      I'm mainly a Java and Ruby developer, though, so I may not have stressed tested the availability of Haskell libraries. Java doesn't use libraries; if somebody writes a third-party library for it, Sun re-implements it, poorly, and bundles it with the VM, which effectively kills the original, and often superior, library. And Ruby... well, you just create whatever bindings you need, dynamically, with 'dl'.

      --- SER

    4. Re:Intrigued? by Coryoth · · Score: 4, Interesting

      I totally agree with your comments about the need for a standard library. But, as you observe yourself, such things can be developed by the community: CPAN for Perl...

      On that front, it will be interesting to see what will happen in Parrot successfully manages its dream of uniting (amongst others) Perl, Python and Ruby - allowing a module from one language to be used in another. Surely that confluence of communities could build a very formidable library indeed...

      Jedidiah.

    5. Re:Intrigued? by Anonymous Coward · · Score: 0

      I think you really should look into Ocaml again if you're under the impression that it lacks a great deal of third party libraries or abilities.

      I've programmed in Java since its introduction, and in C++ for far longer. Ocaml's standard library is 'far' from pathetic. It is definitely lacking a good imperitive library to match its functional one--- but its functional library is by many means far more complete than that of C++, and nearely as complete as Java's.

      I think the assertion that Ocaml's library is 'totally pathetic' in comparison is simply incorrect.

      There is also an Ocaml implementation in Java, and it's easily combined into a stand-alone executable along a C/C++ which allows it to be interfaced with a wide variety of libraries with ease.

      The language is very comprehensive, easy to read and use. Its object oriented features leave some things to be desired, but then again so does Java and C++'s. It can be both natively compiled, and interpreted as byte-code. And, it's damn fast.

      -Jason Thomas.

    6. Re:Intrigued? by Greyfox · · Score: 1
      I don't know about those other ones, but Guile has a very nice set of libraries to play with. I set out to learn a bit more about it and was very impressed with what I've seen so far.

      My biggest learning curve with lisp was with manipulating the data structures. Once I got that out of the way, I found the language to be quite impressive. It still tends to feel like scripting rather than "real" programming though, probably because I started out with E-Lisp.

      --

      I'm trying to teach myself to set people on fire with my mind... Is it hot in here?

    7. Re:Intrigued? by renoX · · Score: 1

      Library is not the only problem of Ocaml IMHO: I tried once to learn it but I disliked its syntax which is "weird" (not bad like Perl, just weird) and the book I used to learn (French book) kept pushing the functionnal style even in situations where it makes the code more difficult to read than imperative style.

      Which is a shame IMHO, in some case functionnal style is easier to use, in other it is not: if a language supports both style, why not use the style which suits the problem?

    8. Re:Intrigued? by upsidedown_duck · · Score: 2, Interesting

      The same limitation applies to Lisp, Scheme, Haskell, Erlang, etc.

      (Common) Lisp lacks only a non-proprietary and useful GUI toolkit. Otherwise it has just about everything. The fact that POSIX interoperability doesn't appear standardized is annoying, but the most annoying thing is that the good Lisp environments cost $$$$. I envy Lisp developers from a distance have never had the balls to really become one myself. It does take balls, too, to say to a group of Java-nerds or C++-nerds that something can be done better, faster, and with fewer problems.

      --
      -- "Makes Little Debbie look like a pile of puke!" - Moe Szyslak
    9. Re:Intrigued? by The+boojum · · Score: 4, Informative

      One solution that many of these languages are now taking is to target either the .NET framework or the JVM. For example, F# and SML.NET are two different projects from Microsoft Research aimed at producing ML-like compilers targeted at .NET. The Bigloo Scheme compiler now has an experimental .NET backend in addition to native code and JVM backends. There are also some Haskell compilers targetting the .NET now. If you look around, quite a few functional languages are beginning to support some combination of .NET and the JVM.

      For many languages, this solves exactly the problem that you describe. The new language instantly gets the benefit of large, useful and well tested library. The language developers can focus on the design of their language and leave the hassle of building and maintaining the supporting run-time and library to someone else. Eventually they can add a more native-feeling system library layer over it, but targeting the .NET or JVM gets them off the ground right away.

      There's a few quirks involved in shoehorning functional languages this way. As I recall, the JVM is a bit more difficult to compile functional languages to since it is really intended to run Java. .NET is a bit easier, though there are still some quirks. Many of those are known at this point, however, and there are even some libraries even to help work around them (e.g. the ILX SDK developed for F#.) I also think I recall something about the next update to MSIL addressing many of those quirks to simplify the development of functional language compilers.

    10. Re:Intrigued? by Anonymous Coward · · Score: 0

      (Common) Lisp lacks only a non-proprietary and useful GUI toolkit. Otherwise it has just about everything.

      The Common Lisp standard library offers "just about everything" except sockets, threads, a relational database API, a GUI API, standard HTTP/FTP/XML-RPC libraries, XML libraries, cryptographic libraries, imaging libraries, and the list goes on. There's also nothing even approaching a consensus on web development frameworks, as exists in Java servlets and EJBs. Plus, the most technically excellent open source implementations don't work on Windows.

      "Just about everything", indeed, as long as you stick to cute quicksort implementations and never try to write a real cross-platform application that a community of human beings will actually--gasp--USE.

    11. Re:Intrigued? by stesch · · Score: 1

      I don't miss anything for Common Lisp. Have you checked the CL community lately?

    12. Re:Intrigued? by fossa · · Score: 1

      Hi, I've been using Ruby for some time and never seen Ruby/DL. It looks very promising. Is this the preferred way to write extensions when a shared lib is available? I've been having good luck with the fairly simple "traditional" method of writing and compiling extensions in C, and I've never (well, now I'm not sure...) run across an extension that used Ruby/DL. Do you know of any good comparisons online? Perhaps I should just try to write my next extension with Ruby/DL. I suppose not needing a C compiler is quite an advantage.

    13. Re:Intrigued? by Anonymous Coward · · Score: 0

      Although the lack of libraries does have an effect on the Caml and other functional languages not being wide spread I think a bigger problem is that functional programming is too different from imperative programming and most C++/Java programmers just can't see the benefits of learning a functional language.

      90% of programmers I know are happy with C++/Java and are not interested in checking any other language out.

      The other 10% usually check out Python or Perl (and to a lesser extent Ruby) partially because they are more accessible then functional languages and partially because they have bigger communities/more libraries.

    14. Re:Intrigued? by hobuddy · · Score: 2, Insightful

      The problem with .NET or Java as a solution to the library problem is that you end up using your functional language:

      1) On a proprietary runtime. In the case of .NET, it's also a platform-specific runtime. Don't even bother mentioning Mono; the Microsoft Corporation that exists in the universe I inhabit will never allow Mono to grow into anything more than a token antitrust smoke screen, a perpetually not-quite-ready, not-quite-compatible runner-up. If you expect Microsoft to behave differently, you must not be referring to the corporation that's been systematically raping its competitors by whatever means necessary for the last two decades. The safest elements of .NET--those that have been submitted to ECMA--exclude almost all useful libraries.

      2) With libraries that were designed for consumption by object-oriented client languages, which robs the would-be functional programmer of much of the value of the functional way. The programming experience degenerates into a sad parody of functional programming that really amounts to object-oriented programming through a functional condom. To paraphrase the famous quote about condoms, "Functional programming with object-oriented libraries is armor against productivity, gossamer against library scarcity."

      3) On a runtime that performs 3-10 times worse than a runtime designed for the langauge in question.

      --
      Erlang.org: wow
    15. Re:Intrigued? by maw · · Score: 1

      Don't forget about nemerle. It's built on .net (and developed on mono). Its design clearly owes a lot to ml, but its syntax is much easier to wrap your head around than that of ml and derivatives, especially if you're coming from a C/C++/Java/C#/Perl/whatever background.

      --
      You're a suburbanite.
    16. Re:Intrigued? by sketerpot · · Score: 1

      Sockets are almost universally available, but they're implementation specific. Threads are much the same. There are several relational database APIs, GUI APIs, HTTP/FTP/XML-RPC libraries, XML libraries, cryptographic libraries, imaging libraries, and more. The biggest problem is that the fancier commercial implementations (which have all the stuff you mentioned built in) cost so much money.

    17. Re:Intrigued? by Anonymous Coward · · Score: 0

      The Common Lisp standard library offers "just about everything" except sockets, threads, a relational database API, a GUI API, standard HTTP/FTP/XML-RPC libraries, XML libraries, cryptographic libraries, imaging libraries, and the list goes on. There's also nothing even approaching a consensus on web development frameworks, as exists in Java servlets and EJBs. Plus, the most technically excellent open source implementations don't work on Windows.

      Wrong and wrong again.

      But you knew that, didn't you?

    18. Re:Intrigued? by Theatetus · · Score: 1
      The Common Lisp standard library offers "just about everything" except sockets, threads, a relational database API, a GUI API, standard HTTP/FTP/XML-RPC libraries, XML libraries, cryptographic libraries, imaging libraries, and the list goes on.

      Eh... as long as you're sticking with a given implementation you have all that, and most of it is pretty good.

      For that matter, nowadays if you're using lisp in a production environment you're pretty much using one of: Allegro, CMU-CL, or SBCL. They each have their own implementation of the libraries you mentioned. And anyways there's a good Allegro/CMU compatability layer and SBCL is compatible with CMU natively. ASDF solved a lot of these library problems.

      htmlgen, odbc, postgres, gtk, sdl, opengl, blowfish, twofish, aes, des, md5, elgamal, irc, tcpip, sockets, and of course ffi: I have all of those installed on my lisp boxes, and they do what they say they do. Now, when I'm working with Forth, that's a different story...

      --
      All's true that is mistrusted
    19. Re:Intrigued? by srussell · · Score: 2, Funny
      No, I think the preferred way is to use real bindings, although I haven't done a speed test to see if there's any real advantage to a true binding. I like Ruby/DL because I've been able to write a cross-platform binding for Matlab with it -- something I was unsuccessful at doing with the standard method. As you suspect, not requiring a C compiler is a huge advantage, especially on Windows.

      --- SER

    20. Re:Intrigued? by Dunedain · · Score: 1

      Scheme is used for real applications with real GUIs -- the PLT web server, for example.

      Also, the crypto library is... a good start. Assuming you mean Cryptokit, it has issues.

      --
      -- Brian T. Sniffen
    21. Re:Intrigued? by Anonymous Coward · · Score: 0

      I said standard library, not "Bubba's Third-Party Code Aggregation Site".

      See, the point is to be able to write code to perform these tasks on one Lisp implementation, and have the confidence that it'll work on all other standards-compliant Lisps, including those running on other operating systems and hardware architectures. Java and one or two other languages deliver this today, whereas Lisp fails miserably.

      Don't get me wrong: I like the Lisp language very much. But the standard library blows, and will continue to do so until people like you stop attempting to sidestep my assertions so you can answer a different, less threatening question.

    22. Re:Intrigued? by Anonymous Coward · · Score: 0

      > as long as you're sticking with a given implementation you have all that

      It's more of a marketing point than anything. (See Java). Or the fear that the Lisp world is small enough without locking yourself to a particular vendor.

    23. Re:Intrigued? by Anonymous Coward · · Score: 0

      Eh... as long as you're sticking with a given implementation you have all that, and most of it is pretty good. For that matter, nowadays if you're using lisp in a production environment you're pretty much using one of: Allegro, CMU-CL, or SBCL.

      You conveniently sidestepped on of my most important points, namely:

      Plus, the most technically excellent open source implementations don't work on Windows.

      Allegro is proprietary and expensive. In today's environment, that eliminates it from serious consideration right off the bat. Hell, even the stuff Microsoft produces is more free than Allegro.

      The other two have little or no Windows support. As long as "portability" means "portability between *nixes", it's meaningless. Do you really expect an ISV or consultant to look a potential customer in the face and say, "Well, you can just get over your unwillingness to shoulder the management burden of *nix in an otherwise Windows-only environment, because my software won't run on Windows."

      Any consultant who behaves that way will be out of business damn quick. Come to think of it, that might explain a lot about the moribund nature of today's Lisp scene.

    24. Re:Intrigued? by Theatetus · · Score: 1

      Maybe. Then again I haven't worked at a site that used Windows since 2001. Different perspectives I guess.

      --
      All's true that is mistrusted
    25. Re:Intrigued? by Anonymous Coward · · Score: 0
      (Common) Lisp lacks only a non-proprietary and useful GUI toolkit.



      There are interfaces to Gtk and Tk available (I think at common-lisp.net, you can find pointers at www.cliki.net). There is also McClim, an open source implementation of the Common Lisp Interface Manager.

      but the most annoying thing is that the good Lisp environments cost $$$$



      try SLIME (common-lisp.net/projects/slime). it's an (X)emacs lisp mode that really rocks.

    26. Re:Intrigued? by matthewknox · · Score: 2, Interesting

      actually, this is not a significant issue in lisp anymore. Lisp developers can access any java libraries from jfli . This is a pretty amazing hack, and means that lisp probably has better library support than any other language at the moment, given that lisp calls to C with ease and has pretty significant native libraries, too. It almost begs the question: what excuse are the parenphobes going to use now?

    27. Re:Intrigued? by arjun · · Score: 2, Informative

      A fair few of programming language geeks seem to be fans, but as someone posted here once before (sorry, can't remember who), functional programming has yet to find its Larry Wall.
      can you say Paul Graham ?

    28. Re:Intrigued? by psbrogna · · Score: 1

      "Historically, this barrier has been surmounted in one of two ways: either a deep-pocketed corporation subsidizes library development until the language gains momentum (see Java, C#) or the languages are sufficiently charming/hip"

      So why did PHP gain momentum? Yes it has commercial backing, but I don't think that effected the take up rate. Is PHP really cool/hip?!

    29. Re:Intrigued? by The+boojum · · Score: 1

      1) I won't argue ideology here; I'm from the pragmatic use-what-works school. But I have Joel Spolsky's Fire and Motion column in mind here. Once the runtime technology reaches maturity, there's not really any need for Mono to try to keep up. Look at Java: how many of the extra libraries are really used? Most programmers won't have a need for too much beyond the core library and won't bother learning all the silly esoteric additions. Once Mono's caught up with the (fairly static) core and can run 99% of the programs out there, it'll probably be good enough for most people.

      2) Functional programming is all about creating abstractions. Yes, depending on the language's FFI the abstraction layer might look ugly. But I'll bet it's still faster to create a small functional-style shim layer on top of a set of FFI calls than it is to reimplement the routines from scratch. You can always migrate to more elegant pure code later if you really want to spend the time on it.

      3) Programmer time is expensive, hardware time is cheap. By your argument we'd all be writing assembly code and no one would ever use a scripting language. Most people using a high level functional language aren't doing it for performance reasons; they're doing it for the higher levels of abstraction they can achieve. I think many would gladly trade the performance penalty you mention for a chance to save themselves the chore of all that extra coding and debugging.

    30. Re:Intrigued? by gnovos · · Score: 1

      OCaml's major problem is that, like every other functional language

      Stop there. that is the problem. The reason functional languages fail is because they are functional languages. They are powerful, but amazingly terse and difficult for even a jedi-level programmer to fully comprehend.

      Great to hack in, great to show your buddies how amazingly awesom0 you are, worth fuck-all when you have a real development environment when the junior engineers outnumber the senior engineers 5-1 or even 10-1.

      Oops bug in the production server that could cost us millions, what do we do? Nope, 90% of our workforce has no chance of even comprehending where it printed out the error to the screen, so I guess we have to call in that fuck-tard who wrote the damn thing. Fire him and rewrite it in visual basic.

      Don't believe me? Here's a random section from near the TOP of chapter ONE in one of the tutorials mentioned above:

      Note - no brackets, and no comma between the arguments.

      Now confusingly repeated ("hello", 3) is meaningful in OCaml. It means "call the function repeated with ONE argument, that argument being a 'pair' structure of two elements". Of course that would be a mistake, because the repeated function is expecting two arguments, not one, and in any case the first argument is a string, not a pair. But let's not worry about pairs ("tuples") just yet. Instead, just remember that it's a mistake to put the brackets and commas in around function call arguments.


      What the fuck does that mean?

      call the function repeated with ONE argument, that argument being a 'pair' structure of two elements for crying out loud!

      --
      "Your superior intellect is no match for our puny weapons!"
    31. Re:Intrigued? by edp927 · · Score: 2, Funny

      The real problem with OCaml (and modern functional programming in general) is that its too frnech. perhaps if it were called Freedom Programming....

    32. Re:Intrigued? by bluFox · · Score: 1

      He cant be for two reasons,
      1) His language is arc, a variant of lisp, not exactly a functional language, nor does it look like one from the available material that he has released. Lisp is a multi-paradigm language that is only incidently functional.
      2) He does not seem too keen to be building up a community :)

      --
      ~561
    33. Re:Intrigued? by vague · · Score: 2, Informative

      Ehrm, that's a problem of education, needing better intro texts, not of the language. Here's the truth: functional programming is no harder to imperative programming. It only appears that way because most of the current educational material isn't written by people who understand the needs of non-programmers. The bracketing is only a problem for those who are used to different syntaxes really.

      --

      -
      Listen. Strange women lying in ponds distributing swords is no basis for a system of government.

    34. Re:Intrigued? by Vintermann · · Score: 1

      Agreed. The syntax is seriously quirky, especially for a functional language. They are usually more attentive to that sort of things, but not ocaml. I worked through the first couple of chapters in that book once, and I remember thinking it was as idiosyncratic as C.

      --
      xkcd is not in the sudoers file. This incident will be reported.
    35. Re:Intrigued? by Richard+W.M.+Jones · · Score: 2, Informative

      These languages face a Catch-22: until they're more popular, they won't attract enough developers to ameliorate the library situation, yet until they offer better libraries, [...]

      This may have been true 5 years ago, but today you can call Perl 5 libraries and Python libraries directly from OCaml.

      Rich.

    36. Re:Intrigued? by meadowsp · · Score: 1

      Ummm. Java does use libraries (in the form of jars), log4j and junit are a couple of examples.

      And the VM run's the language spec, has nothing to do with the libraries.

    37. Re:Intrigued? by master_p · · Score: 1

      The libraries you mention are C libraries, not OCaml libraries. When I use an advanced 4th generation programming language, I want its libraries to also be of 4th generation quality, i.e. no hacked wrapping of other languages libraries. In other words, I want the libraries to reflect the qualities of the programming language I am using. If I am to use C libraries through Ocaml, why bother? I would do it with C++ and gain access to lots of other C++ only libraries, as well as the very fine tools that are available. C libraries use C principles, not Ocaml principles.

      Another important point is that with languages like Java, most of the libraries are packed together with the programming language. Only one download is needed for developing applications. This is important not only for marketing reasons, but for knowing that there are absolutely no integration problems, and that the documentation is coherent.

    38. Re:Intrigued? by renoX · · Score: 1

      "as idiosyncratic as C"

      No, more like Pascal or Ada..
      I remember thinking 'why the hell did they get inspired from Pascal? Nobody use Pascal..'

      If they had tried to imitate C, I think it would have been better (except for the variable definition in C which is a mess, but this is not a problem in Ocaml): many more people know C/C++, the transition would have been less awkward.

      Anyway I don't think, I'll try again to learn OCaml: each time there is a problem, it feels like doing math, Ruby is much more simpler to learn IMHO (but it runs also much more slower unfortunately).

    39. Re:Intrigued? by Vintermann · · Score: 1

      It annoys me that I can't remember exactly what it was about OCaml syntax that annoyed me, but I do remember constantly mixing up OCaml and SML syntax.
      I think there were some odd symbols in OCaml that made me think of C. I like Ada, it doesn't abuse symbols in syntax unnecessarily, and is comfortably verbose for my tastes (my limit goes at SQL :-). It may take a little more time to type, but thinking is the bottleneck when I'm programming!

      Oh yeah, one of those weird things was the different syntax for accessing an element in a string and accessing an element in an array. And coming straight from looking at Ada I felt weird when using three or four different forms of brackets...

      --
      xkcd is not in the sudoers file. This incident will be reported.
    40. Re:Intrigued? by hamfed · · Score: 1

      People interested in OCaml may want to check out Nemerle (http://nemerle.org). Like OCaml, it offers type inference and both functional & object-oriented features. However, since it is built for the .NET platform you can take advantage of the .NET BCL (as well as third-party .NET assemblies). Note that it supports both Microsoft and FOSS .NET implementations.

    41. Re:Intrigued? by Anonymous Coward · · Score: 0

      Surely that confluence of communities could build a very formidable library indeed...

      I'm imagining something like the three-headed knight from Monty Python and the Holy Grail...

    42. Re:Intrigued? by Anonymous Coward · · Score: 0

      No ! They are all written in Ocaml, not C.

      Stop making wrong assumptions from what you saw ten years ago.
      For the integration between the libraries in a single package, it's getting better with the effort called GODI. However I agree it's not as good as the JDK, obviously.

    43. Re:Intrigued? by Anonymous Coward · · Score: 0

      The core syntax is very easy to learn, very space efficient and quite readable with habit.

      But it gets more complex when one learns classes and functors. The time it takes to master the intricacies of the language is probably comparable to C++. However writing correct (ie working, free of bugs) Ocaml is certainly easier than writing correct C++.

    44. Re:Intrigued? by srussell · · Score: 1
      I was being facetious. Sun has an established history of taking popular libraries, duplicating them, and embedding them in the standard library. This is a large part of why the Java API is so bloated these days.

      --- SER

  4. any other questions? by Anonymous Coward · · Score: 0
    Intrigued?

    No. Next?

  5. Re:read on for the rest of Neumann's review. by Anonymous Coward · · Score: 0

    What, me worry?

  6. I tried learning OCaml by Coryoth · · Score: 3, Insightful

    But didn't have a project on hand to try coding in Ocaml with. To be honest I found it hard to kick my brain into the rather different gear that OCaml requires (though I have done a little Lisp programming, I haven't had too much experience in real functional languages). Without an example to work on yourself, and understand quite how to structure things I think it can be hard going. I just didn't have the time to commit properly, unfortunately. What I did see of the language was truly impressive, and this book certainly sounds like an excellent resource. Maybe it's time to go back and try again.

    Jedidiah.

    1. Re:I tried learning OCaml by drafalski · · Score: 3, Informative

      I had a "types and programming languages" (graduate level) course at UPenn that made heavy use of OCaml. Though I can't imagine voluntarily going through that material, the resources page gives a good general background including OCaml references. The homework page provides some OCaml programming examples. The solutions seem to have been pulled, but I imagine they are still easily found on archive.org (which is not responding for me right now to check) or via google.

    2. Re:I tried learning OCaml by Anonymous Coward · · Score: 2, Informative

      I've learned Caml literally by reading the manual and would highly recommend checking the manual out to anyone interested in Caml. It has an introductory section which is enough to get you started, a detailed description of language features and the standard library.

      I would say Caml is a lot easier to get into then Scheme/Lisp or Haskell (having worked with all 3).

      Haskell and Scheme are both nicer to program in however in Haskell it is often difficult to get good performance out of the final program and at the same time maintain code that is readable (simply because you have to "help" the compiler a lot). If you don't need speed then Haskell is great although I found it fairly difficult to get into (in particular getting used to monads - not so much using existing monads as much as figuring out what they do and how they do it).

      Scheme is in some ways nicer then Haskell (extremely simple syntax, great macros, dynamically typed, great for metaprogramming) but in other ways not even nearly as nice (Haskell is a pure functional language unlike Scheme and Caml, elegant handling of side effects, type inference, pattern matching, ability to compose functions and program without variables (to some extent), lazy evaluation). My main problem with Scheme is that there aren't that many implementations that are compliant with the current standard (R5RS) and there are no decent free compilers for Scheme (especially ones that are R5RS compliant).

      Caml is easier to get into because the structure of Caml programs closer resembles structure of programs written in imperative languages. Unlike Haskell and Scheme it also comes with a great native code compiler. It's a great starting point for anyone interested in learning functional programming and once you get into it you'll never want to go back to imperative languages.

      Currently Ocaml is the only functional language implementation that can favorably compete with most imperative languages in terms of performance which makes it great for general purpose programming. MLton, a StandardML implementation, comes pretty close but it doesn't seem as mature as Caml.

      Finally both Caml and Haskell have a great foreign language interface and it's quite easy interfacing them with C.

    3. Re:I tried learning OCaml by The+boojum · · Score: 1

      I've been using Bigloo (from the same folks as OCaml) for Scheme. You might find it gives you a lot of what you want.

    4. Re:I tried learning OCaml by Anonymous Coward · · Score: 0

      Bigloo is not fully R5RS compliant. I've looked at it a number of times but I can't remember the exact details why I gave up on it.
      Petite Chez Scheme still seems to be the most R5RS compliant free implementation however it doesn't come with a native code compiler.

  7. My first Caml script... by Anonymous Coward · · Score: 4, Funny

    _
    .--' |
    /___^ | .--.
    ) | / \
    / | /` '.
    | '-' / \
    \ | |\
    \ / \ /\|
    \ /'----`\ /
    ||| \\ |
    ((| ((|
    ||| |||
    //_( //_(

    Important Stuff

    # Please try to keep posts on topic.
    # Try to reply to other people's comments instead of starting new threads.
    # Read other people's messages before posting your own to avoid simply duplicating what has already been said.
    # Use a clear subject that describes what your message is about.
    # Offtopic, Inflammatory, Inappropriate, Illegal, or Offensive comments might be moderated. (You can read everything, even moderated posts, by adjusting your threshold on the User Preferences Page)

    Problems regarding accounts or comment posting should be sent to CowboyNeal.

    1. Re:My first Caml script... by Davorama · · Score: 1

      Looks more like brainfuck source to me.

      --

      Davo -- Free speech, free software, AND free beer.

  8. Re:Book is five years old, whew... by Anonymous Coward · · Score: 0

    I'm a Ruby zealot myself, but this comment was the most off-topic ever seen on /.! I know nothing about OCaml (I learn Scheme now) and I'd prefer REAL opinion from real OCaml guys...

  9. Chapter 8: Toes by apachetoolbox · · Score: 4, Funny


    :D

    1. Re:Chapter 8: Toes by FerretFrottage · · Score: 1

      Already used all my mod points as that did make me laugh, but then again what type of geek would even consider camel toes that only run with Windows....well now that I think about it, he'd probably consider any.

      --
      "Look Lois, the two symbols of the Republican Party: an elephant, and a fat white guy who is threatened by change."
    2. Re:Chapter 8: Toes by Anonymous Coward · · Score: 0
    3. Re:Chapter 8: Toes by kundor · · Score: 1

      You puzzle me. Who said anything about only running with Windows?

    4. Re:Chapter 8: Toes by Tablizer · · Score: 1

      Wow! Mod parent up

  10. Re:Book is five years old, whew... by Anonymous Coward · · Score: 0

    Wow, and K&R's ANSI C is like over ten years old - C must be like so shit, no wonder no-one uses it!!! God bless a language that needs its goalposts moving every year. Yes, I want to spend more time learning how to use my tool than actually using it.

  11. Careful about speed comparisons by Junks+Jerzey · · Score: 5, Interesting

    OCaml code can rival C++ code in benchmarks...if you write OCaml that looks like C++. Yes, the OCaml code is still probably safer in the end, but the OCaml solutions to many of the benchmarks are just nasty. The prettier, straightforward solution is often 2-4x slower than the C++ version. So is OCaml fast? Yes. But please be careful here.

    1. Re:Careful about speed comparisons by Anonymous Coward · · Score: 0

      This is true (and true of other functional languages too). I think you can reasonably spin this as an advantage however.

      You can say that ocaml allows you to write most of your code in a high level way that's easier to write, understand and maintain and for the small bits of your code that really need high perfomance you can start thinking more like a C programmer and get up to C performance levels.

      Simply stated, the advantage is that you don't have to think like a C programmer all the time, just for the performance bottleknecks.

    2. Re:Careful about speed comparisons by Svartalf · · Score: 3, Insightful

      Considering that the C++ code would have nasty solutions for peak speed- prettier, straightforward solutions for C++ tend to be 2-4x slower than the optimal solutions for C++. The same could be said for C code as well.

      --
      I am not merely a "consumer" or a "taxpayer". I am a Citizen of the State of Texas
    3. Re:Careful about speed comparisons by KoporShow · · Score: 3, Insightful

      The performance difference between C and OCaml depends heavily on the application. I have written a relatively small application in OCaml (an interpreter for the programming language Joy) and the optimized OCaml version was faster than its C counterpart. (The C version, not programmed by myself, is about 6x larger and still slower) There are examples where OCaml is significantly slower, but I think, that you would rarely see a 2X slowdown when programming carefully. On the other hand the development time can be significantly reduced: programming in OCaml is normally about 2-5 times faster than in C++ if one takes the reduced time for debugging into account. And this is true for ma altough I have more than 8 years (and over 100 KLOC) C++ experience while less than one year OCaml experience. One can also add that the object system of OCaml is much more powerful than that of C++. It allows for much more genericness while having a thourough type-safety. You can not achieve the same genericness in C++, since you can add everywhere explicit type delaration (resulting in long and complicated template names) where OCaml can deduce the type information automatically. This makes code-refactorization much more easy. It is not true that OCaml needs a different type of thinking than a procedural or object-oriented language. OCaml has full support for "traditional" programming style and in fact most OCaml programs are written that way. Haskell and Clean are more elegant, but they really require that the programmer uses a purely functional programming style without mutable states.

    4. Re:Careful about speed comparisons by RdsArts · · Score: 1

      But isn't this in general true of all languages? I mean, to write C code to the highest potential, you have to occasionally drop down and inline some cryptic ASM to punch up those few routines that are slow and commonly called.

      Or I suppose what I'm asking is, isn't a increase in readablity worth a reasonable hit in performance, expectally if one can then use the less pleasant code when speed is a considerating?

    5. Re:Careful about speed comparisons by Junks+Jerzey · · Score: 3, Interesting

      But isn't this in general true of all languages? I mean, to write C code to the highest potential, you have to occasionally drop down and inline some cryptic ASM to punch up those few routines that are slow and commonly called.

      Well, not quite. In C you pay as you go. You essentially have a direct mapping to common hardware. You can go faster, yes, but the improvement generally isn't worth it unless you're targeting specific weirdness like MMX or SSE2.

      OCaml has some significant overhead that comes from the language definition. There's garbage collection, which while fast is certainly not free. Floating point values in mixed-type tuples are heap allocated (that is, the floating point values--doubles, actually--are separate heap objects). There's the classic issue with functional languages that the simple and easy way to build a list either involves stack space for each element or a full reversal of the list (not in place) at the end.

      I fully agree with you that readability is worth a hit in performance. I use interpreted languages all the time, and compiled OCaml is certainly much faster than them. But OCaml advocates need to be careful about claiming their language is as fast as C/C++, because it generally isn't true. It's only true if you drop the nice features and write grungy C-style code, and then only in certain situations. This does not mean it is a bad language, however.

    6. Re:Careful about speed comparisons by __aaahtg7394 · · Score: 1

      There's garbage collection, which while fast is certainly not free.

      Actually, running benchmarks, it's found that the GC OCaml uses is faster than the repeated brk()s you get with C's malloc()/free(). If you profile it out, brk() is really expensive when you're dealing with a segmented heap/arena.

      I don't know how the tuple issue falls out, though I'm sure Xavier Leroy and friends have done the best they can, as usual.

    7. Re:Careful about speed comparisons by TheRaven64 · · Score: 1
      Disclaimer: I have never used OCaml. I have, however, used Haskell (a functional language that, apparently, inherits quite a lot from OCaml - the OCaml code in one of the links in TFA looked remarkably similar to Haskell).

      One of the advantages of functional languages that is not often mentioned is that it is relatively easy (at least in comparison with imperative languages) to implicitly parallelise the code. As an exercise, I sat down with a piece of Haskell code and some lambda calculus (*shudder*) to see how much of it a compiler could determine could be executed in parallel. While this may not be a huge advantage now (since most PCs have a single CPU), the advent of multi-core chips, mainstream SMP, and the increasingly slow rate of increase in raw CPU speeds this may make functional languages increasingly more attractive.

      Personally, I'd rather use a declarative language that's actually fun to use, like Prolog.

      --
      I am TheRaven on Soylent News
    8. Re:Careful about speed comparisons by sangdrax · · Score: 2, Informative

      Its not that simple. C++ doesn't provide functional programming constructs; OCaml does and encourages its use. Functional programming can cost much more resources than OO programming.

      To compile functional code that looks pretty, the result is often resource wasteful:

      - Memory is copied at every turn (in functional constructs, variables cannot be changed),

      - About all small functions use recursive calls (no, tail-recursion doesn't solve most of them; often the result of the recursion has to be modified before returned),

      - Generic functions cannot be optimised well (C++ compiles a specific version at instantiation with a template).

      To name a few. If you want raw execution speed in OCaml, use the procedural constructs. The computer is built to run code like that.

    9. Re:Careful about speed comparisons by Junks+Jerzey · · Score: 1

      One of the advantages of functional languages that is not often mentioned is that it is relatively easy (at least in comparison with imperative languages) to implicitly parallelise the code.

      This has been a cited advantage of functional languages since the 1970s, but it hasn't come to fruition. In theory, yes, it's a big win, but in practice it's very difficult to do.

    10. Re:Careful about speed comparisons by Junks+Jerzey · · Score: 1

      Actually, running benchmarks, it's found that the GC OCaml uses is faster than the repeated brk()s you get with C's malloc()/free(). If you profile it out, brk() is really expensive when you're dealing with a segmented heap/arena.

      Yes, GC can be faster than C's malloc/free, but that's not what I'm talking about. I'm talking about statically allocating your memory, as is the norm in embedded systems. Then you have no malloc/free overhead and no GC overhead, period.

    11. Re:Careful about speed comparisons by TomorrowPlusX · · Score: 1

      It's true. I've been bitten by the surprisingly bad performance of std::vector in tight inner loops ( opengl code, doing hairy stuff at runtime ).

      While I try to stick with the STL, there are times when you need to just eat it and use traditional arrays. And all sorts of other nasty things like making local copies of simple objects to avoid repetitive dereferencing and so on and so forth.

      The important part is to explain in your documentation and source comments *why* you've done these things, so that other programmers -- or you in the future -- won't think "what the hell is this crap" and then undo some hairy code in the name of "elegance" and lose a 500% speedup.

      --

      lorem ipsum, dolor sit amet
    12. Re:Careful about speed comparisons by Anonymous Coward · · Score: 0

      It's not completely true : being a strongly typed language, Ocaml allows for efficient optimizations that a C++ optimizer can't do because typing is not always enforced. Also, it makes a better use of the stack than imperative languages.

      But the good news is, as always, having to tweak the source for speed will concern 10% of your code, the 90% that don't need full speed but an excellent architecture can be written in full functional manner.

  12. Full Support? by engywook · · Score: 3, Informative

    Isn't saying, "OCaml also has full support for object-oriented programming that fits in completely with OCaml's strong type system." equivalent to saying, "Ford Thunderbird also has full support for all fuels that meet its fuel requirements."?

    --
    "This signature quote intentionally left blank"
    1. Re:Full Support? by Anonymous+Brave+Guy · · Score: 1

      No. That sentence can be parsed two ways, and presumably was meant the other way to the way you interpreted it...

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    2. Re:Full Support? by Oxy+the+moron · · Score: 1

      No, but you can get OCaml in any color as long as it's black. =]

      --

      Proudly supporting the Libertarian Party.

    3. Re:Full Support? by Anonymous Coward · · Score: 0

      Ocaml came from a type system, in ML, without the concept of objects. An object is a type, but a type in Ocaml isn't neccessarily an Object. In a pure OOP language, this would be true. What this comment means is that Ocaml's Objects work with the underlying strongly typed system. You should look at Ocaml's type inference capabilities if you want to know what implications this has for Object Oriented programming.

    4. Re:Full Support? by Svartalf · · Score: 1

      Not QUITE. The statement probably ought to have been phrased as follows:

      "OCaml also has full support for object-oriented programming that fits in completely with Caml/ML's strong type system..."

      Probably was more of a not-thinking typo than anything else, considering that OCaml is a superset of Caml, which is a superset of ML- both of which have strong variable typing.

      --
      I am not merely a "consumer" or a "taxpayer". I am a Citizen of the State of Texas
    5. Re:Full Support? by Anonymous Coward · · Score: 1, Interesting

      Missing a comma is all. Slashdot editors don't or can't, take your pick.

      The funny thing is, the OO system of ocaml actually doesn't really fit into the type system that well. Methods can't be polymorphic (i.e. they have to take real types, not 'a). Meanwhile, functions can be polymorphic, but can't be overloaded. Try to get too abstract with polymorphism and covariance, and you get monomorphism restrictions coming around and biting you. Let's not even get into how painful it is to represent something as simple as an "unsigned 32 bit int" (kinda useful when doing network programming) in ocaml. And yes, the same could be said for Java, and I say it loudly and often.

      That said, Ocaml's easier to learn than Haskell: objects are easier to deal with than existential types, there's no monads, and you get variables that act more or less like you'd expect. Unfortunately, the core language hasn't seen any significant updates, and even camlp4 hacks are sort of petering out. I'd hate to see Ocaml fizzle out, but I don't know that slashdot articles are going to save it from the apparent neglect by its core developers.

    6. Re:Full Support? by Anonymous Coward · · Score: 0

      Most ML based languages are not object oriented but use higher order algebraic mappings(Functors) to organize code. OCaml is the exception since it can work both ways, i think this is what the user meant.

    7. Re:Full Support? by Anonymous Coward · · Score: 0
      there's no monads
      Yeah, I'm glad I don't have those either.
    8. Re:Full Support? by jodonoghue · · Score: 1

      I'd have to agree with both of your points.

      To be honest, and this is after using Ocaml extensively for a while, Ocaml's object system doesn't really work very well. I loved the language before I started to use the OO features, but working on LablGTK2 drove me crazy. The syntax (both for open types, and for keyword arguments) is ugly and poorly documented.

      For command line software (mainly short scripts and 'parser' type applications), I still love the speed (both of development, and execution) of Ocaml, but I don't touch it for GUI programming any more.

      I'm also inclined to agree that the core developers at Inria have moved on to other things. Whether this is because some of the language 'features' are seen as dead-ends (I'd suggest the implementation of OO polymorphism is one which doesn't meet real-world needs), or whether their research interests have somply moved on is not clear.

      While many (including myself) complain at the lack of an elegent GUI interface, I've also looked into what would be needed to do such a thing myself (my poison of choice was wxWidgets, as I use Mac, Linux and Windows regularly, and *much* prefer having native look and feel. Gtk is really only fine for Linux), and the work involved looked very painful, unless you would accept an ugly interface to the C bindings for wx (I looked at using the wxEiffel C bindings as a starting point).

      I know there's a fledgling wxCaml in the works, and I wish them luck. I agree that it would be a shame to see the language wither on the vine, although I fear that this is what is happening.

      Having said that (and I speak as a real-time embedded developer), I am utterly convinced that many of the ideas embodied in Ocaml (type inference, functional/imperative programming mix etc) are the future of high-performance programming, and will eventually largely replace C for all but the lowest level tasks.

      I doubt that Ocaml will be the language to do that, however. It will probably be a successor which learns from its shortcomings and builds on its (many) strengths. Probably a language yet to be written, in fact.

    9. Re:Full Support? by warrax_666 · · Score: 1
      Methods can't be polymorphic (i.e. they have to take real types, not 'a)

      Yes they can. You just have to declare them slightly differently:

      method blah : 'c. f:('c -> 'c) -> 'c = ...

      will give you a polymorphic method (in the type 'c).

      Unsigned 32bit int: While not representable directly, you can just use int32. Since all platforms which ocaml actually runs on are two's completement all operations except comparisons work as expected. If you need comparisons you can just use an int64 and make sure to (mod 2^32) it when needed.


      Unfortunately, the core language hasn't seen any significant updates, and even camlp4 hacks are sort of petering out

      Nonsense. Examples: the pa_macro camlp4 module was added in 3.07, and the object system had a few significant changes somewhere in the 3.05-3.08 timeframe (can't remember precisely, check the changelog if you care).

      Besides, who says that stabilization is a bad thing?
      --
      HAND.
    10. Re:Full Support? by wirelessbuzzers · · Score: 1
      The funny thing is, the OO system of ocaml actually doesn't really fit into the type system that well. Methods can't be polymorphic (i.e. they have to take real types, not 'a).
      # object
      method trivialPolyMethod x = x
      end
      ;;
      - : < trivialPolyMethod : 'a -> 'a > = <obj>
      Still, you're right, in that you occasionally have to use hacks, like casting self to its own class, to deal with bugs (or design failures) in the type checker.
      --
      I hereby place the above post in the public domain.
  13. BEWARE! by Anonymous Coward · · Score: 1, Funny

    Contains subliminal likeness of goatse "giver".

  14. Push popularity using .net/mono by jerometremblay · · Score: 1

    This is where .net and mono could do a difference. They allow any language to be used with each other. So get your favorite functional language compiled for .net and you instantly have the whole library.

    But despite this and this, as far as I can see there have not been any massive worldwide shifts toward functional programming recently.

    I guess it's hard to change.

    1. Re:Push popularity using .net/mono by killjoe · · Score: 1

      If parrot can host ocaml then you will be able to call perl libraries from ocaml.

      --
      evil is as evil does
    2. Re:Push popularity using .net/mono by jerometremblay · · Score: 1

      Well, it's kinda my point.

      If libraries are not the issue, then why aren't functionnals language more popular?

    3. Re:Push popularity using .net/mono by Taladar · · Score: 1

      And you are locked into Windows just like MS planned .net

      Unless Mono gets some sort of legal backup I wouldn't develop anything in .net
      ...at least nothing that isn't portable to another non-.net compiler/interpreter if necessary.

    4. Re:Push popularity using .net/mono by Anonymous Coward · · Score: 0

      If parrot can host ocaml then you will be able to call perl libraries from ocaml.

      You already can: try http://merjis.com/developers/perl4caml/.

  15. Attack a niche by DavidNWelton · · Score: 2, Insightful

    One way is to find a niche and just nail it. Be the best thing out there for it. PHP did that, and if they play their cards right, they could grow out of that niche too, surpassing things like Python in popularity, even if PHP isn't that beautiful a language.

    To really understand this problem, you are going to have to read *gasp* marketing and economics books. "Crossing the Chasm" and "Information Rules" (network effects, lock-in, and so on) are ones I find interesting. I've heard "the innovator's dilemma" is good too, but haven't read it yet.

  16. FFTW by geneing · · Score: 2, Funny

    I think FFTW would be the most famous and useful if not the most popular.

    1. Re:FFTW by sketerpot · · Score: 2, Funny

      For those who haven't heard of it, FFTW stands for Fastest Fourier Transform in the West, and it's a library for computing some discrete Fourier transforms really quickly.

  17. Huh. by rackhamh · · Score: 2, Interesting

    At first read I thought it said "Developing Applications With Objective Calm" -- which, come to think of it, would probably make for a pretty interesting article.

  18. Moderation Abuse by Anonymous Coward · · Score: 0

    The article was about Objective Caml. Parent post was directly talking about Objective Caml. No way is that offopic.

    I think some moderators are letting their anti-Korean prejudices show when in fact we could learn a lot from the people of Korea. In Korea, these sorts of prejudices are only for old people.

    1. Re:Moderation Abuse by Anonymous Coward · · Score: 0

      Everybody is suspicious of Koreans...in Japan!

    2. Re:Moderation Abuse by Anonymous Coward · · Score: 0

      Perhaps, but in Soviet Russia Koreans are suspicious of YOU.

  19. Dear CowboyNeal by zoloto · · Score: 3, Funny

    Does this count the same as anyone from GNAA?

    Or because it's CAML, will it be allowed? Please tell me what to flame!

  20. In related news, by Anonymous Coward · · Score: 2, Funny

    In Korea, only old people use scripted languages.

    1. Re:In related news, by Anonymous Coward · · Score: 0

      Caml is not and has never been a scriptING language.

    2. Re:In related news, by TheLink · · Score: 1

      In the Spyware Infested Internet, scripting languages use you!

      --
  21. Developing with a half-camel? by Anonymous Coward · · Score: 0

    Buffy and especially Willow/Tara fans know what I mean.

  22. Who needs another boutique goof ball language by Anonymous Coward · · Score: 0

    Someone's pet hobby horse. Perl is bad enough.

  23. No good tutorial about ocaml... by zymano · · Score: 3, Insightful

    I looked everywhere. None are intuitive and easy like the java.sun.com tutorial.

    I downloaded the compiler about a year ago but got turned off by the quality of tutorials.

    You need easier reading material if you want people to adopt.

    1. Re:No good tutorial about ocaml... by Anonymous Coward · · Score: 0

      Out of curiosity have you tried reading the manual? I thought the manual served great as an introductory text/tutorial as well as a language reference.

    2. Re:No good tutorial about ocaml... by nietpiet · · Score: 3, Informative

      but there are!
      I learned the language online, (just as i learned Java from their very good tutorial)

      they gave 2 good ones at the top.
      the Richard Jones'
      Ocaml Tutorial for people who know how to program 'normally'

      There is also an update to Jason Hickey's book

      I like OCaml because it Combines the power of functional programming, like (tail-)recursion, functions as an argument, with 'normal' programming language statements.
      It doesn't force the "functional programming way" on you, like Lisp does, So, you can still use the If then, and While statements if you find them more usefull then a recursion.

      And, it is quite fast!
      both in development and in execution.
      however, i have yet to find a way to well commenting my code.

    3. Re:No good tutorial about ocaml... by voodoo1man · · Score: 1
      It [Ocaml] doesn't force the "functional programming way" on you, like Lisp does
      I don't know how you can claim that, considering that Ocaml doesn't even have goto.
      --

      In the great CONS chain of life, you can either be the CAR or be in the CDR.

    4. Re:No good tutorial about ocaml... by zymano · · Score: 1

      Thanks.

    5. Re:No good tutorial about ocaml... by rsidd · · Score: 2, Interesting

      There's a bunch of good tutorials here. I learned everything I know about ocaml from there, in particular from Jason Hickey's, Richard Jones' and the OCaml manual. I spent a week learning that stuff and playing with it, and another week writing from scratch a rather non-trivial program that would have easily taken two months in C. I found ocaml astounding: nearly as fast as C, as compact and elegant as python (arguably more so, in fact).

    6. Re:No good tutorial about ocaml... by Anonymous Coward · · Score: 0

      You haven't really programmed in Lisp, have you?

      If anything, OCaml is far more of a functional language than (Common) Lisp. Much of the Common Lisp standard library relies on side-effects, and typical Lisp coding style is in fact imperative.

  24. I find that a Camel often helps me code. by Anonymous Coward · · Score: 0

    Damn company only lets me smoke 'em outside though.

  25. Re:Book is five years old, whew... by KoporShow · · Score: 1

    I am a big fan of Ruby either.

    I use Ruby for scripting exclusively, but my experience is that dynamically typed programming languages are not suited for larger projects, since they tend to have a lot of runtime errors, and very sensible to changes in compiler version.

    The file synchronisation tool unison shows that OCaml is exteremely well suited for complex file-manipulation algorithms.

  26. Same Problem by Umbral+Blot · · Score: 1

    I can relate to that. Centum has the same problem ... how can I attract talented developers to write libraries when talented developers usually only work with languages that provide them with the libraries they need?

    1. Re:Same Problem by Anonymous Coward · · Score: 0

      Oh, I dunno, maybe by posting a clever throwaway comment in a slashdot developer thread?

      Always wanted to know what would happen if visual basic met forth in a supercollider. Now i know...

    2. Re:Same Problem by sketerpot · · Score: 1

      You could take a leaf out of O'Caml's book and make an interface to Perl.

    3. Re:Same Problem by Anonymous Coward · · Score: 0

      That is some funny shit.

  27. Re:I'd consider OCAML by KoporShow · · Score: 2, Interesting

    This was my opinion at first. My first OCaml program (a simple fractal computation algorithm) was about 20 lines long and it took me a whole afternoon and it was no fun at all. After I got used to that syntax I learned to like it, and now I really prefer to almost any other languagues (expect for Ruby). I always prefered it over LISP, since the lot of parenthesis makes it too uniform and therfore hard to read.

  28. First o'caml script by sik0fewl · · Score: 3, Funny

    My first o'caml script:

    o
    oooo o
    ooooo o oooo
    o o o o
    o o oo oo
    o ooo o o
    o o oo
    o o o ooo
    o oooooooo o
    ooo oo o
    ooo ooo
    ooo ooo
    oooo oooo

    Lameness filter encountered.
    Your comment violated the "postercomment" compression filter. Try less whitespace and/or less repetition. Comment aborted.

    Important Stuff

    # Please try to keep posts on topic.
    # Try to reply to other people's comments instead of starting new threads.
    # Read other people's messages before posting your own to avoid simply duplicating what has already been said.
    # Use a clear subject that describes what your message is about.
    # Offtopic, Inflammatory, Inappropriate, Illegal, or Offensive comments might be moderated. (You can read everything, even moderated posts, by adjusting your threshold on the User Preferences Page)

    Problems regarding accounts or comment posting should be sent to CowboyNeal.

    God is slashdots compression filter is retarded..

    sik0fewl Preferences Subscribe Journal Logout Sections ain ApacheApple AskSlashdot 1 more Books BSD 2 more evelopers 1 more Games 11 more Interviews IT 4 ore Linux 1 more Politics Science 3 more YRO 2 ore Help FAQ Bugs Stories Old Stories Old Polls opics Hall of Fame Submit Story About Supporters ode Awards Services Broadband PriceGrabber ProductGuide Special Offers Tech Jobs IT Research

    --
    I remember when legal used to mean lawful, now it means some kind of loophole. - Leo Kessler
  29. Pascal comment by Trillan · · Score: 2, Insightful

    We saw from the examples that the typing in C and Pascal failed for several reasons. It was too fine-grained, as in Pascal's useless distinction between an array of twelve characters and an array of thirteen characters. It led to many spurious error messages, which means warnings that are ignored and waste everyone's time. It was too easy to violate the type systems though union types and casts, and it had to be so, because of the preponderance of spurious errors.

    Can't we give this one a rest? Has anyone run into s:array[1..20] of char being incompatible with s:='Foo'; since the 1970s?

    I feel like I get slightly stupider out of empathy every time I read about that.

    1. Re:Pascal comment by Anonymous Coward · · Score: 0

      Can't we give this one a rest? Has anyone run into s:array[1..20] of char being incompatible with s:='Foo'; since the 1970s?

      I wasn't alive in the 1970's, but in the 1990's when I was taught Pascal in school, "array[1..20] of char" and 'Foo' were different types on both compilers I used.

      Maybe it's better now -- I haven't done Pascal in a while -- but it certainly wasn't universally better 30 years ago.

    2. Re:Pascal comment by Trillan · · Score: 1

      I suppose you're right. The real problem is very likely the standardized class content wasn't updated in 20 years. I was given that line in high school, too, late 80s or early 90s -- teachers just evaded the string type for some reason. I'd been using it for years at that point, on that very compiler...

    3. Re:Pascal comment by marcovje · · Score: 1


      Turbo Pascal, that came out mid eighties had a string type. Delphi improved strongly on that.

      Of course, one can try to argue that Borland dialects are not std pascal (the 70ies kind that the anti pascal rants are about), but the Borland dialects do account for 99.9% of the Pascal programmers.

    4. Re:Pascal comment by dunkelfalke · · Score: 1

      yep. the string problem has been solved for years. and it was practically the only real problem with the pascal strong typing

      --
      Conservatism: The fear that somewhere, somehow, someone you think is your inferior is being treated as your equal.
    5. Re:Pascal comment by Trillan · · Score: 1

      I know Apple Pascal had a string type as well. I'm not sure if that predates Borland's, but it certainly predates the Macintosh by at least a year (call it 1983).

    6. Re:Pascal comment by marcovje · · Score: 1


      The point remains the same. Pascal is constantly bashed for things that nearly all production language had before 1985.

      However the other languages are forgiven for it, but not Pascal for some mysterious reason.

  30. Man, I still don't 'get' functional programming by Anonymous Coward · · Score: 0

    Are there any good websites for how to learn a functional programming language that are devoted strictly to people who are experienced in normal programming languages?

    (Sorry for the use of the word 'normal'. I don't mean anything untoward by that)

    1. Re:Man, I still don't 'get' functional programming by stdcallsign · · Score: 2, Informative

      http://merjis.com/developers/ocaml_tutorial/

    2. Re:Man, I still don't 'get' functional programming by kent.dickey · · Score: 1
      I tried that tutorial website and was reading about ocaml. Writing tutorials is very hard, but when he gave an example for a "range a b" function to give a list with integers from a to b, I just had to try to fix it so that it used tail-recursion in a nice way.

      And when I did, I ran right into a problem: "Stack overflow during evaluation (looping recursion?)."

      Here is my first ocaml code:

      let rec range2 a b accum =
      if a > b then accum
      else range2 a (b-1) (b :: accum) ;;

      let longlist = (range2 1 50000 []) ;;

      print_endline (string_of_int (List.length longlist)) ;;
      let list_str = List.map string_of_int longlist ;; (* This fails *)
      print_endline (string_of_int (List.length list_str)) ;;
      So it can't call a basic function map on a list of 50000 items? Can anyone point out what I'm doing wrong? The code works for lower values like 20000.
    3. Re:Man, I still don't 'get' functional programming by Anonymous Coward · · Score: 0

      This is really a question to ask on http://groups.yahoo.com/group/ocaml_beginners/ where you will have more support.

      As the doc says it, List.map is not tail-recursive (and uses a stack of size the length of the list). You can either
      - compile to native code (supports a much bigger stack)
      - use a tail-rec version such as List.rev_map

    4. Re:Man, I still don't 'get' functional programming by kent.dickey · · Score: 1

      Thanks for the help. I was just seeing if the language was ready for general use. 50000 is a very low limit on recursion, and it also fails when using ocamlc. And the error messages are not very helpful. It's clearly not a jump-right-in language, which is too bad.

    5. Re:Man, I still don't 'get' functional programming by vague · · Score: 1

      The decision to use a non-tail-recursive List.map implementation was a choice for supperior efficiency in the (far more) common case, e g with smaller lists, where it's significantly faster than List.rev_map. People who needs to deal with 50000 element long lists can cope with using List.rev_map or switching to a different data structure like, say, an array or a dynamic vector. These kind of engineering tradeoffs, efficiency vs generality and similar, _needs_ to be made, and the fact that OCaml chose to optimize for the common case and chose efficieny over theoretical beauty (while giving easy access to a more general solutin) should actually tell you that OCaml is a serious product and not an academic curiousity (as much as I adore those) or a beginners toy. You can think they traded the wrong way, certainly, but their decision absolutely isn't one of ignorance or immaturity.

      As for a recursion depth of 50000 being too low, how deep does your recursion usually take you before you start considering the tail-recursive option? If you need greater recursion depth, increase your stack. Simple as that. As for the default, trying it out with Python I got a maximum recursion depth of between 900 and 1000, and that's a practical product used by many. C with msys/mingw/gcc on winXP got a limit of around 72000. That's really not all that much better than the 65000 I got from the OCaml interpreter for the same simplistic program on the same machine.

      --

      -
      Listen. Strange women lying in ponds distributing swords is no basis for a system of government.

  31. Eiffel is all this and more... by darp · · Score: 1

    If you add to the list of features the ability to compile to C source and the support for multiple inheritance then you get Eiffel. The lack of strongly typed extensive base library seems to a problem with Eiffel too.

    1. Re:Eiffel is all this and more... by brpr · · Score: 2, Informative

      If you add to the list of features the ability to compile to C source and the support for multiple inheritance then you get Eiffel. The lack of strongly typed extensive base library seems to a problem with Eiffel too.

      O'Caml is a more advanced language than Eiffel in most respects. It has multiple inheritance too, BTW. Features O'Caml has that Eiffel doesn't:

      * Type inference
      * Higher order functions
      * More powerful type definition (e.g. tagged unions).
      * Syntax/semantics generally much more suited to functional programming, which is pretty much impossible in Eiffel.
      * More concise.

      OK, Eiffel has design-by-contract, but that only adds additional safety, not power.

      --
      Freedom is not increased by mere diminuation of government. Anarchy is freedom for the strong and slavery for the weak.
    2. Re:Eiffel is all this and more... by ElHorrendo · · Score: 1

      While you may know Eiffel you clearly do not know Ocaml. Ocaml has multiple inheritance, in fact it has powers well beyond this as compatibility of types is derived! Deriving types is a power that is hard to comprehend until you've experienced the relief this grants programmers. Conventional languages force programmers to do lots of type administration, and the vast majority of these tasks disappear in Ocaml. They disappear in much the same way memory administration disappears when you have efficient garbage collection.

    3. Re:Eiffel is all this and more... by Anonymous Coward · · Score: 1, Insightful

      Other posters have already sent some great replies but just in case their explainations don't mean much to you considering that you don't seem to be familiar with Caml here's a simpler answer.

      You're comparing apples and oranges. Eiffel is an object oriented imperative language. Ocaml is an impure (as in has some imperative features) functional language with some object oriented constructs which are largely unnecessary as anything that can be done with objects can be done with functors and Ocaml types more naturally in functional programming style.

      Many things that are considered good OOP practises (such as hiding state for example) come naturally to functional languages (assignment is not allowed so there is no need to hide state as you can't change it - sounds limiting but that's only because you're used to imperative programming. Functional programming languages are in fact far more expressive).

  32. Things I want to know about a new language: by Pacifix · · Score: 2, Interesting

    If I am fluent in C++ (powerful), Java (run anywhere) and Ruby (scripting), what advantage does this new language have over those? What problems will this new language solve? If it's one of those above, how is this one better than the language I'm already using? I'm all for learning a new language for fun, but for work I'd better have a good reason for putting out the effort.

    1. Re:Things I want to know about a new language: by pkhuong · · Score: 1

      It's pretty safe (IIRC, I think the only type problem is with the unserialisation, which must be cast upward), but, since it has both static and inferred typing, it's fast while not making you write oodles of declaration just to get your program running. Fans of inferred typing argue that if you're not sure of your program's typing, then you're really sure how it's supposed to work either. Since it's inferred, the typing can be extremely fine-grained, allowing high performance, but you, the user, don't have to do all the grunt work. It's also, dare I say it, a clean language.

      --
      Try Corewar @ www.koth.org - rec.games.corewar
    2. Re:Things I want to know about a new language: by Anonymous Coward · · Score: 0

      If I am fluent in C++ (powerful), Java (run anywhere) and Ruby (scripting), what advantage does this new language have over those?

      Well, for starters, it's not new. You might have just heard of it, but O'Caml, and Caml Special Light before it, have been around for well over a decade.

      O'Caml can be compiled to native code or platform-independent bytecode (sort of like Java's .class files). What can you do? Anything.

    3. Re:Things I want to know about a new language: by ElHorrendo · · Score: 3, Funny
      There are many reasons why OCaml comes out on top in language comparisons. Go to the The Computer Language Shootout Benchmarks and compare them yourself. To name a few:
      • Interactive interpreter and fast native compiler.
      • Parametric polymorphism
      • Pattern matching
      • Functors
      • Highly efficient garbage collection
      • Closures (which I find to be more powerful than Objects)
      • Functions as first class values
      • Derived types - Ocaml is efficient, static and strongly typed, but you can write without explicit typing.
      • Time travel debugger (step forward or backward)
      • Very fast and efficient code.
      • Minimal memory consumption.
      See the Wikipedia for a brief overview.
    4. Re:Things I want to know about a new language: by meowsqueak · · Score: 1

      I'm just curious (not trolling or being obnoxious) to know what you mean by a 'clean language'? Few exceptions to the syntax? Looks tidy?

    5. Re:Things I want to know about a new language: by Anonymous Coward · · Score: 0

      Do a search on functional languages. There are quite a few introductory texts comparing them to imperative languages and what benefits you gain from using functional languages. There are also quite a few studies of the increase in productivity you gain by using Ocaml, Haskell, Scheme or Erlang over something like Java or C++.

    6. Re:Things I want to know about a new language: by Anonymous+Brave+Guy · · Score: 2, Informative

      If you use C++ for its power and flexibility then some of the features in OCaml will make you cry, and realise how low-level C++ remains in some respects.

      I write mathematical software all day in C++, which we use for exactly those reasons (and its good portability). Still, it hurts to think how many times 5+ lines of cluttered C++ would become a single, elegant line in a decent functional language. Obviously the work I do is particularly suited to a functional style, but I've always had a background envy of people who get to use grown-up toys like this in their programming jobs.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    7. Re:Things I want to know about a new language: by Anonymous Coward · · Score: 0

      Its much easier to express recursion in ML than the languages you mentioned. From experience I know it's also alot easier to write things like compilers in ML or do any sort of meta-programming in ML ( like M4). It's also as fast if not faster than C++ and much easier to do the sort of programming u would use generics/STL in C++ for, if you know how to work with ML functors and pattern matching properly.

      But for your average IT project it doesn't really have any benefits and actually a good dynamic language like python or Ruby is much better to work with. And for the record, even tho im a J2EE programmer by trade, Java really sucks.

    8. Re:Things I want to know about a new language: by Anonymous Coward · · Score: 0

      I use Java, C++, and Ruby as well.

      Think about code blocks in ruby:

      mySocket = new TCPSocket("127.0.0.1",80)
      mySocket.each_line{|nex tLine| puts nextLine}

      You can iterate a TCPSocket by passing a function represented as an object to the TCPSocket object's method each_line.

      This is a really cool feature because it hides the underlying imperitive commands to actually iterate the file.

      Ocaml can do this too, using a function instead of a code block. I made a Ocaml version of the ruby TCPSocket object, here is a simple ocaml program demonstrating its use:

      let mySocket = new Jsocket.jtcpsocket "127.0.0.1" 80 and
      printLines nextLine = print_endline arg;
      in
      mySocket#eachLine(myBlock)

      Notice I declare the new socket, the function that will print each line, and call the iteration routine all in the same expression.

      A problem with Ruby however comes from the fact that it is, in comparison to C/C++ and Java, slow. Another weakness it has (which is also a strength) is its lack of static typing.

      For instance:

      def testFunc(inputItem)
      if(rand(1000) == 324)
      inputItem.doSomething
      end
      end

      Now, if the 'doSomething' method didn't exist, you r program would run fine 999/1000 times.

      Ocaml can express the same function, take a mutable input, and also understand at compile time if such an error will occur.

      In short, it has the power and speed of C++, but the elegance and scripting abilities of Ruby. Plus hundreds of other features that come with functional languages I can't explain in context of imperitive ones.

      -Jason Thomas.

    9. Re:Things I want to know about a new language: by Anonymous Coward · · Score: 0

      He's a prick!

    10. Re:Things I want to know about a new language: by Anonymous Coward · · Score: 0

      To make it quick, Ocaml is safer than Java and allows at least as much abstraction as C++, with a cleaner and much more concise syntax, and the same performance and memory needs as C++. That is, it has the best of both worlds.
      Add to this the fact that it has both a virtual machine with a command line AND a native code compiler, and a debugger with which you can go backwards in time, and you start to understand the gain in productivity you can get with this language.

      If the language was supported by a major commercial player like, say, Inprise/Borland or RedHat in a complete development environment, I bet this language would quickly become much more competitive than Java.

  33. OCaml tutorial by Richard+W.M.+Jones · · Score: 4, Informative
    Objective CAML (OCaml) is a very cool and powerful language. We use it at our company extensively, and we've released a lot of tools under open source licenses (see my signature). You can, for example, call Perl and Python libraries, and COM objects directly from OCaml, and interfacing with C is trivial.

    I've also written an OCaml tutorial for people coming from 'conventional' languages like C, Perl and Java.

    Rich.

    1. Re:OCaml tutorial by Richard+W.M.+Jones · · Score: 1

      (and also!) If you're a business using Objective CAML, find other businesses and people using it here.

    2. Re:OCaml tutorial by DannyO152 · · Score: 1

      Ocaml has been at the periphery of things I wanted to learn for a while now. Thanks to the reviewer and team for the heads up about and translation of le livre O'Reilly. And thank you Rich for the tutorial which I plan to work through.

    3. Re:OCaml tutorial by nrrd · · Score: 1

      Wow, I've only read the first couple of sections, but it looks like a great tutorial. I've been meaning to do some OCaml programming and I'll be using your tutorial to get up to speed.

      --
      "Eye halve a spelling chequer, It came with my pea sea, It plainly marques four my revue, Miss steaks eye kin knot sea"
  34. Mercury by G.+Waters · · Score: 2

    Here is a beautiful derivative of prolog in desparate need of an o'reilly treatment.

  35. manual by zymano · · Score: 1

    the manual pdf at the link was way over my head.

    I guess I am no computer science major because it was difficult reading.

    1. Re:manual by 808140 · · Score: 2, Interesting

      Lots of CS majors don't cope well with functional programming paradigms. In the old days (and at many tier 1 CS universities) Lisp or Scheme are still taught as introductory languages, which helps some.

      Functional languages are very intuitive to math majors, and people who study abstract computer science (which is essentially discrete math). Concepts like currying, recursion, and the like make a lot of sense if you're used to the way mathematicians think.

      I don't know Ocaml, but I do program in Haskell. I remember looking at the language as a freshman and finding it very confusing. By the time I'd taken graduate level math classes though, and was comfortable with functors and morphisms, lambda calculus and Haskell were not only a piece of cake, but incredibly intuitive.

      Note that this way of thinking is (at least in my opinion) no more "intuitive" than procedural programming paradigms. It just depends on your background. I had some classmates that never groked programming until they were introduced to ML or Prolog.

    2. Re:manual by zymano · · Score: 1

      I will try learning it again.

  36. Parrot may change this by DrYak · · Score: 1
    Is there any realistic prospect that one of the functional languages I mentioned will strike it rich in either of those ways? It doesn't seem likely to me.


    That's one of the hopes behind a common multiple-language (polyglot ?) virtual nachine like parrot.

    Parrot will support big language like Python and Perl6.
    Bindings and libraries will be written for python-vm but could be used from within any language that supports parrot as target.

    Then you could use or create whatever language you like. As long as it targets parrot, all parrot bindings and libraries will be available to your scripts, even if the libraries aren't written in you language but with some other language supported by parrot.

    Maybe once parrot reaches more stable and mature stages in a couple of years, we may see the advent of a lot of small special purpose scripting languages. Developpers won't be affraid to invent some highly specific language for their application, because users will be able to re-use libraries done for other languages.

    Imagine a Parrot-enabled console in Quake V or Doom VI, and you could try using some AI modules in parrot bytecode format from some MOD for Unreal 2009 (or Duke Nukem 4 if there's the slightest chance it ever comes out by then... )
    --
    "Sufficiently advanced satire is indistinguishable from reality." - [Tips: 1DrYakQDKCQ6y52z6QbnkxHXAocMZJE61o ]
  37. How is this news by patonw · · Score: 1

    I've been using this as a reference since college. This has been out for years.

    1. Re:How is this news by Anomalous+Communard · · Score: 1

      It's not -- it's a review.

  38. Re:I'd consider OCAML by pkhuong · · Score: 1

    If you can't see the structure for the parens, you need an editor.

    --
    Try Corewar @ www.koth.org - rec.games.corewar
  39. Re:I'd consider OCAML by Anonymous Coward · · Score: 0

    huh. I find the lot of parentheses in lisp make the syntax uniform enough to comfortably read. But hey, I like forth and APL syntax too. Small number of rules. I DETEST C++ syntax, and don't like "idiomatic" perl or ocaml (while it is possible to write your own code fairly regularly in either, most of your time as a programmer is spent reading other people's code, and other people's perl or ocaml sucks).

  40. goto by CaptainPinko · · Score: 1

    In this talk appears the quotation:

    It was only because he was unfamiliar with 1960's programming styles that he thought that one goto every fifty lines was a frequent use of goto.)

    Which made me physically shudder. What could these ancient horrors look like? Could anyone post a link to some of this ancient and offensive code? I mean I've written code for school if a group member has used *a* goto. This is something I need to see.

    --
    Your CPU is not doing anything else, at least do something.
    1. Re:goto by 808140 · · Score: 1

      Don't write much assembly, do you?

    2. Re:goto by VoidWraith · · Score: 0

      If you've ever programmed a TI calculator, there's no support for functions, so you either have a lot of gotos, or a lot of "programs."

      On a standard computer, its much less common, but still existant.

  41. Big problem with OCaml by sudog · · Score: 1

    I was getting into OCaml a while back, to the point where I wanted to replace my extant software with OCaml rewrites, and then someone pointed something out to me: OCaml has an annoyingly onerous license. You aren't allowed to distribute, fork, change, or anything the main OCaml source. How annoying!

    1. Re:Big problem with OCaml by Anonymous Coward · · Score: 0

      You are not allowed to change the compiler itself without releasing the source under the same license - I don't think there are any limitations on the software you develop with Ocaml.

    2. Re:Big problem with OCaml by Anonymous Coward · · Score: 0
      You aren't allowed to distribute, fork, change, or anything the main OCaml source.

      This is FUD!

      OCaml is distributed using the QPL and LGPL licenses.

  42. great language, but not quite general purpose by geg81 · · Score: 1

    OCAML is a great language. Unfortunately, despite its excellent performance on many benchmarks, OCAML performance on common kinds of numerical or graphics code is still lacking.

    Basically, if you can't write a complex FFT with a user-defined complex number type and have it work about as efficiently (in both space and time) as equivalent Fortran 90 or C++ code, then the language is not suitable for modern general-purpose applications. Java fails this test, too. Among commonly used modern languages, C++, C#, and Fortran 90 pass that test.

    1. Re:great language, but not quite general purpose by tallbill · · Score: 0

      Why do you need to do FFT with the compiled code? If you are doing applications that require a lot of FFT, then would you not get a co-prcessor to do this of the kind that Texas Instruments produces? Even if you use a language like C++ that does not mean that the algorithms that are used or the way that data is jockied about in memory has effciency and gives you fast output. There are many things to consider besides just a choice of languages.

    2. Re:great language, but not quite general purpose by Fourier · · Score: 1

      Basically, if you can't write a complex FFT with a user-defined complex number type and have it work about as efficiently (in both space and time) as equivalent Fortran 90 or C++ code, then the language is not suitable for modern general-purpose applications.

      I completely disagree.

      1) What do you consider "about as efficiently?" A ten-second search turns up an FFT benchmark written by Xavier Leroy; he reports that it runs about 2/3 as fast as C code.

      2) What the hell kind of "modern general-purpose application" needs to compute FFTs quickly? That's a highly specialized application.

      3) If certain algorithms cannot be computed quickly in OCaml, just write them in C. Bindings to C functions are trivial to write. You want to do FFTs? It's already been done.

    3. Re:great language, but not quite general purpose by Anonymous Coward · · Score: 0

      Have you taken a look at fftw? http://www.fftw.org/
      FFTW runtime is in C, but the C code is generated by a program written in Ocaml.
      The point being not that one should write all code in ocaml, but in some cases its useful to know some of these techniques such as meta-programming, symbolic computation etc.

      I learnt ocaml for one main reason, it helps to learn a new style/paradigm for programming. That has helped me create better code (for certain types of problems) even in imperative languages like java. A toolkit approach to languages is certainly valuable, especially for learning about constructs like closures (ocaml), continuations (scheme), backtracking (mercury), lazy evaluation (haskell, concurrent clean), massive concurrency (erlang), coroutines (ruby, sather etc).

    4. Re:great language, but not quite general purpose by geg81 · · Score: 5, Insightful

      1) What do you consider "about as efficiently?" A ten-second search turns up an FFT benchmark written by Xavier Leroy; he reports that it runs about 2/3 as fast as C code.

      That code doesn't use a complex datatype--it uses real arrays and writes out the complex number operations. The FFT example was not to get an FFT, it was to illustrate a point about what operations a language can and cannot support.

      2) What the hell kind of "modern general-purpose application" needs to compute FFTs quickly? That's a highly specialized application.

      FFT itself is needed by lots of applications: financial software, image processing software, speech recognition software, speech synthesis software, etc. But it isn't about FFT in particular or complex numbers in particular: you encounter analogous problems with datatypes appearing in graphics, reliable numerical computing, graph algorithms, language processing, statistics, and lots of other areas.

      3) If certain algorithms cannot be computed quickly in OCaml, just write them in C. Bindings to C functions are trivial to write. You want to do FFTs? It's already been done.

      You just don't get it, do you? Numerical, semi-numerical, statistical, scientific, graphics, and visualization code is moving into applications and the people who are writing want better tools for writing it than using C or even C++. We are f*cking tired of being told by ivory-tower compiler writers that we should just write our code in C just so that they don't have to get their hands dirty. I have "just linked in" C code for 20 years: it's a lot of work, it's difficult to package, and it erases all the runtime safety that writing in OCAML should give you. It's time that language designers with aspirations for designing general purpose languages get a clue.

      Languages like OCAML and Java are defective as general purpose languages because they don't support efficient data abstraction for numerical types. The fact that their designers just don't get that fact is a testament to the ignorance of their designers. It's also what people really mean when they say that those kinds of languages are "just not efficient as C/C++": it means that in C/C++, you can get whatever code you write to run fast, while in OCAML or Java, there are always problems where you have to drop down to C.

    5. Re:great language, but not quite general purpose by Anonymous Coward · · Score: 1, Insightful

      The point being not that one should write all code in ocaml, but in some cases its useful to know some of these techniques such as meta-programming, symbolic computation etc.

      I know how to do metaprogramming and symbolic computation. But a language that forces me to use such techniques just to compensate for the lack of an efficient way of abstracting numerical data types is defective.

      FFTW runtime is in C, but the C code is generated by a program written in Ocaml.

      It's not about FFT. It's about the lack of an efficient way of abstracting complex numbers, small vectors, intervals, derivatives, and other common compound numericla datatypes in OCAML.

      I learnt ocaml for one main reason, it helps to learn a new style/paradigm for programming.

      OCAML is a great educational tool, as are Haskell, and lots of other languages. But as an efficient, general-purpose programming language, it's a failure. That's regrettable, because it is nice in so many ways. But a language can't be general purpose unless it also supports reasonably efficient, high-level numerical abstractions. The only commonly used languages that currently do are C++ and C#.

    6. Re:great language, but not quite general purpose by Anonymous Coward · · Score: 1, Insightful

      Why do you need to do FFT with the compiled code?

      Complex FFT is just an example. It's an algorithm everybody knows and understands. It involves complex numbers and arrays. There are lots of other examples, from graphics, statistics, UIs, etc.

      If you are doing applications that require a lot of FFT, then would you not get a co-prcessor to do this of the kind that Texas Instruments produces?

      Even if it was specifically about FFT, you wouldn't: general purpose processors are fast enough. And coprocessors are completely unsuitable for other kinds of numerical and semi-numerical code. They are also a pain to program.

      Even if you use a language like C++ that does not mean that the algorithms that are used or the way that data is jockied about in memory has effciency and gives you fast output.

      C++ does this a lot better than OCAML.

      There are many things to consider besides just a choice of languages.

      There are lots of things that need to fall into place in order to get good performance. One thing is that the language needs to have the right primitives. Since OCAML lacks the right primitives, you are guaranteed that pure OCAML code won't be doing well on this type of code.

    7. Re:great language, but not quite general purpose by Fourier · · Score: 1

      Thanks for elaborating--you have made your point more clearly. I'm not sure I agree with the conclusion that OCaml (like Java) is defective due to deficiencies in handling of numeric types, but I see where you're going.

    8. Re:great language, but not quite general purpose by geg81 · · Score: 2, Interesting

      I'm not sure I agree with the conclusion that OCaml (like Java) is defective due to deficiencies in handling of numeric types

      Don't get me wrong: I think OCAML is a great language for specific application domains (theorem provers, compiler writing, etc.), and Java has become a decent language for traditional server-side applications. But in order to become general purpose languages, languages that people can use instead of C/C++ without reservation, I think they must get better numerical support.

      Better numerical support does not mean that those languages have to get implementations that can beat optimized Fortran. It also does not just mean that it is possible, in principle, to write fast numeric code (you can write fast numeric code in Java and OCAML if you really have to--it just is a lot of work). It means that people can write decently clean, maintainable numerical code without having to make much of an effort.

      The thing that is frustrating is that language designers keep underestimating the importance of good support for that kind of programming, and one promising language after another dies because of of that misjudgement.

      In the case of Java, people now have an alternative: C# is basically Java with those missing pieces added. There are lots of political issues surrounding the two languages, but if it just came down to technology, it would be a no brainer to figure out which one would win in the market. And I think functional programming languages won't make it big time until one of them adds analogous functionality.

    9. Re:great language, but not quite general purpose by Anonymous Coward · · Score: 0

      Thought I would chime in on an interesting discussion. The thread is getting old, but I share many of your sentiments about feeling like there currently isn't a "right" language for numerical programming.

      I cannot understand why languages like OCaml don't focus more on numerical implementations. To me, functional languages--especially one like OCaml--seem natural for numerical computing (functions, after all, form the basis for much of numerical computing), and I don't quite understand why there hasn't been more of a push to turn OCaml into something more numerical.

      Along that line, are there any technical limitations--e.g., about the compiler design, etc.--that prevent the sort of numerical libraries you mention from being developed? Is it just a matter of a critical mass of effor being focused on numerical computing in OCaml?

    10. Re:great language, but not quite general purpose by geg81 · · Score: 1
      Along that line, are there any technical limitations--e.g., about the compiler design, etc.--that prevent the sort of numerical libraries you mention from being developed? Is it just a matter of a critical mass of effor being focused on numerical computing in OCaml?

      I think it's the usual combination of things:
      • It requires some small language changes that people who don't need the feature consider unnecessary language complexity, so these kinds of proposals usually cause lengthy discussions.
      • It requires a large chunk of work on an implementation that was designed without those features in mind.
      • The people who need the feature are generally not the ones that are in a position to modify the compiler and runtime; and the people who can modify the compiler and runtime think (incorrectly IMO) that other needs are more pressing and find other topics (call/cc, whatever) more interesting to work on.

      It seems to take a few decades until efficient numerical abstraction facilities get added to languages/language families. With Fortran, it took until the 1990's. With C, it took until C++ came out. With Pascal, it also took until the 1990's. Java has steadfastly refused to do anything about this (despite lots of recommendations and push from users), but C# is picking up the torch there. The core of what is needed is efficient value classes, efficient arrays of value classes, built-in mono-typed multidimensional arrays, a small amount of overloading, and a few smaller sundry things. Nice, but not stricly speaking necessary, are built-in data-parallel array operations and linear algebra functionality in the standard library.

      There have been some timid attempts at efficient functional programming languages for numerical computations. One of the best known is probably SISAL. But while SISAL was a valiant attempt specifically for numerical applications, it fails at being a good general purpose language: that is, numerical code is all you ever want to write in it.
    11. Re:great language, but not quite general purpose by jaoswald · · Score: 1

      The issue with performance of things like the FFT is not really with the language, per se, but with the compilers.

      In fact, a naive implementation of the FFT is going to suck in C also. Because FFT performance is not determined by the expression of the algorithm so much as it is determined by the actual bits-meets-metal details, such as instruction pipelining and memory architectures.

      The way you get efficient FFT algorithms is not just by writing them in C, but having a combination of a library writer and compiler writer who both know how to get the absolute peak performance out of a particular processor (and cache hardware.)

      It just happens that C compilers have included enough hooks to low-level processor primitives, and C serves as a universal "high-level" assembler, so that you can create efficient FFTs that link well to C, and might even be written in C. (Although you better make sure to use the right C compiler or your performance will suffer.)

      The reality is that we are just slightly advanced from the need to write performance bottlenecks in assembler. Somebody sufficiently skilled has to write the routines in carefully tweaked C, and use the best available C compiler to generated architecture-specific libraries.

      If Intel (or even the gcc architects) built OCaml compilers that knew as much about IA-86 as their C compilers do, then you wouldn't be complaining.

    12. Re:great language, but not quite general purpose by Anonymous Coward · · Score: 0

      I don't see how C#, a compiler that compiles to bytecode, can make faster executables than Ocaml's nave code compiler.

    13. Re:great language, but not quite general purpose by Fourier · · Score: 1

      Basically, if you can't write a complex FFT with a user-defined complex number type and have it work about as efficiently...

      Of course, I couldn't help myself and had to go experiment a bit. My conclusion is that you're halfway correct. A naive FFT implementation using the standard Complex module delivers very poor performance. A few minutes with the profiler demonstrates that the biggest problem is the immutability of the standard Complex datatype. You end up doing lots of needless allocations and garbage collections--mark_slice alone accounts for 40% of the computation.

      But if you're willing to compromise a bit, you can use a mutable data structure and get rid of most allocations. The tradeoff is that the code has lots of assignments--not very functional in nature.

      C++ and OCaml code is here. On my (slow) machine, I get the following representative times:

      $ time ./fft_cpp

      real 0m3.143s
      user 0m2.881s
      sys 0m0.128s

      $ time ./fft_ml

      real 0m3.785s
      user 0m3.465s
      sys 0m0.123s

      I consider that pretty good. Note that the C++ STL isn't terribly fast here; you can save about 25% on the C++ code by dumping that in favor of something simpler. But still, OCaml is in the ballpark as long as you're willing to write imperative-looking code.

  43. i think, OCaml/Caml can't cross the 64 MB barrier! by Anonymous Coward · · Score: 0
    Common Lisp on AMD64 : Crossing the 4 GB barrier
    http://groups.google.com/groups?hl=en&lr=&threadm= ullcjfgzd.fsf%40gnu.org&prev=/groups%3Fnum%3D25%26 hl%3Den%26lr%3D%26group%3Dcomp.lang.lisp%26start%3 D0

    OCaml/Caml is worse, worse, worse than the rival Common Lisp when it's supporting intensive memory's applications.

    Have I to rewrite Caml-II-0.7?
    Noooooo!!! Arghhhh!!! I've not time!!!

    open4free ©

  44. Slashdot in OCaml. by Anonymous Coward · · Score: 0

    "OCAML is a great language. Unfortunately, despite its excellent performance on many benchmarks, OCAML performance on common kinds of numerical or graphics code is still lacking."

    Well I guess that means we can write Slashdot in it.

  45. Re:Book is five years old, whew... by JamesOfTheDesert · · Score: 1
    I use Ruby for scripting exclusively, but my experience is that dynamically typed programming languages are not suited for larger projects, since they tend to have a lot of runtime errors

    This is getting off-topic, but maybe this is more a reflection on your coding technique than on dynamically-typed languages?

    Annecdotal evidence abounds for all sorts of claims concerning static vs. dynamic typing. My experience is just the opposite of yours.

    More specifically, if you are writing anything larger than one-off admin scripts then your code should have unit tests. And proper unit tests will catch the odd runtime error you might otherwise see in the wild. They'll also catch the cast exceptions and null pointer exceptions that still plague statically-typed languages. Merely passing a compilation stage, regardless of the typing system, is no assurance of robust code.

    --

    Java is the blue pill
    Choose the red pill
  46. RTFL by pikine · · Score: 3, Informative

    I'm not sure how you could refute the official objective caml license, which clearly states that runtime system and standard libraries are licensed under LGPL (to allow linking with commercial programs), and the compiler and tools are licensed under QPL, which allow you to distribute unmodified code as is, or your modification "in a form that is separate from the Software."

    The example given in QPL is using patches, but I don't see why you can't fork the source, since it would still be "separate" (just don't call it Objective CAML, but something else). QPL does not say your modification has to be in the form of patches.

    --
    I once had a signature.
    1. Re:RTFL by sudog · · Score: 1

      Not accurate. You are not allowed to combine your patches and make a new distribution out of it. They put portions of it under the QPL specifically to prevent people from what they call "taking credit" for their work.

      Total bunk of course, but similar license restrictions are placed on qmail, and the patchsets are a complete mess as a result.

      The LGPL is an attempt to hop on the OS bandwagon, but unless the whole thing is free, what freedom is there in that?

      That sucks.

  47. Further clarification by j1m+5n0w · · Score: 3, Informative
    FFTW is written in C, so I was confused what it had to do with Ocaml. According to the faq:
    FFTW is written in ANSI C. Most of the code, however, was automatically generated by a program called genfft, written in the Objective Caml dialect of ML. You do not need to know ML or to have an Objective Caml compiler in order to use FFTW. genfft is provided with the FFTW sources, which means that you can play with the code generator if you want. In this case, you need a working Objective Caml system. Objective Caml is available from the Caml web page.
    1. Re:Further clarification by myowntrueself · · Score: 1

      Sounds to me as if they are using ocaml to compile 'something' to C.

      I don't think that counts as writing it in C any more than compiling a C program to binary means that I *wrote* the machine code.

      --
      In the free world the media isn't government run; the government is media run.
    2. Re:Further clarification by smallfries · · Score: 1

      From the description it sounds as if genfft creates the C code directly, eg it is a meta-program. Hence the program would contain chunks of ML and chunks of C and an explicit knowledge of how the target program is constructed in C. This is different to writing an FFT in ocaml and having it generate C code.

      --
      Slashdot: where don knuth is an idiot because he cant grasp the awesome power of php
  48. Figurehead!?!?! by Anonymous Coward · · Score: 0

    I thought that all you geeks were supposed to be more rational than that. What is with all this cult-of-personality bullshit.

    oh well, if we must have a figurehead, why not Natalie Portman? I mean, honestly...

  49. An alternate view of the book by jodonoghue · · Score: 2, Informative

    I initally used thebook as a resource for learning Ocaml. My review would be more like:

    Language Core

    This covers the basics of the language, although the presentation of material is somewhat disjointed, which makes the book challenging to use as a reference in the first programming steps.

    The book is clearly a translation, and in some areas the translation is not especially literate, although the meaning of the text is always pretty clear.

    The worst problem with the book is that it is severely out of date with respect to the latest distribution of Ocaml. The aspect that had me tearing my hair out was the lack of coverage of open types - something which is essential to using a GUI toolkit, and which is somewhat complex as there are rules which may come as slightly odd to those used to the implementation of polymorphism in other languages.

    Development tools

    This section gives a good overview of many of the tools available, and is probably the best part of the book. The major ommission is Ocamlp4, which, again, post-dates the book's authorship. Users on Windows (bow your heads in shame... this is Slashdot) will find that their platform is not really covered, which is a shame, as there are a few differences from Windows.

    The rest

    Coverage of libraries is way out of date. For a modern user, the only serious GUI choice is LablGtk2, and it is not covered at all. There are other problems in a similar vein.

    The book contains a number of extended examples. While these smack of being 'undergraduate projects', they do indicate some of the techniques and paradigms of programming in Ocaml.

    Conclusion

    I wouldn't recommend this book. It's too far out of date (imagine buying a book on Perl 4 or Python 1.5). Since the Ocaml manuals are quite comprehensive, and there's an excellent tutorial at merjis.com, which is fast paced and does cover modern language features, there's really no need for this without a significant update. Sorry.

  50. Re:I'd consider OCAML by Anonymous Coward · · Score: 0

    Well then you'll be pleased to know that Ocaml comes, thanks to its camlp4 preprocessor, with three different syntaxes : the standard, the revised, and... Scheme syntax, using pr_scheme.cmo.

  51. OCaml? How do you eat that? by Spy+der+Mann · · Score: 1

    OK OK flamebait, troll, whatever... but I still don't see the point of having a very small niché language messing around open source projects... i've seen a sourceforge project that have a part written in Ocaml, and their dependance on a very small language which very few people know about, is stalling the project big time.

    Maybe Ocaml is the heck of a development language, but I think it's about 5 years late...

    my 2 cents.

  52. Top problem: GUI by nikster · · Score: 1

    I develop in a range of languages, but mostly Java for its cross-platform-ness and GUIs, and Python for its clear syntax.

    If i had a combination of the two - python's pureness and cleanliness and Java's x-platform libraries - i would be pretty happy. However, i would still be stuck with Swing for GUI work.

    I would like to see a language that is built for creating rich GUIs, and have it be as clean and simple as Python, and as well thought out as InterfaceBuilder (OS X).

    Java/Swing (and TCL/TK is surely worse) still requires one to write lots of boring code that should be handled by the framework. In addition, Swing has a huge problem with allowing needlessly many options in implementing common things (and, again, doesn't implement them to begin with) so if you read somebody else's code, chances are they did everything completely differently. There are no design guidelines, and even Sun's code is not consistent in any way.

    O'Caml may be better at some things and in some way than Java or Python, but unless a fantastic GUI framework is included, it's not that interesting.

    1. Re:Top problem: GUI by moebius_4d · · Score: 1

      I develop in a range of languages, but mostly Java for its cross-platform-ness and GUIs, and Python for its clear syntax.

      If i had a combination of the two - python's pureness and cleanliness and Java's x-platform libraries - i would be pretty happy. However, i would still be stuck with Swing for GUI work.


      This isn't my problem, but it sounds like Jython would be a perfect fit for you.

      I prefer Common Lisp, and for those pesky apps that have to run on a Java runtime I've had good luck with Armed Bear Common Lisp
  53. F# by anusjones · · Score: 0

    Microsoft is working on a language based on oCaml, called F#

  54. Practical issues with functional languages by master_p · · Score: 1

    Why use Ocaml? the question has been raised before. Should I use it for being functional? but functional programming has practical issues.

    For example, sorting with functional languages is very very slow, since lists are copied over and over, and for each sorted element, a new list is created. For example, the quicksort algorithm takes each element of the input list, then splits the rest of the list to less than the element and greater than the element lists, sorts these lists and then combines the three parts (the less than part, the element and the greater than part) into the result. It may be only a few lines of code, it may be much clearer than the imperative way, but it is much too slower for practical use.

    So, what advantages Ocaml has over traditional imperative languages like C++ or Java when its functional characteristics are not to be used?

    1. Re:Practical issues with functional languages by Anonymous Coward · · Score: 0
      Three advantages:
      • Very fast and efficient native code compilation.
      • Type inference.
      • Strict type safety.
      • Efficient and transparent memory management.
      At the moment, it's the only language that supports all four at the same time.
    2. Re:Practical issues with functional languages by master_p · · Score: 1

      The reasons you mention are not sufficient enough to make me switch to Ocaml:

      1) efficient code output I already have with C/C++/Java.

      2) type inference is not very important. I would say that it is a disadvantage, as many logical errors will go undetected until the program runs.

      3) I was never tempted to violate safety rules in C++/Java, so it is not something important to me.

      4) Hmm, memory management is an issue with C++. I guess Java wins here.

    3. Re:Practical issues with functional languages by Anonymous Coward · · Score: 0

      1) efficient code output I already have with C/C++/Java.
      But do you have efficiency and great expressive power (closures, pattern matching, functors,...)?

      2) type inference is not very important. I would say that it is a disadvantage, as many logical errors will go undetected until the program runs.
      Please know what you are talking about before uttering such sentences! OCaml type inference will catch errors much better than C++/Java because it is (proved) coherent and powerful (unsafe features are not needed to get the job done).

      3) I was never tempted to violate safety rules in C++/Java, so it is not something important to me.
      So you never use casts? ;-)

    4. Re:Practical issues with functional languages by brpr · · Score: 1

      For example, sorting with functional languages is very very slow, since lists are copied over and over, and for each sorted element, a new list is created. For example, the quicksort algorithm takes each element of the input list, then splits the rest of the list to less than the element and greater than the element lists, sorts these lists and then combines the three parts (the less than part, the element and the greater than part) into the result. It may be only a few lines of code, it may be much clearer than the imperative way, but it is much too slower for practical use.

      Yawn, you just use an algorithm which works efficiently in a functional language, e.g. insertion sort.

      --
      Freedom is not increased by mere diminuation of government. Anarchy is freedom for the strong and slavery for the weak.
    5. Re:Practical issues with functional languages by master_p · · Score: 1

      "But do you have efficiency and great expressive power (closures, pattern matching, functors,...)? "

      C++ has pattern matching and functors. It does not have closures, but there are ways around it that are equally powerful.

      "Please know what you are talking about before uttering such sentences! OCaml type inference will catch errors much better than C++/Java because it is (proved) coherent and powerful (unsafe features are not needed to get the job done). "

      Maybe you should do that. I said "logical errors", not "type errors". Logical errors are when I mistakingly use another type (for example map, instead of linked list), and the error propagates down to the project. With type inference, the compiler will not say anything, because the map and linked list have the same iteration interface. Without type inference, those places that a linked list is expected instead of map will be immediately recognized by the compiler.

      "So you never use casts? ;-)"

      I hardly ever need casts in C++, due to templates.

    6. Re:Practical issues with functional languages by Anonymous Coward · · Score: 0

      C++ has pattern matching ? Whereabout ? I guess you're talking about the thing called partial template specialization. The sole fact that nobody (well, sort of) knows how to use it, apart from the Boost coders, is quite testimonial to its usefulness.

      Face it, doing anything even moderately complex in C++ is a real PITA that requires diving head first in the templates hell and complex class hierarchies.
      Entire books are devoted to this, where Ocaml handles complex codes in a much more safe & elegant fashion.

      In your example where two data types/structures can be used interchangeable, type inference is in the contrary absolutely great, because as soon as you see you used the wrong type (after profiling for instance), it's a matter of seconds to change the type. You won't have to change the rest of the code. While in languages like C++, once 200 functions/classes have been defined with the wrong type, you will have to change the interface of the 200 functions/types and all the calling code. I wish you a nice day doing this.

      Besides, if you can't make the difference between a map and a linked list, then I would advise you to stop programming.(this is not directed at you personnally)

    7. Re:Practical issues with functional languages by Anonymous Coward · · Score: 0

      And in such complex codes, Ocaml is likely to be not only much simpler and safer, but also much faster than C++.

      As an example, compare the compilation speed of the Ocaml compiler (written in Ocaml) and gcc.
      The Ocaml compiler, producing a similarly optimized and similarly complex code, probably is something like 5 or 10 times faster than gcc.

    8. Re:Practical issues with functional languages by master_p · · Score: 1

      "C++ has pattern matching ? Whereabout ?"

      It is not only partial template specialization. C++ selects the method to call based on the types supplied to the method. That's exactly the same pattern matching functional languages have.

      "The sole fact that nobody (well, sort of) knows how to use it"

      You are overreacting. Many coders use it.

      "Face it, doing anything even moderately complex in C++ is a real PITA"

      I've done many complex things in C++, and guess what? C++ is the best language for it. It has the best speed, and one of the best ways to do it.

      "Entire books are devoted to this"

      That there are entire books it means that C++ offers a feature that is quite unique and useful.

      "where Ocaml handles complex codes in a much more safe & elegant fashion"

      There is nothing safe with type inference, as I previously demonstrated. And the functional syntax is no way more elegant that simple Algol-like syntax (at least for me).

      "because as soon as you see you used the wrong type"

      I've talked about an error, not a choice: someone mistakenly types 'list' instead of 'map': the error will propagate deep in the code.

      "it's a matter of seconds to change the type"

      I can do the exact same thing with C++. I always typedef my types.

      "While in languages like C++, once 200 functions/classes have been defined with the wrong type, you will have to change the interface of the 200 functions/types and all the calling code. I wish you a nice day doing this."

      Typedef is your friend! (as I explained above). I actually have done type changes across more than 700 classes with a simple typedef change.

      "if you can't make the difference between a map and a linked list, then I would advise you to stop programming."

      Well, both are collections...they have the same iteration interface. With many things having the same interface (for example, widget classes in a GUI toolkit), it is possible for many things to go undetected when type inference is used.

      As I told you earlier, I always typedef my types, so I never have a problem of changing a type. I only change the typedef.

    9. Re:Practical issues with functional languages by vague · · Score: 1

      I'm late, but you really have no clue and basis for these statements:-/

      "C++ selects the method to call based on the types supplied to the method. That's exactly the same pattern matching functional languages have."

      Ok, the way you confuse polymorphism, overloading, and pattern matching in this statement is just dear. Runtime or compile time? Same difference!

      "There is nothing safe with type inference, as I previously demonstrated. "

      No, you certainly did not demonstrate this, you demonstrated that you don't know what OCaml's type inference does for you.

      "I've talked about an error, not a choice: someone mistakenly types 'list' instead of 'map': the error will propagate deep in the code."

      If you've programmed in such a way that this is true, you only have _one_ place to fix it, just like with your typedeffed code. This is a matter of abstraction, in OCaml as well as in C++.

      And type inference and common interfaces are actually contrary, as the overloading, since type inference has to resolve types at compile time it can't properly resolve overloaded functions like an explicitly typed language can. And that's a problem, with OCaml, which we resort to functorial interfaces for solving (i e we dont have overloading but allow parametrisation on name spaces, achieving the same affect in a more controlled manner), since OCaml doesn't have type classes like Haskell does. Look at the great lenghts C++ and Java goes to make sure to define common interfaces for collections and iteration. And for good reason, common interfaces are a _good thing_. Exactly because you can change a 'map' to a 'list' in one place and get great effects.

      You should actually bother to learn stuff properly before showing of, well, your ignorance.

      --

      -
      Listen. Strange women lying in ponds distributing swords is no basis for a system of government.

    10. Re:Practical issues with functional languages by Anonymous Coward · · Score: 0

      Ok, no need to waste my time answering that.

      All your assertions are wrong, as you have clearly shown that you don't know what pattern matching and type inference are.

  55. Mod: funny? by Anonymous Coward · · Score: 0

    Why is this modded funny? Should be interesting or insightful. Lots of posts here are being modded funny when they shouldn't be...

  56. O'Caml , isn't the the irish relation? by Viol8 · · Score: 1

    Along with his cousin O'Bject?

    #read_expression "x-1";;

    Exception: You don't want to be reading from that stream you don't lad, no, that ya don't...

  57. On Learning a new programming language by systems · · Score: 1

    It's a popular advice (wisdom) that to be a good
    programmer one needs to learn a new programming
    language every now and then.

    Also another good and popular advice that a programmer
    should introduce himself to many programming paradigms
    like OOP, AOP, Procedural, Static, Dynamic, Generic, Strongly typed, Weakly typed, Un-typed, etc ...

    I think choosing to learn O'caml achieves both advices.
    So in other words, you might want to learn O'caml, not just because it's a good language, but because by learning O'caml you might become a better programmer!

  58. Translation by Anonymous Coward · · Score: 0

    The function named 'repeated' takes two arguments. In OCaml, parentheses are not used to surround arguments as they are in C. Instead, they are used to surround tuples, similar to the way braces are used to surround literal arrays in C. Translating the example into C syntax: /* The function takes two arguments */
    void repeated (int a, int b); /* Wrong: only one argument is passed */
    repeated ({123, 456}); /* Right: two arguments are passed */
    repeated (123, 456);

    In the first example the function is called with one argument which is a structure of two elements. Putting parentheses around arguments in OCaml is like putting braces around them in C - it groups them into a single argument.

  59. Parent is Not Safe For Work by Captain+Tripps · · Score: 1

    But then, what were you expecting?

  60. I suspect Pot by Anonymous Coward · · Score: 0

    We'll charge the mod with MUI.

  61. Re:I'd consider OCAML by Anonymous Coward · · Score: 0

    I know that. But now get every other OCAML programmer to use it. Idiomatic OCAML examples are in its baroque monstrosity syntax, not the clean one.

  62. Re:Figurehead by Anonymous Coward · · Score: 0

    Xavier Leroy, the main designer of the language, definitely has the charism and the technical authority to fit that role. Unfortunately, he is not interested in this, as Objective Caml is, first and foremost, a research tool for him and the other members of INRIA.
    He is committed to creating the best possible language, not in adding tons of features, and I think he has succeeded so far in this endeavour. However, he and his team are very careful to keep control on the development of the language and are not very keen in including the works made by the community. For instanfe, there are interesting libraries developed by the community which, imho, ought to belong to the standard lib, but aren't.
    This attitude is quite discouraging. Still, the community is slowly organizing itself around a distribution called GODI which aims to be the ocaml CPAN.

  63. Re:Clean is also very efficient by Anonymous Coward · · Score: 0

    Clean is a very powerful language and also comes with a very efficient native code compiler. Slightly less fast than Ocaml, but a vey expressive language.

  64. OCAML vs Fortran by G3ckoG33k · · Score: 1

    Could Ocaml be a serious alternative to Fortran for scientific/technical computing?