Which language would be the best for middle tier?

Middle tier language for interfacing C/C++ with db and web app

  • I have a web application requiring a middle-tier language to communicate between an oracle database and math routines on a Linux server and a flex-based application on a client. I'm not a software expert, and need recommendations for which language to use for the middle-tier. The math routines are currently in Matlab but will be ported to C (or C++) as shared libraries. Thus, by default there's some C or C++ communication necessary. These routines rely on FFTW (www.fftw.org), which is called directly from C or C++ (thus, I don't see re-writing these routines in another language). The middle tier must manage traffic between the client, the math routines, and the Oracle database. The client will trigger the math routines aynchronously, and the results saved in the db and transferred back to the client, etc. The middle-tier will also need to authenticate user accounts/passwords, and send out various administrative emails. Originally I thought PhP the obvious choice, but interfacing asychronously multiple clients with the C or C++ routines doesn't seem straightforward. Then I thought, why not just keep the whole middle tier in C or C++, but I'm not sure if this is done in the industry (C or C++ doesn't seem as web-friendly as other languages). There's always Jave + JNI, but maybe that introduces other complications (not sure). Any feedback appreciated.

  • Answer:

    in your request, I read authenticate user accounts/passwords, and send out various administrative emails So it seems to me that you that what you need is close to a full web app able to call C++ and work asynchronously. Nearly all web frameworks are able to do that. I suggest two possibilities : Ruby on Rails with a native interface to C++ and delayed_job Wt C++ web framework with various libs for delayed jobs and sending emails Now it's up to you to assess if you only need a very small web app and are able to code it "from scratch" (CGI or mongoose) or if you web app will grow and then you need to learn a new language/framework.

gkdsp at Programmers Visit the source

Was this solution helpful to you?

Other answers

I have ran into a similar situation when I wanted to make a web app for exposing large, data intensive computations which would generate neural networks and run sample data through them to see how various algorithms perform. Based on my experience, I think you should break up your app into the following parts: Frontend / Web App Middle Tier / Web Services Backend / Math routines Frontend / Webapp would consist of the flex app or any other app written in Ruby / Python / Perl / PHP or whatever is your favorite web scripting language. This frontend tier would communicate with your middle tier purely through Web Services - REST / SOAP - take your pick. The Middle Tier would consist of Web Services written in Java using something like Jersey (or whatever Java Web Services framework you'd like - take your pick). The data access & authentication can be done easily using Java's plethora of data access frameworks. This middle tier can talk to the 'compute' Backend using: JNI RPC / thrift / avro or whatever. The backend could be written in pure C and then wrapped in JNI or it would expose it's functionality using an RPC mechanism - xmlrpc, thrift, avro, protocol buffers etc. If you decide to take the JNI route then you can implement Queuing, Backgrounding of task extremely easily using Java threads / ExecutorService etc. Also, you would not have to talk to Oracle natively through C/C++ because you can always use Java for data access while the C/C++ library only processes it. But JNI is prone to issues since it's talking to C/C++ code which when not written correctly can lead to coredumps or memory leaks and make your application unstable. If you decide to take the RPC route then you possibly CAN cut out the Java Middle Tier in which case your entire MT & BE would be written in C/C++. If that's the case I would expect that you'd use probably expose your webservices by writing them as Apache DSOs. AND you'll have to write your own backgrounding / queuing mechanism. This is the harder, less maintainable route IMHO. Also, the advantage of dividing up your app into these layers gives you great control over replacing your FE / MT without really bothering to replace your BE which is great when you decide you'd like to use Scala instead of Java or you'd like to create an iPhone / iPad / Android / WebOS app - you can reuse your webservices - yay! ;)

void_ptr

You could use PHP+Extensions in C (for the math routines). It is not easy but it is feasible.

you could consider http://en.wikipedia.org/wiki/Common_Gateway_Interface technology . it allows you to use C/C++ on server side code.

othman

I would suggest using node.js. Because of the fast implementation of it's asynchronous APIs, it is perfect as a middle tier. One can also extend node.js with C++, however the execution model in node.js is single threaded, so you should always make such extensions asynchronous. Alternatively you can just launch a C++ process and communicate with it over stdin/stdout with some lightweight protocol.

back2dos

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.