casid / jte

Secure and speedy templates for Java and Kotlin.
https://jte.gg
Apache License 2.0
804 stars 59 forks source link

Spring Boot integration and binary rendering #327

Closed ltanguy closed 7 months ago

ltanguy commented 8 months ago

Hello,

I was wondering why the spring boot module doesn't include an option to enable binary rendering. Is there a technical reason for not enabling it in this context ?

casid commented 8 months ago

Hi @ltanguy, I think this option was removed to be able to intercept the rendering output: https://github.com/casid/jte/commit/f432fcd713a49117b06d4c1e9131ced4418565a7

ltanguy commented 8 months ago

This feels to me as a rare edge case, typically for projects with a tight coupling with Spring MVC (like the one referenced in this commit). Would it make sense to reinstate this ability through an auto-configuration option, disabled by default ?

casid commented 7 months ago

I think the reasoning was that, the performance difference between binary/string templates would be neglectable compared to the overhead of Spring Boot. The way it is, it is less complicated for users and compatible with all interception mechanisms that spring offers.

@tschuehly what do you think?

tschuehly commented 7 months ago

Yes, that is a good explanation. What do you want to achieve with binary rendering? @ltanguy

ltanguy commented 7 months ago

Nothing very specific actually, probably more the beauty of squeezing as much performance as possible, but I agree that the difference won't probably be significative in most cases. I'm not sure to see where the use case of binary rendering fits, as almost every web application will rely on a framework of some sort (Spring, Quarkus, ...) that will have similar requirements.

edward3h commented 7 months ago

Many applications make network calls to databases or other services. Once you are hitting the network for the data for your models, the CPU cost of binary vs text rendering is basically irrelevant.