Live data from Hacker News

Ask HN: Why did Python win?

news.ycombinator.com

391–400 of 856 posts

Re: Ask HN: Why did Python win?

#391

Python ended up 'specializing' in data contexts, thanks to Numpy / Pandas, and as a result, ended up becoming the first exposure to programming than anyone doing data stuff had. That was millions of people. In that space, it had no competitors. Ruby ended up 'specializing' in web dev, because of Rails. But when Node and React came out, Ruby on Rails had to compete with Nodejs + React / MERN as a way of building a web…

This is part of it, but the reasons go back further. As others have mentioned, Python is a pretty old language. It debuted as "Python" in 1991 even before Linux was out, and it existed as ABC even in the late 80s. It had a very good, easy to use C API early on. Combining that with the way it can load shared object files as modules and the ability to create user-defined operators and effectively extend the default syntax allowed it to mimic both MATLAB with SciPy and Numpy and R's data.frame with pandas, which is a huge part of why it attracted all the people from scientific computing and data analytics. The API to the major packages was nearly identical to what they were already familiar with from before. It's not an array language on its own, but the ability redefine operators and the fact that array indexing is itself an operator made it possible to turn it into an array language. The fact that all of these packages can easily just wrap existing BLAS and LAPACK implementations made it very fast for these purposes, too.

That also happened pretty early. Numpy came out in the 90s. But even before that, Python and Perl were about the only two scripting languages other than the shell that was guaranteed to be present on a GNU/Linux system from the start. That made it really popular to create high-level system utilities in Python. A whole lot of the util-linux packages, libvirt, the apt packaging system, all make heavy use of Python. So it's not just the academics already familiar with it, but system administrators and hackers, too.

It also gained widespread popularity as a teaching language alternative to Java. Once MIT started using it in their intro to programming course and put that on the Internet via OCW, it really took off as many people's first exposure to programming.

The batteries included approach to the standard library makes it very usable for one-off automation tasks, too. I don't even like Python that much, but the other day I was doing some math work and just needed to compute a bunch of binomials and enumerate subset combinations. You want to look up how to do that in your language of choice? Python just has math.factorial and itertools.combinations in the standard library. If you're using Linux or Mac, you already have it. It may not be a great choice for application development, but if you need to do some quick, interactive tasks that are never going to get deployed or even necessarily stored on disk as files but just run once from the repl, and it's too much for your calculator app or Excel to handle, Python is perfect.

Re: Ask HN: Why did Python win?

#392
post #329

Earlier quoted context omitted.

> There should be one-- and preferably only one --obvious way to do it. This is so hilariously wrong in python though

I like Python, but most of the Zen has always been a meme, and not a guideline of design principles of either the language, or software written with it. Besides the one you mention, I also find the "Explicit is better than implicit" line to be against everything Python stands for. The language is chock full of implicit behavior, and strongly encourages writing implicit code. From the dynamically typed nature of the l…

It is absolutely not a meme, it's [PEP 20](https://peps.python.org/pep-0020/). Just because some people don't take it seriously, it's definitely a part of the language's soul.

Re: Ask HN: Why did Python win?

#393

Earlier quoted context omitted.

Only one of the items in your "such as" list is unique to python's philosophy, and that is "there should be one way to do it". Ruby embraces the many ways to accomplish something, it's true. However, the three others are not unique to python. Ruby especially embraces "readability counts". And I can't think of anything in the ruby language itself that is implicit over explicit. Perhaps you are thinking of rails and co…

> And I can't think of anything in the ruby language itself that is implicit over explicit This is surprising to me. I love ruby, but it embraces implicitness more than any other language I've used. method_missing, monkey patching internals, and other types of metaprogramming make things very implicit at the interface level

If you want to really experience the true horror of implicit try Scala.

Re: Ask HN: Why did Python win?

#394
I see the flip happening when MIT switched from Lisp to Python for its introductory courses. That happened in the 00s. They had to choose between Java and some other langues and then choose Python. Gradually everyone else followed. New grads came out learning Python. They started developing with it and took over other langues.

Re: Ask HN: Why did Python win?

#395
Lots of other people have commented on why Python won in general. I can say why Python was a better choice for me personally, in 1997 or so...

I was using Perl a lot to manage an multi-thousand page external site, and a much larger internal site for a major division of a large aerospace/engineering company. These ware all scripts to run on the filesystem to do things like change the company name across thousands of pages, where the historical would be kept for past events, but the new company name would be used for current projects.

I sort of semi-nepotisticaly lucked into the job-- I was doing desktop publishing previously, and one of the managers at the division was a relative of my girlfriend. There also were very few webmasters around, and I had a lot of experience with graphics and the software around it.So I taught myself HTML, some basic programming, and was off to the races. But I was basically a just "computer person", but not much of a programmer.

Doing anything by hand on a site that big was just not going to happen, and Perl had a bunch of great pre-made scripts available for doing lots of stuff, but it was murder trying to modify any of them. It was clear that Perl just was too much work to learn, and the "one way" philosophy of early Python made the documentation easier, examples more consistent, etc...

But Python was much more approachable. It was also pretty clear that it had a better future, and had a pretty good (not great) set of libraries available, pretty good regular expressions, and really good integration with just about anything on Windows 95 (via an external COM library). When I started I didn't realize how the ability to script I.E., or Excel, or whatever was a really powerful tool that saved me countless hours. For example, of of the Marketing execs wanted to review every web page, but didn't want to use a browser, so via Python's COM tools, I could script IE to open, log, and print every page. When something failed (e.g. printer ran out of paper) I could use the log to restart wherever I needed. I could also grab a bunch of data from an Excel workflow some engineer had cooked up and dump all the data into a database, so they could use the tools that were comfortable for them, and still centralize it enough to generate dashboards or reports or whatever for management.

The performance wasn't that great, but computers were getting better, faster, all the time, and programmer productivity was starting to become much more of a concern.

Re: Ask HN: Why did Python win?

#396

Earlier quoted context omitted.

I'll bite on "just a fad in webdev circles", in case you are serious and not trolling. Railsworld is celebrating the 20th anniversary of Rails this year. As I'm sure you know, Rails is built on Ruby. 20 years does not fit my definition of fad.

Just because there are people who still use it, doesn't make the statement that RoR was a fad less true. RoR was "the thing that everyone was using" at one point. It was that for several years. Anyone who's anyone was building stuff with Rails. Now it's probably the third option, when building websites... and a fourth option, when building APIs.

fad - an intense and widely shared enthusiasm for something, especially one that is short-lived and without basis in the object's qualities; a craze.

---

I don't think Ruby is a fad. The drop off Ruby had since early 2010s is dramatic, but it stabilized around 5% of all PRs on GH in the last few years:

https://madnight.github.io/githut/#/pull_requests/2023/2

It's still one of the most popular languages for web development.

Re: Ask HN: Why did Python win?

#397

Earlier quoted context omitted.

Yeah, there's the ongoing Perl joke about writing a script that works today, but not understanding how it works tomorrow. Too much one-liner type stuff that did not allow for maintainability

That’s any code I haven’t looked at for a while, to be honest. I can’t count how many times I’ve looked at code I wrote or bug tickets I fixed and have absolutely no memory of doing it. It’s almost like the act of committing flushes the local storage in my brain.

I run into this problem as well I'll often come across something I wrote a few years ago and struggle to remember why I wrote it that way.

I've learned to add comments to my code - from what I see commenting code is frowned upon by a certain subset of developers but I've taught myself that whenever I am doing something subtle or unintuitive to add a short comment explaining what the code is doing, for every potentially unnecessary comment I've added I've also saved myself time when I've had to come back to something months or years later and been able to refer back to the comment.

Re: Ask HN: Why did Python win?

#398

Earlier quoted context omitted.

> Ruby seemed to be entirely tied to Rails. I’d be interested in going one step further and asking why that was. Rails is great, but so is Ruby, but normally a great library like Rails helps attract developers to the language. Rails is the only example I can think of where a widely popular library (ostensibly) leads to fewer users of the language for other purposes.

I wonder if it's because Rails creates such a specific set of expectations that when you actually try to do something without it you run into problems. "Oh, that's only a rails thing? I thought that was a ruby thing..." Ruby's monkey patching convention might make this worse.

I actually failed a technical interview relatively recently because of this.

It was a fullstack position with some Ruby scripts here and there mostly centered around scheduling. Had a leetcode style takehome that requested I build out a pretty simple reservation system with time off and quarter hours and stuff like that.

I boot up into the leetcode environment and was surprised at just how many things were Rails-specific, rather than being in the ruby STD lib. Completely threw me off since I suddenly had to figure out how to wrestle the Date STD lib to work for me, and anything date/time related is my personal hell :)

Re: Ask HN: Why did Python win?

#399
Some times there's a reason, some times it's just luck.

While I appreciate we love to try and explain the present as an inevitable destination, some times it's just the way the dice rolled on this iteration of the simulation.

Re: Ask HN: Why did Python win?

#400
post #366

Earlier quoted context omitted.

> But Python is -dramatically- better focused, as a community, on finding a Pythonic way to proceed, and then advocating it, than previous cultures. I would revise that to be that the pythonic culture of one acceptable way to to is better matched with a lot of good development practices. Perl was also very good at finding a Perl way to proceed. It's just that with Perl that often mean a lot of implicitness and "do wh…

But Ruby took all the best bits of Perl so I'm still perplexed as to why Python "won".

Ruby did have a lot going for it about 15 years ago. Many Java/JSP people jumped ship and got on the ruby train. Ruby was a breath of fresh air comparatively.

Python had a great community though, and the Python Software Foundation went out of it's way to make people feel accepted in the community. And frankly programming is often more of a social activity than most people realize -- particularly for new programmers.

So new programmers tended to lean towards python, because the resources to lean on others were there. And people like Raymond Hettinger, Naomi Ceder, Ned Batchelder, and Yarko Tymurciak were approachable even if the BDFL wasn't.

Post reply on HN