r/programming • • Sep 15 '20

Java 15 released!

https://jdk.java.net/15/
214 Upvotes

130 comments sorted by

View all comments

Show parent comments

12

u/Certain_Abroad Sep 15 '20

My colleagues are still afraid of using var

Look on the bright side. Better than that having colleagues who just sprinkle var everywhere.

17

u/Programmdude Sep 15 '20

Var is good when you already know the type.

var x = 0; // Good
var y = new FooBar(); // Good
var z = ProcessRequest(); // Bad

Personally I use resharper (or intellij, webstorm) and so it just inserts the type anyway.

7

u/eeperson Sep 16 '20

Why is the last one bad? The type should just be a mouse over away.

9

u/Atulin Sep 16 '20

"I burned my mouse years ago on a stake and exclusively use heavily modified VI running on a Raspberry clone I built with silicone dug up in my backyard"

1

u/eeperson Sep 16 '20 edited Sep 16 '20

Java and vim...eww :P

More seriously, isn't there a command available to show the type under the cursor for Java? I think there is support for this with vim in scala.

1

u/emaphis Sep 16 '20

I can't speak to Vim but with Emacs LSP support, you can get Java type information with a mouse over. You get code completion, import handling/reorganization. Simple refactoring. If you add Projectile, you get project handling and navigation.

I imagine Vim isn't much different.