News for hackers. Stuff that matters.
Re:Java string interpolation feature has been cancelled by aster0id on Thursday June 20, 2024 @07:29AM (#40737424)
Why would anyone use java over kotlin for new projects? At least for server side development, kotlin has proved to be far superior to us.
Re:Java string interpolation feature has been cancelled by eitland on Thursday June 20, 2024 @07:49AM (#40737579)
At work I use Kotlin. At home I often use Java.

My main reason for using it for my personal hobby projects is because I prefer another IDE.

And Kotlin is only supported by IntelliJ, which I admit is a really good ide, but not my favorite.

Re:Java string interpolation feature has been cancelled by kernal on Thursday June 20, 2024 @03:04PM (#40742077)
There are Kotlin plugins for Eclipse, VS Code, NetBeans, etc...
Re:Java string interpolation feature has been cancelled by eitland on Thursday June 20, 2024 @03:55PM (#40742629)
Last I checked they only did syntax highlighting, not completion. And Jetbrains were rather clear that it was not a priority.

I am happy to be wrong now though.

Edit, this is a good step forward, here is the list from NetBeans, the "Toyota Hilux" of IDEs and my favorite:

    Language Feature Support Status
    File type recognition √
    Project type 
    Semantic syntax highlighting √
    Formatting √
    Braces matching √
    Code completion √
    Error Hints/Fixes/Suggestions 
    Code templates 
    Refactoring 
    Debugging
At the pace this is moving now I don't know what will stop me from only using Kotlin in the feature.
Re:Java string interpolation feature has been cancelled by kernal on Friday June 21, 2024 @04:35PM (#40753523)
The VS Code Kotlin plugin also supports the following:

Code completion

Linting

Semantic highlighting

Debugging

Go-to-definition

Signature help

Hover

Formatting

Document symbols

Find references

Re:Java string interpolation feature has been cancelled by rmrfchik on Friday June 21, 2024 @05:33AM (#40747816)
Can you share plugin for NetBeans? Last time I checked it was some outdated plugin from JetBrains (who, obviously, aren't interested in any other IDE).
Re:Java string interpolation feature has been cancelled by pjmlp on Thursday June 20, 2024 @07:43AM (#40737528)
Because Kotlin is a guest language, designed to sell InteliJ.

Like C (alongside C++) and UNIX, JavaScript and Web, CLR and C#, JVM and Java are designed together, and have first class tooling in all Java IDEs.

Re:Java string interpolation feature has been cancelled by binkHN on Thursday June 20, 2024 @07:36AM (#40737480)
It's definitely not limited to the server side of things. Obviously it's the standard for Android app development and, largely, a pleasure to work with.
Re:Java string interpolation feature has been cancelled by DarkNova6 on Thursday June 20, 2024 @07:32AM (#40737443)
Because syntax is the boring part of programming.
Re:Java string interpolation feature has been cancelled by agumonkey on Thursday June 20, 2024 @07:55AM (#40737637)
They also had nice features like conditional type inference right ?
Re:Java string interpolation feature has been cancelled by simon_void on Thursday June 20, 2024 @02:55PM (#40741975)
Kotlin has type inference and smart-casting, which i guess is what you mean!?
Re:Java string interpolation feature has been cancelled by agumonkey on Thursday June 20, 2024 @06:42PM (#40744241)
Most probably, sorry I lost track of languages changelog there's so many of them these days.

Just saying, kotlin wasn't just a more aesthetically pleasing java, there were some deeper benefits as far as i can tell.

Re:Java string interpolation feature has been cancelled by Mesopropithecus on Thursday June 20, 2024 @02:40PM (#40741810)
I agree with that, but null safety would be a big deal for correctness.
Re:Java string interpolation feature has been cancelled by favorited on Thursday June 20, 2024 @03:58PM (#40742662)
Manually writing getters and setters is also pretty boring, in my experience.
Re:Java string interpolation feature has been cancelled by vips7L on Thursday June 20, 2024 @05:16PM (#40743490)
That's purely your choice on the libraries you use. Nothing in the language is forcing you to do this. Getter/setters are just a requirement of JPA which you don't have to use. In fact if you just use jOOQ or query dsl you can map to Java records.
Re:Java string interpolation feature has been cancelled by favorited on Thursday June 20, 2024 @06:14PM (#40744016)
The language isn't forcing it, but idiomatic Java (and decades of Java-based university training) is. Pretty much every professional Java project I've ever seen is full of code like:

  private Map<String, Client> clients;
  
  public Map<String, Client> getClients() {
    return clients;
  }
  
  public void setClients(Map<String, Client> clients) {
    this.clients = clients;
  }
Kotlin's approach, where you declare and instantiate a property, and the getter/setter/backing storage are synthesized for you, is vastly preferable to me:

  public var clients = emptyMap<String, Client>()
Re:Java string interpolation feature has been cancelled by vips7L on Thursday June 20, 2024 @08:26PM (#40744940)
I just disagree. This is not idiomatic Java; it's idiomatic JPA. All of the Java I see professionally and in the community uses immutable classes when not dealing with JPA entities.
Re:Java string interpolation feature has been cancelled by favorited on Thursday June 20, 2024 @09:22PM (#40745249)
I guess you live in a more modern workspace than I do. I just picked an open source project that (A) I know we use at work, and (B) I know is written in Java. I picked a random source file that sounded like it would have some mutable state, and the very first functions below the constructor were a trivial getter and setter around a private ivar.

https://github.com/apache/solr/blob/main/solr/core/src/java/...

I'm a little surprised it was in literally the first place I looked, but I'm not surprised that it was easy to find. "Use private ivars and write getters and setters to encapsulate your state" was probably the second thing that a generation of CompSci students learned in their first programming class, right after "an object is an instance of a class."

Re:Java string interpolation feature has been cancelled by vips7L on Thursday June 20, 2024 @11:12PM (#40745761)
You picked a project that (A) is literally older than the sun, (B) targets Java 11, a version from 5 years ago, and (C) the file is generated.

Right at the top of the file...

> /* QueryParser.java / / Generated By:JavaCC: Do not edit this line. QueryParser.java */

I'm not claiming you're not going to see properties written out. I'm just saying that's not the majority of code you're going to see and to claim that idiomatic Java is all getters and setters is a bit far fetched.

Here is what I would consider modern idiomatic Java, immutable records and immutable classes that may expose some of their state:

https://github.com/jstachio/jstachio/blob/main/compiler/apt/... https://github.com/jstachio/jstachio/blob/main/compiler/apt/...

Re:Java string interpolation feature has been cancelled by kaba0 on Friday June 21, 2024 @05:29AM (#40747788)
Kotlin’s approach was a necessity to interact with a Java convention. Java instead tries to move away from that mutable convention to an immutable-preferring one with clearer rules (e.g. what is the correct setter and getter for an `IP` field?).
Re:Java string interpolation feature has been cancelled by DarkNova6 on Thursday June 20, 2024 @06:15PM (#40744021)
You would be a fool to do exactly that. Use Lombok, or even better: immutable records.

Setters are needed in exceedingly rarely circumstances.

Re:Java string interpolation feature has been cancelled by bradboimler on Friday June 21, 2024 @07:17AM (#40748330)
Can your IDE write them for you?
Re:Java string interpolation feature has been cancelled by bradboimler on Thursday June 20, 2024 @09:39AM (#40738672)
I find modern Java an absolute joy to program in. Kotlin doesn't solve any major problems I have with Java.
Re:Java string interpolation feature has been cancelled by rmrfchik on Thursday June 20, 2024 @10:32AM (#40739196)
Because Kotlin as a mess language and have poor IDE support.

  $ kotlin
  Welcome to Kotlin version 1.6.10 (JRE 21.0.1+12-Debian-2)
  Type :help for help, :quit for quit
  >>> val b=ByteArray(1);
  >>> b[0] == 0;
  error: operator '==' cannot be applied to 'Byte' and 'Int'
  b[0] == 0;
  ^

  $ jshell
  |  Welcome to JShell -- Version 21.0.1
  |  For an introduction type: /help intro

  jshell> byte[] ba={0}
  ba ==> byte[1] { 0 }

  jshell> ba[0]==0
  $2 ==> true
upd: format
Re:Java string interpolation feature has been cancelled by simon_void on Thursday June 20, 2024 @03:00PM (#40742028)
I prefer Kotlin over Java as well. I use it at work (where Java code has a tendency to become Kotlin code if it comes close to me) and at home. I'm looking forward to seeing how the native and wasm backends might extends the reach of Kotlin in the future.