Penguin

Differences between version 15 and revision by previous author of ML.

Other diffs: Previous Major Revision, Previous Revision, or view the Annotated Edit History

Newer page: version 15 Last edited on Thursday, February 20, 2003 5:04:31 pm by GlynWebster Revert
Older page: version 12 Last edited on Sunday, February 16, 2003 1:03:24 am by PerryLorier Revert
@@ -1,21 +1,19 @@
 ''(I'm still working on this, so some parts will still be gibberish. --GlynWebster)'' %%% 
 ''(And I may be wandering off into little tutorials where I don't need to. What do you think? --GlynWebster)''%%% 
-''(Tutorial's are good, this is supposed to be an interesting place to go and learn stuff from, however, not all these concepts are exclusively ML, for instance StaticallyTyped, HigherOrder, PolyMorphic, Functional, Standardi__s__edLanguage , are all attributes of other programming languages too, breaking these out into their own pages would be educational no? -- PerryLorier)'' 
+''(Tutorial's are good, this is supposed to be an interesting place to go and learn stuff from, however, not all these concepts are exclusively ML, for instance StaticallyTyped, HigherOrder, PolyMorphic, Functional, StandardisedLanguage , are all attributes of other programming languages too, breaking these out into their own pages would be educational no? -- PerryLorier)'' 
  
 !!!ML in one paragraph, with buzzwords: 
  
-ML is a family of StaticallyTyped[1], higher-order[2], polymorphic[3], strict [4 ] functional programming languages with a higher-order module system[5]. ML is very good general purpose programming language[6] with a strength in pattern matching[7]. ML can  
- be used interactively for learning, experimentation and testing, or it can be compiled. The two major dialects of ML are [Ocaml] and [SML]. SML is a standardized language[8] with several implementations[9]. Ocaml has a single open source implementation[10],  
- it extends ML with an OOP system[11]. Both major dialects have compilers that produce native code that rivals the speed of C++, and extensive standard[12] and third-party[13] libraries. 
+ML is a family of StaticallyTyped[1], [strict | StrictEvaluation][4] [ higher-order | HigherOrderFunctions] [2], polymorphic[3], [FunctionalLanguage ]s with and a higher-order module system[5]. ML is very good general purpose programming language[6] with a strength in pattern matching[7]. ML can be used interactively for learning, experimentation and testing, or it can be compiled. The two major dialects of ML are [Ocaml] and [SML]. SML is a standardised language[8] with several implementations[9]. Ocaml has a single open source implementation[10], it extends ML with an OOP system[11]. Both major dialects have compilers that produce native code that rivals the speed of C++, and extensive standard[12] and third-party[13] libraries. 
  
 ''(Click a footnote for more info.)'' 
  
 !!!An example of ML code: 
  
  __fun__ interpret_functionally (program : opcode list) : unit = 
  (* Interprets a parsed [Brainf*ck] program using integers 
- on a strip of Turing Machine tape as the memory. *) 
+ on a strip of TuringMachine tape as the memory. *) 
  __let__ 
  __val__ fresh_tape = Tape.make(0) 
  __fun__ step (tape, op) = 
  __let__ byte = Tape.read(tape) __in__ 
@@ -26,10 +24,10 @@
  | Dec_byte n => Tape.write(byte - n, tape) 
  | Putchar => ( putchar(byte) ; tape ) 
  | Getchar => Tape.write(getchar(), tape) 
  | Loop body => 
- __if__ byte = 0 __then__ tape  
- __else__ step (step_sequence (tape, body), op) 
+ __if__ byte = 0 __then__ tape  
+ __else__ step (step_sequence (tape, body), op) 
  __end__ 
  __fun__ step_sequence (tape, oplist) = 
  List.foldl(step, tape, oplist) 
  __in__ 
@@ -45,12 +43,9 @@
  
 [2] 
 !!!Polymorphism 
  
-This is what prevents ML's strong type checking from being a pain in  
- the bum. You don't have to define the type of everything ''exactly'',  
- you can leave some types, or parts of some types unspecified. For  
- example this is a type for binary trees: 
+This is what prevents ML's strong type checking from being a pain in the bum. You don't have to define the type of everything ''exactly'', you can leave some types, or parts of some types unspecified. For example this is a type for binary trees: 
  
  # __type__ 'a tree = Leaf __of__ 'a | Node __of__ 'a tree * 'a tree ;; 
  ''type 'a tree = Leaf of 'a | Node of 'a tree * 'a tree'' 
  
@@ -78,10 +73,9 @@
  
 [3] 
 !!!Higher-order Functions 
  
-Higher-order functions are functions that take other functions as parameters,  
- create functions or return functions. 
+Higher-order functions are functions that take other functions as parameters, create functions or return functions. 
  
 I want make new trees from old ones by changing the leaves. So I write a function to do this for me. One of its parameters will be a function that takes the value of a leaf and returns the changed value. 
  
  # __let rec__ map change tree = 
@@ -108,20 +102,19 @@
 And it does! 
  
 If I write a few more functions like this I will have a reusable library of binary tree operations. ML makes writing reusable code and easy and ''reliable'' process. 
  
-There's a lot more things you can do with higher-order functions, some of then very painful. I've just shown you there's at least ''one'' good thing you can do with then here. 
+There's a lot more things you can do with higher-order functions, some of them very painful. I've just shown you there's at least ''one'' good thing you can do with then here. 
  
 ''Higher-order functions are something ML has in common with [Haskell].'' 
  
  
 [4] 
 !!!Strict Evaluation 
  
-ML expression and function calls are evaluated in the strict fashion: the value of the expression for each parameter is worked out before passing to a function . If you've used a an ImperativeLangauge like [C] or [Java], then this is just what you are used to. Strict evaluation means you can predict the order that ML expressions will be  
-evaluated in, and ML can allow reassignable variables and a conventional I/O system -- which it does. 
+ML uses StrictEvaluation . This means that ML can allow reassignable variables and a conventional I/O system -- and it does. 
  
-''The other approach to evaluation is "lazy evaluation". A functions is passed whole expressions as parameters and do not evaluate them until it need their values. (I won't go into __why__ you'd want that, but there are good reasons.) [Haskell]'s main semantic difference from ML is that is it is lazy . ( If you enjoyed Haskell programming at WaikatoUniversity but because exasperated with "monads" and working out convoluted ways to make your programs preserve state, ML may be the thing for you.) '' 
+''[Haskell]'s main semantic difference from ML is that is it uses LazyEvaluation . If you enjoyed Haskell programming at WaikatoUniversity but because exasperated with [Monad]s and working out convoluted ways to make your programs preserve state, ML may be the thing for you.'' 
  
  
 [5] 
 !!!Higher-Order Module System 
@@ -139,10 +132,10 @@
  
 and creates an abstract data type module for sets of type ''t''. [String | http://caml.inria.fr/ocaml/htmlman/libref/String.html] contains the 
 necessary definitions (t = string) so we can use that: 
  
- # __module__ String_Set = Set.Make(String);;  
- ''module String_Set :'' 
+ # __module__ !StringSet = Set.Make(String);;  
+ ''module !StringSet :'' 
  ''sig'' 
  ''type elt = string'' 
  ''and t'' 
  ''val empty : t'' 
@@ -156,16 +149,29 @@
  
 [6] 
 !!!ML is very good general purpose programming language 
  
-''(more to say. ..)'' 
+The type system means that even when I just sit down and hack, I get good quality code.  
+  
+* I can leave out type definitions. This lets me program in the succinct, flexible way I can in [Python], without the let-down of having all my type errors pop up a runtime.  
+  
+* The type system is very expressive. It encourages a style of programming where you think about your data, what it consists of and how you will transform it. Programs designed by type tend to be very modular, they almost have to be by definition.  
+  
+* The type system is very exact. It allowed the compiler to spot many big, logical errors at compile time, and well as the little nit-picky syntactic ones.  
+  
+ ''(more to say..)'' 
  
  
 [7] 
 !!!Pattern Matching 
  
-''(more to say ...)'' 
+Pattern matching is ML's strength. ML has an expression that is halfway between [C]'s__switch__ and declaration statements. In SML it is called __case__ and in Ocaml it is called __match__. Instead matching a value with single constants, like the __switch__ statement, __match__ can match values of any complexity by example, and select parts of the value to assign to variables as it does it.  
+  
+__Match__ statements are very clear and compact.  
+  
+ ''(example to come ...)'' 
  
+Pattern matching is a very useful in general, but it is particularly handy in programs that manipulate complex tree-structured data, such as the parse trees in compilers. The [original ML language| http://wombat.doc.ic.ac.uk/foldoc/foldoc.cgi?ML] was designed by someone who needed to do a ''lot'' of automated algebra on statements of symbolic logic.  
  
 [8] 
 !!!SML standard 
  
@@ -203,13 +209,14 @@
 !!!Standard Libraries 
  
 The [SML Basis Library | http://cm.bell-labs.com/cm/cs/what/smlnj/doc/basis/pages/sml-std-basis.html] is said to be very well designed. 
  
-The Basis library is indeed very well designed, but for SML/NJ (one of the major SML compilers) it is poorly documented, making it somewhat difficult to use. --GianPerrone 
+'' The Basis library is indeed very well designed, but for SML/NJ (one of the major SML compilers) it is poorly documented, making it somewhat difficult to use. --GianPerrone'' %%%  
+''The Basis Library pages I've linked to above seem adequate to me. Or those not what you are talking about? --GlynWebster''  
  
 Ocaml's library is divided into: a [core library |http://caml.inria.fr/ocaml/htmlman/manual033.html], types and function available at all times; an implementation independent [standard library | http://caml.inria.fr/ocaml/htmlman/manual034.html], modules that can be imported; and set of [optional libraries | http://caml.inria.fr/ocaml/htmlman/index.html#p:library] that are either implementation dependent or special purpose. 
  
  
 [13] 
 !!! Third-Party Libraries 
  
 [The Caml Link Database | http://www.npc.de/ocaml/linkdb/] and [The Hump | http://caml.inria.fr/humps/index.html] are the central repositories for [Ocaml] software.