Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Functional programming versus imperative

Author: Vincent Diepeveen

Date: 07:32:15 02/18/04

Go up one level in this thread


On February 18, 2004 at 08:55:45, Anthony Cozzie wrote:

>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

Professor Swierstra (functional programming) focussed for a few years our
attention upon functional programming languages being so good in parsing.

Especially with a few Haskell scripts he had copied from somewhere you could
very well parse stuff.

After a few years i was so sick from this guy (he's even more stubborn than Uri
Blass) that i took a bet.

Someone who had written his thesis about functional programming and who was
giving courses functional programming took the bet.

We both would write a CGI script. He in gofer + haskell. Diep in C.

The cgi script had to parse certain things from submissions and needed to get
parsed in the CGI script then a HTML form had to get shipped back to the WWW
server. Of course it had to be bugfree.

I took me 30 minutes to write this in C.

It took him a week to get it to work in gofer.

In fact he didn't finish a buggy version until 2 days after the bet.

Additionally his gofer thing was hell slow of course. Lazy evaluation you
know... ...it's dead slow!

Anyone defending functional languages should know better. Any nonsense that is
claimed about the languages doing better than imperative languages is a big
nonsense.

Even quickbasic + 1 string lib beats the hell out of it.

You see, no one has written huge programs with it. That's the problem. As soon
as you have to commercially work, you have to be above that 0.5 source code
lines an hour.

In such functional languages you don't manage, but in C/C++/JAVA/c# you will
easily get to 10 or more.








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.