Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Functional programming versus imperative

Author: Anthony Cozzie

Date: 05:55:45 02/18/04

Go up one level in this thread


At CMU, I took 15-212 (Functional Programming).  Basically, we learned Standard
ML (ML stands for metalanguage) and wrote some rather complex stuff, including a
parser/typechecker/runtime environment for a small Logo-like language (it
included functions, and custom types if I remember correctly).

Basically, it took most people a while to transition from C to ML.  Some people
never did it.  I had one friend who, while an incredibly sharp C/assembly coder
(currently getting his PhD at CMU in signal processing) just didn't "get" ML.
It is simply different, and if you try to write C-ish ML you will fail
miserably.

ML allows you to write some amazingly compact and readable programs.  I seem to
remember posting an implementation of regular expressions in ML - it is about 25
lines, versus several hundred for a C implementation.  I made far fewer mistakes
in ML than in C, and most of those were caught by the type-checker, not at
runtime.  If you can get a program to "compile" in ML, there is at least a 50%
chance it will work perfectly on the first run.

Standard ML is about 10 times slower than C.  OCAML, the french version, is
about 50% slower.  I don't think functional languages are a good idea for
writing chess programs, but they certainly have their place.

anthony



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.