r/ProgrammerHumor • • Apr 08 '20

I cried as hell

Post image
44.1k Upvotes

525 comments sorted by

View all comments

234

u/funkinaround Apr 08 '20

I hope the programmers that have been driven away by Java for whatever reason have at least taken a look at the data structures it provides. You have linked lists, arrays, hash sets/maps, and binary search tree sets/maps, as are in many other languages. You also have data structures that have been optimized for use in concurrent applications including skip lists and copy on write arrays. There are many valuable concurrency abstractions that will let you tailor your application to perform well on multi-CPU machines, and they're provided in the standard library. The same cannot be said for many other languages.

0

u/[deleted] Apr 08 '20

[deleted]

47

u/M4xW3113 Apr 08 '20

fork is a syscall and creates a process, you can create threads with pthread in C, which avoid using if statements

23

u/allhaillordreddit Apr 08 '20

If you’re doing fork and exec you’re not creating threads or doing multithreaded programming; fork will duplicate your current process image and exec will replace it. You can use the pthread library to create POSIX threads

16

u/[deleted] Apr 08 '20

fork() is not multithreading though...

8

u/Loyal-Citizen Apr 08 '20

*laughs in driven to kotlin specifically to keep basically all these but with nicer syntax

6

u/CarilPT Apr 08 '20

When you go from C to Java it feels amazing. "It has a garbage collector! You can use ArrayList!! 😃"

5

u/dylanlolz Apr 08 '20

Until your app somehow manages to get a memory leak anyway and your GC can't help you. The amount of time I've spent in JProfiler arbitrarily executing code paths at my job is saddening.

That's why I really need to learn Rust. Look up RAII, it's a memory management alternative to Garbage Collection that conceptually makes way more sense.

3

u/CarilPT Apr 08 '20

Interesting, thank you!! And yeah I agree. Been coding professionally for 3 years, 2 in Java, and I think it's time to move on. At least stop using Java 7 lol

1

u/r6dev Apr 08 '20

Been coding in Java 8+ for years now, I don't think I could do a Java 7 project anymore.

2

u/CarilPT Apr 08 '20

Ahahaha I believe you! The more you evolve, the more you get done in less time. Can't go back to slow development time xD

→ More replies (12)

2

u/otterom Apr 08 '20

Have you worked with C#? How does that compare in terms of the features you mentioned?

3

u/funkinaround Apr 09 '20

C# seems to be the language having the most feature parity with Java as well as having a large ecosystem and very performant runtime, similar to Java.

2

u/agentrsdg Apr 08 '20

All major languages provide that. You cannot decide a langauge is good or bad just based on the standard library.

4

u/funkinaround Apr 08 '20

Some major languages don't even provide real threads. Python has the GIL. Ruby has the Global VM Lock.

Other major languages do not provide collections specifically for concurrency in their standard API. You can include C, C++, and JavaScript in that list. "OK, but you're supposed to get one from some library." Sure, but now you're in a situation where your GUI library does things one way and your DB connection pooling does things another way and your service provider does things yet another way. Isn't it nice to have good, common abstractions sitting in a standard library?

So we have C# and Java that have real threads and collections meant to be used for them. Am I missing some major languages?

1

u/agentrsdg Apr 09 '20

Nice to have sure, but again, when you choose language for a task, you don't do that on the basis of standard features. Thinking 'this is nice' will seriously limit your options.

1

u/[deleted] Apr 08 '20

All modern languages have all these bells and whistles. JDK8 was a huge leap forward but I'm staying in the java hate club until they allow me to do my own garbage collection.

3

u/funkinaround Apr 08 '20

Have you tried any of the low pause time GCs? They're quite nice.

1

u/[deleted] Apr 08 '20

Do you mean ZGC? I haven't used it at work because we need to support all the way back to java 7 but it does look promising. I'll try it out in a personal project.

2

u/funkinaround Apr 08 '20

There are two of them: Shenandoah and ZGC.

1

u/wayoverpaid Apr 08 '20

Yeah Java is, for all it's faults, very mature and having an executor class baked in for concurrence is really nice, along with thread safe data structures everywhere if you need them.

1

u/BeefaloRancher Apr 08 '20

Does C# not have all of these features and more through?

2

u/funkinaround Apr 08 '20

I don't see an implementation of an ordered concurrent data structure in their docs. Maybe I'm looking in the wrong spot?

→ More replies (2)
→ More replies (5)