caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Jon Harrop" <jon@ffconsultancy.com>
To: "'Jonathan Kimmitt'" <jonathan@kimmitt.co.uk>, <caml-list@inria.fr>
Subject: RE: [Caml-list] teaching OCaml
Date: Tue, 16 Dec 2014 19:17:58 -0000	[thread overview]
Message-ID: <012d01d01965$04f54ac0$0edfe040$@ffconsultancy.com> (raw)
In-Reply-To: <sympa.1417002734.16986.738@inria.fr>

Jonathan Kimmitt wrote:
> First of all by using the CLR it runs rather slowly, especially considering almost everything is an object.

That is certainly not true in general. Purely functional code is likely to be slower in F# than OCaml. Imperative and numerical code is likely to be faster in F# than OCaml. For example, hash tables with keys/values that are value types were several times faster on .NET than in OCaml, last I looked. And multicore code is likely to be a lot faster in F#, of course.

> The second blunder is the re- introduction of the NULL pointer, that beast of many horns which OCaml works so hard to get rid of (Some _/None is the type-safe alternative).

F# has both type safe Some|None and null. Note that you cannot interchange them accidentally in your program as null is not a valid value of any ordinary ML types in F# but you can still observe them quite easily:

> [Some 3; None];;
val it : int option list = [Some 3; null]

See the "null" creeping in there as the (design flawed) internal representation of None...

Also, .NET also provides a System.Nullable<T>.

On a related note, the two different syntaxes for parametric polymorphism tend to confuse students in my experience. F# offers both "int list" and "list<int>" to mean the same thing, which is rather ridiculous.

> A further complication for beginners is that the char type is unicode so it is not possible to make use of nice syntax like "match ch with 'A'..'Z'".

The syntax 'a'B and "Hello world!"B gives you ASCII chars and strings as bytes and byte arrays, respectively. You still cannot do 'A'B..'Z'B in a pattern though.

> But the real bugbear for teaching is that indentation is by default significant in the syntax (instead of using ()/begin/end like OCaml). You can easily imagine the wonderful results of importing an indentation specific language into Outlook or Word to write an assignment given the cavalier attitude to line breaks which is taken by the Office suite in general. I know there are supporters of the lite syntax on the list but to me it is a can of worms, comparable to the way that Outlook uppercases every word at the beginning of a line whether it is the start of a sentence or not.

Yes, that sucks. I suffer the most when pasting code from the web. And having translating some significant commercial code bases between OCaml and F# I can tell you that indentation sensitivity doesn't buy you much.

> Finally don't forget F# has operator overloading so in a routine "let f x y = x+y" instead of assuming x and y are integers as OCaml would do, instead some obscure error message pops up such as "unable to infer type in this context".

Operator overloading is a huge win over +, +., +|, +/ and so on though. And "1.2 + 2.3" giving a type error is not optimal. And the F# approach to operator overloading is the best of any language, IME, because any errors are local and you never take a performance hit for it.

From my point of view the OS is the elephant in the room here. If you're running Windows then OCaml is a disaster and F# wins hands down. If you're running Linux then F# is a disaster and OCaml wins hands down (although it'll be interesting to see what open source .NET for Linux does). This is true to the extent that I teach quite different courses in OCaml and F#. OCaml is great for metaprogramming with tools like lex and yacc but GUIs are an absolute nightmare. In F#, lexing and parsing are harder (I use active patterns) but GUIs are a piece of cake.

Cheers,
Jon.



  reply	other threads:[~2014-12-16 19:18 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-25 16:03 robert.muller2
2014-11-25 16:33 ` John Whitington
     [not found]   ` <CAKmYinnv1arGZGQ2s0O7K2u=hr=oieiDXzR8YU_habM4+bUdJA@mail.gmail.com>
     [not found]     ` <5474C87D.4030307@coherentgraphics.co.uk>
2014-11-25 18:21       ` John Whitington
2014-11-26 14:26         ` Drup
2014-11-26 16:34         ` Xavier Leroy
2014-11-25 19:40 ` Daniel Bünzli
2014-11-26 11:37 ` Kenichi Asai
2014-11-26 18:12   ` Yaron Minsky
2014-11-26 22:09   ` Marek Kubica
2014-11-26 12:16 ` Jonathan Kimmitt
2014-12-16 19:17   ` Jon Harrop [this message]
  -- strict thread matches above, loose matches on Subject: below --
2014-11-25 16:43 Arthur Charguéraud
2014-11-25 17:27 ` Alain Frisch
2014-11-25 17:33   ` Arthur Charguéraud
     [not found] <16574.54515.560699.848619@gargle.gargle.HOWL>
2004-06-03 14:27 ` [Caml-list] Teaching OCaml Brian Hurt
2004-05-17 11:28 Simão Melo de Sousa
2004-05-17 17:27 ` Michael Hamburg
2004-05-17 17:40   ` David Brown
2004-05-18  8:52   ` Richard Jones
2004-06-02 17:41     ` Holger Schulz
2004-05-17 21:12 ` Evan Martin
2004-06-02 12:43 ` Holger Schulz
2004-06-02 13:06   ` Nicolas Cannasse

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='012d01d01965$04f54ac0$0edfe040$@ffconsultancy.com' \
    --to=jon@ffconsultancy.com \
    --cc=caml-list@inria.fr \
    --cc=jonathan@kimmitt.co.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).