Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python vs. Java -- Which would you pick to do concurrent programming and why? [closed]

Also, if not python or java, then would you more generally pick a statically-typed language or a dynamic-type language?

like image 821
Setzer Avatar asked Dec 07 '09 17:12

Setzer


People also ask

Is Python good for concurrent programming?

Python is not very good for CPU-bound concurrent programming. The GIL will (in many cases) make your program run as if it was running on a single core - or even worse.

Why would you choose Python over Java?

There is more experimentation than production code. Java is a statically typed and compiled language, and Python is a dynamically typed and interpreted language. This single difference makes Java faster at runtime and easier to debug, but Python is easier to use and easier to read.

Is Java good for concurrency?

While Java isn't necessarily the best language for concurrency, there are a lot of tools, libraries, documentation and best practices out there to help. Using message passing and immutability instead of threads and shared state is considered the better approach to programming concurrent applications.

When should I use Python vs Java?

Java is popular among programmers interested in web development, big data, cloud development, and Android app development. Python is favored by those working in back-end development, app development, data science, and machine learning.


1 Answers

I would choose the JVM over python, primarily because multi-threading in Python is impeded by the Global Interpreter Lock. However, Java is unlikely to be your best when running on the JVM. Clojure or Scala (using actors) are both likely to be better suited to multi-threaded problems.

If you do choose Java you should consider making use of the java.util.concurrent libraries and avoid multi-threading primitives such as synchronized.

like image 168
johnstok Avatar answered Sep 22 '22 09:09

johnstok