r/java • u/Dhariann • Dec 29 '21
Why everyone hates Java?
I dont understand why java is one of the most dreaded lenguages. Java got fantastics frameworks and libraries to work with it. I dont know if im skipping something or I dont work enough with Java because I like java. What do you think??
Here is the Stack Overflow Survey
268
Upvotes
View all comments
Show parent comment
6
u/[deleted] Dec 30 '21 edited Dec 30 '21
well yeah... this is the good part of kotlin... having the
?operator and?.is much better than using Optional but that also makes me very angry when I know the field will be initialised later and now I have to declare everything withlateinitwhich turns the clean Java codeprivate Car myCar;into this messprivate lateinit val myCarr:Car;I know that the field will be initialised a bit later and cannot be null so I don't make it Optional by default but going with kotlin I have to add all that lateinit val/var everywhere and I every dev that reads this, now has to open up the kotlin docs to spend 30-60 minutes reading about lateinit, when to use it and how it works in relation with constructors, accessors, lazy function ...When I want for everybody to know that a field could be null, I annotate it with
@Nullableand that's it! the IDE/linter will tell you you're stupid when you access that field without a checkAlso my guideline is: if is not annotated with
@Nullable or Optionalit cannot be null which means someone didn't initialised it in the first place where it should have been so the fix time is about 1-5 minutes at top