this post was submitted on 23 Aug 2023
526 points (97.0% liked)

Technology

59709 readers
5518 users here now

This is a most excellent place for technology news and articles.


Our Rules


  1. Follow the lemmy.world rules.
  2. Only tech related content.
  3. Be excellent to each another!
  4. Mod approved content bots can post up to 10 articles per day.
  5. Threads asking for personal tech support may be deleted.
  6. Politics threads may be removed.
  7. No memes allowed as posts, OK to post as comments.
  8. Only approved bots from the list below, to ask if your bot can be added please contact us.
  9. Check for duplicates before posting, duplicates may be removed

Approved Bots


founded 1 year ago
MODERATORS
 

Since its inception, Microsoft Excel has changed how people organize, analyze, and visualize their data, providing a basis for decision-making for the flying billionaires heads up in the clouds who don't give a fuck for life off~~the~~line

you are viewing a single comment's thread
view the rest of the comments
[–] Asifall 197 points 1 year ago (2 children)

Damn they found a way to make python slower

[–] some_designer_dude 29 points 1 year ago (2 children)
[–] Aceticon 5 points 1 year ago* (last edited 1 year ago) (1 children)

I used to make high performance distributed computing server-systems for Investment banks.

Since the advent of Just In Time compiling, Java isn't slow if properly used.

It can however be stupidly slow if you don't know what you're doing (so can something like Assembly: if you're using a simple algorithm with a O(n) = n^2 execution time instead of something with O(n) = n*log(n) time, it's going to be slow for anything but a quantum computer, which is why, for example, most libraries with sorting algorithms use something more complex than the silly simple method of examining every value against every other value).

[–] [email protected] 5 points 1 year ago (1 children)

Just because you can make slow assembler doesn't make Java fast.

Java is clunky and not fast compared to C++ which is clunky and fast, Python which isn't clunky but slow bla bla bla bla...

[–] Aceticon 7 points 1 year ago* (last edited 1 year ago) (1 children)

That's oversimplifying things.

For things like algorithms Java can be as fast as C++ because ultimatelly it all ends up as the same assembly code: the differences in performance between one and the other are within the same range as the differences in performance between different C++ compilers or even optimization flags chosen and ultimatelly boil down to how good the implementation of the Java Virtual Machine is for a specific architecture (things like whether the generated assembly takes in account the way the microcontroller handles conditional jumps and cache misses).

Were Java is slower than C++ is in things like memory management: even the best garbage collection will never beat the kind of carefully handcrafter managing of memory that you can do in C++, though the upside of the different memory management architecture in Java is that your programs don't just start behaving in weird ways because you incorrectly accessed a variable in stack using a pointer and overwrote other stuff or even the function return address.

Then again if performance is your greatest consideration you would go for C, not C++ (note that I didn't say Assembly, as good C compilers are actually better at optimizing than most Assembly programmers).

[–] [email protected] 0 points 1 year ago (1 children)

Well that was a lot of misconceptions.

So compiler will make java as fast as C++ but not C++ as fast as C?

Also, when speed matters it's never great to have huge Java classes, it just won't be optimised away (anough) and you'll have a memory / bus bottleneck.

Also, if you really want speed you go parallel, IDK if java is up for the challenge lol (can you configure stackspace and so?) or to beat them all, you run it on the GPU (or several GPU lol :-)

[–] Aceticon 5 points 1 year ago

I think I didn't explain myself correctly.

The Just In Time Compiler in a Java Virtual Machine which does a final compilation step at runtime from JVM assembly to native code will make the typical code in algorithms run as fast as in C++ because ultimatelly they both end up as the same assembly. I've actually measure this by the way, though it was years ago.

However things like memory architectures are different between those languages and the one in C++ can easilly be made faster than in Java, though the downside of that memory architecture is nastier bugs.

Further, and this time about general performance, if you're worried about performance above all, then in terms of general performance, C is generally faster than C++: for example virtual functions in C++ objects have calling overheads which function calls when there is no inheritance do not have so unless you don't use inheritance at all, some function calls in C++ will be slower.

As for parallelization, I've actually worked both in massive parallel Java with distributed computing and GPU computing and they're completelly different kinds of parallelization with different capabilities and optimal use cases: good luck making a CUDA application optimized for serving paralled requests from millions of clients sourcing data from multiple sources and good luck making an LLM runtime with distributed computing in Java were parts of the pre-trained neural network are in different machines - GPU computing can't arbitrally decide it needs some data and fetch it whilst the overhead of synching two parts of a Java system running in different machines is way (millions of times?) larger than the overhead of synching read-then-write-access to the same position in a RWStructuredBuffer from 2 different processing units.

Comparing these two kind of parallelism is not an apple and oranges comparison, it'sm more like an apples and horseshoes comparison.

[–] kameecoding 4 points 1 year ago (2 children)
[–] milady 16 points 1 year ago (2 children)

I mean, whatever speed java has or doesn't have, what the other person said was emulate, you'll have your os then on top of that the JVM then on top of that your python implementation, then finally the python code. If that's faster than os->python imp..

[–] Aceticon 2 points 1 year ago

Just like Python doesn't run from the source code through the interpreter all the time (instead, if I'm not mistaken, the interpreter pass converts the code to a binary runtime form, so interpretation of the source is done only once), so does "modern" Java (I put modern between quotes because it's been like that for almost 20 years) convert the code in VM format to binary assembly code in the local system (the technology is called JIT, for Just-In-Time compiler).

[–] [email protected] 1 points 1 year ago (1 children)

It’s Jython and it’s like 25 years old

[–] [email protected] 1 points 1 year ago (1 children)
[–] setsubyou 2 points 1 year ago

If you need python 3 there's also graalvm but its python support is still "experimental".

[–] [email protected] 16 points 1 year ago

That made a python interface wrapper arround VB Script.