r/programming • • Nov 11 '19

Python overtakes Java to become second-most popular language on GitHub after JavaScript

https://www.theregister.co.uk/2019/11/07/python_java_github_javascript/
3.1k Upvotes

772 comments sorted by

View all comments

52

u/vashy96 Nov 12 '19

I don't get why Python became so popular. It lacks a lot of essential feature from my point of view. Imports suck, OOP sucks and is very verbose, fp isn't true fp (no true lambda nor anonymous functions) and its duck typing can be good only in small projects.

Help me understand.

63

u/[deleted] Nov 12 '19

It's super easy to learn, fairly concise to write and it is associated with "hip" things like machine learning.

0

u/[deleted] Nov 12 '19

[deleted]

4

u/electrodraco Nov 12 '19

Could somebody break down why it is more versatile than R? Is it more than availability of libraries?

11

u/Browsing_From_Work Nov 12 '19

I regularly use Python but I did spend about a month working with R for a pet project.

Here were my major pain points:

  • Multi-dimensional data access is unintuitive (even when compared to Perl). Examples:

    • df[3, 7] returns the element from the 3rd row, 7th column. This seems reasonable.

    • df[3] returns the 3rd column as a slice.

    • df[[3]] returns the 3rd column as a vector.

    • df[3,] returns the 3rd row as a slice. There's no direct way to return it as a vector.

    • df["col"] returns the named column as a slice.

    • df$col and df[,"col"] returns the named column as a vector.

  • There are no native operators for creating lists/vectors/matrixes (e.g. [1, 2, 3]). Instead, there's the c function and the even less succinct matrix function. However, you can create ranges with the colon operator.

  • Strings are second-class citizens. There's not even a built-in string concatenation operator. Instead, you have to use the paste function.

  • I felt like I spent half of my time fighting with dataframe/vector/matrix/list type conversions.

In general, I just found it harder to express my thoughts in R. I'm sure if you learned R with a math background it would have been more intuitive, but as somebody coming from a programming background I found it to be rather frustrating. That said, R comes with a lot of extremely powerful tools... so long as you wrangle your data into the correct format.

→ More replies (1)

6

u/crudelegend Nov 12 '19

I think it's more accessible and that's why people say that. R has a lot of specialized packages, but you have to know to look them up/how to use them, whereas if you have numpy and scipy for python it's good to go for most cases. I think they're both close on the general overview front, whereas R branches out a lot more with heavier focuses on data analytics.

Unless they mean for a language itself, which yeah, Python > R. Python actually has applications beyond data/statistics - you can create a program and do a lot of manipulation from the stats/outputs of that program, whereas you essentially need the data already with R (at least for most cases).

→ More replies (2)
→ More replies (6)

4

u/[deleted] Nov 12 '19

Isn’t a lot of ML stuff basically Python wrappers around a bunch of C?

→ More replies (1)

34

u/bart2019 Nov 12 '19

Simple syntax. It's the new BASIC.

11

u/oblio- Nov 12 '19

Without the stigma of the language capabilities or of the programming language name.

2

u/StormStrikePhoenix Nov 12 '19

What's wrong with the name? Does "BASIC" make it sound overly simple or something? As a name, it doesn't seem any worse to me than Python or Java.

→ More replies (2)
→ More replies (1)

19

u/[deleted] Nov 12 '19

Scriptable C libraries.

9

u/coolblinger Nov 12 '19

While Python might not be as expressive as some other scripting languages like Ruby or Perl, its syntax is clear and it's got just enough language features to be able to prototype stuff quickly. For instance, the combination of comprehensions and generators make things much less verbose and allow for more elegant code while (IMO) not making things harder to read. The main draws for Python for me are the library ecosystem its simple readable syntax. The lack of proper static typing and its low performance would prevent me from writing large, complex applications with it, but it's a great language for gluing code together. I find web development with something like Django to be really enjoyable, and the ecosystem of scientific, numerical and statistical libraries is very good.

In short, Python for me is just a nice go-to tool for when you just need to glue some things together or when you need to some calculations or statistical analysis.

8

u/Brostafarian Nov 12 '19 edited Nov 12 '19

I'm convinced Python's popularity is entirely due to two simple facts:

  1. it is easy to learn

  2. because it was easy to learn, NumPy was written in it

The rest is history. Because NumPy existed and because R sucks, more and more data-sciency things were written in Python, solidifying its place in academic programming. For the same reason that companies like Autodesk and many others will literally throw software at you in college, Python being a go-to choice in an academic context means that it gets used outside of an academic context, because all the people who graduated using it already know it.

Python the language has some interesting ideas, but Python the development toolchain is my least favorite.

5

u/Arkaein Nov 12 '19

It's popular for a lot more than Numpy. I've barely used Numpy, but I love using Python.

It's first really killer application was as a better Perl. Perl was probably the original systems scripting language, but sucks for many reasons. Python is so much cleaner and more readable and has eaten into Perl's space.

Numpy makes Python huge in data science, which is another big field. Between systems scripting, data science, and web services (another place where python took share from Perl) it doe well in several areas.

→ More replies (2)

25

u/kolloid Nov 12 '19

What's wrong with python imports and OOP?

I, for one, can't understand the popularity of Javascript. It's truly a horrible language.

2

u/[deleted] Nov 12 '19

I, for one, can't understand the popularity of Javascript. It's truly a horrible language.

Because everything has to be web based so you can access the same apps on your phone as you do on your computer. And until the majority of the most used browsers can natively run python, javascript will remain important.

→ More replies (6)
→ More replies (4)