Let's compare and contrast these programming languages in terms of features, best use cases for each, and perhaps which is "better" than the other depending on context.
For further actions, you may consider blocking this person and/or reporting abuse
Latest comments (91)
Python excels at general flexibility and scripting use cases. Java does well at GUIs and GUI prototyping. Both are good at server-side uses. Both are weak at packaging but for different reasons. I use both languages, and I'd recommend that you do too!
Can you do stuff with SIM cards in JavaScirpt? Highly doubt it. And such examples might trigger "niche" comment which basically is saying let's ignore elephant in the room and focus on mouse - which is web app development and that includes microservices and such.
Go check how big is Spring alone. It's not a framework it's quite a few frameworks which can make a platform. Check Apache Java stuff, like Apache Camel which is similar to Spring Integrations - still Java and still one of the go-to solutions for integrations none of which I've seen in JS and integrations are even out of "businesses niche" now. Almost all of us do it even for mid sized projects. Try to look at Red Hat stuff made for Java alone. Go browse through maven repository. Not even C# ecosystem (or .NET to be more correct) can compare to it in terms of size/quantity. And this is why people are not willing to leave JVM. It has so much things done you rather cry how hard they are to work with than to write it yourself in another platform.
It's plain simple, number of libraries, frameworks and such, regardless of their use case, are bigger for JVM mainly written in Java because it was the language before Scala, Groovy, Clojure, and such, and Kotlin lately.
Basically that "niche" your talking about is waaaaay bigger than your "non niche" which makes no sense for me to call it that word then.
You might call it new COBOL which indicates it will be forgotten by many at some point but live like a plague and poison anyone who touches legacy system that must work, but it doesn't change the fact that we still need something to catch up with it's size to be able to say "Java is dead" and make sense.
Better to ask forgiveness than permission ;)
Java is niche? I disagree strongly. It might be (falsely so) considered legacy by some, but it is by no means niche.
Java is now, with microservices and containers, facing a huge demand and second wind once again.
I usually don't defend any language, because it's mostly flavour and opinions, but Java is definitely a language we can call full-stack.
Javascript may be much larger in it's userbase, but even so it's ecosystem is smaller.
With Java you get full fledged and battletested CI/CD (Jenkins), package and artifact Management (Nexus, artifactory), security scanning (NexusIQ, Sonar), observability (built into JVM), deployment Management (AppServers of different flavours) and much much more.
Everything managed by commonly accepted and well-defined Standards.
Thats not something you can get with Javascript as of now.
Libraries, of which Java has more than enough for every possible use-case, aren't everything I'm afraid.
I'm not denying Javascript it's deserved glory, far from it. The improvements it made over the last 10 years are astonishing!
But the tooling changes so rapidly and often, getting something as proven and tested as the Java World Counterparts will take a lot more time.
I would also like to add Quarkus. I am not very experienced but It looks really awesome to me. with graalVM and quarkus, we can now make native java executable and size of these executable are very small compared to JAR. It's performance will also be better since it is machine code instead of byte code. The startup time is also very fast, which is important for microservices in some cases.
Best of all, we can use same API's like JPA, CDI etc. so an experienced java developer can get easily started with quarkus.
Do check it out - quarkus.io/
Absolutely true.
In one of my clients projects we are using Quarkus and migrate quite a few webservices to it currently.
The performance and minimal overhead of the resulting native binaries is amazing.
It takes quite a bit of modification to the typical CI-Chain, but if you get it to run smoothly, the results are astonishing.
If you want, I could write up a little article about it here
yeah, I would love it.
It will be very helpful as there is relatively less material available on quarkus.
Consider it in the works :)
It is done :)
I use both languages. Let's compare the two languages:
Cross platform support:
jarfile. It is also possible to generate a binary using GraalVM and other ahead of time compilers.Concurrency and Parallelism
java.util.concurrentpackage is a great for different types of abstractions like threadpools, atomic primitives, concurrent hashmaps. Futures and CompleteableFutures provide library support for async functions (no syntactic sugar).Type safety
Python's built-ins are very expressive (list, set, dict, tuples) and most are sufficient or most simple programs. This allows you to quickly prototype your projects.
Performance
Expressiveness
Ecosystem
Both Java and Python have extensive ecosystems. You will generally find libraries doing what you need in either of these languages.
The JVM ecosystem also has other languages which avoid the short-comings of Java e.g Scala, Kotlin, Clojure. These languages are much less verbose and can also leverage the extensive Java libraries.
Summary
At the end of the day, choosing Java or Python boils down to your preferences.
Here are a few niches where one can be better than the other (just my opinion):
I really like the accuracy and neutrality of your comment. However, I would like to add two more aspects to it.
Learning curve
Java: requires more overhead to get started, has more concepts to grasp (proper OO, == vs equals, hashcodes, ...) and lower "expressivity"
Python: trivial to pick up, very intuitive, easier to learn and get something done quickly
Culture
Java: many libs tends to over-engineer stuff, perhaps because their tooling is so good. But this leads to a large slow paced ecosystem. The JDK itself has also a poor "stewardship" (you still need a signed Oracle Agreement to even suggest a bugfix to the *Open*JDK)
Python: embraces simplicity and intuitiveness as its core philosophy. Fast paced ecosystem. Contributions and evolution of Python itself is also very open and community driven.
My own opinion: I find python very pleasant to work with. It's easy, it's intuitive, it has lots of "batteries included" and my usual choice for small projects. However, for bigger projects, I still tend to Java. The typing system, the tooling and good multithreading just beats it at some point when the project grows.
Additional info: there's a version of Python (stuck at Python 2 unfortunately) which runs on the JVM: jython.org/
Yes, it is unfortunate that JPython never took off as much as JRuby did.
New java versions can create custom small jre images within applications so the need for a user to have a jre installed is no longer needed. Also jpackager can create installers. Overall java experience to deliver a full application as a whole has gotten a lot better.
And one comment: yes, Java is verbose. But Java verbosity is not a bug, but feature. It allows Java code to explicitly provide context. This context significantly reduces mental overhead and navigation back and forth between usage and definition.
One clarification: usually Java performs very close to C (no 3x slowdown). In some cases (heavy allocation/deallocation) it may outperform C due to much lower overhead for such operations in Java runtime.
Thank you, Raunak!
I know that the question was Java vs. Python.
But I think that for web development, at least from my end, JavaScript is the top.
I don't know many people who still develop frontend with Java and Python.
Another point regarding Expressiveness, there are many languages that are built on top of the JVM and with a goal to reduce verboseness from the code.
What do you see from your end?
which JVM language do you use? ( if any :) )
In web development, I feel that familiarity with a framework (its strong points and pitfalls) often tops any language feature. I use Flask in Python for quick prototyping and Dropwizard in Java for production ready applications. I have heard good things about Express in Node.
Re JVM languages I am getting familiar with Kotlin. It has many good features like data classes, Sum types, pattern matching and coroutines.
In nearly any development, familiarity is king! If someone understands general principles of good software design, they can make good software in any language or framework they know well, whether that be Java, Python, C++, Haskell, or COBOL.
Minor typo: that's Clojure, not Closure.
Thanks!
When Python and Java married then Kotlin was born which is better than it's parents!
In the attempt to be"better Java than Java" Kotlin made a lot of stupid mistakes. Attempt to achieve brevity by removing semicolons is one of the my favorites: as a consequence of this decision it's possible to break "DSL-like" code just by wrapping line.
Let it be noted that Java is one of the first programming languages that I learned and specifically it's the first language that I used to make actual GUIs and it made me very happy at the time. Yet...
Java is an utter lack of flexibility, boring patterns and incredibly unbearable editor (Oracle rot in hell). People will ask "YES BUT HAVE YOU SEEN THE LATEST FEATURES THE LANGUAGE HAS CHANGED" to which I will reply: I don't care this language has so much legacy of abuse and stupid libs and over-engineering that it's just crap. The language is made to make you do stupid shit like silencing exceptions all the time or typecasting pointers because there is no other way to communicate your data (Android Intents I'm looking at you).
Python has all the tools in the box. Strong typing, duck typing, objects, functions, very extensive standard library, JIT in general, JIT for math stuff, C extensions, ..., everything. It just doesn't get in your way to do whatever you need to be done using the paradigms that you want to use. And as a bonus it has some very nice constructs like iterators, list comprehensions or context managers that make your life really easier and that don't really exist in other mainstream languages.
Your points are valid, however let my suggest you that Java support for VSCode is very good; and if your problem is just with JDeveloper, there are many others to choose from: Eclipse and Idea just to cover the greater part of the market. Also, Android can't completely be called "Java" because technically it isn't, but your point is valid. You seem to have seen lots of what is considered bad Java code.
Sorry I meant Oracle as editor of the Java itself.
And I must admit that I never saw any good-looking Java code. Though just switching to Kotlin for Android and using the exact same APIs already feels much better.
I assume you meant JDeveloper with unbearable editor? Urgh, the thought already kills me a little bit inside...
And Oracle ADF. God save me
Java has such an enormous eco-system built around itself, it's hard to even compare it to any other language. It probably can do almost anything, setting aside the age-old topic of "if we can do it, should we?".
Pythons ecosystem on the other hand is rather small in comparison, but it got a nice niche in AI/Big Data it dominates handily.
To be honest, it's not the language java itself, that I love. It's what Maven and Gradle make out of it that really eases the process of developing with java. Once you get used to your build-tool of choice, it's just copy-pasting dependencies and bam, you get everything you may need, including the appropriate build plugins for your workload.
Fire up a simple build command and you get a nice deliverable artifact. How amazing is that?
While Java is heavily restricted by it's conventions, you get a lot out of it for free. Getting back to maven, for example. Add your pom.xml with the typical boilerplate stuff and you essentially get the whole build-chain for free.
Python doesn't have as many conventions, but that freedom costs you the effort of doing most things yourself.
Edit: I'll refrain from editing out my wrong statements, but absolutely recommend reading the answers to my comment that correct them!
I hear about this purported "niche" a lot, but in nearly a decade of Python coding, I've never observed it. Python has a fairly broad ecosystem when you factor in libraries (installable via pip or poetry in one line): it handles not only AI and data, but is excellent at GUI, networking, system interoperability, and just about anything you can throw at it. The only area Python really doesn't excel at is true multiprocessing, thanks to the Global Interpreter Lock (GIL), but there's work being done to resolve that too.
Uhm, this is most certainly not true. Python has a greater emphasis on convention and The One Obvious Way (as we put it) than most other languages, Java included. We have no fear of boilerplate — cargo cult programming, as Guido calls it — but we do avoid mindless boilerplate when we can (except, perhaps, in
setup.py). Testing, packaging, deployment, all of these work well once you know where a couple of pieces fit, to the same degree as Java and Maven.Interesting, I never really observed Python like that, though judging by your comments, it's absolutely certain you are far more knowledgeable with Python than I am.
With eco-system I meant more the tooling around the languages, like CI/CD, Security Scanning, Lifecycle-Management and the likes.
I would assume a big portion of that is probably not even necessary for Python. What would your take be on that?
So thank you for your input and correcting my wrong statements.
It seems I have to do more Research next time
CI/CD: There are a number of robust testing frameworks, including PyTest, Nose, and the newer Ward. Python also integrates beautifully into most CI/CD frameworks, especially given the relative ease of deploying a package. (On that note, many Python projects even automate publishing their package to the Python Package Index using GitHub Actions or the like.)
Security Scanning: Bandit is one prominent example, and I know there are others.
I don't know about Lifecycle-Management, as I haven't used it, but a casual glance through the Python Package Index, or PyPI, it looks like there are plenty of options.
It's a common myth that Python isn't suitable for large projects. In fact, there are a number of very large applications and libraries built entirely in Python. It has its flaws, but Python is often excellent for software architecture and deployment because it "just works" in most situations, and aims to be intuitive while staying out of your way.
Thank you for your take, you never stop learning!
I guess I'll spend this weekend on Python and taking a look at the tools you mentioned.
The last time I had any python on my screen was when I wrote custom ansible filters and a few shallow dips into Django, which confused the hell out of me.
It's about time for a refresher :)
You may appreciate this, then:
Introducing "Dead Simple Python"
Jason C. McDonald ・ Jan 13 '19 ・ 3 min read
It turned out that many java limitations are very useful in long run. For example, quite strict linking between class and it's file name and location allows to keep at least some level of order in project codebase. Once this restriction is removed (Kotlin) maintaining order became a sensible effort, since devs tend to make shortcuts.
I absolutely agree.
Though I am more focused on the conventions part that comes with Java, since that is probably the first thing a Newcomer encounters.
Most frameworks, especially in the EE Version are convention over configuration. Conventions are just that, they can be ignored.
Which you absolutely shouldn't, but hey, you could even use pointers and allocate memory yourself if you want, so theres that.
The conventions are, mostly, of intelligent design and as a bonus it saves you a lot of time you would otherwise spend on cumbersome configuration, by having sensible defaults.
CDI/JPA (especially compared to their initial/earlier versions) would be a great example of convention over configuration and how much is done in the background for you.
Chrome vs Firefox would be nice in future :)
Back in my days (upper '90s), we had stints like these; they were borderline flamebaits, and led to (by far) more heated debates. A couple of those were "Perl vs Python" (the way it ended is... interesting, given that at the time I was in the Perl camp) and "Vim vs Emacs".
I want all schools teaching Java to complete beginners to stop and change to Python. The amount of boilerplate to start up a Java project hinders understanding of the essence of computing.
Below is hearsay.
Reserve Python for utility scripts and data exploration. For production, pick Julia if you are doing data analysis and AI, and Java if you are writing a service. The extra speed can keep your monolith fast enough longer so your scale wouldn't force you to split it up.
Yes Julia for data analysis an AI for speed (apparently, still not found the time to play with it properly yet), but with the tradeoff being that Julia is still far from an 'accepted' language.
A significant proportion of the data-science field that I interact with I would doubt have heard of it. FWIW when asked about why Jupyter notebooks are called Jupyter, I would give it 50:50 that a user would be able to state it stands for Julia-Python-R notebooks. Looking at AWS as a major example, their docs for their data science services talk about python first, R sometimes, and Julia extremely rarely.
That said, I am not embedded in the Julia community at all, so there is significant bias in my understanding. Is Julia something you have put into prod? What were your experiences, would you mind descirbing a high level over view of the tasks and the stack? I'm always keen to learn.
Sorry I have to disappoint you, but as I wrote, it was hearsay -- I am not involved in prod system with Julia. TIL that Jupyter is Julia-Python-R! I've read a few cases of unintentionally running loops in Python instead of numpy, which is slow. I hope you have better luck exploring Julia further elsewhere!