Lisp vs C++
I'm testing out Lisp against C++ for a brief bit of practice in the former. Bearing in mind that I'm vastly more experienced in C++, the results are surprising.On the radiant primes problem, my C++ solution, very sparsely-commented, takes 272 lines. So many brackets! Even stripping out all the comments and all of the spacing-related and argument-reading code (which is built-in to Lisp), it's still 164 lines.
Character-wise, it's 408 words and 3405 characters, according to wc.
The Lisp version, which I did in an afternoon, while learning the language, using descriptive function names, is a mere 38 lines; 147 words, 1036 characters. I'm sure there are much better solutions in both languages, of course!
Conclusion: a more general, malleable, and comprehensible solution in Lisp is between one-third and one-eighth the verbosity of the C++ version.
I must assess the execution speed.
Posted at 2004-02-12 12:33:00 by Richard • Link to Lisp vs C++
