Live data from Hacker News

Why Python is Important for You

blaag.haard.se

41–50 of 231 posts

Re: Why Python is Important for You

#41
post #16

I am kinda afraid of getting down voted, but I have used Python and I feel like I get all this and more (CPAN) when using Perl. The major difference in my opinion is that Perl gives you even more freedoms, which causes you to need some self discipline, but you get stuff done even quicker that way. It feels a bit like Python is better for programming beginners or people that tend to be too lazy sometimes and Perl is f…

It feels a bit like Python is better for programming beginners or people that tend to be too lazy sometimes and Perl is for people who want to be able to be lazier since they know what they are doing.

I'm sorry, I don't understand this at all. What does this mean?

Also, I think Python (and most other language projects) should clone CPAN (including CPAN testers). Seriously it's a major deficit.

The Python Package Index (http://pypi.python.org/pypi) is no CPAN, but I've never had a problem with it.

Re: Why Python is Important for You

#42
post #11

As a commenter on the article wrote: what about Ruby? I say this as a happy Python user. Ruby seems very similar but I'm reminded of a pg essay on language power: looking up the power curve, you see '$Language plus a bit of weird stuff that is probably irrelevant.' So I don't trust myself. As someone who loves Python and doesn't know any Ruby beyond a few bits of syntax and the obvious bits that are common to most la…

I'm an extremely happy ruby user but have nothing against python, it's just that the languages operate at such a similar level of abstraction that it seems like a bit of a waste to spend time learning python when I could be learning C or Haskell.

FWIW though, I get serious library envy, especially with regard to NLTK. Ruby has web development cornered but is decades behind python when it comes to anything around machine learning and scientific computing.

Re: Why Python is Important for You

#43
post #3

I like to call this cognitive compatibility - the amount of effort required from an uninitiated English-speaking observer to understand what a program does. Most people who are deeply familiar with a language will have a tendency to discount this effort, but really it is essential because it minimizes the translation layer that your brain has to use any time you read code. Python encourages code which is readable in…

I want to make what I think is an important qualification which conflicts with a reading of your comment: Python is readable to people who are familiar with conventional Algol-based programming, i.e. every modern programmer. That does not make it readable to an arbitrary English-speaker, which is an assertion I sometimes hear: "Oh, Python is so much like English, people who aren't even programmers can read some of it…

Yes - I agree with you in principle. Python is not the perfect combination of computer language design and cognitive compatibility - it's just that I think it's doing better at it than anything else that has traction right now. Hopefully something better will come along and improve on it!

Re: Why Python is Important for You

#44

My biggest problem with Python is that projects larger than a given size tend to become unmaintainable rather quickly. This is in large part because of the lack of strong typing and type annotations; if you aren't the only author or can't keep the codebase in your head, it takes real effort to figure out what a function does. Even the type annotations provided in a language like Java or C++ make this task much easier…

Yup. This is also the case with Ruby, and is one of the challenges when trying to dive in to a large unfamiliar project. For example, when something in Rails doesn't behave correctly and you flip deep into a source file, it's not always easy to track down exactly what kind of arguments a method expects. Often you'll have to breakpoint inside the method just to inspect what's around.

Re: Why Python is Important for You

#45
post #11

As a commenter on the article wrote: what about Ruby? I say this as a happy Python user. Ruby seems very similar but I'm reminded of a pg essay on language power: looking up the power curve, you see '$Language plus a bit of weird stuff that is probably irrelevant.' So I don't trust myself. As someone who loves Python and doesn't know any Ruby beyond a few bits of syntax and the obvious bits that are common to most la…

Ruby's blocks and built in regular-expressions are two examples of things you're missing.

if result =~ /regex/

that kind of thing is awesome for readability, but it can also be pretty darn slow.

There's also some interesting things about the ruby object model and interpreter that are different from python's approach. Whereas in the python REPL you type help(object) to get the docs on that object, in ruby you type object.methods or object.public_methods, etc. It's less documentation oriented, and more code-exploration oriented, but the two end up delivering the same sort of information.

Hope that's helpful! Ruby's a lot of fun to tool around with, and there are (in my opinion) fewer things about it to trip you up completely than there are when first learning python. But once you use it for a while and get beyond the basics, it becomes clear that there's a lot of unfocused cruft foating about, which fits no rhyme nor reason. Much more than Python has.

(cautionary note: I'm not an expert with either language)

Re: Why Python is Important for You

#46

My biggest problem with Python is that projects larger than a given size tend to become unmaintainable rather quickly. This is in large part because of the lack of strong typing and type annotations; if you aren't the only author or can't keep the codebase in your head, it takes real effort to figure out what a function does. Even the type annotations provided in a language like Java or C++ make this task much easier…

Just to be clear, Python is strongly typed but not statically typed. But I definitively agree with your comment. The startup I'm working for is Python based, but I'm currently learning Haskell, because I'd like to take advantage of a good type system for my larger efforts.

Re: Why Python is Important for You

#47

Earlier quoted context omitted.

I want to make what I think is an important qualification which conflicts with a reading of your comment: Python is readable to people who are familiar with conventional Algol-based programming, i.e. every modern programmer. That does not make it readable to an arbitrary English-speaker, which is an assertion I sometimes hear: "Oh, Python is so much like English, people who aren't even programmers can read some of it…

Thankyou! So many programmers seem to forget they have an enormous base of syntax and logic which is not at all like natural language. They see python and say, oh wow this is so easy to read, just like English! But its only an easier way to express a syntax that really is nothing like what a nonprogrammer would consider English.

It varies.

When I was helping @limedaring learn Python, I'd read source with her and explain what it does. Quite often I'd feel somewhat embarrassed when explaining what a line does by verbatim reading what it says.

"for user in users: ..."

"if user.is_admin: ..."

It was especially nice that the topic of "what code block does this condition apply to?" did not even occur to either of us. The indentation-based blocks made it completely organic. (Try explaining Bash to someone and when to use do/done, if/else/fi, case/esac.)

But sure, things get weird with decorators and generators and other advanced features.

Re: Why Python is Important for You

#48
post #19

I have used Python for a rather long time (I think 1997 when I was 17 was when I first used it). As the the writer of the article stated Python is awesome for writing "tools" and throughout my career I have used it for such. However I have used Python also for big projects and that is where its gets a little messy. I know I am going to get down-voted to kingdom come but I think Java is a better language for big proje…

In my mind--probably not the majority opinion, but so be it--it's really the opposite: Python is a dynamically typed Java. So it's not that Java has been underrated but rather that Python has been overrated. I do not like working with either.

Also, I'm not quite sure what generics have to do with algebraic types.

Re: Why Python is Important for You

#49
post #11

As a commenter on the article wrote: what about Ruby? I say this as a happy Python user. Ruby seems very similar but I'm reminded of a pg essay on language power: looking up the power curve, you see '$Language plus a bit of weird stuff that is probably irrelevant.' So I don't trust myself. As someone who loves Python and doesn't know any Ruby beyond a few bits of syntax and the obvious bits that are common to most la…

Blocks.

Ruby gets a lot of things wrong, but blocks are one thing they more or less do well. Everything good that has been built from/for Ruby owes a large measure of its success to Ruby's block implementation.

Python programmers are definitely looking up the power curve at Ruby.

Re: Why Python is Important for You

#50
post #26

Earlier quoted context omitted.

Neither solution is great. Excessive use of return and continue is an incredibly fast way of making code completely incomprehensible. Such complicated control flows should be treated as a major, fundamental problem. Keeping them in place will cause bugs and prevent future contributors from having confidence that their changes are correct. The problem of complicated control flow is too deep to be solved with a band-ai…

Hmmm, you have a point there, but what is your proposal to solve it in a correct way, then? Some problems need a deeply nested control flow and arcane business rules, you have to implement that somehow, and in such a case the method I use looks like the lesser of two evils. I'd rather have some flat ecosystem of meaningful functions than one monolithic deeply nested control structure. From time to time I like defensi…

The way I would do it is to push the processing out to functions, too. Something like:

  verdict = get_verdict(the_thing)
  if verdict not in blessedsolutions:
      return
I'd advise against running returns onto the same line - I find it makes it harder to read, particularly when you have a lot of checks like this.
Post reply on HN