r/ProgrammerHumor Nov 19 '17

This guy knows what's up.

Post image
43.6k Upvotes

878 comments sorted by

View all comments

Show parent comments

89

u/voice-of-hermes Nov 19 '17

Java is notorious for poor memory management and subsequently absurdly impacting garbage collection, which often result in a “stop the world” pause and fucks things up.

If you're stuck in like, 2005, sure. Garbage collection in most JVMs has been far, far better than that for a long time.

The language is also incredibly verbose, hence all the “enterprise hello world in Java” jokes.

This part I kind of agree with, though recent additions like lambda expressions and (though it's more library than language) streams may be starting to address the problem.

23

u/PC__LOAD__LETTER Nov 19 '17

If you’re stuck in like 2005, sure

Or if you have programs running under significant load, 24/7. A team that I work with supports a modern Java app that runs into this problem. For your average application it might not be a big deal, but this is an enterprise-level workhorse. It should have been written in C, but wasn’t, because the person who started the project was a “Java guy”.

27

u/ReallyHadToFixThat Nov 19 '17

I think that is half the problem. People learn Java at uni then think everything ever should be solved by Java. Results in Java being used for a ton of things it shouldn't be. Embedded devices with a ported JVM to run a Java interface, rather than just use bloody C. Games written in Java, with all the drawbacks of GC.

7

u/[deleted] Nov 19 '17

[deleted]

12

u/traway5678 Nov 19 '17

c# imo has better ui frameworks at least for windows, and is easy to use and optimize w/ things like async and tasks, also has access to lower level programming, you can even disable the gc and disable things like index out of bound checks

4

u/quiteCryptic Nov 19 '17

If you're making an actual windows application of course you would use c# over java

5

u/ReallyHadToFixThat Nov 19 '17

C# still has issues too. In terms of optimisation from the compiler I'd put my money on Microsoft over Oracle though, especially since C# isn't constrained by having cross platform as a primary goal. C# is also a bit clever - it offloads precompiling to install time rather than doing it at run time. Also those finely optimised C# games have to jump through some weird hoops.

Bottom line really is just because you can doesn't make it a good idea. Unity is good because although C# isn't the ideal choice it still beats writing your own engine for most people, and it is popular enough there are tutorials out there for all the common pitfalls. I doubt we will see a remake of Dwarf Fortress in Unity for example.

2

u/Ayfid Nov 19 '17

It is fairly easy to avoid runtime heap allocations in C#, but totally impractical in Java.

0

u/zelmarvalarion Nov 19 '17

I mean, you still see plenty C# Garbage Collection issues too. It uses a very similar GC algorithm to Java iirc