68

More OCaml

 5 years ago
source link: https://www.tuicool.com/articles/hit/iaUbii3
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

(Note, long after I wrote this entry: I think OCaml has some fairly fundamental problems that keep it from being a first choice for server-side development. If I were to use it for anything, it would be as a substitute for C++ in delivering client-side executable/GUI programs, e.g. for Windows systems. And I still think it's a really cool language.)

I wasn't really planning on writing another blog entry on OCaml, but... gosh. And I use the word "gosh" advisedly. I'm at a loss for words here.

Sure, yes, OCaml generates lightning-fast executables, with much, much better code than C++, apparently regardless of which C++ compiler or platform you're comparing it with.

And yeah, OCaml is pretty much the most expressive language I've ever used, maybe more expressive even than Ruby and Lisp, and I'm still not finished learning the more exotic features like Functors.

Yes, yes, it supports OO, imperative, functional and logic programming, seamlessly intermixed, so you can program a solution in any style appropriate to the problem at hand. We all know that.

And it's no big deal that there's a perl4caml module that lets you use *any* CPAN module seamlessly in your OCaml program, and a mod_ocaml for Apache, etc. etc.

And most people probably don't care that it has an exceptionally high-quality Emacs mode, and an interactive intepreter (as well as a high-performance native-code compiler), and some great libraries (including graphics bindings for various UI toolkits).

It probably doesn't even matter that it has full C++ bindings for those times when you really need to make calls into code written in a slower language.

You might not even care that it comes with a rich set of libraries that rivals the Java platform APIs in comprehensiveness and usability. Or that it's been ported to .NET (and soon, the JVM).

But come on... you have to stop and take notice at the OCaml replay debugger, which can step backwards through time as well as forwards. You don't see that every day.

At first I was a bit amazed at how much support there is for real-world development in OCaml - as far as I can tell, it's got everything you'd find in any other mainstream language, with a relatively smaller user community.

But now I think it's not amazing at all; it's a natural consequence of the fact that it's simply a superior language. It stands to reason that if you have a language that really does live up to the promise of making people (say) 10 times as productive as the other languages out there, then it will only take 1/10th the people (or time) to reproduce the functionality that's been created for other languages. And it's been around for a decade - much longer if you consider that it was derived from ML, which started in the late 1980s.

All that hoity-toity stuff aside, though: nobody really cares about most of that when they're actually using a language. To learn a new language takes a real commitment, especially if it's not from the Algol imperative family (as are C, C++, Java and Perl). What really matters is whether you can get stuff done, and whether the language feels "comfortable" when you're using it. I can't speak for anyone else, of course, but in my experience with it so far, I find it a real pleasure to use - and I would even if it didn't have such incredible runtime performance.

It was one of the more difficult languages to pick up, and took some serious digging and head-scratching before I started to write in it naturally. But once you get past the syntax, and work with it for a while, I think you'll find that it's a really comfortable language. There are LOTS of ways to do things; you can program in a Lisp-y style if you like, or a Perl-y style, or just about any other style. But when you finally get your stuff past the compiler, it usually works correctly the first time. The only runtime bugs I've ever had were incorrectly specified algorithms. I'm really starting to like having code that works the first time - more often, in fact, than in Java or other statically-typed languages I've used a lot.

If you're interested in looking at it, you should start here:

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

Have fun!

(Published July 02, 2004)


Recommend

  • 123

    Emacs Plugins in OCaml: Hello, Ecaml! (part 1) Published: 2017-11-05T16:00:00-05:00 Last updated:...

  • 127

    vim-ocaml Vim runtime files for OCaml. These are synced periodically with the builtin support that comes with Vim. Users are recommended to use this repository directly however as it's more up to date. Installation Dependi...

  • 26
    • www.tuicool.com 6 years ago
    • Cache

    Plans for OCaml 4.08

    With the external release of OCaml 4.07.0 imminent, we in Jane Street’s Tools & Compilers group have been planning what we want to work on for inclusion in OCaml 4.08. These days OCaml uses (or at least attempts) a ti...

  • 51
    • www.tuicool.com 6 years ago
    • Cache

    Introduction to OCaml

    Preface This post series started as a response to requests from some friends curious about OCaml. There are quite a few nice books already, but I realized that if I just recommend them any one of those books, i...

  • 73
    • www.tuicool.com 5 years ago
    • Cache

    Deep learning experiments in OCaml

    Last year we held a machine learning seminar in our London office, which was an opportunity to reproduce some classical deep learning results with a nice twist: we used OCaml as a programming language rather than Python....

  • 59
    • www.tuicool.com 5 years ago
    • Cache

    Adding an Effect System to OCaml

    March 8, 2018 Effective Programming: Adding an Effect System to OCaml Presented by: Leo White Type systems designed to track the side-effects of expressions have been around fo...

  • 39
    • www.tuicool.com 5 years ago
    • Cache

    Ocaml vs Maybe Not

    In Rich Hickey's recent talk, Maybe Not , he argues various weaknesses of static types, using Haskell as an example, and the strengths of Clojure Spec. To sum...

  • 33

    Dune is fast. However, if you try to use Dune to develop in a big workspace such as the OCaml platform repository , you will notice that on every run, even if there is no...

  • 55
    • www.tuicool.com 5 years ago
    • Cache

    OCaml bindings for PyTorch

    ocaml-torch ocaml-torchprovides some ocaml bindings for the PyTorch tensor library. This brings to OCaml NumPy-like tensor computations with GPU acceleration and tape-based au...

  • 67
    • www.tuicool.com 5 years ago
    • Cache

    Functional Programming in OCaml

    Functional Programming in OCaml Spring 2019 Edition Based on courses taught by Michael R. Clarkson, Robert L. Constable, Nate Foster, Michael D. George, Dan Grossman, Daniel P. Huttenlocher, Dexter...

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK