tags:

views:

260

answers:

3

i wonder if the multi threading in python/ruby is equivalent to the one in java?

by that i mean, is it as efficient?

cause if you want to create a chat application that use comet technology i know that you have to use multi threading.

does this mean that i can use python or ruby for that or is it better with java?

thanks

A: 

Both Ruby and Python use a global interpreter lock. The issue is discussed in detail here: http://stackoverflow.com/questions/56087/does-ruby-have-real-multithreading

philosodad
This is not true. Neither the Ruby Language Specification, nor the Python Language Specification say anything about a Global Interpreter Lock. And, in fact, only two Ruby Implementations and only one Python Implementation have a GIL.
Jörg W Mittag
+4  A: 

This is not a question about Ruby, Python or Java, but more about a specific implementation of Ruby, Python or Java. There are Java implementations with extremely efficient threading implementations and there are Java implementations with extremely bad threading implementations. And the same is true for Ruby and Python, and really basically any language at all.

Even languages like Erlang, where an inefficient threading implementation doesn't even make sense, sometimes have bad threading implementations.

For example, if you use JRuby or Jython, then your Ruby and Python threads are Java threads. So, they are not only as efficient as Java threads, they are exactly the same as Java threads.

Jörg W Mittag
A: 

philosodad is not wrong to point out the constraint that the GIL presents. I won't speak for Ruby, but I am sure that it's safe to assume that when you refer to Python that you are in fact referring to the canonical cPython implementation.

In the case of cPython, the GIL matters most if you want to parallelize computationally intensive operations implemented in Python (as in not in C extensions where the GIL can be released).

However, when you are writing a non-intensive I/O-bound application such as a chat program, the efficiency of the threading implementation really just doesn't matter all that much.

Jeremy Brown