Originally posted by bug77
View Post
Coroutines -> Java Loom is on the horizon and is in Java 20. Virtual threads are easier to use than Kotlin coroutines IMO.
String Templates -> JEP 430 exists and is in Java 20. Its in a pretty good state of affairs. It should release GA in Java 21
Null safety... if you aren't using Optional or some library variant of an Optional in modern code then I just don't know what to say? If you are interacting with legacy code... you need to push it down into null safe code around an Optional centric layer. You don't get any better when using Kotlin and legacy code. You still have to riddle your 'null safe logic' with ? everywhere. And the language lets you earmark variables with nullable so I am not sure what you are trying to get at. Kotlin doesn't save you from anything when you work with old libraries. Gosu kind of does, but that is another can of worms you mess with there regarding class loader compatibility that limit use cases.
While the first two examples are language Previews and you should not use them for building frameworks or hardened API's you can get a lot of mileage out of them for small projects, especially ones that will serve an ephemeral lifespan through agile development.
Originally posted by bug77
View Post
Furthermore, Java Lambda's don't run in a vacuum on AWS. If you are executing from s3 triggers or sinking from sqs or sns enough you should be making thread-safe Hot loaded contexts that get shared between invocations. You can use functional programming to lazy load your clients 1 time and are available across all instances. Put all your expensive to create objects in there and all that gets invoked is the lambda will be shared while the lambdas are hot. They are as fast as anything else. If you are trying, for instance, to create a Jackson ObjectMapper every time then you are missing some opportunities.
There is a bigger cost to NOT doing something sometimes. There is room for 'good fit' nonsense. Right tool for the right job. Your build of materials will typically let you know a path forward that is correct. It is a developers job to help itemize the costs of doing it responsibly and letting the product owner decide what they still want.
Comment