Live data from Hacker News

Lombok makes Java cool again

bytes.grubhub.com

81–90 of 239 posts

Re: Lombok makes Java cool again

#81
post #58

I spent considerable time playing with Java and various usability extensions, but if I could go back I would have ditched Java much sooner. ML based languages really are an order of magnitude productivity boost.

"ML based languages really are an order of magnitude productivity boost."

Is this still true when you consider available libraries, performance, concurrency, build and dependency tools, development environments, and deployment options?

Re: Lombok makes Java cool again

#82
post #59

Earlier quoted context omitted.

I see Kotlin as a great choice for these who don't want Java verbosity but can't really get used to read Scala.

I can read Scala fine but I'd like fast compilation and good IDE support.

The IDE support is pretty good these days, as least in IntelliJ.

Re: Lombok makes Java cool again

#83
Reading this just reminds me of all the terrible things about Java. The lack of reasonable default string representations, comparison and hashing methods, etc. are all glaring mistakes in the language design that have wasted huge amounts of time for millions of programmers. It's as though Java programmers are so deep in the grips of Stockholm Syndrome that ordinary, sensible behaviour seems amazing and "cool".

This is similar to the situation with design patterns. When design patterns came along, Java folks talked about them as though they were a wonderful new invention. But they only exist because Java is so clumsy that it needed crutches to do things that had been easy and natural in other languages for years; someone merely came along and gave the crutches names.

Re: Lombok makes Java cool again

#84
post #43
post #12

My main issue with Java is all the annotation based programming. Some of these are nice and can make the easy case super easy but if you need go even slightly off the easy path you seem to quickly loose all the time gained on the easy path. i.e. @GET(url=" http://host/users/$userid" ) public abstract User getUser(String userid) isn't that much easier than the python requests version but much harder if you need to add…

Yep. I love data classes for the simplicity and utility but pretty soon there are more annotations than java code. In Java I prefer Immutables over Lombok but once you add Jackson annotations, customize the Immutables generated code (@Value.Immutable, @Value.Parameter, etc), add some javax.validation (@NotNull, @NotEmpty) it gets very noisy very quickly. And yet it is still better than writing mutable bean classes by…

Or just register the Jackson Java 8 datatypes module.

Then you can create a standard immutable class with a constructior, and Jackson's object mapper can then serialize and deserialize.

The only catch is that you must add -parameters to your javac args.

Re: Lombok makes Java cool again

#85
post #69
post #44

What's the point of this part of the generated Java code? (I split it out onto multiple lines for legibility) favoriteFoods = new java.util.LinkedHashSet ( this.favoriteFoods.size() Why not just? this.favoriteFoods = new java.util.LinkedHashSet (this.favoriteFoods);

1073741824 is maximum (signed) integer size divided by 2. This is trying to optimize for the initial size of the set so that it doesn't have to allocate too many elements, since iirc Java's hashsets are backed by a hashmap implementation which has to be sized appropriately.

I understand what it’s doing. I’m curious why it’s necessary to do it explicitly. Wouldn’t the optimal sizing be the default behavior when passing in the collection that will populate the set?

Re: Lombok makes Java cool again

#86
post #58

I spent considerable time playing with Java and various usability extensions, but if I could go back I would have ditched Java much sooner. ML based languages really are an order of magnitude productivity boost.

"ML based languages really are an order of magnitude productivity boost." Is this still true when you consider available libraries, performance, concurrency, build and dependency tools, development environments, and deployment options?

I'd say it depends on which ML derivative you're talking about.

I've found F# to be pretty good in all of the areas you mentioned. Although not enough to literally provide an order or magnitude boost like the post you were replying to suggested.

I think people use "order of magnitude" a little too freely. Developing with Java (and to a lesser extent, C#) feels slower than with F#, but not 10 times slower.

Re: Lombok makes Java cool again

#87

I use the elements of programming from SICP[1] as a litmus test for this kind of frameworks. The main issue with these annotation hacks is that they fail in the area of “means of combination” and “means of abstraction”. For example if you have: @X @Y class Something{} You cannot tell if X & Y can be combined (or how it’s combined), or you cannot easily create an abstraction Z with X and Y (you may be able to do that…

I agree, but it's helpful that the things Lombok abstracts away are very idiomatic and straightforward. I would never want to use it to take on anything more complicated.

Re: Lombok makes Java cool again

#88

I'm interested in the downsides of using Lombok, since the article seems to only focus on its positives and makes it seem like I should download it and start using it right now. Is there anyone here with Lombok experience that wants to share any issues they've run into while using it? All I can think of right now is the fact that the source code isn't compatible with Java.

The only downside I've come across was test coverage tools like jacoco can have problems with the auto-generated code (complaining about your tests not covering enough branches of an auto-generated hashCode() implementation, for example). However it seems new-ish versions of jacoco seem to have built support for it.

Re: Lombok makes Java cool again

#90
Something like this would be handy for the .NET framework.

Off the top of my head; PostSharp (although not free) would get you much of this. Also might be achieveable via Roslyn? And there is another .NET AOP framework whose name eludes me at the moment... EDIT: Fody.

Post reply on HN