[Tutor] python, speed, game programming
spir
denis.spir at gmail.com
Sat Jan 4 12:19:53 CET 2014
On 01/04/2014 10:14 AM, Steven D'Aprano wrote:
> While I agree with Devin, it is possible to write absurdly slow code in
> *any* language. This is why is is better to write straightforward,
> simple code in preference to complicated, intricate code -- it is easier
> to understand simple code, which means it is easier to work out which
> bits are bottlenecks and do something about them. Then, only if it turns
> out the code is too slow, do you add complexity to speed it up.
+++
I would add: it is preferable to write _clear_ code, in the widest sense of
"easy to understand". Simplicity is not the only factor or clarity (good naming,
using right constructs [1], direct mapping from conception to code structure &
logic...); also, some simple schemes are very difficult to figure out (eg
various functional programing idioms).
From clear code, everything else is easier: modification, extension, improving
efficeincy (time and/or space), doc, debugging, testing, trials... I would even
say (surprisingly?) that clarity has precedence over correctness: it's easier to
correct clear code, while correct but obscure code makes anything else harder.
personal point of view: Issue number 1 in programming is understanding (what
code actually means and actually does). That's why we spend about 97.531% of our
time thinking ;-)
Denis
[1] Python's "one good way to do it".
More information about the Tutor
mailing list