r/Python • • Nov 13 '20

News Python swallows Java to become second-most popular programming language

https://www.theregister.com/2020/11/12/python_swallows_java_to_become/
2.3k Upvotes

205 comments sorted by

View all comments

585

u/[deleted] Nov 13 '20

C is #1 according to this article, if anyone wants the TL;DR.

A quote at the end that I found interesting:

"And Python's 'slowness' is overstated. Who cares about some other language that's a few nanoseconds faster if you spend hours (or days or weeks) trying to figure out how to use it? A human's time is more valuable than a computer's."

I think this quote just about sums up the creator's POV on other languages, specifically Java. I don't think he's really comparing Python to something like C/C++ because those languages will run circles around Python with more than just "nanosecond" margins if used properly. Not to mention other languages like C/C++ are mature and are used to build projects that last for decades, even longer. I still see companies struggling to move their technologies from Python2 to Python3 due to it's end of support.

I love Python and use it often, but in certain fields people have to care about speed, performance and stability. Sometimes it's a matter of life and death. I wouldn't even trust Java for those types of tasks tbh let alone Python. It's easy to learn and use and it's fast enough to do most tasks that people need, but I still think languages like C/C++ are superior.

169

u/harylmu Nov 13 '20 edited Nov 13 '20

I think this quote is really not accurate because speed isn't the most important (well, usually), but a good concurrency story can save big dollars. I rewrote one of our Python app in .NET Core 5 and I wasn't able to kill it with load testing (2000 req, 200 concurrency), while the Python 3.8 app with FastAPI (literally) hanged around 25 requests per second. And to be clear: I made sure that all IO operations are async in the Python version (database queries, Consul queries, SNS publish, S3 upload - even though aioboto3 isn't too stable yet). This alone means that we're able to save thousands (millions on long term?) of dollars by running less instances.

Other than that, the speed difference between Python and typed languages is really NOT nanoseconds. I don't know what to say, test it yourself.

45

u/aes110 Nov 13 '20

I dont know anything about what your app did, but 25req/s hanged? are you sure there wasn't any bug there?

I rewrote my previous company's system from sync (flask) to async (sanic) and saw huge improvements, we saved ~7K dollars monthly on instances because of this.

In my current company, I'm also using sanic and my server easily handles 400 reqs per second, didnt really tried pushing more to it.

In anycase typed/compiled languages sure are much faster, but I think asyncio cand easily handle most stuff

0

u/[deleted] Nov 13 '20

[deleted]

13

u/aes110 Nov 13 '20

I prefer sanic, for the current project that I'm working on I had time to decide so I investigated both of them, for me FastAPI has good pros:

  1. Seamless integration with Pydantic and type hints

  2. Amazing documentation which is extremely beginner friendly.

  3. Seamless support for sync methods, however while this is good for beginners I dont think you should use it, when mixing sync and async code it's important to know what you are doing.

However I feel like FastAPI takes too many decisions for you so its much less flexible.

I wrote my own small sanic integration with pydantic that I carry around from my previous company as well.

Tbh I cant think of something specific to highlight as sanic's pros, it just works really well

Although the two are not different to such extremes, but in a sense you could say that sanic and FastAPI are like Flask and Django

45

u/Metalsand Nov 13 '20

While it does bear noting that RetiredMandalorian is being a bit facetious and exaggerating, and Python vs Java is mostly about "I need a quick thing" not about larger apps, that is the direction we are slowly heading into. Electron for example is widely known as inefficient and yet modern computers are powerful enough that those efficiencies don't matter as much as the development time does for simple applications.

38

u/[deleted] Nov 13 '20

It still matters. The problem with this view is that computers really haven’t gotten that much faster over the past decade and yet the software inefficiency is insane. Python can be built for larger applications too... but packaging is a nightmare (and is unlikely to ever get addressed) and the performance really does matter when it matters (which is becoming more and more important as software bloats)

14

u/cheese_is_available Nov 13 '20

It really does matter. zoom took off because it just works while skype does not. If your program is slow and there is a fast alternative with similar features, your program is basically dead even if you're Microsoft.

3

u/[deleted] Nov 14 '20

The problem with Microsoft is that they don't really care about their side products. At least not in the same way as a single focus company like Zoom Video Communication Inc does

13

u/grimonce Nov 13 '20

Speed doesn't come from type inference only. Other than that I 100% agree. Python is the main tool on our shop but I am really starting to hate it. Java really isn't all that bad as people paint it, it is fine.

Maybe thats my point of view because I actually have a degree in electronics (rf specialization), I actually don't mind C or C++ either, I just dislike to he competing cross platform dependency management systems, cmake is ugly but it gets the job done.

Pythons ecosystem is against the zen of python, where it says explicitly to try and have just one way to do something, Java does this way better that Python. Python provides infinite ways to make your project management a hell worse than npm dependency hell.

8

u/DanKveed Nov 13 '20

I recommend learning rust. A little bit of rust in your python can give massive speed gains. And the rust tooling of light years ahead of c++, in fact packaging is even better than python. Very similar to JS actually

→ More replies (2)

0

u/[deleted] Nov 13 '20

[deleted]

2

u/reddisaurus Nov 14 '20

Pandas doesn’t have C wrappers, it just wraps numpy. Pandas is slower than plain Python that just calls numpy directly, by a factor of 10 - 500 depending on the task.

Pandas provides abstraction for the sake of programmer time, but there’s a cost to that. Use a data class or NamedTuple and watch your code perform much better.

→ More replies (9)

42

u/tr14l Nov 13 '20

You wrote bad Python. The difference is NOT 2000 vs 25 unless you did something terribly wrong. There will certainly be a difference, but that was your code running that slow, not Python itself.

2

u/DanKveed Nov 13 '20

It depends on use case too. A heavily multithreaded CPU intensive app can be way more than 2000vs 25 no matter how well you write it, especially when you compare it with rust/c++

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

4

u/pipai_ Nov 13 '20

That seems very strange. Were you running it with full gunicorn setup?

→ More replies (2)

9

u/Doomphx Nov 13 '20

I'm ditching django for .Net 5 Asp.net and you're not lying. My story is similar to yours where I couldn't even possibly lag my new server with testing.

My next move is to move all my django channels over to SignalR where I can guarentee less than 100ms response times. Dev is looking good with nothing really taking more than 20ms so fingers crossed!

The performance, productivity, and ease of deployment I get with .Net has been life changing.

Git push, pull .Dotnet publish, restart server, all done :)

3

u/tomatotomato Nov 13 '20

With Azure Devops, it's just git push.

3

u/supremacyofthelaces Nov 13 '20

I don't really know any languages other than Python, and it mostly takes a while because my laptop is an old piece of junk and I always have a million things open at once. What kind of scale sre you talking here?

11

u/Aidtor Nov 13 '20

Production environments or places where you need a lot of compute.

Production servers these days are typically cloud based. Horizontal scaling (adding more machines to the pool of resources handling requests) is very easy with rented compute but the cost can really add up for a business over time.

Tasks that require heavy compute, like ML, typically use python as an interface to code written in faster languages.

4

u/--Shade-- Nov 13 '20

Python is an exellent language to call C from, but a terrible language to write C in. If you have a nice pythonic library that wraps some 'C thing' then Python shouldn't be your bottleneck. If it is, then isolate and profile (and apply the common speed up tricks where neccicary).

→ More replies (3)

2

u/latrociny Nov 13 '20

What is your opinion on Julia? It is touted to be superior than python wrt speed and speeds comparable to C especially for ML tasks

4

u/Aidtor Nov 13 '20

My opinions are mixed.

On a personal level I deeply disagree with 1-indexing.

But my personal quibbles aside, it is superior to python. It’s faster and you can actually type things which is a huge deal for large codebases. The interop is great! The writing code like mathematical expressions is overblown.

Overall I’m bullish on Julia. I don’t think it will ever “overtake” python, but they will coexist.

I do have some concerns though for Julia’s future. And that concern is called JAX.

→ More replies (1)

2

u/hilomania Nov 13 '20

In python today you wouldn't solve that with threads but with AsyncIO.

→ More replies (1)

2

u/Max_Insanity Nov 14 '20

*fewer instances

After only just barely understanding all of that, my ego needs sth. where I could correct you :P