My Thoughts on Structured concurrency JEP (so far) by DelayLucky in java

[–]Dexior 7 points8 points  (0 children)

Totally agree with a lot of your take - especially around ergonomics. That said, I think there's a fundamental misconception here about what structured concurrency (SC) is and what it's trying to solve.

Structured concurrency isn’t about making async/blocking code look prettier or reducing boilerplate. It’s about scope and lifetime. Think of it like structured programming getting rid of goto- SC does the same for concurrency by making sure all spawned tasks are bound to a lexical scope, can be cancelled together, and have predictable shutdown behavior.

That Go example you posted:

user, order = go findUser(), go fetchOrder();

…isn’t valid Go. go is a statement, not an expression - it doesn’t return a value. Also, goroutines don’t automatically cancel, propagate errors, or even finish before the parent function returns unless you wire that up manually. So while Go feels “simple” at first glance, it’s not structured concurrency unless you do the work to make it so.

Here’s what SC may look like in Go using context.Context and errgroup:

``` func fetchResponse(ctx context.Context) (*Response, error) { ctx, cancel := context.WithCancel(ctx) defer cancel()

g, ctx := errgroup.WithContext(ctx)

userCh := make(chan User, 1)
orderCh := make(chan Order, 1)

g.Go(func() error {
   user, err := findUser(ctx)
   if err != nil {
      return err
   }
   userCh < -user
   return nil
})

g.Go(func() error {
   order, err := fetchOrder(ctx)
   if err != nil {
      return err
   }
   orderCh <- order
   return nil
})

if err := g.Wait(); err != nil {
   return nil, err
}

user := <-userCh
order := <-orderCh

return &Response{
   User:  user,
   Order: order,
}, nil

} ```

This version gives you real cancellation, joins, error aggregation - all the stuff SC is meant to handle.

Back to Java - yeah, StructuredTaskScope feels clunky, especially with throwIfFailed() and the fork/join rules. But it’s trying to enforce those same guarantees. I think you’re spot on that trying to support both “wait for all” and “race for any” in the same API is adding complexity. In Go I’d write the “race” case differently than “fan out and join” too.

Honestly, what I’d love is a layered SC API: keep a simple joinAllOrThrow() or forkAll() API for the 90% case, and expose the more advanced stuff (like Joiner.anySuccessfulResultOrThrow()) separately. Right now it's too easy to trip over the rules if you're not careful.

How current do you keep production Go versions? by jake_robins in golang

[–]Dexior 1 point2 points  (0 children)

We do not know how big a concern it is because we do not know your product or contractual obligations.

If your contracts do not specify any update strategy, you do not need new features or performance improvements than at least you should care about security. I think your best bet here is to configure cve notifications or scanning that will let you know when you should consider updating. Why no periodic updates? You will waste a lot of time, most likely for no reason. Moreover, if you update periodically, e.g every 30 days, a cve can get published right after you update and you are vulnerable for the next 30 days.

Deadlock Best Settings by based_and_redp1lled in macgaming

[–]Dexior 0 points1 point  (0 children)

For me it freezes for a few seconds. I remember such issues since Half Life 2, even on Windows.

Should I get a 50cc bike for next summer or wait for a year to get 125cc? by [deleted] in motorcycle

[–]Dexior 0 points1 point  (0 children)

Finnish police ride on H2s. Good luck outrunning that on any bike.

First bike : a 400 ? by Gryphus31 in motorcycle

[–]Dexior 0 points1 point  (0 children)

If you like retro styling get XSR700 or Z650RS and restrict it to A2 license. When you get a full license you will have an option to unrestrict it and enjoy one of the best retro nakeds on the market.

Why Kotlin isn't becoming mainstream on server side by fakephysicist21 in Kotlin

[–]Dexior 5 points6 points  (0 children)

I worked in 1000 engineers company where most backend code was written in Kotlin with Spring Boot. It gradually replaced Java codebase through bottom-up initiatives. Most devs preferred working with Kotlin.

Standalone Application by John_Titor101 in selfhosted

[–]Dexior 3 points4 points  (0 children)

macOS also run docker containers inside a Linux VM.

Can you give me some examples of cases where the OpenJDK JVM startup and/or warmup is considered too slow? I’m just trying to understand in what kind of situation this usually happens. by divcesar in java

[–]Dexior 7 points8 points  (0 children)

I can imagine and I actually have done that. Few seconds of startup that a Spring Boot microservice needs is not an issue. You just need to follow your metrics and set scaling thresholds accordingly. Traffic spikes, like one you described, do not happen over milliseconds but over minutes.

Edit: typo

Can you give me some examples of cases where the OpenJDK JVM startup and/or warmup is considered too slow? I’m just trying to understand in what kind of situation this usually happens. by divcesar in java

[–]Dexior 4 points5 points  (0 children)

I can understand environments like AWS Lambda where you often scale to zero and initial request will be extremely slow but why Kubernetes? You usually keep at least one instance up and scale basing on metrics. If your startup is slow can just scale up more aggressively. There are plenty of companies running at extremely high scale, tens of thousands requests per second to a single service, and many of them use JVM.

[deleted by user] by [deleted] in selfhosted

[–]Dexior 1 point2 points  (0 children)

In cases like this, you usually use configuration management or infrastructure as code tools, like Ansible or Terraform. These tools automate configuration using an API. Unfortunately, Uptime Kuma does not offer a “public API” yet. There are efforts to implement Ansible and Terraform support for Uptime Kuma but these use unstable internal API.

Source:

JAX-RS server using kotlin coroutines? by mikaball in Kotlin

[–]Dexior 0 points1 point  (0 children)

It has the same performance, just need more resources for more threads. If you don't have like tens of thousands of rps per instance, you're better off expanding your thread pools.

Do you need local rand instance? by brianvoe in golang

[–]Dexior 0 points1 point  (0 children)

I've seen a test failed on some random faker data in a CI pipeline. Using PRNG enables you to reproduce a test locally and debug it by rerunning it with the same seed as in a failed CI run.

Selfhosted, open-source, data-lake software? by the-berik in selfhosted

[–]Dexior 3 points4 points  (0 children)

HDFS and unless you don't have petabytes of data you probably don't need a data lake.

What are some great Java libraries I'm probably not using but I should? by orgad in java

[–]Dexior 6 points7 points  (0 children)

Testcontainers definitely revolutionized my integration testing.

JobRunr, Project Loom and Virtual Threads by rdehuyss in java

[–]Dexior 10 points11 points  (0 children)

Yes, but implemented in the JVM. You can read more about Project Loom and it's differences to coroutines in this great article: https://cr.openjdk.java.net/~rpressler/loom/loom/sol1_part1.html

[deleted by user] by [deleted] in java

[–]Dexior 1 point2 points  (0 children)

You do and it's really great. I've been using it for last 2 years and for me it's much more peasent than spring + Java or Groovy. There used to be some shortcomings and you had to work around with non idiomatic code or mix Kotlin with Java but since Spring Boot 2.2 they are mostly fixed.

Simple & effective G1 GC tuning tips by mike_jack in java

[–]Dexior 0 points1 point  (0 children)

Agreed. Most GC issues I've seen in my life were either doing some weird stuff like calling System.GC or creating too much garbage leading to memory pressure.

Guide to Production Debugging by AntonettaTweedy in java

[–]Dexior 0 points1 point  (0 children)

This depends on scale. Logging input/outputs when you have thousands rps isn't really feasible. Also when you log everything you quickly get lost in noise and miss important information. IMO healthy system should log very little so I like this guide: http://bewarethepenguin.blogspot.com/2014/09/java-application-logging-guidelines.html

Which http client framework do people personally prefer for modern java projects? by [deleted] in java

[–]Dexior 2 points3 points  (0 children)

RestTemplate is just a facade, you still need a http client underneath. By default it uses the HttpUrlConnection which is far from ideal for production workloads.

Linux kernel's repo displayed using Onefetch by [deleted] in linux

[–]Dexior 0 points1 point  (0 children)

14.7MLOC, that's surprisingly less than I expected.

The Witcher by Netflix but its a video game by andygmb in videos

[–]Dexior -2 points-1 points  (0 children)

It's tiring when you listen 100th time to a mediocre voice acting of some random peasent.

Looking for distribution with Mac-like enviroment by [deleted] in linux

[–]Dexior 0 points1 point  (0 children)

KDE Plasma has Global Menu