Most active commenters
  • pylua(8)
  • gf000(5)

←back to thread

257 points pmig | 25 comments | | HN request time: 1.612s | source | bottom
Show context
philipwhiuk ◴[] No.43097227[source]
As a Java developer...

If the entire problem domain space is written in a language it's dumb not to follow suit. Libraries that solve problems reduce your work to your own specific issues, rather than 'building an apple pie from scratch'.

Java is good right now because most problems have libraries to do what you want. Most formats have APIs.

It's not perfect in any area - the start-up time is a bit lame, you have to write 'anti-Java' to really get close to native performance. But it's quick to build in, the toolchain is solid, the dependency framework works better than all the alternatives. It's a 95% language that's been made development friendly.

(Golang somehow added versioning late and is 'Git+' at best, NPM unpublished stuff, C++ is hell, etc. Rust crates just doesn't have much but seems to have been built properly).

But if you're working in a new space (crypto, AI, cloud) then you should definitely look at what the state-of-the-art libraries are written in.

And you should think real hard before you implement your app in anything else. Because there will be a real, long term, painful penalty unless you get VERY lucky and the entire ecosystem pivots to your language.

replies(3): >>43097402 #>>43098224 #>>43099533 #
1. pylua ◴[] No.43097402[source]
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?

replies(7): >>43097852 #>>43098236 #>>43099325 #>>43099962 #>>43100846 #>>43101310 #>>43102551 #
2. cmrdporcupine ◴[] No.43097852[source]
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.

replies(2): >>43100131 #>>43100337 #
3. throwaway2037 ◴[] No.43098236[source]

    > 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.
replies(1): >>43099167 #
4. tonyhart7 ◴[] No.43099167[source]
well if the argument is cheaper, I can argue that JS/python dev would be more cheaper since there are more pool of talent
replies(1): >>43109857 #
5. rootlocus ◴[] No.43099325[source]
Have you tried AoT compilation with graalvm?
replies(1): >>43107887 #
6. znpy ◴[] No.43099962[source]
> 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.

replies(1): >>43101327 #
7. rahen ◴[] No.43100131[source]
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.

replies(1): >>43100860 #
8. tugberkk ◴[] No.43100337[source]
why the downvote on this? is it wrong?
9. gf000 ◴[] No.43100846[source]
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).

replies(1): >>43101486 #
10. gf000 ◴[] No.43100860{3}[source]
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.

replies(1): >>43101501 #
11. conwaytwitty ◴[] No.43101310[source]
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.

replies(2): >>43101493 #>>43113413 #
12. conwaytwitty ◴[] No.43101327[source]
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

13. pylua ◴[] No.43101486[source]
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.

replies(1): >>43101596 #
14. pylua ◴[] No.43101493[source]
I’ll have to look into burst cpu usage. Thanks
15. pylua ◴[] No.43101501{4}[source]
What do you define as medium size?
replies(1): >>43101587 #
16. gf000 ◴[] No.43101587{5}[source]
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)

17. gf000 ◴[] No.43101596{3}[source]
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.
replies(1): >>43101624 #
18. pylua ◴[] No.43101624{4}[source]
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.

replies(1): >>43101746 #
19. gf000 ◴[] No.43101746{5}[source]
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.

replies(1): >>43107871 #
20. marginalia_nu ◴[] No.43102551[source]
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.

21. pylua ◴[] No.43107871{6}[source]
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.
22. pylua ◴[] No.43107887[source]
No, the product has a lot of aop and I figure it would be difficult to make that work.
23. throwaway2037 ◴[] No.43109857{3}[source]
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.
replies(1): >>43109955 #
24. pylua ◴[] No.43109955{4}[source]
Is it really to the point of challenging java ? Seems like Java is still the way to go here.
25. ivan_gammel ◴[] No.43113413[source]
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.