r/learnjava • • Jul 06 '22

F string For Java

Hello Everyone,

I Have created F string for java using reflection api.

Kindly check the below utility.

All contributions will help.

Thanks :)

https://github.com/chinmay-sawant/FString-For-Java

2 Upvotes

14 comments sorted by

View all comments

2

u/chinmay06 Jul 06 '22

If anyone can help me integrate the code directly in java then it would be great help instead of instancing it multiple times through all classes

6

u/8igg7e5 Jul 06 '22

They're already considering something richer than this with String Templates.

It even has a work-in-progress branch in the jdk and a fair bit of discussion on the JDK dev lists (Project Amber).

2

u/chinmay06 Jul 06 '22

Thanks for your reply ! I have check the above String Templates that is for open JdK right ? I am using Java 1.8 Oracle and trying to create a program which will be similar to F strings in python above string Templates needs to specify the backslash as escape characters ;_

2

u/8igg7e5 Jul 06 '22

Note that the Oracle JDK is now just a build of OpenJDK.

Jave 8 is now quite old (2014), with two LTS releases since then (11 and 17), the current release being 18 (and the next due in September, every 6 months).

While a lot of older projects still use JDK8 (and will likely continue to do so, as there are some challenges to migration past Java 9), newer projects (and those that were able to upgrade) have moved on. Some major frameworks are moving to Java 17 as the minimum.

Each Java release is a specification, and features/changes (other than fixes) are almost never added once released - so 'integrating into Java 8' won't happen, and clearly String Templates would be a much richer alternative in the future anyway.