Hacker News new | ask | show | jobs
by floodfx 888 days ago
I think String Templates are pretty cool. For example it enables "tagged template literal"-like behavior which is super powerful in JS land.

I used it to support a LiveView implementation for Java: https://github.com/floodfx/undead

Sure the syntax isn't "pretty" but understandable and you get used to it like anything else.

1 comments

The whole reason for string interpolation is to have a “pretty” syntax.
But the security problems that string interpolation introduces are one of the reasons why Java has decided to reject string interpolation as a language feature in favour of string templates (you can use string templates for interpolation as a special case of a template processor, but that's not the feature's raison d'être). The reason for string templates is to improve the convenience and (very poor) security of string manipulation.

The JEP explains why Java is getting string templates and is not getting string interpolation (as a language feature).