Computing Reviews
Today's Issue Hot Topics Search Browse Recommended My Account Log In
Review Help
Search
Practical OCaml
Smith J., Apress, Berkeley, CA, 2006. 488 pp. Type: Book (9781590596203)
Date Reviewed: May 22 2008

Functional programming--in the form of various dialects of Lisp, ML, Haskell, Extensible Stylesheet Language Transformations (XSLT), XQUERY, and Erlang--has been around for a while and has proven its worth both in academic projects, where functional programming is much more popular, and in real-world applications. Functional programming has become a hot topic recently. In particular, Microsoft’s release of F#, a functional programming language for the Common Language Runtime (CLR), has significantly raised the visibility of the field. Learning to program in a functional style is not just an exercise in learning yet another programming language. Functional constructs are showing up in other languages: Java will soon have support for some functional constructs, Python has incorporated list comprehensions, and Ruby incorporates a number of functional notions. It can also be a good way for programmers who may use other paradigms to improve their programming style.

This book is an introduction to objective Caml (OCaml); the acronym CAML originally stood for categorical abstract machine language, although OCaml abandons this abstract machine. OCaml is a functional language, in the ML tradition, with support for both imperative and object-oriented programming. OCaml is a relatively popular functional language and has a large presence, but this seems to be the only book published so far on the language.

The 27 chapters can be divided into three types: discursive--including the introduction and the “digressions” explaining why OCaml is not pure, and what functional programming is good for; tutorial--including chapters on the syntax of the language, on functions, on types, and so on; and practical--presenting worked out code to solve relatively simple problems, including a spam filter and a Web crawler.

The practical chapters are not terribly bad. The code is relatively readable and the problems are real but simple enough to be solved in a single chapter, with solutions encompassing 100 to 200 lines of code. There are several places where new language constructs are not well explained, the code tends toward the cryptic, and some things just don’t seem to make sense. The code is available for download, although this fact does not seem to be mentioned anywhere in the book. From the perspective of the rest of the book, the practical chapters actually look pretty good.

The problems start in the second chapter with the first real interaction with the language. The text says that you can enter code at the prompt and it will be evaluated after you type ;; and return, leading the reader to believe that the word “return” must be typed. There is no explanation of why two semicolons are used. OCaml uses ;; differently than ; or even ; ;. I could understand why this was not explained in the second chapter, but I couldn’t find it explained anywhere else in the book. Yet, both the double semicolon and the single semicolon are used in the code samples. An online search quickly turns up an explanation, but then again, an online search also turns up several OCaml tutorials, extensive documentation, and lots of code samples.

A complete enumeration of the problems and downright errors is neither feasible nor reasonable for this review. Many of the problems seem to arise from Smith’s assumption that the reader already knows what is being explained. In some cases, further explanations are given later in the book, although they are not always indexed; in far too many other cases, the reader is left adrift.

Other problems stem from code that is less than readable. In some cases, lines of code are continued with a curved arrow indicating end-of-line, even though they could easily be continued on the next line and properly indented. Code is often far terser than required, and sometimes variable names are very poorly chosen. These problems are far worse in the tutorial sections where their impact is greater.

For the determined reader who already knows OCaml, the practical chapters provide usable code and some small applications worth looking at. I would not recommend this book to anyone else.

Reviewer:  Jeffrey Putnam Review #: CR135623 (0903-0210)
Bookmark and Share
  Reviewer Selected
Featured Reviewer
 
 
Very High-Level Languages (D.3.2 ... )
 
 
Compilers (D.3.4 ... )
 
 
Applicative (Functional) Programming (D.1.1 )
 
 
Formal Definitions And Theory (D.3.1 )
 
 
Object-Oriented Programming (D.1.5 )
 
Would you recommend this review?
yes
no
Other reviews under "Very High-Level Languages": Date
Design of very high-level computer languages
Klerer M., McGraw-Hill, Inc., New York, NY, 1991. Type: Book (9780070350984)
Mar 1 1992
Icon semantics--a formal approach to icon system design
Chang S. International Journal of Pattern Recognition and Artificial Intelligence 1(1): 103-120, 1987. Type: Article
Jun 1 1989
High-level languages and software applications: a reference
Birnes W. (ed), McGraw-Hill, Inc., New York, NY, 1989. Type: Book (9789780070053946)
Mar 1 1990
more...

E-Mail This Printer-Friendly
Send Your Comments
Contact Us
Reproduction in whole or in part without permission is prohibited.   Copyright 1999-2024 ThinkLoud®
Terms of Use
| Privacy Policy