7 ms·
>There is nothing, absolutely nothing, that you can do in Go that you can not do via libraries in Java Yes there is. You can run thousands of concurrent gorou
by fauigerzigerk 14y ago
>There is nothing, absolutely nothing, that you can do in Go that you can not do via libraries in Java
Yes there is.
You can run thousands of concurrent goroutines. Creating thousands of threads in Java will bring the system to its knees. java.util.concurrent doesn't solve the stack size problem.
You can have compact structured value types in Go but not in Java, meaning Java will always eat a lot more memory than Go.
- markokocic 14y agoIn Java you can use executors and thread pools to "start thousands of threads" in the same way those "thousends of concurrent goroutines" are running "in the same time" on a modern 16 core cpu.
- fauigerzigerk 14y agoThat's not true at all. Each goroutine has its own variable sized stack whereas Runnable objects in Java don't have a stack of their own. They use the thread's stack. So as long as a Runnable uses its stack (that is the run() method hasn't finished), the thread cannot be used by other Runnables. So, in Go you can have thousands active function invocations (i.e tens of thousands of stack frames on thousands of stacks) at the same time and they do not occupy thousands of threads. You can't do that in Java.
- pjmlp 14y ago> Each goroutine has its own variable sized stack whereas Runnable objects in Java don't have a stack of their own. Which JVM or native Java compiler are you talking about? This is implementation specific.
- Evbn 14y agoWhich ones give stacks to each runnable? Does Oracle? Does OpenJDK?
- pjmlp 14y agoOracle and OpenJDK are just two JVMs. I know at least the following JVMs Oracle JVM OpenJDK JVM Metro JVM IBM JVM Aonix JVM Cacao VM Squawk VM Jikes VM VMKit BlueRay VMs Excelsior JET Java native compiler GCJ native Java compiler Aonix Perc Java compiler ... (many many others) I doubt every single of the above implementations does threading the same way.
- fauigerzigerk 14y agoSo have you checked if any of these do what you claim they could do?
- pjmlp 14y agoAnd you have done it?
- fauigerzigerk 14y agoWhy would I? I said none of the implementations I know of do what you say. If you do know an implementation that does, then please tell me which one.
- pjmlp 14y agoNo you did not. You stated that is not possible in Java at all regardless of the implementation. I don't see any mention of " none of the implementations I know of" on your comment. <quote> That's not true at all. Each goroutine has its own variable sized stack whereas Runnable objects in Java don't have a stack of their own. They use the thread's stack. So as long as a Runnable uses its stack (that is the run() method hasn't finished), the thread cannot be used by other Runnables. So, in Go you can have thousands active function invocations (i.e tens of thousands of stack frames on thousands of stacks) at the same time and they do not occupy thousands of threads. You can't do that in Java. </quote>
- 14y ago
- deleted 14y ago[deleted]
- deleted 14y ago[deleted]
- fauigerzigerk 14y agoI'm talking about every single Java language implementation that I know of. And I believe (although I'm not completely sure) that the Java language specification requires it at least implicitly.
- eternalban 14y agohttps://github.com/kilim/kilim https://github.com/kilim/kilim