Java vs. Python: Which Should You Learn First for Finance IT?

If you’re thinking about learning a programming language to safeguard your financial services career, or to transition into a technology job, then the language du jour is Python; a fine choice in of itself, and very handy if you want to work in fintech. I work in it myself every day. However, getting a technology job can be a numbers game thanks to tortuous interview practices; and at banks and with many asset managers, Java still reigns supreme in the open job count.

When I first started coding in Java at investment banks over a decade ago, I routinely came across horror shows of spaghetti code. Things have moved on significantly, and overall the quality of code I see day-to-day is now pretty good. Opinionated Java frameworks such as Spring mean that you can get a lot done with very little code. The latest incarnations of Java contain many of the functional aspects available in Python, and whilst it lacks popular finance packages such as Pandas and NumPy, it makes up for it in a rich landscape of native data structures and third-party libraries.

Others may disagree, but I think it would be far easier to learn Python coming from a Java background than the other way around. I did this myself, and it took me a week or two to become very productive in Python. Studying Java, you will learn important concepts around object orientation such as encapsulation, abstraction, polymorphism and inheritance. Frameworks such as Google Guice and Spring will introduce you to dependency injection and how to structure programs so they are easy to test and maintain. Python is object-oriented, but it’s such an open language that if you start with it first, you may lack awareness of how to structure large programs properly.

Python has other problems, too. At a scale where you’re sharing and working on code with many other people, Python can present problems due to duck typing and a lack of verbosity. Duck typing is where you don’t specify the type of variable (such as integer, character or Boolean); it is inferred. And a language being not very verbose means a lot can be accomplished with not much code. All of this is great in isolation, but it can make what is going on very opaque to others.

There are some concrete examples of Python’s problems in finance. For example, JPMorgan’s Athena platform has millions of lines of Python code, and novice users can find it difficult to discern what kind of data is being manipulated. The obvious solution is to look at unit tests, but often there aren’t any because the file was created before the mandatory unit test rule was enforced.

In systems as large as those used by banks, it can be difficult to figure out what the intention of basic code is simply by looking at Python. When everything is coded in Python, banks are forced to rely on developers being good citizens. In a large organization, that’s not ideal, because they’ll naturally have their fair share of checked-out coders who don’t adhere to standards.

In Java, on the other hand, navigating a large codebase can be easier, as you always know what datatypes are being referred to. Even if there are no unit tests, you still have a rough idea of what is going on at a glance.

Java is also truly multi-platform. You’ll be able to package and run your code on many different kinds of machine, and it’s the official language of Android. You may have heard that Java runs much faster than Python, which is true most of the time. Because of this, high frequency trading, order management and trading execution are almost certainly going to be implemented in a language such as C++, C# or Java, rather than Python. And whilst Python does have threads, you’ll make much more use of them in Java, and you’ll learn a lot more about how to code in a multi-threaded way.

Having both languages under your belt is really where you want to be – but take it from me, start with a language like Java first if you’re serious about becoming a top-class technologist.

Oscar Varone is the pseudonym of a former VP-level technologist in an investment bank, who now works in fintech. This article originally appeared in eFinancialCareers. 

4 Responses to “Java vs. Python: Which Should You Learn First for Finance IT?”

  1. Java 11 allows inferred types now,
    Not convinced it’s a good thing.
    Also the lamdas and streaming now take more time to interpret.

    I would add debugging and performance tuning java seems easier.

  2. james lankford

    the author is an idiot — python is bad because its not verbose ???
    LOL, what a moron
    “JPMorgan’s Athena platform … novice users can find it difficult to discern what kind of data is being manipulated. The obvious solution is to look at unit tests,”
    LOL, OMG — the OBVIOUS solution is to read the comments and documentation

    ” but often there aren’t any because the file was created before the mandatory unit test rule was enforced.”
    how the hell is that python’s problem
    you can just as easily have shitty difficult to understand java code that was written before mandatory unit tests were enforced

  3. Jing Ke

    Telling a beginner to learn a more difficult language first because it benefits them long term is wrong. Humans learn best incrementally.
    It is far better to begin learning with something simple, and as you get the foundation of development down, then expand to more complicated, and potentially better languages and paradigms.