• Alex

Learn Python or Java as your first language?

Updated: Feb 11, 2018

There are so many opinions all over the place on what is the best language to learn first. Is it Python? Or maybe Java? To understand better how they compare, I read multiple articles from on this topic and selected some opinions. We start with opinions about Python. I added the Quora articles links as well in case you want to read more. Why is Python a good choice for the first language to learn? FROM

Java is geared better towards applications, where as Python is geared better towards tasks. Most programmers will eventually need C# or Java under their belt. Python is generally a language for Sys Admins, mechanical engineers, and other adjacent career paths. As a first language, Python is arguably easier. Variables don't need a type, indentation is obligatory so you don't make block mistakes, syntax is very English-like, iteration is very easy, the standard library does a lot of things in very few lines of code, and so on. Python’s syntax is much more simple and readable than that of Java.  It also does a much better job of minimizing the amount of code needed to complete a task, which is incredibly convenient for people learning to code as they don't have enormous walls of code to deal with.

FROM Python has surpassed Java as the top language used to introduce U.S. students to programming and computer science, according to a recent survey posted by the Association for Computing Machinery (ACM). Eight of the top 10 computer science departments now use Python to teach coding, as well as 27 of the top 39 schools, indicating that it is the most popular language for teaching introductory computer science courses Python has been growing in popularity in the educational realm for at least the past few years, though this survey is the first to show it has eclipsed Java, which has been the dominant teaching language for the past decade.

FROM Go for Python if you already have a background in computer science and want to apply that knowledge on quickly building something real, that be a web application or software tool.  Python is very quick and easy to learn, with tons of modules that do any kind of job for you, is less verbose than Java with a great community.

Why is Java a good choice for the first language to learn? FROM You can write VERY SIMPLE programs in Python faster than you can write programs of the same length in Java, so in that respect, you can learn Python faster. For any serious program (longer than a few dozen lines of code), Java is much better because of various safeguards, such as static typing. Since you spend less time debugging stupid errors in Java, you can spend more time learning the art of programming and software engineering.

FROM To learn, as a first language, I think it's probably Python. I think if you compare a 'hello world' in each language, Python is obviously shorter, and it obviously makes more sense to a complete beginner. When you get into beginner programs like 100, or 200 line programs, Python is probably still easier, because you're likely using built-in types, and it's obvious what the types and methods do. When you get into intermediate size of programs, a few thousand lines, or maybe tens of thousands of lines, I think the advantage skews very strongly in favour of Java. Dynamic typing makes your first few hundred lines of coding very easy, and your next ten thousand lines a complete nightmare. Learning slows down, and mystery builds. Each object type you add, further increases the mystery (more class types to remember), whereas in Java, it makes things clearer as there is a total rigidity in what everything is. For learning, I think if you want your first week to be easy, learn Python, if you want your first 6 months to be easy, learn Java. I've used Python for longer than I've used Java, I've probably written more Python code than I've written Java code. I was using Python almost before Java was even released, but I strongly (very strongly) prefer Java. Java is just incredibly strict by comparison, and strict means simple, it means not vague, not flexible, not forgiving. Unforgiving is good, it provides structure and predictability. A forgiving language means it's vague, fragile, and prone to run time errors, which would (and should) be caught at compile time. FROM