←back to thread

234 points chhum | 2 comments | | HN request time: 0.413s | source
Show context
exabrial ◴[] No.44006194[source]
Java performance isn't the fastest, that's ok, a close 3rd place behind C/CPP ain't bad. And you're still ahead of Go, and 10x or more ahead of Python and Ruby.

Java syntax isn't perfect, but it is consistent, and predictable. And hey, if you're using an Idea or Eclipse (and not notepad, atom, etc), it's just pressing control-space all day and you're fine.

Java memory management seems weird from a Unix Philosophy POV, till you understand whats happening. Again, not perfect, but a good tradeoff.

What do you get for all of these tradeoffs? Speed, memory safety. But with that you still still have dynamic invocation capabilities (making things like interception possible) and hotswap/live redefinition (things that C/CPP cannot do).

Perfect? No, but very practical for the real world use case.

replies(16): >>44006269 #>>44006358 #>>44006411 #>>44006567 #>>44006570 #>>44006865 #>>44007100 #>>44007464 #>>44007662 #>>44007666 #>>44009121 #>>44009861 #>>44011219 #>>44011642 #>>44012473 #>>44015715 #
hintymad ◴[] No.44009121[source]
> And hey, if you're using an Idea or Eclipse (and not notepad, atom, etc),

Java's tools are really top notch. Using IntelliJ for Java feels a whole new different world from using IDEs for other languages.

Speaking of Go, does anyone know why Go community is not hot on developing containers for concurrent data structures? I see Mutex this and lock that scattering in Go code, while in Java community the #1 advice on writing concurrency code is to use Java's amazing containers. Sometimes, I do miss the java.util.concurrent and JCTools.

replies(4): >>44009525 #>>44009597 #>>44011488 #>>44014396 #
zwnow ◴[] No.44009525[source]
Just implement concurrency with actors and u save up on some locks and mutexes...

The patterns are available, its up to the community to apply proper concurrency patterns.

replies(3): >>44009714 #>>44009956 #>>44012415 #
saagarjha ◴[] No.44012415[source]
Actors are implemented using locks.
replies(1): >>44012956 #
pimeys ◴[] No.44012956[source]
Is it really so? I haven't checked all the implementations, but my take here would be to use a channel with atomics instead of a lock...
replies(1): >>44013079 #
saagarjha ◴[] No.44013079[source]
It's probably possible to do if you think about it carefully but generally enqueuing a message is going to take a lock, especially if you can send an arbitrary number of messages (which may require the queue to be reallocated).
replies(1): >>44013463 #
1. pimeys ◴[] No.44013463[source]
One very common queue implementation you can use to implement actors is the crossbeam-deque. It's work-stealing in nature, works in multi-threaded environments and has no locks. The implementation is quite simple to follow:

https://github.com/crossbeam-rs/crossbeam/blob/master/crossb...

replies(1): >>44014986 #
2. surajrmal ◴[] No.44014986[source]
Note that the mpsc queue in the rust stdlib is also a clone of crossbeam and therefore also lockless.