I am having a mobile app created for ios. The developers built the app in php. The app requires an algorithm so I found another programmer to develop it. The algorithm programmer built the algorithm in python. The developers refuse to finish the app because they say it won't work with python, while the programmer insist it will. The programmer says put the algorithm in its on server and connect then over http. Will this work and I'd so how risky is it to future problems?
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
Yes it will work, and how risky it is depends on how good your implementation is. This is perfectly acceptable if done correctly. I have successfully integrated PHP and C, when PHP was simply too slow to do certain niche tasks in real time (IIRC, PHP is 7 times slower than its C counterpart).
The best implementation is to ignore the fact they are PHP/Python specifically, and just treat them as two separate languages.
Now, you need to pick some 'standard' way of interacting. HTTP is probably the easiest: everyone has a web server setup already so it's just a matter of putting the script online.
From here, you need to get away from the fact they are PHP/Python still and design your API without knowing that. For example, imagine you had a calculator:
Then your API would be
Since your API would be
Python side - you just need to make sure HTTP requests fail gracefully. If you can't connect to your script, perhaps try again, and if that fails, give up with a nice error message asking them to try again later. Don't just display them a Python stack trace.
You should also document your API as well as possible - this will save you a lot of time down the line. Say what each of the inputs should be, what ranges they should fall in, and give some good examples of how to use it.
API side - you should also try to fail quickly if something is wrong. If a variable is missing, incomplete, or invalid, print a message and exit as the first thing you do. Do not just run with the values, and then let them get back a PHP error message (remember, they should not know or care what language your API is implemented in), but should get a nice friendly