views:

2080

answers:

12

On our embedded device, we currently use PHP for its web interface, and unfortunately it's quite slow. We've been experimenting with Python, but is seems (at least on FPU-less ARM architecture) to be as slow as PHP.

Therefore we're thinking about implementing web interface in some compiled language like C++, but so far the only thing we've found is Wt, which looks more like desktop than web framework and it's documentation is rather complicated for a beginner.

So my question is: do you know about any good web frameworks for C/C++? What would make me totally happy would be something like C++ Django, but I doubt such thing exists :-)

+1  A: 

Try Lua. There is Xavante embeded web server somewhere on LuaForge.

It's very fast, very small and very extensible - as all about lua is.

You have power to use Lua where scripting fits betteer, and use C++ functions where in need of more speed and conection to existing native code.

dmajkic
+8  A: 

What is the reason your site is slow in PHP? Have you profiled the code to figure out the bottle necks? Replacing the entire codebase with another language is likely to be too large a tool for the job.

Perhaps if some portion is computationally intensive, then maybe you can implement a PHP module in C++ to do the job.

spoulson
As far as I know most of the delays are caused by including files with classes that generate various components of the final page.
che
Are you sure? Even complex PHP frameworks only have a delay of a few MS when including their complex web of files, and if you're using a framework-less PHP then its likely to be even less.
ryeguy
On our mildly loaded XScale box, including stuff and creating the objects takes between 0.75 and 1.7 seconds.
che
I'm curious why you're using a minimal processor for a PHP web application server. Is this a mobile device?
spoulson
It isn't exactly pocket-sized. The key issue is the cost of the hardware.
che
+5  A: 

Do you really need a web framework or just an html templating library?
See here for template options: http://stackoverflow.com/questions/355650/c-html-template-framework-templatizing-library-html-generator-library

Martin Beckett
Thanks for the link, templates are certainly heplful, but having something that would dispatch requests and provide nice API for HTTP requests and resposes would be nice as well.
che
I thought if you were in the embedded world you might want something light
Martin Beckett
+5  A: 

How about Nanogear. I haven't used it, so I'm not sure if it is a good fit. Here is a quote from the website.

C++ is a great, general purpose programming language but no modern, easy-to-use and powerful C++ web frameworks were made during these years. We try to fill the gap with Nanogear. Inspired by the Zend Framework and Rails we want to bring C++ to the web, easily.

Here is a link to the older googlecode site Google Code Nanogear Looks like there is more info there.

Philip T.
Nono-gear is mostly "draft" of project. It includes very few code
Artyom
It seems to not be updated anymore :/
Klaim
+1  A: 

Since no one else has said it, I will. Try Java. Java is a compiled language with a good web framework. It is also very scalable. Every coperation I have worked for uses java as its main web-technology, and this is mainly due to this scalability factor. Not sure if it will work with your architecture, but it answers the question:

Are there any web frameworks for compiled languages like C++?

windfinder
Java is hardly a compiled langauge. It compiles to byte code, and then the JVM interprets (or maybe JITs) it.
Sunny
Performance of java is almost 1:1 with C++ once the code has optimized. While it is true that bytecode isn't true native code compilation performance was the important point here.
windfinder
Unless using very expensive development tools, java will be very slow on these ARM processrs. There are no byte-compiling JVMs available afaik (and even then, I expect byte-compiling on that architecture to be very slow too).
Depends critically on the availability of Jazelle (HW accel for Java on ARM)
MSalters
+5  A: 

You can take a look at CppCMS. I don't know how mature or good it is, but it sounds like what you are looking for.

Another option is to write the main application in Python/PHP and then rewrite the critical parts in C, which seems more sane to me.

HolySpirit
+1 for cppcms. a.
augustin
+3  A: 

One thing to look at here is using C++ for some sort of web service instead of an actual web app development environment. On one of my current projects we generate JSON(and parse for requests) then let the client(web browser) deal with the rest. You have a great deal of computing power available to you on the client machine, mix in some javascripty magic and boom, now your embedded device can go back to doing what its supposed to do. I personally kind of like Wt and think it is your best bet if you want to dev the whole "web app" thing in C++.

As to the specifics of how you get your C++ code to start serving up web services, you can use the amazing boost.asio library(they have an http server example) and json_spirit(I think its on codeproject)

Hippiehunter
+6  A: 

If I were you, I would give Wt a try. I don't think you will find another solution as complete and easy to use as Wt with similar performance. The mailinglist are active, and has regular posts of people who use it on embedded devices. The Wiki (here) of the project mentions some numbers for embedded deployment and performance on ARM.

+2  A: 

I had just seen this link as a referrer to CppCMS. Several questions/answers about it.

Q. How is it mature?
A. There is a Wiki 100% based on it. Developers blog runs on CppCMS as well. So you can see it quite works. well. At least for author.
Q. "What would make me totally happy would be something like C++ Django"
A. Actually it is "C++ Django". Many Ideas had been taken directly from Django, like forms, template inheritance and some more. So you would probably feel at home
Q. Nanogear
A. I had taken a look on it... It has many plans but not-too-much code.
Q. How many projects using it.
A. Not many. It is quite new project.
Q. Who am I?
A. To be honest I'm the developer of CppCMS.

I can't get the site to load :(
crashmstr
try this http://cppcms.sourceforge.net/
Artyom
A: 

You may give a try to embedded version of CppCMS.

It's quite new and exprerimental development but It looks like it is much more suitable then Wt because it is ore web oriented (more closer to Django) and not GUI like.

Artyom
A: 

C on Concrete. :)

ionut bizau
A: 

Check out the ffead c++ application framework (http://code.google.com/p/ffead-cpp/), its developed on the lines of Spring for JAVA.

Sumeet