And Go is better if you do I/O.
That's my points. Compromises.
I'm not saying "Java is bad". I'm saying, "I have no use case where I, personally, would use Java over something else."
I do know other people have use cases for it.
I just don't, because those compromises don't make sense for me.
Java does have android right now, although it has to share with ReactNative, Xamarin and flutter. Again, for different compromises.
Java also has the IDE ecosystem between Netbeans, Eclipse and all JetBrains offerings, with exception of Apple and Microsoft offerings.
You are trying to move the debate toward the quality of java, which is was never my point.
> If I do, I won't go Java, I will choose something that is built for performance. Python is good enough for 99% of my performances need. The last 1%, jumping to java is not a big difference, I'll use rust or go.
So given that, I am curious where are those GUI alternatives with the required perfomance in Go and Rust.
- you need a GUI
- you need perf beyond what Python is capable and you identified it clearly in advance
- you can't use numpy / multiprocessing / cython, pypy or they won't give you the perf you need
- you can't find a main hotpath you can optimize with a 5 lines c or rust extension and write 99.99% of your app in python. Or you don't want to bother.
If you ever find yourself in this very use case, then yes, use Java.
But I never found myself in this very precise use case.
Please.... That's literally the worst option for python on this planet. For all "just do multiprocessing" the tooling is horrible garbage. Then we get to Twisted and Gunicorn the Spring Framework of Python world.
Its only saving grace is that all other cross-platform GUI systems also suck, and if you're doing everything else in Java it might be the path of least resistance.
(Though I haven’t tried its mobile “backend”)
"Filthy Rich Clients" by the nowadays Android UI architects
"Swing Hacks: Tips and Tools for Killer GUIs" by Joshua Marinacci, well know in the UI research community
https://www.amazon.de/dp/0596009070
And then commercial libraries like
It's hard to separate the absolute performance of Java the language from Java the culture where inefficient patterns or attempts to implement dynamic behaviors in some framework code defeat the JIT (not to mention the benefits of type-checking). If you have a team which cares, it should be faster but the average business app I see does not have that team and will, if lucky, perform within the same order of magnitude as Python.
Speed doesn’t matter always, but when it does it Java feels snappy. Our programs our command line based so our framework use is limited. Also the built in data structures are nice. I still find getting Java’s set up painful, which is a huge impediment for us using it more.
(yeah I know it has type hints now)
import random
import time
from concurrent.futures import ThreadPoolExecutor, as_completed
def hello(seconds):
print(f"Starting hello in {seconds}s")
time.sleep(seconds)
print(f"End of hello in {seconds}s")
return seconds
# At the end of this blocks, it automatically join() and clean
with ThreadPoolExecutor(max_workers=2) as executor: # 2 tasks in parallel max
# this send jobs to threads via safe queues
a = executor.submit(hello, random.randint(0, 5))
b = executor.submit(hello, random.randint(0, 5))
# this collect results from queues in order of completion
# sync is automatic
for future in as_completed((a, b)):
print(future.result())
And if about network I/O only, you can get even more perfs using asyncio.Threads in Python are only inferior to Java threads when it's about using several CPU.
I do enjoy in python that it is quite easy to utilise multiple processes in a code-light fashion, but some things are more natural as threads.