Java by default means
-
mutable objects:
person.setName
- references to mutable objects
- overriding
equals
andhashCode
- overriding
- references to mutable objects
-
statements > expressions:
doX(); doY();
-
RuntimeException
s en masse -
bad error messages
-
mutable variables:
setName(
final
String name)
-
package public members:
private
String name;
- (implicit) constructors
-
extensible classes:
final
class Person;
-
no exhaustive type matching (only as a java 17 preview feature)
-
eager evaluation
-
unreadable formatting
- actually useful info near the end of the line:
public final class <Example> { public static void <main(String[] args)> { System.out.<println("Hello world")>; } }
- all-caps:
enum Fruit { BANANA } static final Fruit YELLOW_FRUIT= BANANA;
- 1-letter type variable names:
<T, U, V> V map2(...<T> ..., ...<U> ...)
- actually useful info near the end of the line:
-
verbosity
-
gotchas:
'h' + 'e' + 'l' + 'l' + 'o' // == 532
... it's easy to write bad code in java.
After a year with elm, I disagree with nearly every basic design decision.
If you are required to use java – just like me, here are some tips to make the best of java:
Note: This list covers only a few tips.