Welcome Guest.   Make a donation to an author on the site April 19, 2014, 02:01:54 AM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
The N.A.N.Y. Challenge 2011! Download 30+ custom programs!
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1] 2 Next   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: Python Language Annoyances  (Read 7605 times)
mouser
First Author
Administrator
*****
Posts: 32,668



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« on: January 22, 2010, 05:28:08 PM »

[EDIT: This discussion was originally on this thread]

first let me just say this, python uses implicit variable declaration (ie you dont have to declare a variable before it is used, you just use it).

to me, this is the single worst most harmful idea in the history of programming languages, and it completely baffles me that it can be found in a modern and popular language.  that single issue is reason enough that no one should be using this language.

this is actually a little related to why the issue of significant indentation is such a bad idea -- because it makes it so easy to introduce bugs that are nearly invisible to the naked eye (using a tab instead of a space, mispelling a variable name, etc.)

the syntax is a personal thing, but just feels wrong to me.. having to declare object functions with "self" as the first parameter (even though when you invoke it you dont pass that.  this optional class documentation string stuff, by just specifying a string after the def line.. it just feels kludgey and dirty.
« Last Edit: January 24, 2010, 07:54:06 PM by mouser » Logged
kartal
Supporting Member
**
Posts: 1,529


View Profile Give some DonationCredits to this forum member
« Reply #1 on: January 22, 2010, 09:21:13 PM »

mouser,

Please check out these articles if you have time. These are quite old but I think that they explain where Python is really practical and easy to use

http://www.ibm.com/develo...orks/library/l-pycon.html
http://www.ibm.com/develo...linux/library/l-prog.html
Logged
tinjaw
Supporting Member
**
Posts: 1,926



I'm so glad breakbeat techno isn't an illegal drug

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #2 on: January 24, 2010, 02:37:22 PM »

Just very brief comments, since I know you will investigate deeper if you care to (and have the time).

It boils down to static typing versus dynamic typing; and the workflow that goes along with that.

And most Python programmers do TDD, so bugs are found via testing and there is no need to compile so you just run and debuging realtime based on stacktraces (which are integraded into the python tools that are worthwhile using).
Logged

 
tinjaw
Supporting Member
**
Posts: 1,926



I'm so glad breakbeat techno isn't an illegal drug

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #3 on: January 24, 2010, 02:40:34 PM »

Oh, and regardless of what tools you use, use IPython. Yes, it is that good. I always have an IPython window open regardless of what platform I am on or tool I am using. Think of it as a fulltime realtime debugger with built in macros.
Logged

 
f0dder
Charter Honorary Member
***
Posts: 8,774



[Well, THAT escalated quickly!]

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #4 on: January 24, 2010, 07:39:15 PM »

First: this is about Python, not IDEs - I suggest a moderator separate this post, and the posts below, to a new thread:
It boils down to static typing versus dynamic typing; and the workflow that goes along with that.
No, it doesn't smiley - you can do dynamic typing even if you have to predeclare variables (just declare them as "var" rather than a specific type). Even though I generally prefer static typing (catching bugs at compile-time = Kiss), I do accept that dynamic typing can be useful (especially while prototyping stuff  - nice not having to bother with endless type conversions)... but not requiring variables to be predefined is a big mistake, IMHO.

And I also agree with mouser that it's also a big mistake depending on indentation for program structure... there's just too many ways this can screw you over, and it's not like it's a big hurdle to {enclose structural blocks}. These two things are items I find problematic (and downright stupid) in the core Python language.

Also, as mouser, I think the "__self__" for Python OOP looks kludgy, nasty and superfluous. This is more of an aesthetic issue though, and not something that bothers me majorly. Most importantly, it's not dangerous as the above two points.

Final gripe is probably the standard library, which feels... messy. Some stuff tries to look like POSIX C which is OK for a lot of stuff, while other parts look like WIN32 emulations. Of course one shouldn't re-invent the wheel all the time, but it would be nice with a somewhat more coherent standard library. There's also the issue of not everything being available everywhere, leading to perhaps having to do platform-specific code (probably less of a problem now than when I last bumped into it - and I can't remember the specifics anyway).

There's also been a fair amount of times where I've scratched my head pondering why a particular routine throws an exception instead of using a return code... IMHO exceptions should be for exceptional conditions, whereas return codes signal "failure" that can be "expected" (ie, a file-read that fails would be an exception, file-not-found would be return code) - but when to use exceptions (and when not to) is somewhat of a religious subject.

And most Python programmers do TDD, so bugs are found via testing and there is no need to compile so you just run and debuging realtime based on stacktraces (which are integraded into the python tools that are worthwhile using).
Even with that, I'm still a firm believe in my first two points... doing those properly costs you almost nothing, and will very likely end up saving you a lot more in the end.

But in spite of all the above, I still do like Python, and find that it's a pretty nice tool for a lot of things, where you'd spend too much time in C++ focusing on auxillary stuff rather than getting your job done.
Logged

- carpe noctem
mouser
First Author
Administrator
*****
Posts: 32,668



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #5 on: January 24, 2010, 08:02:05 PM »

Sorry to be harsh, but here's another example of what i think is almost unbelievably shoddy language design, and is a huge warning sign for me that Python should be dumped in favor of a new language at the earliest possible time:

http://www.velocityreview...t-operator-in-python.html

The use of ++variable and variable++ is a very common way of incrementing and decrementing variables, from the days of C and C++ and it can be found in Java and many other languages.

Now.. it's completely fine that Python not implement this -- I am all in favor of eliminating redundant ways to write expressions.  I have no complaint about python not supporting the increment operator.

However, what is totally insanely stupid is to design a modern language where the ++variable syntax is completely legal, and does nothing.

That is a decision absolutely guaranteed to cause problems and i'd be extremely surprised if there wasn't production code with such errors.

It just boggles my mind that someone could design a modern programming language and come up with such a poor design choice.

It's almost as if one of the goals of Python is to make it as easy as possible to write incorrect code that doesn't trigger any obvious errors.  This is not the way languages should be designed.

[In the interest of full disclosure, i should say that i am a native C/C++ coder, and C has it's own share of such things, for example in making this kind of conditional legal but misleading "if (a=5) ..", which was one of the great blunders of language design.  Haven't language designers learned not to do this by now?]
« Last Edit: January 24, 2010, 08:06:22 PM by mouser » Logged
mouser
First Author
Administrator
*****
Posts: 32,668



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #6 on: January 24, 2010, 09:29:59 PM »

Disclaimer:
I get very mad at things and have been known to rant incoherently at every piece of software I have ever used.  I am actually now using Python in a new little project, and I can say for some things it's very nice..  And I use PHP quite a lot which has it's own set of problems.  Every language does.

So don't take my harsh words against Python as some indication that i think it's any worse than every other major programming language.

I'm just trying to lay the groundwork for making my own programming language in the coming years Wink
Logged
mouser
First Author
Administrator
*****
Posts: 32,668



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #7 on: January 25, 2010, 03:22:42 AM »

Just thought that I should add that, despite my complaints above, which i stand by, i've been coding in Python all weekend, and i do have to admit I'm having a lot of fun with it and getting a lot done.  Love the built in stack-trace printout when it hits an error, and nice module importing/compiling/etc.
Logged
parkint
Supporting Member
**
Posts: 119


It's bad luck to be superstitious

see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #8 on: January 25, 2010, 08:43:40 AM »

In my experience (spanning 30+ years, with over a dozen different languages) EVERY language/OS/protocol has its own peculiar annoyances.
Of course, each has its strengths and I like calling upon a particular "solution" based on how well it will address the "problem" at hand.
I appreciate the variety from which to choose.

Remember, "The great thing about standards is that there are so many to choose from"
Logged

tinjaw
Supporting Member
**
Posts: 1,926



I'm so glad breakbeat techno isn't an illegal drug

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #9 on: January 25, 2010, 11:40:32 AM »

Just a word for "outsiders". I am considered one of the Python fanbois on this site. And I have been a regular here for years. I just wanted to let you know that mouser is being sincere here. He just doesn't have the time to list the many things he likes about the language, and we around here don't feel ashamed to just cut to the chase when discussing things. So please don't take his comments the wrong way.

With out boring you with details and requiring time I don't have to dedicate to this, let me just say that I believe much of this has to do with keeping things as simple as possible and python being more "metaprogramming" focused than other languages.

And a reminder to import this, as it will give you a better understanding of python.
Logged

 
mnemonic
Supporting Member
**
Posts: 176



see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #10 on: January 25, 2010, 03:33:32 PM »

For someone like myself, without any formal development background, Python is great as it is easy to learn and quick to develop in. I can't comment on any of the issues that mouser raises, as I don't know anything different.

I did start to learn C++, but barely enjoyed a moment of it due to the trickiness of some of the syntax.  As someone who only develops in spotty bits of spare time, having a simple language is a godsend.

Simple languages with easy syntaxes are great for allowing beginners to get into developing and that can only mean more people developing  Thmbsup

Plus, having implicit variable declaration quickly teaches you to write tests everywhere  Grin
Logged
urlwolf
Charter Member
***
Posts: 1,783



see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #11 on: January 25, 2010, 05:57:47 PM »

I'm on the same boat.
I don't like many things about python, ant this is why I'm looking at scala. Type inferencing is good.
Logged
kartal
Supporting Member
**
Posts: 1,529


View Profile Give some DonationCredits to this forum member
« Reply #12 on: January 25, 2010, 06:23:46 PM »

What I like about Python is that there are applications out there that use Python as internal scripting engine which makes it more available. That way I do not need to learn every other scripting engine that applications might require.

For example Open Office, Gnumeric and Gnucash offer Python scripting
« Last Edit: January 25, 2010, 06:52:40 PM by kartal » Logged
urlwolf
Charter Member
***
Posts: 1,783



see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #13 on: January 26, 2010, 03:35:56 AM »

Quote
Plus, having implicit variable declaration quickly teaches you to write tests everywhere 
Actually, I see very little python code out there with tests. Ruby, on the other hand... even pastie clips have tests!
Logged
ewemoa
Honorary Member
**
Posts: 2,241



View Profile Give some DonationCredits to this forum member
« Reply #14 on: January 26, 2010, 04:39:17 AM »

On a side note, if you want to see some (lots?) of tests for a piece of Python code, Mark Pilgrim's Universal Feed Parser might be something to take a look at.
Logged
kakarukeys
Supporting Member
**
Posts: 25



Save time play more

View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #15 on: January 28, 2010, 12:18:27 PM »

Now.. it's completely fine that Python not implement this -- I am all in favor of eliminating redundant ways to write expressions.  I have no complaint about python not supporting the increment operator.

However, what is totally insanely stupid is to design a modern language where the ++variable syntax is completely legal, and does nothing.

That is a decision absolutely guaranteed to cause problems and i'd be extremely surprised if there wasn't production code with such errors.

In mathematics, +x simply means x with a positive sign, and ++x = +x = x
Python simply conforms to what we learned in primary, secondary schools
Another example: 1 / 2 = 0.5 in Python, but 1 / 2 = 0 in C
And what's wrong to write x += 1, if you want to increase the value of x by 1?

this is actually a little related to why the issue of significant indentation is such a bad idea -- because it makes it so easy to introduce bugs that are nearly invisible to the naked eye (using a tab instead of a space, mispelling a variable name, etc.)

An IDE or a good text editor will help. Same could be said for programming languages that use braces, unmatched braces could give you trouble that isn't easily spotted by naked eyes.
Logged

life is short, play hard
ewemoa
Honorary Member
**
Posts: 2,241



View Profile Give some DonationCredits to this forum member
« Reply #16 on: January 28, 2010, 08:21:53 PM »

In mathematics, +x simply means x with a positive sign, and ++x = +x = x
Neat Thmbsup
Logged
mouser
First Author
Administrator
*****
Posts: 32,668



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #17 on: January 28, 2010, 08:26:30 PM »

Let's get real here.. like all languages, context means everything.  In python, like many languages, the + character sometimes means positive (a=+7), or it means addition (a=b+3), or it means string concatenation (a="hello "+b).  Few languages are stupid enough to allow a ++ to mean nothing (or signifiy a positive number) and not throw an error.

TEST:
What does ++---+-+7 evaluate to in python? or is it an error?

If everyone who uses Python can't immediately, obviously, and confidently surmise the answer to this (and be in agreement), then you have to accept that this is a terrible flaw in the language.

Hell even if you can, it's just plain stupid.

It's like me introducing a language where + means division and * means addition.  It may be internally consistent, but it is spitting in the fact of decades of established syntax, for no good reason, and will lead to tons of undetected errors.

Again, it's fine to break with precedent, but you need to have a good reason and make an attempt to flag likely incompatibility problems.  Python has too many of these kinds of pointless problems.
« Last Edit: January 28, 2010, 08:37:07 PM by mouser » Logged
kakarukeys
Supporting Member
**
Posts: 25



Save time play more

View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #18 on: January 28, 2010, 08:57:16 PM »

 Cool well, remember 3 things:
(1) +/- in front of variable is a unary operator that changes the sign (as in maths)
(2) plus plus = plus, minus minus = plus, plus minus/minus plus = minus (as in maths)

To me these are rules that were established long before programming language, since the time of Greek. It's C which changed the rules, and that's why I and some had had a hard time learning C in school, Python is more natural to me.

(3) There is usually only one way to perform certain task (Pythonic principle)

It is not hard to understand Python's choice and figure out the answer to the TEST.
 smiley
« Last Edit: January 28, 2010, 09:06:24 PM by kakarukeys » Logged

life is short, play hard
wraith808
Supporting Member
**
Posts: 5,809



"In my dreams, I always do it right."

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #19 on: January 29, 2010, 10:33:26 PM »

Well, what I can say, is that I took a programmer with minimal knowledge and got him Hello World! (the book on manning.com for Christmas).  I had never used python up until now, but I've been going through the PDF that I received for free with the book so that I could answer questions for him.

The Pros:
1. He's gotten up to speed quite quickly- moreso than I would have expected.
2. It's very easy to pick up- much more than any other language that I have used- and get concrete and useful things done without all of the baggage of most languages

The Cons:
1. The errors that he's had to bring to me are because of the indentation and the lack of implicit variable declarations

I think it's a nice, lightweight language- especially for teaching (and learning).  I do expect him to move on fairly quickly, but this was a way to get him programming and into the problem solving mindset rather quickly before starting classes as a developer.
Logged

ewemoa
Honorary Member
**
Posts: 2,241



View Profile Give some DonationCredits to this forum member
« Reply #20 on: January 30, 2010, 01:49:47 AM »

I'm curious (famous last words?), how many Python-using folks here use PyChecker or something like it?  I found it useful for the few things I used it for and IIRC it can point certain kinds of things out that the interpreter doesn't tell you about.

To drift a bit OT, FWIW:

For Perl, I tended to use -w and use strict, both of which helped.  (It appears there's now a Perl::Critic.)

For Javascript I used jslint.

May be there's a pattern here? Wink
Logged
tinjaw
Supporting Member
**
Posts: 1,926



I'm so glad breakbeat techno isn't an illegal drug

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #21 on: January 30, 2010, 03:09:42 PM »

I code with Eclipse/Aptana/Pydev and get all of the code checking that come with that.
Logged

 
f0dder
Charter Honorary Member
***
Posts: 8,774



[Well, THAT escalated quickly!]

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #22 on: January 31, 2010, 11:59:17 AM »

1. The errors that he's had to bring to me are because of the indentation and the lack of implicit variable declarations
I suppose you mean explicit?

I'm still a firm believer that choosing indentation for blocks was a mistake - delegating checks to a 3rd-party tool instead of the language core doesn't really help. Same goes for not requiring explicit variable declaration (which, as mentioned previously, has nothing to do with static vs dynamic typing).
Logged

- carpe noctem
wraith808
Supporting Member
**
Posts: 5,809



"In my dreams, I always do it right."

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #23 on: January 31, 2010, 09:31:13 PM »

Oops... yeah.  Explicit.  I found that really prone to causing errors on vb if you had the option for Explicit declarations off... and it's no different in Python.  And yes, considering that different editors indent in different manners- indentation sucks as a block method.
Logged

ajp
Participant
*
Posts: 22


View Profile Give some DonationCredits to this forum member
« Reply #24 on: February 09, 2010, 12:37:12 PM »

@Mouser:
Implicit variable declaration... I don't now. (Disclaimer: I am a Python fanboy of some sort but) I learned programming with Pascal and C, so I pretty much became used to the discipline of declaring variables. So, all my "relevant" variables get declared (well, initialized) in meaningful places. "Non-relevant" ones (i.e. counters that are used in a loop and don't get re-used later) I just use them as I go without taking much notice (which is sometimes convenient). Since I already have the mindset of "declarations go at the beggining of the block", it's simply natural and convenient at the same time. But I guess for someone who is using Python as a learning language, s/he must be taught of the importance of declaration for readability's sake.

As for indenting, if you and your teammates get to an agreement on tabs vs. spaces (I know, flame war's awaiting), it quickly becomes natural, and you won't miss typing { or } again in your life.

If I must rant about something, here it comes:
* "self". Yep, it's unelegant. It leaves the context clear and explicit, but it's ugly.
* unicode support. I guess in v3.0 it's better (haven't used it yet), but on v2.x, since I normally need "special" chars (I'm Mexican; accents are nothing sort of "special" in Spanish), it's a chore that simple read/write ops get polluted by unicode(x), x.encode('utf-8','replace') and so on.

Still, I love Python.
Logged
Pages: [1] 2 Next   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.057s | Server load: 0.33 ]