DEV Community

Cover image for Python or Java? Which is better to learn to code?
javinpaul
javinpaul

Posted on

Should I Learn Java or Python Python or Java? Which is better to learn to code?

Disclosure: This post includes affiliate links; I may receive compensation if you purchase products or services from the different links provided in this article.

Hello guys, today, I'll try to answer one of the most pressing questions from people who wish to learn to code, Python or Java, which is better to learn programming and coding? Here, we are not talking about coding for fun but learn to code to live and get a job, so it's not just the ease of learning which is important but also job prospect, opportunities, and salaries which needs to consider.

Java and Python are two of the most popular and influential programming languages of the present time. Beginner programmer often get confused, one of the most frequently asked questions is should I learn Java or Python? Is Python is an excellent programming language to start with? Which programming language would you recommend for beginners to learn first etc?

Since I am a Java developer, my opinion is a little bit biased, I will always suggest you start with Java and then learn Python, but if you ask this question to a Python developer, you might get just the opposite answer.

I have well documented my reasons as to Why Java is the best Programming language and Why a programmer should learn Java. One of the most important reasons you would see in that blog post is an active Java community, which will help you throughout your Java career.

You can ask some beginner stuff starting from how to set PATH and classpath to advanced material about debugging Java program in Eclipse, no matter what kind of question is, there is always someone is Java community, who is ready to answer and help you.

This is one of the reasons that StackOverflow is full of Java questions. By the way, Python is not a spring chicken anymore, it has fully grown and given stiff competition to mainstream languages like Java, Ruby, JavaScript, and C++.

Python vs Java - which is better to start programming

When I first come across Python, I thought it's a scripting language, but that is an understatement. You can do object-oriented programming in Python as well. It's also used heavily in web development. Popular internet websites like Reddit are build using Python and now the sunrise technologies of machine learning and Data science make Python even more useful.

On beginners point of view, I always suggest pick a language which is easier to learn, powerful to attract you and have strong community support, now both Java and Python fits this bill, and until you do some excellent comparative analysis, you can not decide which language to learn from Java vs. Python.

Thankfully, we have an infographic, which highlights some vital difference between Python and Java, I am sure after taking a look at this Infographic, you will be able to decide which is the right programming language to start with.

If you already made up your mind to go with Java, then The Complete Java Masterclass course by Tim Buchalaka on Udemy is an excellent course to start with. It's not only the most up-to-date course and covers the latest Java features from recent releases but also the most comprehensive and well-structured course which makes learning way easy.

Python or Java? Which is Better for Beginner Programmers?

Being two different programming languages, Java and Python can be useful tools for modern developers for developing applications.

Before learning any programming language, it is a must to know the difference between them.

It could be wrong to declare that Java can be less productive compared to Python due to numerous elements.

Let's go through this infographics to learn some differences:

Infographic Via Perception System

From this Infographic, you can easily see that Java is very verbose than Python. It takes 10 lines of code to read from a file in Java, while it only takes 2 lines of code in Python. This point goes towards Python because beginner programmer definitely likes to write less code.

The second point is about the static and dynamic type of variable, In my opinion, you need a strict typing programming language and compiler to detect silly mistakes made by beginners, In Java, you can not store an integer value in a String variable.

So on this point, my vote goes to Java. Speed, which is a crucial thing on enterprise-level application development, you can see that Java is faster than Python, but do remember that you need to compile and run Java program, while Python doesn't need to be compiled.

Python shell can directly interpret python commands, which means easier for programmers. So now Python and Java are both 2 and 2.

This is an important reason to learn Python for beginners because it just makes it easy to try and learn, and if you choose to learn Python, then The Complete Python Bootcamp by Jose Portilla on Udemy is an excellent place to start with. It covers Python 3 from scratch.

Things have improved with the introduction of JShell in Java 9, but I still rank Python better in terms of quickly whipping up a script and running.

You can also see that hello world in Java takes more lines than hello world in python. The rest of the examples you can analyze by yourself, but all it comes that both Java and Python are equally capable, no one is lesser than others.

And, if you look at the image which compares the Java vs Python trend in last 5 years, you can see the rise of Python with the expsense of Java. This rise is not just in terms of search queries but also number of Python developers, opportunites, jobs and that's why it makes sense to learn Python over Java now.

But, as a Java developer, I can say from my personal experience that you will not regret learning Java and choose it as a career; of course, you can learn Python anytime, and it's suitable for writing small utilities, but Java is Java.

Recommended Books and Courses to learn Java and Python

Thanks for reading this article so far. If you like this article, then please share it with your friends and colleagues. If you have any questions or feedback, then please drop a note.

P.S. - If you are looking for some free tutorials to kick-start Python or Java journey, don't worry, there are many of them. I personally recommend Java Tutorial for Complete Beginners and Introduction to Python Programming on Udemy. These are completely free and trusted by more than 500,000 programmers. All you need is to create an Udemy account to enroll into this free programming courses.

Top comments (15)

Collapse
 
olegthelilfix profile image
Oleg Aleksandrov

Thanks for your post, but java 8+ can be more compact
For ex:
String operation:

        String test = "compare Java with Python";
        Arrays.asList(test.split(" ")).forEach(System.out::println);

About maps

        Map<String, String> map = new HashMap<String, String>() {{
            put("1", "2");
            put("2", "3");
        }};

        map.forEach((key, value) -> System.out.println("key=" + key + " value="+ value));

And other examples I think can be made shorter.

Collapse
 
javinpaul profile image
javinpaul

Indeed, Java 8 makes Java code more concise.

Collapse
 
drm317 profile image
Daniel Marlow • Edited

There are three programming styles: structured, object-oriented and functional.

I’d say pick a language for each.

Collapse
 
javinpaul profile image
javinpaul

That's actually the best suggestion for professional programmers. What is your pick for those? Mine is C, Java/Python, and Scala

Collapse
 
w3hubs profile image
w3hubs.com

I preferred python. :)

Collapse
 
javinpaul profile image
javinpaul

Good choice, congratulations :-)

Collapse
 
w3hubs profile image
w3hubs.com

ya thanx :)

Collapse
 
jouo profile image
Jashua • Edited

Nice post!

Today I began a course on JVM performance and memory management (I've been experiencing memory leaks), it's been a joy so far, I already liked Java and now even more

There are so many JVM settings to enable and / or tweak, it's amazing! (along programs to check the memory, all sorts of stuff)

Is there a thing like that in Python? serious question, I don't know

Collapse
 
javinpaul profile image
javinpaul

That's actually a good skill to master. which course are you using? would you mind to share with us? Regarding performance improvement settings in Python, no I have not heard of, maybe someone knowledgable in DEV can show us light.

Collapse
 
jouo profile image
Jashua

This one, it doesn't have many ratings but the guy is an amazing teacher

udemy.com/course/java-application-...

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt • Edited

My favorite is Kotlin, as

  • You can extend anything. (But it can be overdone.)
  • You can use any reserved words, but quoting with backticks
  • Not forced to use Class
  • async is easy.
  • generator / yield is easy.

Not sure if you have to learn Java first, though.

JavaScript with modernized syntax can be pseudoly good. (Because it actually stands on older syntaxes.) It is quite elastic to my needs too. That's why I love Node.js.

I have come to dislike Python, because of snake_case and namespace cluttering (e.g. global, reserved words, after for loop).

I believe that Golang should also be learnt, because of different syntaxes / style of coding.

Collapse
 
javinpaul profile image
javinpaul

Yes, Kotlin is good and you can't avoid JavaScript anymore. Python has its shares of problems like managing a big code base is not that easy and whatever you mentioned but the power it gets from its module is just too big to ignore.

Collapse
 
shaijut profile image
Shaiju T

😄, I used to have questions like which language is better ? After discussing with my friends and listening to people online, I realized that Its better to stop asking these questions. Instead start asking which tool is better for current Job and Trend.

Choose the right tool for the Job.

  • Based on your experience, you can use C# or Java for building enterprise and large applications.
  • Instead JSF you can think of using Anuglar orReactorVueetc. for Front End.
  • Python for Machine Learning.
  • Go for Micro Services based performant applications.

In future maybe today's Languages and Framework may be outdated, so to survive you will be forced to learn new language of that time.

Conclusion:

  • Developer Happiness, stick to the language which make your life easier, like easy to read syntax, maintainable, has Good IDE. I like C# for current work, and its up-to you to decide what you like.

  • Its always good to be Open to learn any language as required and Choose the right tool for the Job.

Hope this helps.

Collapse
 
manishmha profile image
Manish Maha

Thanks for sharing all the information with us all.
Data Science Online Training

Collapse
 
jerome profile image
Marc Jerome

I think transitioning to other programming language wouldn't be an issue if a beginner chooses java as his first programming language. Since it's verbose, transitioning to other verbose language such as C# or any languages with just enough writeability, would not be so difficult.

Also, beginners may want to explore other programming languages so I think java's verbosity can help.