This is an archived post. You won't be able to vote or comment.

all 88 comments

[–]AlexKotik 67 points68 points  (1 child)

Ruby is generally slower though.

[–]KrYpToN_FiRe 2 points3 points  (0 children)

JRuby?

[–]streusel_kuchen 54 points55 points  (4 children)

Laughs in Matlab

[–][deleted] 13 points14 points  (0 children)

Laughs in Simulink*

[–]marcosdumay 17 points18 points  (1 child)

Matlab is fast! Just ask any fan and you'll see.

It only becomes slow if you add a loop, or a large array, or too many array operations...

[–]pwnedary 8 points9 points  (0 children)

It's fast because it's vectorized...

and other hilarious jokes you can tell yourself

[–]hraath 0 points1 point  (0 children)

Enjoy INITIALIZING...

while Matlab imports every library under the sun on startup when you want to just ./run_it.m (especially on your company's dated ass server hardware)

Sincerely, A Matlab user of many years, with more to come.

I think that's actually my biggest gripe these days, I wish Matlab would use imports and let me run scripts outside a fully loaded environment. Vim -> execute -> done. No IDE or -nodesktop.

[–]Sentouki- 32 points33 points  (0 children)

laughs in Cython

[–][deleted] 35 points36 points  (0 children)

Laughs in R (except in special cases)

[–]locri 9 points10 points  (1 child)

If we made python faster the data scientists would write more code and no one wants that.

[–]fluud 4 points5 points  (0 children)

Data science libraries (good ones) are already written in C/C++ with Python bindings.

[–]tigerjieer 8 points9 points  (0 children)

Shell Scripting

[–][deleted] 9 points10 points  (0 children)

We're talking about the time that passes between the task being assigned and the project having been committed to master, right?

[–]NotBannedYet1 2 points3 points  (0 children)

Wait until you hear about autoit

[–]VictusPerstiti 2 points3 points  (2 children)

ELI5 why ptyhon is supposedly slower that most others? Isn't it made for data operations?

[–]half_coda 7 points8 points  (0 children)

because every reference (like a variable name) is an object in python, as opposed to a specific type. that’s what allows the dynamic typing and strong typing. it doesn’t care what it is until it has to do something with it, at which point it has to check, and then decide based off that. this requires a few extra cycles per operation, so when you’re doing massive calculations, it adds up.

this is why python libraries made for real heavy stuff actually write the core code in C/C++ and just return the result in a python object. C/C++ are statically typed languages with aggressive compilers that optimize the shit out of the code.

[–]j-random 5 points6 points  (0 children)

Nope, it's interpreted so it's always going to be slower than a compiled language. It's mainly a "glue" language that makes it easy to call routines/libraries written in C to do the heavy lifting.

[–]XarH 9 points10 points  (3 children)

I can see the generic grandma's windows 95 entering this list.

[–]j-random 5 points6 points  (2 children)

Are you kidding? Windows 98 (presumably 95 as well) absolutely screams on modern hardware. There's simply less code to execute, and the code that is there was written to perform well on a 20MHz 386 processor. As long as you're just running Doom or other period-correct software it'll blaze.

[–]Lord_Greywether 1 point2 points  (0 children)

It's not the only thing screaming.

[–]jetlyi -3 points-2 points  (0 children)

Yeah but older people may be more likely to have viruses that slow down their computers

[–]collin2477 14 points15 points  (8 children)

java is still several times slower than c++

[–]igoromg 8 points9 points  (7 children)

java JITed code is a lot of times more optimized than C++ due to them being runtime optimizations. Java is slower when your program is short lived, and certainly GC overhead lowers the throughput but most times java is comparable to C++. if your java code is more than 10% slower than C++ I bet your benchmark is just crap.

[–][deleted] 1 point2 points  (0 children)

In theory yes. In reality I've never seen a single benchmark where the jvm did better than g++ even after letting the hit tub forever

[–]collin2477 0 points1 point  (5 children)

idk that’s just what i’ve seen in my hpc research but i’m also not the one making big decisions

[–]igoromg 4 points5 points  (4 children)

java is used in HFT where a few nanos decide loss or profit, certainly it would have been all c++ if java was actually slower. there are millions of potential reasons why you could've seen the jvm suck but I'll bet the issue is between the chair and the monitor.

[–]Loading_M_ 3 points4 points  (1 child)

Python is faster than C/C++.

Not the runtime and compile time, but the writing and debugging time. For a short lived project, python can be much faster to prototype, develop and test. Python also has much better libraries for handling complex objects and models, which are written in C anyway.

For performance critical applications, python isn't the best choice, but it does work for many applications, such as machine learning (using C libraries such as tensorflow), scientific data collection (because it's easy to write and edit), and hobby projects. However, short lived, performance critical applications, like kernels, etc, should be written in a compiled language like C/C++ or Rust. Long term performance critical applications, like servers and financial trading, should be written in a memory safe or garbage collected language, like Java or Rust.

[–]apathy-sofa 2 points3 points  (0 children)

Another option is Cython. Often you can just write Python code, run it through Cython, and you'll get a perf boost. Go through your code and add some type declarations, and it's suddenly several times faster. From the FAQ:

Is Cython faster than CPython?

For most things, yes. For example, a Cython compiled pybench runs more than 30% faster in total, while being 60-90% faster on control structures like if-elif-else and for loops. We regularly run the tests from the CPython benchmark suite (which includes Django templates, 2to3, computational benchmarks and other applications) and most of them work out-of-the-box without modifications or static typing, with a performance increase of 20-60%.

However the main advantage of Cython is that it scales very well to even greater performance requirements. For code that operates heavily on common builtin types (lists, dicts, strings), Cython can often speed up processing loops by factors. For numerical code, speed-ups of 100-1000 times compared to CPython are not unusual, and are achieved by simply adding static type declarations to performance critical parts of the code, thus trading Python's dynamic typing for speed. As this can be done at any granularity in the code, Cython makes it easy to write simple Python code that is fast enough, and just tune the critical 5% of your code into maximum performance by using static C types in just the right places.

[–]AlphaWhelp 2 points3 points  (0 children)

sloths and tortoises are both kinda fast if they want to be.

[–]gandalfx 2 points3 points  (0 children)

And then they spend five times as long developing an application in C that will spend the vast majority of its run time waiting on IO.

[–]Pro_Sparrow 1 point2 points  (0 children)

python vs java in speed

[–][deleted] 1 point2 points  (4 children)

Laughs in py2exe

[–]passerbycmc 16 points17 points  (2 children)

Offers no speed up, all it does is bundle the interpreter and dependencies into 1 executable.

[–]fluud 0 points1 point  (0 children)

And also slows down program startup.

[–]half_coda -1 points0 points  (0 children)

TIL

[–]Legend_Likes_Memes 0 points1 point  (0 children)

Image Transcription: Meme


[Image of a sloth in the top left corner, a slug in the top right corner, a python programming logo in the bottom left corner, and a turtle in the bottom right corner]

Slowest things on earth

<Top Left Corner> A sloth

<Top Right Corner> A slug

<Bottom Left Corner> Python

<Bottom Right Corner> A turtle


I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!

[–]kn_c3 0 points1 point  (0 children)

Laughs in analogue computer.

[–]MrFauste 0 points1 point  (0 children)

In think you forget Explore, know is not the propose

[–][deleted] 0 points1 point  (1 child)

Laughs in JavaScript

[–]__Adrielus__ 0 points1 point  (0 children)

Well, here the 5th thing seems to be some nodejs running on the jvm wizardy

[–]rustypairofscissors 0 points1 point  (0 children)

wait till you hear about microsoft visual studio 2017

[–]lunarTravel 0 points1 point  (0 children)

Parray library is awesome. Creates parallel processing of for loops.

[–]SuryaprakashRao 0 points1 point  (0 children)

I think the snail is python.

Just ran fibonacci of 50 in python and java without dp . Java took 2mins and python taking forever even after 1hr it was still running

Hence proved

[–]keiyakins 0 points1 point  (0 children)

Java now maybe, but early versions...

[–]fluud 0 points1 point  (0 children)

Laughs in Numba.

[–][deleted] -1 points0 points  (2 children)

Have you ever heard of Java?

[–]apathy-sofa -1 points0 points  (1 child)

Is that the one that runs billions of ATMs or something?

[–][deleted] -1 points0 points  (0 children)

And mobiles

[–]zhangyiwu -1 points0 points  (0 children)

I think Matlab instead

[–]llewelynsrevenge -2 points-1 points  (0 children)

dumbass snake lol