is there any principle when writing python function
steve+comp.lang.python at pearwood.info
Sat Aug 27 16:27:32 EDT 2011
Chris Angelico wrote:
> On Sun, Aug 28, 2011 at 3:27 AM, Emile van Sebille <emile at fenx.com> wrote:
>> Code is first and foremost written to be executed.
> +1 QOTW. Yes, it'll be read, and most likely read several times, by
> humans, but ultimately its purpose is to be executed.
You've never noticed the masses of code written in text books, blogs, web
pages, discussion forums like this one, etc.?
Real world code for production is usually messy and complicated and filled
with data validation and error checking code. There's a lot of code without
that, because it was written explicitly to be read by humans, and the fact
that it may be executed as well is incidental. Some code is even written in
pseudo-code that *cannot* be executed. It's clear to me that a non-trivial
amount of code is specifically written to be consumed by other humans, not
It seems to me that, broadly speaking, there are languages designed with
execution of code as the primary purpose:
Fortran, C, Lisp, Java, PL/I, APL, Forth, ...
and there are languages designed with *writing* of code as the primary
Perl, AWK, sed, bash, ...
and then there are languages where *reading* is the primary purpose:
Python, Ruby, Hypertalk, Inform 7, Pascal, AppleScript, ...
and then there are languages where the torment of the damned is the primary
INTERCAL, Oook, Brainf*ck, Whitespace, Malbolge, ...
and then there are languages with few, or no, design principles to speak of,
or as compromise languages that (deliberately or accidentally) straddle the
other categories. It all depends on the motivation and values of the
language designer, and the trade-offs the language makes. Which category
any specific language may fall into may be a matter of degree, or a matter
of opinion, or both.
More information about the Python-list