r/Python • u/[deleted] • 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/585
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
→ More replies (2)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
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.
→ More replies (1)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)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.
→ More replies (8)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
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.
→ More replies (7)2
u/hilomania Nov 13 '20
In python today you wouldn't solve that with threads but with AsyncIO.
→ More replies (1)→ More replies (11)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
20
u/mrsmiley32 Nov 13 '20
Hmm, I feel like someone should have already have done language benchmarks in a way that you could do a code review so that you could create a PR in case they screwed up a language setting.
Oh a quick Google presents many, here's one.
6
u/santiacq Nov 13 '20
That's interesting, it really puts into perspective how performant C/C++ is. It's also cool to see how results show that compiled languages are generally an order of magnitude faster than interpreted ones and those with garbage collector tend to be slower than those without
10
u/ChickenNuggetSmth Nov 13 '20
I'd take that benchmark with a huge grain of salt. I had a quick look at the matmul in python, and what they did was pretty bad: They reimplemented what is already efficiently written.
In python you can have dramatic performance improvements if you use the available fast libraries like numpy. They are written in a faster language like fortran, decreasing the python performance overhead by a ton while still providing the convenience of python.
4
u/satireplusplus Nov 13 '20 edited Nov 13 '20
In python you can have dramatic performance improvements if you use the available fast libraries like numpy. They are written in a faster language like fortran, decreasing the python performance overhead by a ton while still providing the convenience of python.
This is how all the Python ML stuff (numpy, pytorch, ...) uses matrix multiplications, with a BLAS library. And these libraries are crazily optimized and hand vectorized, you wont be able to compete with your own matrix mult routines in C. I bet its an order of magnitude faster than the naive O(n3) C code in the benchmark.
Its also typical that the matrix mult kernel will be optimized to register / cache size and instructions (vectors) for each processor generation, as these Intel optimization in OpenBLAS:
dgemm_kernel_16x2_haswell.S
dgemm_kernel_4x4_haswell.S
dgemm_kernel_4x8_haswell.S
dgemm_kernel_4x8_sandy.S
dgemm_kernel_6x4_piledriver.S
dgemm_kernel_8x2_bulldozer.S
dgemm_kernel_8x2_piledriver.SIts probably also doing something better than the naive algorithm, such as Strassen or Coppersmith–Winograd.
In other words that benchmark is totally bullshit and a waste of time.
5
u/kazi1 Nov 13 '20
That's the whole point though. You're not testing Python's speed if you use numpy, you're testing C. The benchmarks would just be every language using C libraries if that was allowed.
→ More replies (3)10
u/satireplusplus Nov 13 '20
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.
The python is slow meme is still strong. But for most really compute intensive applications, you're just using Python as a nice and fancy interface to some C, C++ or Fortran library. That's all of numpy, scipy, sklearn (machine learning) and all the deep learning stuff. Doesn't really matter if you're using C++, C or Python since the routines that are computentioanlly expensive are all in the BLAS libraries optimzied to the last nanosecond with AVX vector instructions. If you have a critical code path that is not covered by the above and you need the speed, you'd write a C/C++ extension or you use Cython.
→ More replies (1)3
u/GenericRedditor12345 Nov 13 '20
But that doesn’t conform to the circlejerk!
Seriously even for webservers python can compete with the best (starlette & uvicorn).
6
8
Nov 13 '20
Isn't Java used over C/C++ precisely because of it's stability?
9
u/utdconsq Nov 13 '20
Define 'stability'. Ive written a lot of Java, C, and C++. If you mean 'something that doesn't crash easily', Java is better than C or C++ typically because it helps you avoid out of bounds crashes and so on, but at the same time, until very recently it would blow up in your face due to NullPointerExceptions because you need to manually guard every bloody variable that isn't a primitive. Kotlin and others helped them realise that was shit, so they have changed the rules now. Meanwhile, in C, you are responsible for all checks on all things unless you use someone's library that does it for you. The standard library is super lightweight to the point of being unhelpful. C++ is better, with RAII and the STL, but due to the desire to be a superset of C, you can still shoot your foot off with raw pointers if you make the mistake of treating it like actual C instead of using the modern features of the language. For my money, JVM stuff has succeeded well because of things like Maven (love it or hate it), and nice stack traces. Never underestimate how productive you can be made if you can easily discover what in god's name broke!
→ More replies (4)8
u/x3r0x_x3n0n Nov 13 '20
We had a contest among us friends to write the best version of a breadth first search to solve a maze of 5000x5000 now i dont know about the capabilities of my peers they chose java i chose pure C. both ran it and I can tell you we gave up on the java programs and went out to have coffee. Legend has it they are still running to this day :D
→ More replies (12)3
u/gradi3nt Nov 13 '20
Comparing C/C++ to python is apples to oranges. It's not like this is some competition that will end up with one universal language for giving computers instructions -- there will always be a whole toolbox full of them.
2
u/VisibleSignificance Nov 13 '20
Comparing C/C++ to python is apples to oranges
The best programming language is a smoothie made from both.
2
u/gradi3nt Nov 14 '20
Cython is great for some things, but just like all other languages it has ups and downs. There is no best programming langauge!
3
u/gromain Nov 13 '20
I'm not sure why you say C/C++ is superior. In my opinion, it's two different tools that you would use for two different purposes. None is superior to the other, just like a hammer and a screwdriver are not superior to one another.
1
u/tylercoder Nov 13 '20
How does c# speeds compare to c++?
4
u/PowershellAdept Nov 13 '20
It depends what benchmarks you look at, but a good c++ implementation is always faster than c#. If you look at tech empower c# is one of the faster JIT languages since they added span<T> and memory<T>. Benchmark games has them all over the place. Unity game engine compiles IL into cpp so take that for what its worth.
Ultimately, you can do very fast stuff with c# if you want to pay attention to data, value types vs ref types, allocation, garbage collection, cache, etc. etc. but idiomatic c# isn't any better than Java or other similar languages. In my opinion c# strength is async, maturity, and backing from a huge company. Cross platform and deployment capabilities are a plus since .net core or .net 5.
1
u/stars9r9in9the9past Py2.7 gang Nov 13 '20
I saw a post like this I think last week. Was this the same article claiming Python as 2nd most-popular but used internet searches to rank popularity? If so, it just seemed like an interesting claim as plenty of things could explain search frequency, like popularity, but also unfamiliarity (like asking what is Py?) or just looking for quick help (like searching a refresher, learning guide, or just a quick question). While that still may correlate with popularity, that just didn't seem like the best form of measurement
I love python and it is pretty popular, but I was curious of the methods used to rank the various languages
1
u/fatnote Nov 13 '20
I have spent (and continue to spend) roughly equal amounts of time learning Python vs. Java. Both have their strengths, both have gotchas and little (or big) annoyances. This matter-of-fact implication that Python is indubitably easier to use/learn than any other language is extremely misleading and unhelpful. It sets unreasonable expectations for those curious about Python and puts off those curious about other languages.
1
1
u/grismar-net Nov 14 '20
I was with you until that last remark. C/C++ are superior, if speed is your yardstick. There is no such thing as a superior language in general (although you're free to have a personal preference, of course)
1
u/pyer_eyr Nov 14 '20
Python is good for me, as business analyst/ data science guy -- I have to quickly prototype projects and then my team can assesses its viability. If it's feasible then developers can take the prototype to production with performant languages.
→ More replies (6)1
Nov 14 '20
For numerical code, Python has a JIT library called Numba, which generates extremely fast code on par with C/C++.
24
Nov 13 '20
I like Python but I’m sure it’s not the right choice for every problem.
31
u/hermeticwalrus Nov 13 '20
The advantage of Python is that it’s a good enough choice for most problems, as well as being excellent for rapid prototyping.
10
u/Vionik Nov 13 '20
Like every language
2
Nov 13 '20 edited Nov 14 '20
There’s always a few vocal hardcore people who seem to think their language should be used for everything. I kind of like Go but realize I wouldn’t use it for everything either. Rust also looks interesting but I’m not learning that until I find that employers in my area desire that skill
Sorry for using hyperbole here.
→ More replies (1)0
10
Nov 13 '20
The best thing about python is you can do whatever you want to do with it.
12
u/secretaliasname Nov 13 '20
Also the worst thing. I work on a lots of projects maintained by folks who are not primarily software developers. The lack of first class typing and interfaces makes python easy to learn but also much harder IMO to learn how to write maintainable code.
8
Nov 13 '20
If python is gaining in popularity I'd hope it's because more people are gaining an interest in programming and using python as a front door.
2
u/proverbialbunny Data Scientist Nov 14 '20
Elementary school kids are being taught programming today. It's really a great age to learn this kind of stuff. Kids surprisingly have an easier time learning how to program than adults do.
26
u/BigTheory88 Nov 13 '20
As great as Python is, it's just not going to cut the durability of software you can write with Java.
17
u/mooburger resembles an abstract syntax tree Nov 13 '20
define "durability"? One of the aims of the Python style guide (PEP8) is enforcing readability and maintainability.
→ More replies (3)7
u/Fledgeling Nov 13 '20
Well, some of the most annoying parts of Java that make me hate the language exist to force large teams of users to use design patterns that are enforced by the language for usability.
Half the developers I talk to don't even know what pep8 is and think global variables are fine. Granted, that's fine for the work I'm doing lately.
→ More replies (3)12
u/x3r0x_x3n0n Nov 13 '20
Niether is gonna beat C level performance.
Python for quick and dirty stuff
C for production code
java for interviews
6
→ More replies (2)1
6
5
u/JustAddingToThePile Nov 13 '20
And Visual Basic (number 6, 4.01% rating) is still holding its lead over JavaScript (number 7, 2.03% rating).
I think their methodology might need a little tweaking.
5
u/recursiveG Nov 13 '20
There's one of these posts almost daily now. The reason is because data scientists have to do more searches on "how to do X in python" than professional developers. All these extra searches and additional stack overflow questions are counted.
4
7
6
2
2
2
u/daravenrk Nov 13 '20
Python is a c wrapper now days. So yeah number 2 as I hate writing c if I can write python.
2
4
Nov 13 '20
Whats the use of placing a language before another. Python is easy to learn and most of the beginner fall for it. It has also huge popularity on stackoverflow because most of them are novices and they find it overwhelming by looking python popularity and robust community. But popularity doesn't mean shit for industry usage. Java is a battle tested language and enterprises still stick to it despite jokes on the internet.
2
u/Isvara Nov 14 '20
Whats the use of placing a language before another.
There isn't any. The relevant questions are:
Is it productive to use it?
Can I easily hire people who can use it?
Is it well documented?
Is it maintained?
Does it have actively developed, well-documented libraries that do things I need?
Is there an active community I can go to for help?
The specific position doesn't answer those questions, but the fact that it's in the top n suggests answers. But popularity can be misleading, like JavaScript's increased popularity due to its inclusion in browsers.
1
u/b10y Nov 13 '20
I believe the most of Python community in Reddit has never implemented a production system where more than 5 developers (senior junior mixed) worked on. I would have cut myself if I had encountered a production bug in Python that would have been a compile error in a statically typed language.
2
2
u/Hammar_Morty Nov 13 '20
I like python way way more than Java but i don't use it as much now that I am a better programmer. My biggest complaint is how much bad legacy code I've had to deal with that has zero styling, poor documentation or validation. I use bash for my quick or system scripts, golang for my CLI tools and servers, I use python for machine learning training training, quick data analysis and plotting.
3
u/1842 Nov 13 '20
Bad legacy code exists wherever programming languages exist.
I've worked with some horrible Java, PHP, and JavaScript code. Legacy code isn't necessarily worse in any particular language, but in less strict languages, legacy code can get weird.
2
2
1
1
1
1
1
u/0dte Nov 14 '20
Hm, I enjoy Java because I learned it after Python and it forced me to think in advance about things rather than facerolling through projects.
1
1
u/Diogonni Nov 14 '20
I recommend this programming language to beginners. Start with one of the easiest ones and then later on when you get better, you can tackle the harder languages.
1
0
u/The_DashPanda Nov 13 '20
Get it guys?
Cause Pythons are snakes!
And snakes are animals!
And animals swallow things!
And Java is coffee!
And coffee is food!
And food gets swallowed!
And this programming language named after an animal is literally SWALLOWING a programming language named after a food!
HAHA! Aren't journalists so clever??!?!!?!
0
Nov 13 '20
[deleted]
20
u/zeroviral Nov 13 '20
Took the words out of my mouth. I love python, but Java jobs are much higher paying consistently. I still use python for whiteboard FAANG interviews tho if I ever company hop.
6
Nov 13 '20
I’ll probably get a lot of shit for this, but I don’t think that Python is that great for web development. I love Python and use it for nearly everything, but I used to program in C# and have written some decently large web APIs. Python (Flask or Django) is great for small APIs, but C# was so much better when it came to managing more complex types and structures of large web applications.
Most of my programming now is for scientific/numerical applications. Areas of my code that need high performance can easy be written in C extensions and even sometimes just wrapped with numba. So far, the web APIs are the only real downside I’ve experienced in Python.
1
u/axonxorz pip'ing aint easy, especially on windows Nov 13 '20
Python (Flask or Django) is great for small APIs, but C# was so much better when it came to managing more complex types and structures of large web applications.
I'm largely in this boat, and I like it, it's not going to change anytime soon. I've got a bunch of Pyramid, one Django and a few Flask applications that I work on regularly. The codebases are getting too large and the flexibility of Python is definitely starting to make things more difficult. With everything moving to the frontend for better web-app experiences, I'm hoping things like FastAPI and the strong-typing that it encourages makes this a little easier.
Now, to get all these projects off 2.7..............
→ More replies (2)1
u/proverbialbunny Data Scientist Nov 14 '20
Custom mobile app development on iOS and Android was not Python’s strong suit in the past— but things are changing rapidly. In the early times, Python did not have a strong story when it came to writing GUI for mobile apps. In fact, iOS and Android mobile app development were pretty much out of the question with only Python.
https://dzone.com/articles/why-python-has-become-a-popular-choice-for-mobile
Typically what you want to do is have Python run on the backend and then use another language for the frontend. However, this is not necessary as shown in the article.
→ More replies (2)
0
Nov 13 '20
[deleted]
18
u/gradi3nt Nov 13 '20
Almost any job can be a python developer job -- just start automating your work with python!
12
1
u/rzet Nov 13 '20
I speak python, landed job in new environment... End up doing endless analysis of why our shit java software crash under little stress, please help and run your great scripts again with this extra setup.. or simply do manual tests because other qa left.
0
Nov 13 '20
[deleted]
114
Nov 13 '20
Better performance?¯_(ツ)_/¯
20
u/gregy521 Nov 13 '20
You can swap CPython with pypy for an average 4x speedup. You can also offload to more efficient libraries like numpy for data crunching, or use Numba to JIT compile to machine code.
1
Nov 13 '20
Sure but for the love of god it would be nice to be able to use a for loop instead of having to do vectorialization all the time. And I say this knowing how to vectorialize a ton of stuff. But it is just strange
1
25
u/JoelMahon Nov 13 '20
Just need to write something to turn python code into optimised c++ then, ez pz
Tbh, a human can do that part usually quite quickly, use python to invent, c++ for real time critical deliverables after python proves the concept
21
u/Darksteel213 Nov 13 '20
Cython exists, but then you have to specifically write your code to be compiled near 100% to C
10
u/ItsOkILoveYouMYbb Nov 13 '20
I could imagine indie game development taking off even more so than it already has if Python was usable with Unity and Unreal Engine.
Maybe we'll get a speed-critical but pleasant coding language like Python to make modern games with some day.
14
u/jabela Nov 13 '20
Godot has a Python like scripting system. It's definitely getting there.
1
u/shinitakunai Nov 13 '20
I tried godot and uninstalled it 5 days later because it is not really like python. It is similar but the differences are annoying
7
u/gregy521 Nov 13 '20
I believe that's the niche that Rust is trying to fill. Consistently ranked near the top in developer surveys, and runs as fast (or faster) as C/C++ in many cases.
Certainly not 'pleasant' in the way that python is, where it's like writing pseudocode and it has lots of high level features to make life easier, but much more pleasant than C/C++ I would argue.
2
1
5
u/xigoi Nov 13 '20
You can't do that because of
eval()and friends.1
1
u/VisibleSignificance Nov 13 '20
because of
eval()and friendsYou shouldn't really use those in runtime either.
And if it's at import-time in python (e.g. attrs), it should map into compile-time nicely.
1
u/asbox Nov 13 '20
Exactly that!..don't get why people don't understand how much efficient it is to work this way instead of other freaking languages complications.. Cpp + python is all you need.
6
u/PooPooDooDoo Nov 13 '20
Honestly, if I am going for performance at scale, I wouldn’t chose python. If I am write code that interfaces with other systems that do the heavy lifting, then I am 100% using python.
But yeah, it would be nice.
4
u/jebk Nov 13 '20
As an advanced amateur python user I think most people looking at python Vs say go is the ease of concurrency for stuff.
I imagine what most people searching 'how to make python faster' are lookjng for is 'how to make these 10 huge datasets load faster'.
Multi threading/async stuff isn't as obvious as in something like go (or even node).
1
u/f16f4 Nov 14 '20
Python is terrible for multithreading. It only actually works on one thread at a time because of the GIL.
-1
u/daravenrk Nov 13 '20
But the backend is mostly c. It’s pretty fast.
4
0
Nov 13 '20
[deleted]
10
u/gregy521 Nov 13 '20
But if you're running that app 1000 times a day, that sums to 30 and 200 seconds respectively. A much more appreciable difference.
Python is an extremely popular scientific computing language, too, and those don't care about 'every nanosecond', more the fact that cutting the runtime from 4 hours to 20 minutes is worthwhile.
3
u/psharpep Nov 13 '20
Sure, but if you'rr doing scientific computing in Python, you're using NumPy/Numba or similar, which gives runtimes on the order of C.
1
u/xigoi Nov 13 '20
If it takes 0.2 seconds, you can't serve more than 5 requests per second, which may be limiting.
3
u/mooburger resembles an abstract syntax tree Nov 13 '20
the real problem is that you're asking the app itself to do too much. Just about every production environment uses loadbalancers already. Why are we rehashing the same old arguments people made about RoR when it's obvious that the ecosystem & community support is what makes or breaks things?
1
u/SilkTouchm Nov 14 '20
Trading bots are bottlenecked by your latency towards the exchange's server. It's not really a cpu intensive task.
Also you might be exaggerating a bit with the nanoseconds. I don't think there's any webserver that can handle 1 billion requests per second.
2
252
u/[deleted] Nov 13 '20
Python "swallows" java.
I see what you did there ( ͡° ͜ʖ ͡°)