- Computers & Software»
- Computer Science & Programming»
- Programming Languages
My experiences with Python and Java
Tale of Two Languages (and how I've seen them used)
I write this comparison between Python and Java because these are two popular general purpose programming languages used in all sorts of fields - particularly the ones that I have been exposed to through interviews and projects.
Note that I don't plan on making a blow by blow syntax comparison*. Rather, I'm going to run through specific examples of where Python and Java are used in some different fields of interest.
My exposure to programming in finance has been limited to research and interviews (so far). In short, they prefer to use Python (and other scripting languages) for strategy and research and Java for infrastructure and trade execution (though C is preferred over Java).
In proprietary trading companies and hedge funds, hard-core statistics is needed for research, analysis and reporting. For quick and dirty analyses, Python seems to be tool of choice. The amount of code you have to type to get an analysis done is generally far less than that in Java. However, proprietary trading companies must also execute trades quickly. Milliseconds can make the difference between huge profits and hug losses. For this work, an understanding of networking and C are recurring themes. Although some of Python's constructions like list comprehensions approach C speed, customized Python code (which would be necessary in these situations) can never do so. Java is also slower than C and C++, but is highly used nevertheless because of its large community and the ever-growing amount of development in the programming language. I have also seen it used in infrastructure such as analytical web tools for the entire company.
Note that at many finance companies, big mathematics tools like R, SAS, Stata, Matlab are used because the syntax for doing statistical analysis is even simpler. Also, they come with many pre-built packages to reduce coding as much as possible.
Chemical engineering was my major in college. In short, Java and Python were not used extensively. Custom tools were preferred. However, I did find ways to sneak in Python code to automate a lot of work quickly.
I've done so many assignments with Matlab and other proprietary analytical tools like Jacobian. They are used for the same reasons that the prop software is used at finance companies - ease of use. The user can focus on the analysis with recognizable functions and in general, not worry about destroying their computer in the process (this was a concern when C and C++ were used to perform analyses).
Recurring theme - Python for quick and dirty, Java for big and bulky. This will certainly depend on the nature of the project.
In a field where making meaning out of mountains of data is key, Python and Java are used very heavily to do the analysis and make the tools to simplify it. I've found tons of code implemented in both Python and Java (and some in Lisp, Matlab, etc. as well). From my experience, Python is easier to write and maintain for small projects. To some extent, I have used it to replace a lot of my Matlab code since I no longer have access to Matlab (free at many universities but costs $$$ elsewhere). For larger projects, other functionalities from external programs may be needed. A lot of these are in Java and it is simply easier to interface with them in Java (though Jython, the Java implementation of Python is possible). Alas, I have had to go this route as well. At least there's a large community around it.
Rapid Web Development
I'm a little uneasy about talking in this area since it's a topic that tends to spark holy wars in geek communities. That said, I will throw in my two cents - use whatever the rest of your company is using (or whatever you're most comfortable).
In the early days, rapid web development in Java was not possible (or very painful). After Ruby on Rails, there was a rise of web frameworks. In Java land, there came Grails, Tapestry and some others. From the Python world, we have Django, Pylons, TurboGears, Web2py, and many others. In general companies, that have most of their code implemented in Java will have an easier time using a Java based framework (these companies also have the heavy duty servers to manage it). Those who have PHP in their codebase, will probably find it easier to convert to Python or Ruby if needed because of their similarities in languages used for scripting.
This was a pretty quick run-down of how Python and Java are used in different fields from my personal experience. Hopefully, it has given you some insight into how Python and Java are used in fields that involve programming.
*For a syntax comparison, I recommend reviewing Python Conquers the Universe. It goes into a lot of detail about how Python is far more simpler than Java but remains powerful. Obviously, there is a Python bias in this blog.