r/programming • • Feb 22 '15

Java Makes Programmers Want To Do Absolutely Anything Else With Their Time

http://www.forbes.com/sites/quora/2015/02/21/java-makes-programmers-want-to-do-absolutely-anything-else-with-their-time/
35 Upvotes

636 comments sorted by

View all comments

Show parent comments

2

u/F-J-W Feb 22 '15

relaxed atomics.

aka the nuclear landmines that won't help much most of the time. They have been called the single most experts-only feature in all of C++!

World-class experts like Stephan Lavavej fucked those up. And there are basically just two architectures on which you will gain anything from them (IIRC old ARM-versions and power-pc).

Oh, and their necessary price is completely undefined behavior.

So: No, you don't want them in Java. (And probably you don't want to use them in C++ either.)

1

u/Tulip-Stefan Feb 22 '15

I don't agree. It's true that at the hardware level the improvement over plain atomic is limited to a few architectures (ARMv7, consoles, itanium). Using relaxed atomics also allows the compiler to optimize a bit more in some situations, even on hardware with a strong memory model.

I wouldn't advice anyone to actually use them, because often it isn't important. But it is these things that give C/C++ an edge over other programming languages when it actually matters.

Saying that there's undefined behavior is kind of a bad argument. The entire C++ standard is littered with undefined behavior. Even multiplying 2 uint32_t can result in undefined behavior, but that doesn't mean we should avoid them.

1

u/F-J-W Feb 22 '15

Saying that there's undefined behavior is kind of a bad argument. The entire C++ standard is littered with undefined behavior.

Yes and that is great for C++, but it would be weird in a language that doesn't contain it by explicit design.

Even multiplying 2 uint32_t can result in undefined behavior

Only if int would be at least 64 bit wide, otherwise you will get mod 232 arithmetics.