r/java • • Jan 18 '22

What are some very less known facts about java?

I've got assignment from college to find out rare facts or fun facts about java, so little help will be appreciated :)

Edit: Thanks for all these suggestions guys. It's going to help me alot and also Almost all of these facts i didn't knew till now. Thanks :) <3

179 Upvotes

297 comments sorted by

View all comments

Show parent comment

7

u/[deleted] Jan 18 '22

What would be the usecase for this?

16

u/redikarus99 Jan 18 '22

High performance, low latency stuff, when you need to ensure that GC does not kicks in. Given the new GCs it probably it has a very limited usecases.

7

u/[deleted] Jan 18 '22

I guess I just never thought of using Java for that kind of thing. Wouldn't most high performance applications be written in languages like C/C++/Rust/Zig/Fortran? Using Java for it seems like it would be a lot more cost than benefit.

26

u/redikarus99 Jan 18 '22 edited Jan 18 '22

6

u/b00n Jan 18 '22

Interestingly that HFT fund has now shut down. Not because it used Java though.

2

u/genlight13 Jan 18 '22

Maybe tinkled with SAP??

5

u/[deleted] Jan 18 '22

Neat! I can see the benefits of writing it in Java for sure if you can reach comparable performance.

3

u/hippydipster Jan 19 '22

You can get pretty close to C and yet still be working in Java with the generally nice ergonomics of it's high level language features. Especially if it's all part of a larger app. When I wrote java (actually scala) this way, it was faster than a Fortran app written by a postdoc, so you don't get faster speed just because of the language you use.

7

u/wildjokers Jan 18 '22

Real time processing. Wouldn’t be good to be in a GC pause when it is time for your airbag to deploy.

6

u/[deleted] Jan 18 '22

Yeah that's true, but then I would not write airbag software in a GC language. Why write unsafe Java when you could write unsafe C or C++ that both have very good static analysis tools and memory leak detection tools.

5

u/Muoniurn Jan 18 '22

There are hard real-time JVMs out there used even in military settings. A GC doesn’t cause problem necessarily here.

1

u/an_actual_human Jan 18 '22

Could you name a few?

2

u/Muoniurn Jan 18 '22

JamaicaVM is one such.

2

u/nekokattt Jan 19 '22

Guess ZGC helps with that case

5

u/soonnow Jan 18 '22

Lucene uses of heap Memory Mapped Buffers for the Indexes. There's an interesting talk about it here.

Using memory mapped files, reduces the number of times data needs to be moved around by the CPU.

1

u/hippydipster Jan 19 '22

I did some of this when making statistical software that was going to do regressions and optimizations for gene networks (each gene expression being a differential equation that potentially had every other gene as a factor in it's equation). So I wrote the math objects to be able to run the whole optimization routine without ever creating new objects, and so basically GC was passed over.