I am building a web application for chemical industry. Its basically searching in database of chemical structures. A lot of cheminformatics calculations is needed and there are many open source solutions to do it written in Java.
I am currently wondering what programming language to use. I need to use some functions in Java and I dont want to write whole system in Java because I am not familiar with writing web apps in it.
So I have this idea to prepare some .jar files with needed functions and use them in PHP through command line. I wonder about scalability of this solution.
Is it fast to call .jar file in PHP for example 1000 times in one cycle? How long the parameter passed to .jar can be? I assume large arrays converted to string as parameters. I have doubts if this is a good idea in general and why I sould not do this?
Thank you for your ideas.
It can be done
You mention parameters. I assume you mean command line parameter. You are correct that is probably not scaleable. Instead, use stdin for input and stdout for output.
You mention calling the jar file 1000 times. I assume you mean calling the main method of the jar file. This will be very slow. Instead implement as much as you can in java, so you start the jar file few times per request. A handfull calls could be acceptable. Just not anything in a loop.
Basicly prepare all the data for an entire requuest inside java and print it to stdout which you read from php.
Of course running in a servlet container is faster if you have time to learn jsp+servlet.
No, it's not efficient. You'd be running 1000 copies of the JVM. Plus the overhead of starting/shutting down those jvms. You'd be better off using a proper java server, like Tomcat.
You're right to question this. Aside from probably being slow, it is also probably not a wise idea to mix PHP and Java. You should either use 100% PHP or 100% Java, but not a mix of both. I think both are capable of meeting your needs, so I think you should probably study the problem better.
I would personally advise Java since it handles both the back-end and the front-end fairly extensively and there is a lot of support and libraries available for it online. If you wish to stick with PHP, then I think you could do that as well, though you should be careful about structuring your code well or you risk to easily complicate your web application.
However, assuming that neither of these options is the path you wish to take: I think any limitations of parameter size would be that of the operating system first and foremost. However if you think you might be hitting these numbers, you should probably consider writing to a file and having these jars read from it.