10 ms·
In principle I like Java but there are a few minor details that just make it not worth dealing with it. Getters and setters are incredibly annoying. There are l
by imtringued 6y ago
In principle I like Java but there are a few minor details that just make it not worth dealing with it. Getters and setters are incredibly annoying. There are lots of crazy things going on in the JEE ecosystem. The latter is a big deal when you accept an average "Java job".
If you were to give it a small facelift I wouldn't have to worry about all the tiny flaws that add up. I don't really need Kotlin, Scala or dead JVM language x. Just a slightly better Java.
- noisem4ker 6y ago>Getters and setters Meet Project Lombok. Problem solved and forgotten.
- ivan_gammel 6y agoWell, no, it is not. Lombok does not mask invocations, so it is still foo.getA().getB().getC()
- Vax45 6y agoI prefer Immutables for code generation. Lombok tends to interfere with Eclipse' code evaluations (last time I used it, it kept interfering with searching for a generated method's usage in your code base) and tends to confuse me when trying to figure out if something's an actual method or a method that was injected into the AST during compilation. Immutables has its own set of problems, but at least it uses the standard Annotation processor and has a clear separation of generated code and the interface you write. Haven't used Java's new record's yet, so don't really know anything about that.
- dehrmann 6y agoI can't remember the exact issues, but there's enough magic going on in Lombok that it doesn't play well with Kotlin, so you're better off with Autovalue or Immutables to future-proof things. I also generally don't like how much magic Lombok uses, regardless of if you needs support for any other JVM languages.
- kulig 6y agoAn external dependency for generating getters and setters? Whats next? Dependency to check if a value is null?
- zmmmmm 6y agoAfter spending nearly a whole day trying to get a lombok build configured and working in my IDE ... I just gave up on it. It's a nice idea but I prefer to use something like Groovy where the AST transformations happen directly in the language space rather than in a meta-build step that requires so much IDE involvement. (not to mention most of them not even needed because Groovy just does those conveniences by default).
- frevib 6y agoKotlin is slighty better Java. No more getters, setters, hashcode and toString. Kotlin is also much better Java for asynchronous programming, null-safety, and functional programming. It’s modern Java.
- deleted 6y ago[deleted]
- pjmlp 6y agoWithout a VM to call its own, unless we start talking about ART or the failure of Kotlin/Native memory model.
- twistedpair 6y agoSame goes for Scala and Case Classes. Alas the type astronauts went crazy with Scala, scaring some folks off.
- eweise 6y agoI agree. I wish the Scala community would inherit some of the simplifying culture of the Go community.
- ebruchez 6y agoScala 3 introduces a number of simplifications. For example, typeclasses and other constructs are much easier with Scala 3. This said, Scala always included the idea of having a powerful type system. From this perspective, it can never be as simple as a language that doesn't have a comparatively powerful type system (or no static type system at all).
- deleted 6y ago[deleted]
- bcrosby95 6y agoThe philosophy behind Kotlin and Java really couldn't be more different. Go is much closer to a modern Java than Kotlin. Kotlin does have some nice additions. But it is very much a kitchen sink language. I wish I could take some of those nicer additions and leave the sink.
- u678u 6y agoThe weird thing is you dont even need getters and setters, you can make member variables public (and final if you have to). Just its the Java culture that is so wedded to it. I like Java but its the culture that makes everything soo complicated.
- xxs 6y agogetters/setters became popular with RMI. Public fields have all kind of security/code smell issues. Most classes should be immutable.
- JulianMorrison 6y agoPublic writeable fields are threading and encapsulation smells but public read-only fields just say, this data is part of my interface.
- deleted 6y ago[deleted]
- xxs 6y agowell, yes however fields cannot be part of an 'interface' in java. (they can but they'd be static) I do use package private fields liberally, though. Just not non-static public fields.
- JulianMorrison 6y agoInterface as used here means the broader concept of a "a class's interface is its public advertised operations" and not the specific Java thing called an interface.
- derefr 6y agoI don’t fault Java programmers for their “love” of getters/setters; they’re taking something that really is a best-practice in certain situations, and which mostly doesn’t hurt otherwise (that best-practice being “making the contractual interface for an object its methods, so that the implementation can change while the interface remains stable”) and just deciding to do it all the time rather than only when it will likely have future benefits. Which makes a lot of sense, if you look at it through the lens of cultural anthropology. Enterprises dictate approaches like this, because the alternative is leaving the choice to the individual programmer — and these same enterprises don’t hire experienced-enough programmers to trust their judgement. And so all the programmers who work for these enterprises end up absorbing this approach as a social norm, just “something you do”, rather than “independently rediscovering the need for it” in a way that would lead to them actually knowing when it’s useful. So, even when not locked into an enterprise that forces it on them, they just keep doing it, because that’s the culture that’s been inculcated on them (and how all the examples look, how all the libraries do it, etc.) Personally, I’m not in theory against “unilateral” use of getters/setters, either. I just kind of which they worked in Java the way they work in Ruby: where referencing a field on any object other than `this` would actually just be sugar for a call to the getter/setter. Where the Java optimizer would then take special care to optimize-away the call frame for known-‘trivial’ getters/setters.
- xxs 6y agoWell, getters and setters are a choice that's not predominant for the core java packages: java.lang, java.util, java.io, java.nio, etc. Of course there were added with awt 1.1 and swing in an attempt to catch up with the visual programming jazz and for many it never disappeared. Later on there was (still is) a trend to use builders... and a general shift for immutability.
- neeleshs 6y agoNot in the language, but Lombok makes it a non-issue
- freedomben 6y agoJava was (and still is) IMHO a great language, but the culture around it is why I refuse to do it professionally. Things I can't stand: 1. Multiple (often unnecessary) layers of abstraction that end up being much more complicated than the thing they were intended to simplify through abstraction. There is no concept too simple to abstract it seems 2. Verbose and hard to follow "builder" patterns 3. The extreme proliferation of design patterns. I have literally seen hundreds in various Java codebases. 4. Gradle is great but requires memorizing a non-trivial API and learning a whole new (awesome, but still) language (Groovy). 5. There's always a "Java" way of doing stuff that is different (often because of abstractions, see #1) so you have to re-learn everything that way. Example: Managing TLS certificates 5. Legacy code is everywhere, and can be really painful. So much of it was hacked together and became critical and can never be re-written and never retired There are more, but I weary of this discussion :-)
- pjmlp 6y agoGradle is only a thing in Android circles, thankfully. Legacy code is everywhere on the world, only a selected few get to work on shiny things from scratch. Even cool startups eventually turn into legacy. I wonder what technology used at enterprise level, doesn't suffer from those bullet points.
- tannhaeuser 6y ago> Gradle is only a thing in Android circles, thankfully. Wish that were the case, but unfortunately Gradle builds showed up in server-side, SpringBoot-heavy FinTech startup code I worked with not too recently. I guess it's due to the copy/paste nature of Spring development, like other choices in those code bases.
- pjmlp 6y agoI don't do Spring, so I am spared from that. That is to be expected, given how Spring is now hyping Kotlin as they did previously with Groovy, Scala and Clojure support, and Kotlin folks tend to push for Gradle due to its use on Android.
- parasubvert 6y agoMuch of the JEE ecosystem (not all) has been replaced by Spring Boot or Quarkus. Generally they have been a delight.
- Deinumite 6y agoI see this cited a lot, but honestly I would say the majority of jobs use Spring, and it has been that way for quite a while.
- zmmmmm 6y agoCan I suggest trying Groovy (properly, not in the form of hacking together gradle or jenkins scripts, but as an application language)? It's basically what you want but unlike the other "dead" languages it is designed to complement Java rather than compete with it and is unlikely to ever become obsolete for that reason.
- AtlasBarfed 6y agoUse groovy with @CompileStatic. At least for your beans. Autogenerates the getter/setters.