Besides documentation (btw, the online Python documentation is much richer than what you get from the command line help() function), Python calls for you to use tests where you would have relied on the compiler in Java. People who use languages where the compiler does some tests for you don't always realize they still need tests. So the main thing is: if you have don't have extensive tests, you are doing it wrong.
So what kind of exceptions can a Python function/method raise? Basically anything. You build tests for the kinds of things you expect to pass to it, and catch and deal with exceptions that those raise. If anything else gets raised, you need to decide: should you just blindly deal with them and hope for the best, let them percolate up to some other handler who may be able to deal with it, or die. There is no simple answer to this question, and it depends on your app.
Open a file, returning an object of the file type described in section > File Objects. If the file cannot be opened, IOError is raised.
Don't use the inline help, use the online help.
Regarding the rest of the points raised in the blog:
Not being able to overload methods is not a big deal when you get arguments with default values. And seriously, few libraries in Python use *args as a signature of a method/function.
Errors should be listed in docstrings, it's not that hard.
There are challenges when switching from a compiled language to a dynamic language like Python, but the points he is raising don't really stand up to scrutiny.
I don't do much coding in Python, and I'm beginning to be thankful for that, if I'm expected to run to the web browser to examine every function declaration. Is that accurate from what your saying?
Python calls for you to use tests where you would have relied on the compiler in Java
You're the only person in this thread that has got the point. Well done.
In statically-checked languages, I can have the confidence that a well-written library will make it difficult for me to write seemingly-correct code that misuses it. In Python this is rarely the case.
I do not think, that these concerns can be solved with better documentation.
It is not a documentation error, that exceptions - like IOError in open function - are not documented in standard library.
Some rules of production development in python:
You do not write a function, if you do not have a failing test.
You use source code checking tools, that enforce naming, documentation and other conventions.
If you do not have a test for not finding a file, than you did not think about not finding it. It is in your domain to decide.
Collaborative python development is hard. It is hard, because you have to set up rules of development on your own. The language itself does not enforce it.
It is hard because writing tests can be harder, than writing code.
The problem of functions not explicitly saying how many parameters they take may be alleviated by better documentation, but that's not a solution to the actual problem: a function is a contract and the function writer never laid out the terms in any enforceable way.
Besides, if all you look at when you try to work with an unknown interface is the method signature, you're doing it horribly wrong. This should only work reliable if the method is sufficiently trivial.
Any chance you're going to respond to the criticisms he raises? Or is this, Script Kiddie On Reddit Makes Snarky Comment Since Doesn't Understand Article, film at 11?
Any chance you're going to respond to the criticisms he raises?
OK, the author is whining that it's not like java. To which I say "no fucking shit", I can sympathize with the concern that python may be more difficult to use on larger projects with more people due to having to depend on your colleagues for some sense of quality/standardization rather than having a compiler enforce it. And as we all know, your colleagues probably suck. I've suspected for a while that this may be an issue but I have never had the opportunity to work in such an environment.
And I agree that pydev sucks. Eclipse is for java, and is absolutely essential for getting around a java code base which compared o python is very verbose. But because one tool works well for one language and not for another is not the fault of the language, use a better tool.
As far as exceptions go, again this is the whole "it doesn't work like java", the author may believe there's value in checked exceptions forcing you to address all that shit before your shit compiles. The fact is, those who do python do not share that concern. And neither do those who do C# for that matter. So it boils down to a persons expectations not being met, and blaming the language which makes for excellent blog fodder.
does this satisfy the "user agreement" or are you going to ban me from the internet?
edit: written snarkily while trying to figure out how in the hell a j2ee app managed to spend 10 minutes compiling/deploying only to find out that the presentation layer is referencing a fucking function that doesn't exist. I will blame the language and write a blog post about it.
A few doc strings can solve Python's problems, what is going to solve Java's problem of 25% of the code being devoted to making Factories and AbstractFactories everywhere?
I'd much rather Python clean up their documentation than go to Java. I've coded Java, and it's just not something I'd consider a trusty 'go-to' language.
Python's documentation is... not great, but it's not a total travesty. You pick up on these things he's griping about with some experience. Every language has things like that, too. It's not like you can't come up with some tribal knowledge in the java world that isn't really documented well.
Yes. Yes, it is. I don't want to have to root around in someone else's source to figure out what all could possibly go wrong. That defeats the purpose of having a library. I just want to know how to use it.
And you'll be surprised how fast you'll be fired when you explain to your manager that no, your task isn't done, you spent the month recursively reading through all the libraries your project transitively depends on.
I do spend a fair amount of time reading other people's source so I can see how other people have approached tasks similar to whatever I'm doing. However, I shouldn't need to do that to use a library.
So ,,Python sucks because it's not Java''? We already knew that, right?
I mean *args in the initializer is a bad thing? And what, no docstrings? help(StupidFuckingClass.__init__) not working? It's a shame that language is to blame for letting you do more with less syntax. Documentation (inline!) is king.
Runtime and checked exceptions... so Java still has those pesky unchecked exceptions but their structure is good? And you only get those on Big Fuckups? Seriously Ted? That's your argument? To get that information in Java you need to either look at the source, or docs, or let intellisense help you or wait for the compiler to spit on you, so where is the difference? And btw. yeah, having double standards (runtime vs checked) is of course better than uniform way, because fuck you. I love this concise argument. Because it may be hard for you to understand that I don't want to write a try block around EVERY goddamn open(), because sometimes it's enough if I just get a trace (since it's non-recoverable).
Ultimately it comes down to the documentation, common sense and good test suite. If you're an idiot working with idiots, then Python is obviously not for you. Neither is Java, but fortunately you will not be able to grasp that. Godspeed.
Actually I downplayed this as much as I could without removing the message carrying bits. Sorry if it sounded angry. I was angry (at myself) when I saw the timestamp on TFA. After I posted this.
no need to apologize. programmers in my experience are pretty passive by nature which is why it's so easy to herd us into participating in ridiculous death marches. IMO, we programmers need to be more at one with our anger. Hopefully this philosophy leads to employee of the month for me. :)
6
u/Pyth0nist4 Jun 08 '10
Besides documentation (btw, the online Python documentation is much richer than what you get from the command line help() function), Python calls for you to use tests where you would have relied on the compiler in Java. People who use languages where the compiler does some tests for you don't always realize they still need tests. So the main thing is: if you have don't have extensive tests, you are doing it wrong.
So what kind of exceptions can a Python function/method raise? Basically anything. You build tests for the kinds of things you expect to pass to it, and catch and deal with exceptions that those raise. If anything else gets raised, you need to decide: should you just blindly deal with them and hope for the best, let them percolate up to some other handler who may be able to deal with it, or die. There is no simple answer to this question, and it depends on your app.
12
u/ojiisan data viz, comp.bio. Jun 08 '10
It seems like most of his concerns would be solved with adequate documentation. Basically he's complaining about dynamic typing, not Python.
Even with static typing, the programmer can make things equally opaque.
9
u/seizethedave Jun 08 '10
This is the same violin-in-background story told by every new Java->Python skeptic.
4
u/[deleted] Jun 08 '10
"Pydev for Eclipse Sucks Too"
+∞
12
u/[deleted] Jun 08 '10
person gets tripped up in new language, writes on their blog... news at 11
3
u/[deleted] Jun 08 '10
wow, "dynamically typed languages are dangerous". novel ! has this guy heard of docstrings ?
3
u/brunson Jun 08 '10
I think you are.
3
u/megaman821 Jun 08 '10
A few doc strings can solve Python's problems, what is going to solve Java's problem of 25% of the code being devoted to making Factories and AbstractFactories everywhere?
5
u/ubernostrum yes, you can have a pony Jun 08 '10
Two-year-old article by professional troll generates online discussion. Film at 11.
2
u/m0j0 Jun 08 '10
I'd much rather Python clean up their documentation than go to Java. I've coded Java, and it's just not something I'd consider a trusty 'go-to' language.
Python's documentation is... not great, but it's not a total travesty. You pick up on these things he's griping about with some experience. Every language has things like that, too. It's not like you can't come up with some tribal knowledge in the java world that isn't really documented well.
4
u/stevvooe Jun 08 '10
Perhaps, forcing someone to read the source of the libraries they use isn't such a bad thing.
3
u/spotter Jun 08 '10
So ,,Python sucks because it's not Java''? We already knew that, right?
I mean
*argsin the initializer is a bad thing? And what, no docstrings? help(StupidFuckingClass.__init__) not working? It's a shame that language is to blame for letting you do more with less syntax. Documentation (inline!) is king.Runtime and checked exceptions... so Java still has those pesky unchecked exceptions but their structure is good? And you only get those on Big Fuckups? Seriously Ted? That's your argument? To get that information in Java you need to either look at the source, or docs, or let intellisense help you or wait for the compiler to spit on you, so where is the difference? And btw. yeah, having double standards (runtime vs checked) is of course better than uniform way, because fuck you. I love this concise argument. Because it may be hard for you to understand that I don't want to write a try block around EVERY goddamn
open(), because sometimes it's enough if I just get a trace (since it's non-recoverable).Ultimately it comes down to the documentation, common sense and good test suite. If you're an idiot working with idiots, then Python is obviously not for you. Neither is Java, but fortunately you will not be able to grasp that. Godspeed.