George Flanagin

Software Development, Management, and ... other stuff ... at least on this one page.

This article first appeared in Quora. It continutes to get a couple of upvotes per week.

Between Java and Python, which one is better to learn first and why?

But first ... regardless of the language that you choose, you will do better with it if you learn the fundamentals of computer science in parallel with your language studies. It has seemed to me that programmers who work without much knowledge of the "guts" of a computer's execution never seem to be as good as those who have the safety net of a deeper understanding, and those who lack depth in CS never become excellent.

Although I bill myself as 98% biography free, for this answer a sentence or two is required. Ending in 2004, I taught in the Department of Computer Science | VCU School of Engineering at Virginia Commonwealth University. The CS program at VCU was Java-oriented, in the sense that Java was the declared teaching language. In the 1990s I lived and worked in and around Silicon Valley, primarily getting my work done in C++. In the 1980s, it was C and Fortran.

I now work (but I do not teach) four miles down the street at University of Richmond, where we are a Java and Python-3 shop. We have purchased a number of vendor authored packages, but we glue them together with Python, and some of the faculty are Python proponents.

Teaching in the EE program a decade ago, I often seemed to be de-programming the students who had started in Java. For the classes I taught, most of the students were upper division. They knew very little about the most useful construct in programming: the pointer. The idea that there were non-class objects in other languages baffled them. Internal representations of data in memory were foreign. But that's why they are getting a university degree, yes?

At University of Richmond, and I once again find myself flummoxed by the operational contrasts between Java and Python, and I believe they are connected to learning.

  1. Python requires no "set up." A full Python environment is already on every Linux machine, and on Macs. On Linux, the program yum, or the Yellowdog Updater, Modified is written in Python, so Python is here to stay. Java requires a substantial amount of setup. So if you want to get started with Python programming, just type python at the prompt. Now. That's it. To start with Java, call someone who knows it.
  2. The systems written in Java that we have purchased all suffer from the need to have particular versions of Java installed, and thick clients of these systems also have that requirement. Support of Java appears to be expensive. We do not yet have a similar number of Python systems, but no one is expecting configuration management to be an issue with them. From an educational standpoint, this sounds like a good way to become frustrated.
  3. Python has its own idiosyncrasies. In Java, every object must be a representation of some class, but in Python the "variables" are of a unique flavor. Variables do not represent objects [cf. object: something in memory that has an address] nor are they pointers, nor are they references. It is best to think of them as temporary "names" for an underlying reality, much like the Allegory of the Cave in The Republic (Plato). From a learning standpoint, this may be more difficult for those of us with 35 years of experience than it is for those first taking up programming.
  4. A number of companies are stuck with a great deal of legacy code written in Python 2. Consequently, Python suffers from a misconception about how strict or loose the typing system may be, and how strictly it may be enforced. Keep in mind that because Python mainly works with "names" of objects, we are really not discussing the same thing when we discuss types of Python's objects that we are discussing in other languages. Python does offer some rather seamless type conversions that can make it seem that the concept of types is less strict than it is in fact. Learning Python 3 first makes sense, but most of the employment is still in Python 2.
  5. Compared with Java, Python is terse. Personally, the growing amount of arthritis in my hands welcomes this feature. In truth, my C++ code was frequently criticized for its overuse of operator overloading and the ternary operator. This may not make it a good learning experience, because for many people learning comes more easily when the material is spelt out.
  6. If you plan to make a generalized career of programming, choosing a language based on employment prospects is pointless. In the past three and a half decades of continuous employment, I have made money from and forgotten the following languages: 6502 assembly, 8086 assembly, Fortran 66, Pascal, ... You get my drift. Now I am all Python all the time, except when I am asked to do Java.

But finally ... go back and read the "but first" section.