Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java or Python for math? [closed]

Tags:

I'm trying to write a pretty heavy duty math-based project, which will parse through about 100MB+ data several times a day, so, I need a fast language that's pretty easy to use. I would have gone with C, but, getting a large project done in C is very difficult, especially with the low level programming getting in your way. So, I was about python or java. Both are well equiped with OO features, so I don't mind that. Now, here are my pros for choosing python:

  • Very easy to use language
  • Has a pretty large library of useful stuff
  • Has an easy to use plotting library

Here are the cons:

  • Not exactly blazing
  • There isn't a native python neural network library that is active
  • I can't close source my code without going through quite a bit of trouble
  • Deploying python code on clients computers is hard to deal with, especially when clients are idiots.

Here are the pros for choosing Java:

  • Huge library
  • Well supported
  • Easy to deploy
  • Pretty fast, possibly even comparable to C++
  • The Encog Neural Network Library is really active and pretty awesome
  • Networking support is really good
  • Strong typing

Here are the cons for Java:

  • I can't find a good graphing library like matplotlib for python
  • No built in support for big integers, that means another dependency (I mean REALLY big integers, not just math.BigInteger size)
  • File IO is kind of awkward compared to Python
  • Not a ton of array manipulating or "make programming easy" type of features that python has.

So, I was hoping you guys can tell me what to use. I'm equally familiar with both languages. Also, suggestions for other languages is great too.

EDIT: WOW! you guys are fast! 30 mins at 10 responses!

like image 777
Dhaivat Pandya Avatar asked Jan 21 '11 13:01

Dhaivat Pandya


2 Answers

Java will usually be quicker to run (don't take this as an absolute truth), but slower to write.

Python is the opposite. Since libraries such as SciPy and NumPy already exist, which are built upon fast C code, I'd suggest going with Python if you prefer to go the "speedier" way in terms of code writing. Unless fundamental blocks for your application are missing in SciPy + NumPy, and those exist for Java.

like image 98
darioo Avatar answered Nov 01 '22 22:11

darioo


Why not get the best of both worlds by taking advantage of multiple languages on the JVM:

  • Write the performance intensive parts in Java (or use existing great Java libraries)
  • Use Jython to write the user interface / application in Python and call the Java code when needed
like image 26
mikera Avatar answered Nov 01 '22 21:11

mikera