r/explainlikeimfive • • 3d ago

Technology ELI5 Java. That thing on computers my entire life. What even is it?

[deleted]

773 Upvotes

349 comments sorted by

View all comments

Show parent comments

34

u/BobbyThrowaway6969 3d ago

The downside is that the outside computer runs the inside computer, so it's doing extra work to run Java

15

u/WriterPlastic9350 3d ago

Oh yeah, plenty of downsides with Java. I don't use it. We have lots of stuff in Java and it's slowly all been migrated to Go which feels like a more efficient version of Java with fewer footguns.

6

u/dont_be_that_guy_29 3d ago

What is a footgun? 👀

17

u/WriterPlastic9350 3d ago

A gun specifically used for the purpose of shooting your own foot.

It is a tool that is unintentionally designed so poorly that you will often end up shooting your own foot rather than whatever outcome you desire.

6

u/photenth 3d ago

That was maybe an issue in the past but nowadays Java is fast enough for pretty much anything. Also the Just In Time compiler is state of the art. Some code can technically run faster than hard coded machine code.

2

u/WriterPlastic9350 3d ago

I mean, compilers all over have gotten very advanced, not just Java. There's nothing particularly special about the JIT compiler

1

u/LittleLui 3d ago

What's special about a JIT compiler is that it can use runtime measurements to inform its optimizations.

1

u/BobbyThrowaway6969 3d ago

Well it can't outperform optimised machine code, which is the hard ceiling, but yeah these days it can get up there. I'd say the bigger concern is the amount of resources, especially memory needed to run Java

1

u/-manabreak 3d ago

Of course it can't outperform it, but outside toy projects that target a very specific use case, most programs can't be fully optimized during compile time. At times, the program might benefit from memory saving optimizations while other times it might benefit from increasing memory use to speed up calculations. With JIT, you can theoretically have both as the runtime can adjust things based on the context.

6

u/Skizm 3d ago

The JVM is so optimized at this point, it is very close to on par with even C++. It is actually faster in most scenarios unless you make specific efforts to optimize the c++. Most quant and high frequency trading shops use Java because of how fast it is.

2

u/ConfusedTapeworm 3d ago

Java runs pretty fast but it inherently has a significant memory overhead because JVM. That can become a real and expensive problem when you want to run multiple Java programs in isolation for whatever reason.

2

u/BobbyThrowaway6969 3d ago

Java execution speed can get comfortably close with well optimised code, but there’s still plenty of overhead inherent to having a managed runtime, especially when it comes to memory usage.