Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Functional programming versus imperative

Author: Uri Blass

Date: 19:41:10 02/17/04

Go up one level in this thread


On February 17, 2004 at 19:33:52, Vincent Diepeveen wrote:

>On February 17, 2004 at 06:41:11, Tord Romstad wrote:
>
>>On February 16, 2004 at 14:38:44, Robert Hyatt wrote:
>>
>>>On February 16, 2004 at 14:25:10, Tord Romstad wrote:
>>>
>>>>On February 16, 2004 at 14:03:11, Robert Hyatt wrote:
>>>>
>>>>>Please re-read my statement.  Look at the date.  Then re-read yours.
>>>>>
>>>>>My statement was written in 1997.  In general Lisp _was_ interpreted.
>>>>
>>>>No, it wasn't.  Lisp has been a compiled language for *decades*.  If you
>>>>look at the ANSI Common Lisp standard (from 1991, if I recall correctly),
>>>>you will see that the standard even *requires* a compiler.  There is
>>>>one implementation (CLISP) which compiles only to bytecode, all other
>>>>major Lisp implementations have compiled to machine code since a very
>>>>long time.
>>>>
>>>>>Of
>>>>>course, so was BASIC.  Yet there were basic compilers as well.  My primary point
>>>>>was speed.  Lisp is slow.  It always was slow.  It always will be slow.
>>>>
>>>>It *isn't* necessarily slow.  I have even provided one data point (from
>>>>1999, just two years after your statement was written) to illustrate that
>>>>Lisp in practice often enables you to write *faster* programs in *less*
>>>>time compared to C/C++.
>>>
>>>Personally, I would take _any_ challenge to compete with a lisp program, when
>>>the goal is performance.  Granted, high-level languages may reduce the
>>>_development_ time.  All the previous languages I have mentioned come to mind,
>>>from Prolog, to APL, to Snobol.  But when execution speed is the issue, I'll
>>>take C _every_ time, and if I were unable to beat a lisp program at speed, for
>>>the same functionality, I'd probably turn in my coding pad.  :)
>>>
>>>Just as surely as I would take assembly over C if speed were the ultimate goal,
>>>no matter how good the C optimizer is.  A bad programmer can write bad C code.
>>>A programmer that is not familiar with a computer (take a Cray) will probably
>>>get beaten by the optimizer.  But for a human that knows the architecture, I'll
>>>take the lowest-level language every time, when raw NPS or whatever is the goal.
>>
>>The key point is the "knows the architecture" part.  Just like an assembly
>>language program doesn't automatically run faster than a C program just
>>because it is written in assembly language, a C program doesn't automatically
>>run faster than a Lisp program just because it is written in C.  In both
>>cases, you need some in-depth knowledge of the computer hardware to take
>>advantage of the low-level features of C or assembly language.  In both
>>cases, the performance gain given by the lowest-level language isn't
>>extremely big.  Given optimizing compilers of the same quality, the
>>performance difference between assembly language and C is probably
>>comparable to the difference between C and Lisp.
>
>Though i love Hyatt crawling over the floor, i have to admit that in this case
>he must be crawling laughing for your idiocy here.
>
>Let's start the functional programming subject.
>
>I wrote a checkersprogram in a functional language. It was called gofer
>(developed at university amsterdam). Deliberately i didn't use Haskell features
>because haskell is in fact imperative and that would defeat the goal.
>
>The checkers program using lazy evaluation and such high level language stuff,
>was searching at 2 nodes a second.
>
>It took me a week or 2 to make and optimize the gofer program.
>
>Then i converted that by hand into a C program. That took 1 day and it was
>10000-20000 times faster. Of course interpreted.
>
>When compiled the C program was factor 50-100 faster.
>
>Functional programming languages would be great to parse anything and easy to
>use.
>
>Well after writing a checkersprogram i realized at least 2 of its disadvantages.
>Not only it's dead slow but also you can only make small functions. Have you
>ever written a serious application in LISP?
>
>I doubt it.
>
>Really i do.

I know nothing about lisp but Tord wrote a complicated chess program in C and he
defines himself as better in lisp than in C so I guess he wrote more serious
application than his chess program in lisp.

Uri



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.