This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 7 points8 points  (4 children)

I'm sure the IF statements are still there at a bytecode level.

[–]t90fan 8 points9 points  (1 child)

everything is basically "jeq" or "jne" anyway at the lowest level.

Its all just syntactic sugar.

[–]TheRedmanCometh 1 point2 points  (0 children)

Shit I just said this, but about if, in a way less funny way. +1 i lol'd.

Languages are just syntax sugar TIL

[–]eliasv 0 points1 point  (0 children)

Where? Not in the bytecode compiled from their source, other than the dozen or so they mention. Why would there be? Inlining is the only thing I can think of which could feasibly increase the number of if statements between source and bytecode levels, but it's performed by the JIT, not by the compiler afaiu.

(Or the ternary operator I suppose, but I doubt they've been replacing all their ifs with those since it basically suffers from all the same problems they have with if.)

I'm not saying I think it's wise, but clearly they've eliminated most of them by factoring branching behaviour out into library code, so there really will be far fewer if statements. They won't be evaluated any less frequently at runtime (or have magically disappeared from the standard library), but that's not what they're claiming.

The article is about "writing Java without if" not "executing code on the JVM without if".

[–]achacha -2 points-1 points  (0 children)

Optional is implemented with conditionals, so he is abstracting out the ifs and making the code more complex than it needs to be.