5 ms·
That looks like a good addition because anything that makes code more concise and easier to read is a win. Off topic, but I have been feeling nostalgic for Jav
by mark_l_watson 7y ago
That looks like a good addition because anything that makes code more concise and easier to read is a win.
Off topic, but I have been feeling nostalgic for Java, even though I now almost exclusively use Lisp languages and I am happy with that. In early Java years, Sun‘s main Java web site had a link to my site and I wrote a number of Java books. I was the number one search result for “Java consultant” for about a decade; Java was good for my career.
- rumanator 7y ago> That looks like a good addition because anything that makes code more concise and easier to read is a win. Arguably, as Java already had Lombok for years, this does not add anything really new.
- mark_l_watson 7y ago+1 for mentioning Lombok. I used to use it a long time ago.
- cle 7y agoForcing usage of constructors is hardly more readable IMO. Which bug is easier to spot? cat = new Cat(1, 2, 4); cat = Cat.builder().eyes(1).legs(2).heads(4).build(); Additionally, from the examples in that post, records aren't valid JavaBeans either, so they can't be used with the myriad of existing tools/libraries that expect beans. From my first impression, it looks like records don't really address many of the reasons we use Lombok and its ilk, so many of us will just ignore this feature. Or do like I've done in the past couple of years, and just ignore Java altogether.
- skocznymroczny 7y agoJava could really used keyword arguments as a replacement of the Builder pattern: cat = new Cat(eyes=1, heads=2, legs=4);
- rooam-dev 7y agoToo much for small classes/records imho e.g. `new Name("First", "Last")` vs. `new Name(first="First", last="Last")` Also, IDEs can help with parameter hints when is needed.
- deleted 7y ago[deleted]
- deepsun 7y agoThey can be optional, like in Kotlin -- you can give name to only some (after unnamed ones).
- rooam-dev 7y agoI think it's perfect for parameter objects
- kelnos 7y agoI expect the reason that they didn't want them to be valid beans is because then they'd lose immutability.
- Rebelgecko 7y agoIf you're using a decent IDE, that bug is just as easy to spot when using a constructor. My IDE adds the var names in front of the values, so when I create a new Cat(1,2,4) it actually looks like this: new Cat(eyes:1, heads:2, legs:4);
- electrum 7y agoThis is how they look in IntelliJ IDEA: https://www.jetbrains.com/help/idea/viewing-reference-information.html#inlay-hints https://www.jetbrains.com/help/idea/viewing-reference-inform...
- cle 7y agoIf using an IDE is necessary to make the code readable, then Java should ship with an IDE. Or just add it to the language. I find myself often reading code outside of an IDE, such as in GitHub or other hosted repos. Why should it be less readable in those cases? Because it's marginally easier to write? I also write a lot of Go code, and appreciate how "go vet" disallows unkeyed struct literals, forcing you to write the field names when creating structs. It is not an IDE feature, and I can freely browse GitHub or grep around in the command line and the code is just as readable as in an IDE. It also means Go works in a lot of editors and IDEs more easily, because those editors/IDEs don't need to implement a bunch of extra features to make the code actually readable.
- seanmcdirmid 7y agoVerbosity is a huge problem in a language. Verbosity that makes unfamiliar code easier for you to read can actually hurt the readability to a more familiar reader trying to figure out where the bug is. I don’t need that thisIsTheBloodyFooArgument: all over the place if I already know it is the bloody foo argument. Eventually, the code becomes so repetitively noisy that I have to rewrite it stripped down into a text file just to get a gist of the real things I need to understand (like when comments get in the way and don’t help. But really, this is a problem we don’t need to have...tooling could make it so we have the verbose repetitive version that make unfamiliar readers happy and the more concise to the point version that makes familiar readers happy. But for some reason, our profession is infatuated with text files that make this best of both worlds impossible.
- mister_hn 7y agoAssuming you are using an IDE, the new Cat(1,2,4) is far better and concise, plus the IDE tells you already what they are.
- d_t_w 7y agoWhich Lisp flavour do you use Mark? I worked in Java for 15 years before moving to Clojure a decade ago. I find it superbly powerful to be able to leverage the JVM and the Browser with the same language.
- mark_l_watson 7y agoI mostly use Common Lisp, Racket, and periodically like to try the latest versions of Gambit, Chez, and Guile. I used to have two customers who paid me to use Clojure on their projects, I liked Clojure (donated in the early days) but fast natively compiled tools like SBCL, etc. feel better to me. You have found a good home: Clojure and the JVM ecosystem is good for a wide range of uses.
- thu2111 7y agoHave you tried Clojure with the GraalVM native-image? I am curious to what extent native-image can delete the overhead of Clojure and make fast natively compiled binaries.
- mark_l_watson 7y agoNo, I haven’t tried it. I retired last year and the limited time I spend on tech is now persuing personal research on hybrid symbolic and deep learning systems; I use the Hy language ( hylang) for this because it wraps Python (for deep learning) in a reasonable Lisp language with a Clojure-like syntax. I am also writing a book on Hy. Otherwise Common Lisp and Racket(and a little Haskell) suit my hacking needs.