Live data from Hacker News

Python has brought computer programming to a vast new audience

economist.com

111–120 of 268 posts

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

#111
post #52

Earlier quoted context omitted.

Other than interfaces and generics (which would make no sense to add in Python, since it's dynamically typed), can you name some OOP features Java has that Python doesn't have?

This may sound super n00b but I really like that Java is explicit about everything. So for instance, you explicitly specify variables, methods as private with the keyword 'private'. In python you have to use an underscore, and its still not really private, its obfuscated. That's just one example, but in general I really like that kind of by-the-book verbosity, instead of having to mentally map it into the OOP concept…

Double underscore is the real 'private':

    >>> class Foo:
            def __fn(self):
                return 2
    >>> Foo().__fn()
    Traceback (most recent call last):
      File "", line 1, in 
    AttributeError: 'Foo' object has no attribute '__fn'
    >>> Foo()._Foo__fn()
    2
A single underscore is more like 'protected', ie. it doesn't prevent subclasses from easily/accidentally overriding your function.

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

#112
post #100

Earlier quoted context omitted.

No interfaces? from collections.abc import Sequence Slower? import numpy as np

You're referring to duck typing, which to me contradicts the Zen of Python: Explicit is better than implicit . > Slower? Yes, overall the language is slower than PHP. It's not a bad thing, just the result of benchmarks. It doesn't mean one should stop writing Python.

No, I'm not referring to duck typing. An abstract base class enforces the interface. Explicitly.

Some benchmarks might be slower, but I don't know anyone doing high-performance computing with PHP. I do see the topic at Python conferences.

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

#113

Earlier quoted context omitted.

> 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 y…

Isn't it amazing how an insular group managed to independently come up with Haskell-like list comprehensions, and even give them the same name? And how they managed to develop a unit-test framework for the standard library which coincidentally happened to be similar to the xUnit architecture? It's a miracle that a group so dedicated to ignoring things even heard about the 'await' and 'asynch' keywords for asynchonous…

> Isn't it amazing how an insular group managed to independently come up with Haskell-like list comprehensions, and even give them the same name?

That's the big irony: The very same things the senior community and GVR pan are in fact their bread and butter. They're smart and informed. But the engender an attitude of willful ignorance in their community.

GVR is smart. I've been on a pretty intense private mailing list with him. He can competently talk to both advanced functional programming and OO programming. He can talk about advanced compiler and gc subjects. He just doesn't in public, because that'd weaken the message and persona he adopts in public.

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

#114
post #94

Earlier quoted context omitted.

"However, the slight difference in syntax makes Python dramatically easier to read and write" Please prove it.

The evidence is in the usage. As I said, Javascript decided it was a bad idea, despite its popularity in Python. Your phrasing is a little aggressive, so I'm guessing this is one of those discussions where there's no real chance to change your mind, but I'll give it a shot. Consider one of the most friendly languages, SQL. Python comprehensions follow the same pattern as SQL. SELECT expression FROM table WHERE condit…

> The evidence is in the usage.

That's not what I asked for. You're asking me to accept a concrete proposition that I obviously don't. To sway me, I'd like proof, not a single example labeled evidence.

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

#115
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.

Here are some examples from the Python standard library:

  multiprocessing/pool.py:
      self._number_left = length//chunksize + bool(length % chunksize)
  test/test_math.py:
      tmant = tmant // (2*h) + bool(tmant & h and tmant & 3*h-1)
From NumPy and SciPy:

  numpy-1.11.0/tools/swig/test/testArray.py:385:
       sys.exit(bool(result.errors + result.failures))
  scipy/scipy/signal/signaltools.py:2003:
       n_out = n_out // down + bool(n_out % down)
  scipy/scipy/signal/signaltools.py:3001:
       n_out = x.shape[axis] // q + bool(x.shape[axis] % q)
Here's one from my own code, where I allow a query to be specified through --query , or as a hex-encoded query through --hex-query or as an input file through --queries, but I only allow one of them:

  if bool(args.query) + bool(args.hex_query) + bool(args.queries) > 1:

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

#116
post #96

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…

I believe SQL is "the most deployed programming environment family in human history". SQLite is seemingly everywhere. Your second paragraph does not follow from the first. It could instead be that HN commenters are poor at this sort of analysis, or that people in general are poor at this sort of analysis. What were the contemporaries with similar design constraints? I started looking at Python in 1995, and the major…

> I believe SQL is "the most deployed programming environment family in human history". SQLite is seemingly everywhere.

How many computers have a browser on them vs an interactive and instructable version of an SQL server?

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

#117
post #86
post #52

Earlier quoted context omitted.

This may sound super n00b but I really like that Java is explicit about everything. So for instance, you explicitly specify variables, methods as private with the keyword 'private'. In python you have to use an underscore, and its still not really private, its obfuscated. That's just one example, but in general I really like that kind of by-the-book verbosity, instead of having to mentally map it into the OOP concept…

Why would you want to actually enforce privacy? That makes it harder for the user to patch. Better to provide a mild discouragement via "_name".

That's an eternal ideological debate where there is always a rebuttal on the form "a-ha - but you could just...", but the rationale is this: Your class will probably be doing things with the private variables that aren't obvious, and will break things if you access them from outside. (Either by them having a different value than you expect, or expecting a different value than you set).

Of course, if you have a perfect understanding of the code, this will never be a problem, as the program is always executed as it is written. But most likely, not everyone in your organization will be as patient, smart and attentive to the details as you are.

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

#118

Earlier quoted context omitted.

Isn't it amazing how an insular group managed to independently come up with Haskell-like list comprehensions, and even give them the same name? And how they managed to develop a unit-test framework for the standard library which coincidentally happened to be similar to the xUnit architecture? It's a miracle that a group so dedicated to ignoring things even heard about the 'await' and 'asynch' keywords for asynchonous…

> Isn't it amazing how an insular group managed to independently come up with Haskell-like list comprehensions, and even give them the same name? That's the big irony: The very same things the senior community and GVR pan are in fact their bread and butter. They're smart and informed. But the engender an attitude of willful ignorance in their community. GVR is smart. I've been on a pretty intense private mailing list…

To the contrary, I cannot reconcile your statement about their insularity with the observed behavior.

It's almost as if you are wrong in your interpretation.

It's easy to prove me wrong - where has van Rossum panned list comprehensions or the new async/await features?

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

#119
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…

I don't think Java's take on OOP is good to learn before you really understand OOP already. Its heavy handed style of OOP really hasn't aged that well and is rightfully being avoided in all newer languages.

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

#120

Earlier quoted context omitted.

Is there strong evidence that this will happen anytime soon? I've heard many arguments that claim this wouldn't happen anytime soon, particularly because of the level of difficulty and the required determination.

I don't know the situation in the US, but here in Germany the companies always say "Oh no, we don't have enough computer scientists" and continue to pay low salaries. Many people thought that CS grads were needed and chose it, but they earn average salaries and sometimes even have to fight for the good seats. Our definition of skill shortage is that there are only 3 applicants for one open position. This means a skil…

“We don’t have enough X” can also mean “teach more X in schools/tertiary education so we don’t have to pay for training”.
Post reply on HN