News for hackers. Stuff that matters.
Re:One Year After Switching from Java to Go: Our Experiences by pylua on Tuesday February 18, 2025 @08:18PM (#43097402)
I’m also a long time java spring developer. I started writing a game recently and was really surprised about how bad the performance can be when you run it in a tight game loop.

The startup time is also a real problem, as you really want to be able to scale up pods quickly.

That said, it’s good enough right now. You can make it work at scale, and it’s worth the cost trade off of trying to do it more efficiently in a different language.

I would be curious to see how a rust microservice would compare in my companies infrastructure. How much cloud saving could we squeeze?

Re:One Year After Switching from Java to Go: Our Experiences by throwaway2037 on Tuesday February 18, 2025 @10:27PM (#43098236)

    > I would be curious to see how a rust microservice would compare in my companies infrastructure. How much cloud saving could we squeeze?
So, replace cheap Java developers for expensive Rust devs to squeeze out some savings? It makes no sense to me.
Re:One Year After Switching from Java to Go: Our Experiences by tonyhart7 on Wednesday February 19, 2025 @01:23AM (#43099167)
well if the argument is cheaper, I can argue that JS/python dev would be more cheaper since there are more pool of talent
Re:One Year After Switching from Java to Go: Our Experiences by throwaway2037 on Wednesday February 19, 2025 @08:00PM (#43109857)
Double agree. If Java was the right choice 10-15 years ago for cheap enterprise apps, then certainly NodeJS is the way to go today. There are heaps of cheap developers and the ecosystem is ginormous.
Re:One Year After Switching from Java to Go: Our Experiences by pylua on Wednesday February 19, 2025 @08:16PM (#43109955)
Is it really to the point of challenging java ? Seems like Java is still the way to go here.
Re:One Year After Switching from Java to Go: Our Experiences by cmrdporcupine on Tuesday February 18, 2025 @09:25PM (#43097852)
Most "microservice" backend type stuff is I/O bound, not CPU bound. You're likely not going to win much.

Maybe get away with lower memory instances though.

Re:One Year After Switching from Java to Go: Our Experiences by rahen on Wednesday February 19, 2025 @04:05AM (#43100131)
Cold latency is an issue with microservices. If you need to use Java, you'll likely end up using frameworks like Spring or Quarkus, which somewhat diminish the advantages of using the JVM and Java as a language.

At that point, you might as well start with Go from the beginning.

Re:One Year After Switching from Java to Go: Our Experiences by gf000 on Wednesday February 19, 2025 @06:10AM (#43100860)
Is it really an actual issue? How often do you restart instances or scale up horizontally?

A cheap 10 years old desktop PC can easily handle all the traffic a medium-sized website generates at all times.

Re:One Year After Switching from Java to Go: Our Experiences by pylua on Wednesday February 19, 2025 @07:48AM (#43101501)
What do you define as medium size?
Re:One Year After Switching from Java to Go: Our Experiences by gf000 on Wednesday February 19, 2025 @07:55AM (#43101587)
Stackoverflow famously ran on a single, although quite beefy server PC for a long time (not any longer, but not for performance reasons AFAIK).

I think it's a good data point to have to scale your workload to stackoverflow's, and reconsider the hardware costs.

(Obviously horizontal scaling has its place, but if it's that variably scalable, maybe there are better solutions, e.g. a single bigger instance -- often times even for cheaper)

Re:One Year After Switching from Java to Go: Our Experiences by tugberkk on Wednesday February 19, 2025 @04:37AM (#43100337)
why the downvote on this? is it wrong?
Re:One Year After Switching from Java to Go: Our Experiences by rootlocus on Wednesday February 19, 2025 @01:50AM (#43099325)
Have you tried AoT compilation with graalvm?
Re:One Year After Switching from Java to Go: Our Experiences by pylua on Wednesday February 19, 2025 @04:23PM (#43107887)
No, the product has a lot of aop and I figure it would be difficult to make that work.
Re:One Year After Switching from Java to Go: Our Experiences by znpy on Wednesday February 19, 2025 @03:37AM (#43099962)
> The startup time is also a real problem, as you really want to be able to scale up pods quickly.

I was learning a bit of spring last week and a spring boot web application, generated via the web interface boots in like 800msec:

    ...
    Initializing Spring embedded WebApplicationContext
    Root WebApplicationContext: initialization completed in 339 ms
    Tomcat started on port 8080 (http) with context path '/'
    Started DemoCourseApplication in 0.746 seconds (process running for 1.012)
    ...
Reusing my experience from other technologies... I'd say the issue might be in whatever you're doing in your initialization and/or how much stuff you're loading.

Looks like the core spring is decently fast, to me.

Re:One Year After Switching from Java to Go: Our Experiences by conwaytwitty on Wednesday February 19, 2025 @07:27AM (#43101327)
depending on the size of the app, this can go from a few seconds locally, to 60 seconds when running on 1cpu nodes

there's just so much being done during startup it requires some burst cpu

Re:One Year After Switching from Java to Go: Our Experiences by gf000 on Wednesday February 19, 2025 @06:08AM (#43100846)
Could you expand on "how bad the performance can be" part?

If you are doing graphics, it is entirely more likely that you do something dumb there - there are many pitfalls.

Also, unless you are doing something very CPU-heavy, there won't be any noticeable difference as web servers are doing IO predominantly. Maybe slightly less RAM usage (but you could also just decrease the heapsize to tradeoff a bit of CPU-time for memory, if it were to make sense).

Re:One Year After Switching from Java to Go: Our Experiences by pylua on Wednesday February 19, 2025 @07:46AM (#43101486)
In my game loop I was using optional. When I profiled it the use of optional was one of the slowest points that could be optimized using null checks and ifs.

There were a lot of other slow areas as well, not where you would expect it.

Re:One Year After Switching from Java to Go: Our Experiences by gf000 on Wednesday February 19, 2025 @07:57AM (#43101596)
Sure, Optional is not the most optimal thing to use/do, though depending on how many entities you were operating with, that itself may still be negligible.
Re:One Year After Switching from Java to Go: Our Experiences by pylua on Wednesday February 19, 2025 @08:00AM (#43101624)
That’s the pain point - well written java code may not be the most performant depending on the situation.

It wasn’t just optional but other areas as well.

Re:One Year After Switching from Java to Go: Our Experiences by gf000 on Wednesday February 19, 2025 @08:11AM (#43101746)
That's not my experience, though game development is certainly a niche and Java may not be the top choice for that.

You might sometimes have to reach for SoA-like structures and reference them via indices, at least for the core ECS, but for the rest you can easily use bog-standard Java -- not everything has to be "ultra-fast, specially written java", just certain hot loops.

Re:One Year After Switching from Java to Go: Our Experiences by pylua on Wednesday February 19, 2025 @04:22PM (#43107871)
Right. I didn’t started digging into it until I realized the application was clearly sluggish in certain scenarios. As I am doing this for fun I am going to see what kind of speed up I get in rust for this.
Re:One Year After Switching from Java to Go: Our Experiences by conwaytwitty on Wednesday February 19, 2025 @07:26AM (#43101310)
Spring Boot startup time is indeed a problem, especially when scaling horizontally on low cpu nodes.

If your environment allows for burst cpu usage until ready to accept traffic, you can start up really fast as spring does so much reflection magic during startup that can't be done during compilation "trivially". You can include hints for runtime configuration from a build, but it doesn't do much to help in really low cpu envs.

Then you can of course just do native images, but you lose some of the spring "magic", and might be annoying to refactor towards.

Re:One Year After Switching from Java to Go: Our Experiences by pylua on Wednesday February 19, 2025 @07:47AM (#43101493)
I’ll have to look into burst cpu usage. Thanks
Re:One Year After Switching from Java to Go: Our Experiences by ivan_gammel on Thursday February 20, 2025 @06:16AM (#43113413)
This actually makes me wonder if it is possible to preserve post-startup state and then restore it as a way to mitigate long computational stage during startup. I bet it is, maybe we could just serialize the application context and restore it.
Re:One Year After Switching from Java to Go: Our Experiences by marginalia_nu on Wednesday February 19, 2025 @09:36AM (#43102551)
Writing high performance Java is definitely a bit of a dark science, a lot of the performance isn't just the code loop you're looking at, but memory allocations matter quite a lot as well. Complex hierarchies of large long lived objects can absolutely tank your performance.

There can also be a lot of performance to be gained by going off heap. I'd be probably be looking at an ECS design around MemorySegments, rather than modelling the game state with Java objects. Though, to be fair, this is how you'd write a game engine in C++ as well.