Andreas' practical language comparison

Andreas Koch nospam at kochandreas.com
Mon Apr 26 15:49:01 EDT 2004



Andrea Griffini wrote:

Hi Andrea!

>>I really would like to see the linecount. I do belive that it is one of the
>>indicators of the power of the language and its batteries.
> 
> Then at least you should be talking of the same problem and
> of the same solution to the problem. For example the Delphi
> solution for the 8 queens problem is completely different
> from the ALGOL one (and I must say IMO the Delphi solution
> is quite terrible from an algorithm point of view)

I didn't really get the ALGOL one. My first Delphi version
was using bitmaps and marking endangered fields, but the
code was pretty horrible because i found no elegant way
to fill the diagonals but using 2 loops (~ 20 lines of
not very intuitive additional code)

I find the current version to be quite nicely readable,
while the bitmap solution would probably be faster.

> comparing
> a linecount for that that with a linecount for a totally
> different solution is just nonsense.

Depends. The solution often reflects how certain problems
are handled in a language.

> However this create problems for very different approaches;
> implementing a certain algorithm in prolog and comparing it
> with the same algorithm in C has any meaning ? If say one
> solution uses generators (may be heavily and with backtracking,
> for example in Icon) how can you implement the same solution
> on a language that has no generator concept at all ?
> Even if you manage to do that, what's the point in finding
> that you needed a lot of lines of code to do it ?

I have some tests that require to solve an problem, and some
that require to use an certain algorith. I think you can
encounter both situations in real life. Of course, saying
"A needs 20 lines so its better than B which needs 22 lines"
is idiotic.

> I'm very new to python, but anyway this is my solution to 8
> queen's problem:

Thanks, i allready had lots of submissions by mail this
night. Lots more feedback than expected :-D

> Does this mean that Python is less expressive ? that
> C is less clear ? Or just means one program has been
> written trying to be expressive and the other trying
> to be compact ?
> 
> If I run that Delphi solution for the 8 queens problem
> should I conclude that Python is faster than Delphi ?

Good questions. Any ideas for solutions?

-- 
                                   Andreas
He screamed: THIS IS SIG!



More information about the Python-list mailing list