Live data from Hacker News

Python has brought computer programming to a vast new audience

economist.com

71–80 of 268 posts

Re: Python has brought computer programming to a vast new audience

#71
post #16

Earlier quoted context omitted.

bools can be silently converted to int. 1 + true is ok, but 1 + "true" throws. Sometimes you do want to do math on bools, but it would avoid a class of errors if they would make you wrap them in 'int(the_boolean_variable)'.

> Sometimes you do want to do math on bools.. Can you provide a concrete example for when this would be useful? I assume you're not talking about binary arithmetic.

  sum(x > 3 for x in iterable)
True == 1, False == 0, so this counts how many items in iterable are greater than 3.

But I think that's the only non-dirty way I've used it, and if that wasn't possible a trivial count() function could do the job.

If I remember correctly, bool subclasses int mostly for compatibility with pre-existing conventions. People were already defining their own "True = 1" and "False = 0" constants before they became part of the language.

Re: Python has brought computer programming to a vast new audience

#73
This seems misspoken. Python hasn't necessarily brought computer programming to a new audience. A new audience is being brought to computer programming. They just happen to be given python as their first steps.

There is nothing intrinsic to python that is helping these use cases. Some people like it. Some people don't. I have not seen studies showing any real advantage or disadvantage to it. Do those exist, and I've just missed them?

Re: Python has brought computer programming to a vast new audience

#74
post #48

Earlier quoted context omitted.

What other language are you comparing Python's flaws and tradeoffs to?

Java, PHP, C#, heck, even JavaScript/ES[6,7]. I feel like Python has a lot of its own ways of doing things, whereas a more idiomatic approach is imho a better way to go. Why the hell in the world would you call a class constructor as __init__? Pretty much every popular OOP language does it either by naming a constructor the same name as the class name or through some form of a `construct` notation. Why `self` and not…

> whereas a more idiomatic approach is imho a better way to go.

I don't know what you mean by "idiomatic approach". That phrase, I thought, refers to languages that are highly opinionated about using a specific style -- this philosophy is encoded in Python's philosophy:

https://www.python.org/dev/peps/pep-0020/

There should be one-- and preferably only one --obvious way to do it.

> Pretty much every popular OOP language does it either by naming a constructor the same name as the class name or through some form of a `construct` notation

Seems kind of arbitrary to complain about the constructor keyword `__init__` when the constructor word for pre-ES6 JS, C, Perl, Ruby varies between prototype, constructor, __construct(), and new. Not sure how you say Python's use of `__init__` is somehow worse. As for why `self`, no idea, but seems to be a pretty easy convention to figure out.

As for the complaint about the `if __name__ == '__main__':`, to which language are you referring to that has a more self-evident way of encapsulating that functionality?

Re: Python has brought computer programming to a vast new audience

#75
post #67

Read the comments here. Look at the diversity of opinions and the number of them that, while professing love for Python, directly contradict each other. Python is verbose|concise, simple|advanced, disciplined|experimental, modern|classical. It goes to show: something doesn't need to be actually-better. It doesn't need to be actually-simpler. It doesn't need to make your job easier or better. It needs to make people t…

> Python is not, in any way, revolutionary. Several contemporaries exist with similar design constraints. I think it was revolutionary in its own terms. For example, list slicing was revolutionary and it reduced many lookups to the minimum. Sure, it was implemented by other (not so popular) programming languages before but not in addition of many other features like easy interpreter embedding, good reflection/metapro…

> I think it was revolutionary in its own terms.

I think this is precisely what I said. If you discount any other competitor and what they did, Python was revolutionary within itself. Which is not all bad, it means the language has had progress. But it's a very narrow metric.

Re: Python has brought computer programming to a vast new audience

#76

I remember hating the whitespace thing so much when I started with Python circa 2.4, but have really come to love the language in a lot of domains since then. A huge, huge "thank you" to Mr. van Rossum for creating this quirky language that I've become so fond of and for the countless hours of his life he's given to the project.

Same here. I remember that one of my first attempts at trying out Python, coming from Ruby, seeing that indentation compilation error made me immediately give up. Hard to give up the freewheeling nature of Ruby but I am very glad that I did. "Use whatever style makes you happy" has extremely diminishing returns the more you code in a language.

Re: Python has brought computer programming to a vast new audience

#77
post #53

Read the comments here. Look at the diversity of opinions and the number of them that, while professing love for Python, directly contradict each other. Python is verbose|concise, simple|advanced, disciplined|experimental, modern|classical. It goes to show: something doesn't need to be actually-better. It doesn't need to be actually-simpler. It doesn't need to make your job easier or better. It needs to make people t…

> It goes to show: something doesn't need to be actually-better. It doesn't need to be actually-simpler. It doesn't need to make your job easier or better. It needs to make people think it does that. I don't agree with that takeaway. You ask us to consider all the diversity of opinions here, but then you evaluate them out of context, what one person says about Python is not necessarily in reference to the metrics tha…

> Why do you think Python, or any programming language, has to be "revolutionary" -- or engage in cultmindthink -- for it to become popular?

I don't think it has to, and I didn't say you HAVE to. I'm saying that you can accomplish the goal with a community that prides itself on ignoring things. Python's community is even more insular and ensconced in their opinion than editor proponents. Most Vi proponents can tell you about how they know Emacs and hate it (and vice versa). In the Python world, not knowing these things is in fact often a purity test, with GVR doing some kind of classic, "I'm just a hyperchicken lawyer" gag reel in public while in private engaging in complex debates about the very concepts he claims are inherently not understandable.

Re: Python has brought computer programming to a vast new audience

#78
post #15

Python is a great language to start programming in. My biggest frustration with traditional programming languages (well, C/Java mostly) was just how much upfront effort and understand is required to do useful stuff. Whereas with python it is pretty easy to whip up a script, read input and transform it into output in real time etc. That said, I think its also important for Python programmers to dabble at least a littl…

W/O going into the war of I'm better than you (Python vs JAVA)... Python is built to make it easy to write good programs... where as JAVA is built to make it hard to write bad programs.... same objective but different thinking/approach to achieve it... hence one(Python) would eventually have larger adoption....

I agree with this sentiment but it is a bit of a double edged sword for Python professionally. There is some really good Python code out there but there is also a lot of bad stuff too. I know this can be said for every language but I think I have seen it most in languages like JS and Python because of the ease of access.

Re: Python has brought computer programming to a vast new audience

#79
In case anyone else was confused by the literary reference, "one with Nineveh and Tyre" is from Kipling's "Recessional":

https://en.wikipedia.org/wiki/Recessional_(poem)

Which, I think, is the poem that made "lest we forget" a well-known phrase (though the original is from the Bible).

Nineveh (now Mosul, Iraq) and Tyre (in Lebanon) were great cities of their time, but now mostly known for their ruins. In Britain, they're commonly used as symbols of foregone empires.

Re: Python has brought computer programming to a vast new audience

#80

Read the comments here. Look at the diversity of opinions and the number of them that, while professing love for Python, directly contradict each other. Python is verbose|concise, simple|advanced, disciplined|experimental, modern|classical. It goes to show: something doesn't need to be actually-better. It doesn't need to be actually-simpler. It doesn't need to make your job easier or better. It needs to make people t…

A Javascript array comprehension [0] in theory is similar to a Python list comprehension [1]. However, the slight difference in syntax makes Python dramatically easier to read and write. Javascript dropped the feature. Pythonistas use it often.

Many programmers, even Python core devs, don't understand what makes one syntax more readable than another.

[0] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

[1] https://docs.python.org/3/tutorial/datastructures.html#list-...

Post reply on HN