Live data from Hacker News

Ask HN: Why Did Python Win?

news.ycombinator.com

121–130 of 162 posts

Re: Ask HN: Why Did Python Win?

#121
post #23

Years ago I wrote article on this topic: https://www.notonlycode.org/why-python-has-won/ In short (all below is my opinion): it was popular in academia and got some corporate adoption, so when ML exploded in popularity it was a natural choice as the scripting language for ML tooling. On top of that it’s easy to pick up as a language, and it’s a general purpose language - there are lots of scientific tools like pandas…

> Ruby could have won,

Seems unlikely. Its got its own fair share of Perl-inspired quirks.

Re: Ask HN: Why Did Python Win?

#122
post #87

It was designed by a person with good taste, not by a committee. That's about it, there's nothing inexplicable or accidental about a well designed language rising to the top. The excessive mentions of Perl are weird — it, along with PHP are prime examples of awful taste. Those are the languages that only gained any traction because they happened to be available at the time, not because they were any good.

To be fair, it is my understanding that PHP is still king in the niche of "simple language with practically zero cost to spin up and deal with a web request."

Now it _may_ be that the erroneously named "serverless" architectures that are the soup du jour will make this less true, but I don't have enough insight on web stuff to know how that's proceeding.

Re: Ask HN: Why Did Python Win?

#123

Earlier quoted context omitted.

I wonder why activating a venv ended up being implemented as a script you source (updates env vars in the current process) and deactivate (puts them back) rather than being something that puts you in a subshell (detects your current shell and re-invokes it with new vars). subshells would let you nest venvs so you could have a "sane defaults" venv, and then you could descent into madness with another "wacky experiment…

> I wonder why activating a venv ended up being implemented as a script you source (updates env vars in the current process) and deactivate (puts them back) rather than being something that puts you in a subshell (detects your current shell and re-invokes it with new vars). The venv is just the folders and Python stubs. The activation script concept is probably just what happened to occur to Ian Bicking first. But al…

> But I think the use case you describe just doesn't resonate with a lot of people.

Yeah I suppose "flat is better than nested" is right there in the zen.

I guess I'm just an oddball. The idea of exiting all the way up to the root and finding nothing installed there except for the ability to descend into one or more specialized transient environments feels so... clean to me.

Re: Ask HN: Why Did Python Win?

#124
Three things:

1. The Rise: 2005 - 2010 Google hired Guido van Rossum in 2005 (stayed on for seven years) and gave corporate blessing that made everyone comfortable with moving from Perl to Python. It was seen as the language of scientists and smart people so a lot of people working in misc. languages like Fortran, MATLAB, Perl moved here. To remove the speed issue the official Google mantra was "Python where we can, C++ where we must". AI heavy weights like Peter Norvig (I think he was the chief AI scientist at one point and co-author of the famous AIMA book), promoted Python to be an acceptable Lisp.

2. Near Death: 2010-2015 Python almost died due to self inflicted wound from the 2 -> 3 transition and there was a good chance it would have gone nowhere like many languages before. Guido also moved away from Google and Google seemed to have shifted it's attention to Golang (apart from the standard C++ and Java). BTW, Python's dominance was not seen positively within Google hence they stopped actively promoting it. For ex. a leaked transcript from Eric Schimdt had him saying this

   So another definition would be language to Python, a programming language I never wanted to see survive and everything in AI is being done in Python.
https://gist.github.com/sleaze/bf74291b4072abadb0b4109da3da2...

3. Resurrection: 2015-Now Data science and ML took off and Python was right there thanks to the initial sponsorship from Google and ecosystem of scientists and engineers who were familiar (including working in the two-language mode). There was no language that could rival at this point.

Most of the syntax, power considerations etc.. are side shows as most scripting languages just tap into very powerful libraries written in c/c++/fortran or wrappers around shell. Doubt that distinguishes Python to the point where it has become so dominant.

Re: Ask HN: Why Did Python Win?

#125
My totally amateur take:

Python is C/C++ but without syntax decorations and pointer problems and who cares about speed when CPU cycle is so cheap.

Python is shell but you can build large projects with a shebang change

Python is Java but with less verbosity and no company behind

If one only affords to learn/master a single language (which holds for the majority), this should be Python.

The only drawback, there is no Python interpreter in browsers (like JS and PHP). But then Python might have faced anticompetitive measures :-)

Re: Ask HN: Why Did Python Win?

#126
post #118

One contributor that I don't see mentioned elsewhere: For many many python users, their only touchpoint for the language is reading and writing it. Python gets a lot of grief from the perspective of people who are frustrated because they didn't start off using virtual environments and now their global python package namespace is a nightmare. Legit criticisms, but for many non-developer python users those problems are…

> [conflicts in virtual environments are] most likely our problems, but we aren't the users that python is made for. We're support for those users. Maybe? I mean, if people aren't noticing these issues and you are, how are they relying on your support? > It's winning because its audience is not code specialists, but other kinds of specialists which sometimes need to use code. Their work often has a sort of immediate…

I mean that several professors have learned that I'm useful for resolving packaging related problems and they contact me for help with them. They expect that if they had a job in industry then there would be somebody who they would file a ticket with and then that person would help sort out the tangle.

Also, in a previous job, I was responding to tickets of that kind (e.g. "why does installing this version of foo prevent the bar from running at a all?").

Others provide support in other ways. The guy racking and stacking GPUs at a data center somewhere is doing so, at least partially, in support of some specialist wielding python to move data around.

Sure plenty of specialists do their own stunts, but plenty others do not and instead have support, institutional or otherwise, for that kind of thing.

Re: Ask HN: Why Did Python Win?

#127
post #117

Earlier quoted context omitted.

All true. But also: > It just turns out that homoiconicity is not hugely useful the large percentage of the time that you don't need metaprogramming, It turns out that metaprogramming, like anything else, has many possible levels, and that for the shallower levels, Python's reflection, magic methods, and metaclasses suffice without too much heartburn.

Honestly I feel like even metaclasses are overused, where class decorators would often suffice.

That's probably true, but there are a few reasons for it:

- Face it, decorator syntax is kinda ugly

- History. Decorator syntax is new

- For things which will be repeatedly subclassed, the metaclass automagically tags along

But it's almost certainly easier for a maintainer to look at a decorated class and figure out what's going on.

Re: Ask HN: Why Did Python Win?

#129
post #99
post #85

Earlier quoted context omitted.

I feel like if #1 was done today, there is no way on god's green earth that whitespace would be used for code blocks. It is far and away the most common footgun novices run into when I'm answering questions about why their code doesn't work.

> It is far and away the most common footgun novices run into when I'm answering questions about why their code doesn't work. It was , in my experience, before Python 3 clamped down on mixed spaces on tabs; before the `SyntaxError`s got better (for example the handling of `try` without `except`); and before VSCode got so popular (such that all the novices were using who-even-knows-what random editor and you had to fi…

Whitespace cleanliness is only part of the problem. The much bigger issue is the fact that the ending of a block is invisible. This leads to several problems:

1. It becomes much more difficult to tell beginners where the end of a block is, because the ending of the block isn't something you can describe verbally. You have to point to it instead.

2. Students who might be prone to using the wrong number of "}" or "end" tokens to close a block will instead un-indent the wrong number of times. It doesn't prevent the kinds of mistakes that mismatched parens tend to cause.

3. When closing a block, the thing you're trying to align a prior block with might not be on screen any longer. I don't know why, but I've seen more off-by-one spacing gaffes after the close of a nested block than I ever expected to see.

That said, I don't doubt that Python arrived at the choice of whitespace blocks empirically. However, I highly suspect that the majority of the users learning how to program in the late 80's and early 90's were familiar with monospaced text, which was ever-present in most productivity applications of the day, and thus easier for them to reason about.

And to be clear, I don't really care that much about Python's whitespace blocks. I don't like them, but I'm at the age where I feel like quibbling over minor syntax gaffes is beneath me, and Python is my top "swiss army knife" language when I need a job done quickly. My only point is that I feel like whitespace blocks are a relic of the time when they were developed, and I don't think they are as beginner friendly as advertised.

EDIT: After stepping away from the post, I realized that in my perfect world, a beginner language would look a lot more like Lua than Python. Then I remembered how popular Roblox is, and how popular Garry's Mod was before that. Given the success of those platforms, there might be something to it.

Post reply on HN