Why are they both widely used instead of just one?

why are they both widely used instead of just one?

Attached: java-vs-c-1-300x171.png (300x171, 16K)

because java is better

Java is slower but less prone to errors, faster to develop, has tons of libraries provided in the jvm and works on almost any device.
C++ is faster and can access native OS and hardware features better.
If I'd implement a prototype of a generic algorithm I'd do it in Java, if I'd try to create a virtual drive or a real time application I would obviously use c++

this. i wish people woudn't be so fucking dense and just use the right tool for the job

Java has GC, C++ can be used in real-time software.

pajeets and boomers

Why are both hammers and drills widely used instead of just one?

>java is slower
>c++ is faster
No. C++ requires more effort to get good performance. But the control it gives simplifies a lot of systems. Imagine trying to take control in Java. That's why C++ and C exist.
The JIT Java has is also much better for long running processes. It's really impressive what it can do in systems where you might see a large general case to cover but in reality there's a large homogeneity. With inputs that are temporally dependent. The JIT can do things like partial specialization on the inputs at runtime. Or at least memorization. That may not be realistic in more static systems.

A novice programmer won't make good C++ or C code. They can probably get by in Java.

And of course the peaks are also hard to reach in Java. It switches from being a design problem like you have in C to being a configuration problem. You'll see a lot of effort put into configuring the GC for instance because you want to encourage contiguous memory accesses and low fragmentation.

Java is good for internet server apps. C++ good for desktop apps.

They're two entirely different tools. Java is interpreted while C++ is compiled to machine code and gives you more low level memory management tools, and allows you to make system calls.

>vans
>trucks

Why are they both widely used instead of just one?

>Java is interpreted

Attached: 1512274161641.jpg (777x704, 57K)

Yes, that's what the JVM does.

Nope, it creates an enviroment to run an applet, you can't edit that applet and reset the vm to see live changes like a interpreted language does.

because niggers don't know about nail guns

Java has a wide support range due to the JVM. C++ has high performance.

why not both?

Different uses in practice.

Java developed a nice VM with GC that helps with stability, debugging, cross-platform support and so on, plus the library ecosystem is different - it has more libs for big data / big processing / running larger web stacks / databases and so on.

Meanwhile it was never all that good at interacting with a GPU, and even native GUI support was never all that fantastic. Nor was it good at guaranteeing minimal latencies on single process use. And even where it was equal: Of course various ecosystems where C++ libs were already dominant and some billions had been invested wouldn't just switch to Java.

> C++ has high performance.
It is better for optimizing individual threads.

But it really looks like Java (+ Scala, with Akka and Spark and so on, but also the Twitter stack and other stacks) won with the distributed / parallel application computations and distributed databases (with Cassandra).

Definitely also a very important form of "high performance", both businesses and private entities rely a lot on these big fast huge data systems and processing power pools.

>cross-platform support
is a huge reason, and definitely something you learn when you start working verse what you do in school.
Currently at work we only to build for two specific linux builds using two different GCCs and MSVC on windows, and it can be a pain in the ass building and testing on all of them which means we need multiple environments setup with the right dependencies. Having the JVM take care of all of that and not needing to worry about the platform your customers are running on can save a ton of development time with not having to test on multiple archs/targets.

Attached: LadyJava.jpg (441x500, 46K)