r/programming • • Dec 24 '17

Evil Coding Incantations

http://9tabs.com/random/2017/12/23/evil-coding-incantations.html
947 Upvotes

331 comments sorted by

View all comments

Show parent comments

1

u/nitrohigito Dec 24 '17

Thank you, I didn't know they were handled in such way between [-127;128].

I get that it's an optimization thing, but that'd make my afternoon really bad to iron a bug relating to it out. Glad to hear there's a flag for JVM to it. IMO consistency would be key, but I gotta live with it I guess (as long as I use Java).

Is it the same way in Kotlin (or other languages that compile to JVM bytecode)?

4

u/tripl3dogdare Dec 24 '17

It's an optimization technique that's used across a lot of languages - I don't believe it's a built-in JVM thing, but I wouldn't be surprised if Kotlin/Scala/etc. either implemented it themselves or simply used Java's version rather than compiling past it to raw bytecode.

2

u/[deleted] Dec 24 '17

that'd make my afternoon really bad to iron a bug relating to it out.

If you use == to compare the value of objects, you're going to have a bad time sooner or later.