How coding in Python is bad for you
bc at freeuk.com
Mon Jan 23 19:44:14 EST 2017
On 23/01/2017 22:09, Chris Angelico wrote:
> On Tue, Jan 24, 2017 at 8:55 AM, BartC <bc at freeuk.com> wrote:
>> On 23/01/2017 17:34, Chris Angelico wrote:
>>> On Tue, Jan 24, 2017 at 4:24 AM, <breamoreboy at gmail.com> wrote:
>>>> The article is here http://lenkaspace.net/index.php/blog/show/111
>>> I would respond point-by-point if I thought the author had a clue.
>> I thought points 1 to 4 were valid, in that the assertions were true.
> 1 is wrong - there is structure, same as in every language. Or if it's
> true, it's true in every language.
Python (I think in common with other scripting languages) allows you to
place statement outside functions, either before, after or in-between
functions. While functions themselves, as well as imports, can be
2 is also trivially true - you can
> ALWAYS define variables wrongly. Yes, okay, so you don't have data
> type checking, but that's only going to catch a specific subset of
With Python, you can take function names that you've defined, imported
modules, or math.pi, and set them all to "edward g robinson". (The name
just came into my head..)
> 3, well, okay. But if you get your indentation wrong in C++,
> Java, etc, it should fail code review.
With C++ or Java, it's possible to tell the indentation is wrong
(because of the extra redundancy of having the indentation /and/ block
delimiters). That's a bit harder in Python making source more fragile.
> 4 is flat out wrong.
(About having no compiler.) Yes (C)Python does have a byte-code compiler
but there are a vast range of errors that it cannot trap at compile-time
because of its dynamic nature.
Maybe you can run tools to do extra analyses, but as it's normally used,
many errors are not detected until execution. Spelling errors in names
for example. (Actually when I tested my assertion above I assigned to
math.p rather than math.pi; no error not even at runtime, just the wrong
result. Or technically the right one, as math.pi still had the usual value!)
I'm not criticising it, just stating facts which may well have been the
experience of the guy who wrote the article, giving the impression of a
more chaotic, free-for-all language than they may have been used to, or
More information about the Python-list