5 ms·
That is actually a misconception. You may have this mental classification of Java as a slow language if you looked at its performance 20 years ago. Now it's act
by drKarl 6y ago
That is actually a misconception. You may have this mental classification of Java as a slow language if you looked at its performance 20 years ago. Now it's actually really fast, it goes neck to neck with C++. Sure, Rust or Go or C (or definitely assembler) might be faster in some workloads, but Java is definitely very very fast nowadays. It uses a lot of memory because of the way Garbage Collection works, but it is fast. It's definitely faster than Python, Ruby, PHP and many other kids on the block...
- xamolxix 6y ago> it goes neck to neck with C++. Sure, Rust or Go or C I hate to be that guy but 1) java does not go neck to neck with c++ unless you mean it can be in the same order of magnitude and 2) C++ is not slower than C or Go or Rust Note: by c++ I mean c++ compiled by a decent compiler e.g. gcc/clang/msvc
- sweeneyrod 6y agoYes, out of Rust, C, C++ and Go, the slow one is going to be the one with a GC.
- apocalyptic0n3 6y ago> It's definitely faster than Python, Ruby, PHP and many other kids on the block... I don't know why, but I got a good laugh from that statement. Those "kids" are all the same age or older than Java; PHP, Ruby, and Java were introduced within a few months of each other in 95 and Python dates back to 91.
- drKarl 6y agoI know, I didn't say "kids" implying these languages were new, it was just a manner of speaking.
- apocalyptic0n3 6y agoYeah, I assumed as much. I doubt anyone is calling those languages "kids" at this point, even with PHP's reputation. I just found it funny to word it like that.
- deleted 6y ago[deleted]
- devmor 6y ago>It's definitely faster than Python, Ruby, PHP and many other kids on the block... I would seriously contest the speed of Java compared to modern PHP. The JIT puts PHP at near-C performance levels with competently written code. Which shouldn't be surprising if you realize PHP is largely a "wrapper" around C.
- victor106 6y agohttps://www.techempower.com/benchmarks/#section=data-r19&hw=ph&test=query https://www.techempower.com/benchmarks/#section=data-r19&hw=... Vertx framework which is based on Java is at 8th position and PHP is 18th. But the larger point is performance is only one aspect while considering which programming lang. or framework to use
- RobAley 6y agoI think you've proved your second point by getting your first wrong. The benchmarks posted are for a stack including PHP, not PHP itself (and not the fastest stack with e.g. pgsql). Also, I don't think thosd benchmarks use php 8, which is the first version with the jit that the post above referred to.
- victor106 6y agohttps://www.google.com/amp/s/onilab.com/blog/php-7-vs-php-8/amp/ https://www.google.com/amp/s/onilab.com/blog/php-7-vs-php-8/... From the page above The bottomline: PHP 8 is still slower than PHP 7. This is a realistic comparison of running Magento on php7 vs php8.
- ta988 6y agoYou may not know that Java has a JIT and a AOT if you want even a bit more perf for cold start. And they are really good.
- tomjen3 6y agoJava is fast enough for most things, but try working with an array of a million objects in C++ vs Java and you will see the difference. In Java you will have to deal with an array with a million pointers to a million objects and in C++ you will deal with a sequential segment of memory that is a million times the size of your object - and mostly in your CPUs cache. That alone will be much, much faster. But you can't do that in Java at all.
- hucker 6y agoYou typically wouldn't use an array with a million objects in Java if you cared about performance though (for exactly that reason), you'd architect it some other way. Using SoA style when appropriate, for example.
- iamcreasy 6y agoDo you mean Structure of Arrays? Can you point to some resource to learn more about Java SoA? Quick google search didn't yield anything useful.
- nlitened 6y agoI think in this case you’re holding the tool wrong. When you want, for example, an array of (float x, float y) “objects” in Java, you just keep them as two arrays (float[] x, float[] y) — and I guarantee it will use the same amount of memory and will have nearly the same speed as C++ (depends on what cache locality you need for a specific task, it might even be faster to have two separate arrays for some tasks). So yeah, depending on the language, a slightly different implementation is more efficient, so one has to know its tools. Also, as far as I know, when project Valhalla extension goes live, you will have an option to do packed structs the same way as C++ or C# does. Edit: Oops, there was another reply about the same in the thread. I should remember to refresh the threads before answering in the morning.
- tomjen3 6y agoThat would be a workaround, but it annoys me when you have to make a workaround for something that is available in the language it set out to replace. And if you are doing something like nearest cluster mapping, or anything else where you process your data in linear order you are not going to get the optimized cache locality. Plus you can't read the file with mmap if your data is from there.
- jcelerier 6y ago> Now it's actually really fast, it goes neck to neck with C++. yet every time I try a Jetbrains IDE every action seems to take 10x the time to be processed than it takes in QtCreator
- drKarl 6y agoOnce it's finished indexing things it feels darn instant to me. What hardware do you use? Also which programming language? I've used IntelliJ with Java, Scala, Kotlin, Groovy, Markdown, and many file types and it's really snappy.
- jcelerier 6y agoI have an i7 6900k and 64 GB of ram. Indexing on the project I work on takes something like 3 hours. But I'm not even talking about that - just the basic user interaction, opening a menu, switching tabs... It's notslow but it drags its feet a bit.