From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id EADD4BC88 for ; Fri, 4 Feb 2005 17:33:22 +0100 (CET) Received: from first.in-berlin.de (dialin-145-254-052-111.arcor-ip.net [145.254.52.111]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j14GXLOD032450 for ; Fri, 4 Feb 2005 17:33:21 +0100 Received: by first.in-berlin.de (Postfix, from userid 501) id 3E585A73A1; Fri, 4 Feb 2005 16:43:15 +0100 (CET) Date: Fri, 4 Feb 2005 16:43:15 +0100 From: Oliver Bandel To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Estimating the size of the ocaml community Message-ID: <20050204154315.GD498@first.in-berlin.de> References: <891bd33905020213315a2ebb18@mail.gmail.com> <009a01c50a1e$f6c92080$0100a8c0@mshome.net> <200502040233.40444.jon@jdh30.plus.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.6i X-Miltered: at concorde with ID 4203A3D1.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; oliver:01 bandel:01 oliver:01 in-berlin:01 caml-list:01 ocaml:01 wrote:01 statically:01 ocaml:01 functors:01 subsection:01 segfaults:01 ...:98 ...:98 abstract:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.2 X-Spam-Level: On Fri, Feb 04, 2005 at 10:29:53AM +0100, Thomas Fischbacher wrote: [...] > If I multiply a speed (in m/s) with a mass (in kg), > I get a momentum (in kg m/s), which I neither can sensibly add to a > speed, or a mass. If I further consider a change in momentum with time, I > automatically get something with units kg m/s^2, that is, a force. > > Of course, I could introduce types for all intermediate quantities which I > will encounter in a problem statically. However, there are many problems > where I do not know a priori which quantities will appear with which > powers, hence I would like to have this with full dynamical flexibility. So, you have to decide, what you want: Flexibility or not? If you want clearly typed values, you can use a language that supports it. If not, use a language that ignores types. But as you said above: Yes, it's necessary to have distinct types that doesn't match and are clearly distinct and incompatible to avoid problems where mixing up different types would be a problem. In your example: "a momentum (in kg m/s), which I neither can sensibly add to a speed, or a mass." So strictly checking types is really helpful here. In OCaml you can use the module system to be helpful here (abstract data types). It is possible to define incompatible types, which are also can be restricted by value and to raise exceptions from within that types. And because of functors it's also possible to use the same structure but by using signatures it can be done that the types are differing. There is an example on this in the Ocaml-book from O'Reilley. Look for subsection "Hiding Type Implementations" in section "Modules and Information Hiding" in Chapter 14 ("Programming with Modules"). The type system of OCaml has helped me a lot in even smaller programs to avoid problems that would be there, when using languages like C, where the "type system" is very loosely, would have caused many problems. Especially when using pointer-stuff, many Segfaults may would have appeared in the program run (and hopefully in the testing phase), where the type system has stopped me. How much more helpful will it be in larger/large projects! I didn't believe that the type system really supports the programmer until I have worked a while with it, and especially (as mentioned by others here), when changing code that is older (and where you may have forgotten a lot of the program's structure because it's too long ago, when you touched the code the last time). In the beginning I similar to you thought: "Well, people say it might help, and so it might help... but I really find it annoying!". Now I see: Well, it might be annoying, when you are new to it, but I now can see *through experience* that it DOES help in programming. Even in small programs it is helpful! Ciao, Oliver