From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 72AE07FB2F for ; Tue, 16 Dec 2014 20:18:04 +0100 (CET) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of jon@ffconsultancy.com) identity=pra; client-ip=84.93.230.235; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="jon@ffconsultancy.com"; x-sender="jon@ffconsultancy.com"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of jon@ffconsultancy.com) identity=mailfrom; client-ip=84.93.230.235; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="jon@ffconsultancy.com"; x-sender="jon@ffconsultancy.com"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@avasout07.plus.net) identity=helo; client-ip=84.93.230.235; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="jon@ffconsultancy.com"; x-sender="postmaster@avasout07.plus.net"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArIAAEiEkFRUXebrnGdsb2JhbABahzbIZAKBHBYBAQEBAREBAQEBAQYNCQkULoQMAQEBAwEIAhlbCAMCCRgCAiYCAhkjDQENAgQBHQUOiAYMvnOGU49lIIEhiGmFb4JogUEFjgJMiS6MdoM4giACHIFQgzEBAQE X-IPAS-Result: ArIAAEiEkFRUXebrnGdsb2JhbABahzbIZAKBHBYBAQEBAREBAQEBAQYNCQkULoQMAQEBAwEIAhlbCAMCCRgCAiYCAhkjDQENAgQBHQUOiAYMvnOGU49lIIEhiGmFb4JogUEFjgJMiS6MdoM4giACHIFQgzEBAQE X-IronPort-AV: E=Sophos;i="5.07,588,1413237600"; d="scan'208";a="113688272" Received: from avasout07.plus.net ([84.93.230.235]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 16 Dec 2014 20:18:03 +0100 Received: from XPS ([213.162.118.65]) by avasout07 with smtp id UKHt1p0031QkhfZ01KHuhu; Tue, 16 Dec 2014 19:18:01 +0000 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=T7ICTp6Q c=1 sm=1 tr=0 a=npoQGnjoXlZRf5WRtrkx/g==:117 a=npoQGnjoXlZRf5WRtrkx/g==:17 a=0Bzu9jTXAAAA:8 a=IkcTkHD0fZMA:10 a=r2vSxAw-AAAA:8 a=uCfUsy1Gknj-KER39XoA:9 a=QEXdDO2ut3YA:10 X-AUTH: jdh302:2500 Reply-To: From: "Jon Harrop" To: "'Jonathan Kimmitt'" , References: In-Reply-To: Date: Tue, 16 Dec 2014 19:17:58 -0000 Organization: Flying Frog Consultancy Ltd. Message-ID: <012d01d01965$04f54ac0$0edfe040$@ffconsultancy.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 14.0 Thread-index: AQI6G8KffbMg76ArljBUheBrMXxXupu+iz/g Content-Language: en-gb Subject: RE: [Caml-list] teaching OCaml Jonathan Kimmitt wrote: > First of all by using the CLR it runs rather slowly, especially consideri= ng 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 f= aster 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 beas= t 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 ordin= ary ML types in F# but you can still observe them quite easily: > [Some 3; None];; val it : int option list =3D [Some 3; null] See the "null" creeping in there as the (design flawed) internal representa= tion of None... Also, .NET also provides a System.Nullable. On a related note, the two different syntaxes for parametric polymorphism t= end to confuse students in my experience. F# offers both "int list" and "li= st" 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 by= tes and byte arrays, respectively. You still cannot do 'A'B..'Z'B in a patt= ern though. > But the real bugbear for teaching is that indentation is by default signi= ficant in the syntax (instead of using ()/begin/end like OCaml). You can ea= sily imagine the wonderful results of importing an indentation specific lan= guage into Outlook or Word to write an assignment given the cavalier attitu= de to line breaks which is taken by the Office suite in general. I know the= re are supporters of the lite syntax on the list but to me it is a can of w= orms, comparable to the way that Outlook uppercases every word at the begin= ning 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 havi= ng 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 =3D x+y" instead of assuming x and y are integers as OCaml would do, ins= tead some obscure error message pops up such as "unable to infer type in th= is 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 ope= rator 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 ru= nning Windows then OCaml is a disaster and F# wins hands down. If you're ru= nning 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 i= s great for metaprogramming with tools like lex and yacc but GUIs are an ab= solute nightmare. In F#, lexing and parsing are harder (I use active patter= ns) but GUIs are a piece of cake. Cheers, Jon.