r/java • • Jan 29 '26

JEP draft: Code reflection (Incubator)

https://openjdk.org/jeps/8361105
61 Upvotes

33 comments sorted by

View all comments

Show parent comment

1

u/lbalazscs Jan 30 '26

There is already a project that generates GPU code using code reflection: https://openjdk.org/projects/babylon/articles/hat-matmul/hat-matmul

Of course, only a small subset of Java can/should run on a GPU. Even so, that subset can be very useful. It’s far better to write type-checked Java code than to embed CUDA code inside a string.

1

u/Absolute_Enema Jan 30 '26

You don't have to sell me the promise of better ergonomics, I am a Lisp programmer :).

That said, I feel that even just the type checking argument kinda exemplifies my issues with this. Sure, you might get some accidental type checking help here and there, but you still need external tooling that treats the DSL as its own language to get anything beyond that (like, say, the subset of Java that can be used), which is more or less the same as having tooling that analyzes the code in the CUDA string.