As a true programmer, I need fun projects to stay alive. Don’t get me wrong, my client work fulfills me, and eventhough I’ve been slacking lately in keeping up with its workload, CakePHP is also a lot of fun. However, true programmers are always looking for a fun project, one they can call their own. Meet CLAPP, a C++ MVC Web Framework.
I am not even close to finishing it, but so far I’m having LOTS of fun. What is amazing is that missing only the M in MVC (the database abstraction layer), CLAPP’s performance is already astonishing. Running as FastCGI, it outperforms the most basic PHP file by a ratio of 1000%. Amazing.
So what am I looking to gain from this? Nothing, just having fun going back to my absolute favourite language: C++. In the meantime, I get to play with speed comparisons, which gets particularly interesting as I enable more stuff in the framework. My ideal goal is to include a lot of the you-just-have-to-have-this kind of things available on real, serious frameworks such as CakePHP. This doesn’t mean that I will hereon start developing every web application in C++, that would just be dumb (if you are asking why, then that’s because you haven’t given CakePHP a try). It does mean, however, that I’ll be posting about CLAPP every now and then.
To calm your expectations, here’s a very, VERY small preview of the Dispatcher, which is directly attached to every controller:
#ifndef __CLAPP_DISPATCHER_HPP #define __CLAPP_DISPATCHER_HPP #include <clapp/cgi_stream.h> #include <clapp/controller.h> namespace clapp { template <class C> class Dispatcher { public: Dispatcher(); ~Dispatcher(); void dispatch(); private: #ifdef CLAPP_WITH_FASTCGI CgiStreamFastCgi * cgiStream; #else CgiStream * cgiStream; #endif void execute(); }; } template <class C> clapp::Dispatcher<C>::Dispatcher() { #ifdef CLAPP_WITH_FASTCGI this->cgiStream = new CgiStreamFastCgi(); #else this->cgiStream = new CgiStream(); #endif } template <class C> clapp::Dispatcher<C>::~Dispatcher() { delete this->cgiStream; } template <class C> void clapp::Dispatcher<C>::dispatch() { #ifdef CLAPP_WITH_FASTCGI FCGX_Request request; FCGX_Init(); FCGX_InitRequest(&request, 0, 0); while (FCGX_Accept_r(&request) == 0) { this->cgiStream->setRequest(request); this->execute(); FCGX_Finish_r(&request); } #else this->execute(); #endif } template <class C> void clapp::Dispatcher<C>::execute() { C *controller = NULL; try { controller = new C(); controller->setStream(this->cgiStream); controller->dispatch(); delete controller; } catch(...) { if (controller != NULL) { delete controller; } throw; } } #endif
As you can guess from the source code, CLAPP can produce FastCGIs and regular CGIs. It uses ClearSilver for its view / layout templates, the FastCGI development kit (when FastCGI mode is enabled), and GNU cgicc as a CGI / FastCGI input wrapper. More news coming soon!
Nao [Visitor] wrote:
Cakephp to c++ version :
Great initiative, I look forward to more!
Link
Nao [Visitor] wrote:
The best is to create php module named php_cakeFramework : Speed of c++ and simplicity of php for developper!
Link
Coward [Visitor] wrote:
Check out http://fastcgipp.com/
Link
Coward [Visitor] wrote:
And also http://cppcms.sourceforge.net/
Link
mariano.iglesias [Member] wrote:
@Coward: FastCGIpp is not exactly a framework. In fact, its mainly a C++ implementation of the FastCGI protocol. It does provide several other things (that’s why they say is a framework for C++ development), but it’s nothing of what a Web Application framework should be.
I checked CppCms thoroughly before. It’s very interesting indeed. However, in my opinion, it has one major design flaw: Views are compiled. That for me is a huge no-go. Thinking that if my designers need to change a view I have to recompile the project? No thanks
Link
artyom [Visitor] wrote:
> However, in my opinion, it has one
> major design flaw: Views are compiled.
> That for me is a huge no-go. Thinking
> that if my designers need to change a
> view I have to recompile the project?
Not correct, see http://cppcms.sourceforge.net/wikipp/en/page/ref_templates_bld
The views are generally compiled to shared objects or dll and dynamically loaded. Thus if you change view you only need to do a very short build of shared object.
For example, full rebuild of wiki++ view takes 3.5 seconds and 6 seconds for fully optimized release version.
So, it is not as bad as you think, in fact, build times are similar to thous of JSP or Asp.Net views.
Link
mariano.iglesias [Member] wrote:
@artyom: I don’t get it. You say not exactly but you are explaining how you have to rebuild the views. I wasn’t talking about how fast it is to build a view. You still have to build it.
I’m not saying: “I’m right, you are wrong”. Just that I don’t think it makes much sense to build a view, be it as a DLL that is dinamically loaded, or anything else.
Link
artyom [Visitor] wrote:
I mean
> I have to recompile the project
Is not correct, you need only to build
a **very small** part of it.
> Just that I don’t think it makes much sense to build a view, be it as a DLL that is dinamically loaded
Actually such things are already done in Asp.Net and
in Java Servlets.
It is defenatly not “one major design flaw”, this is something common to many frameworks.
Link
mariano.iglesias [Member] wrote:
@artyom: Ok, we are really NOT understanding each other. I don’t care if it’s done on other frameworks or not. I DONT like the fact that you have to build EVEN A SMALL part of it.
It’s just me. There are TONS of frameworks that DONT require you to re build ANYTHING when you change a view. Period. That’s what I’m working for.
Link
juicer [Visitor] wrote:
Made any progress on this project? I think it’s a great idea! Why not post it on SourceForge and let the community help you build it?
Also, have you taken a look at the approach being taken over at puremvc.org?
Lastly, I’d like to know more specifically about why you believe that having to build anything when you change a view is a significant drawback. Is it only really a disadvantage when the site scales up? Even if the build is automated?
Link
juicer [Visitor] wrote:
Oh yeah, almost forgot…
What do you think about Felspar’s Frost 4 framework?
Link
asterisk.net.ru wrote:
Hello mariano!
Do you have any news or progress in C++ Web Framework (CLAPP) ?
Could you provide a link for downloading?
Thanks.
Link
mariano wrote:
I plan to start updating it very soon, and publish its code in github. Stay tuned!
Link
Mayuresh Kathe wrote:
This is cool stuff

Keep at it, don’t give up.
If possible, create a mailing list and if you do, do add me in
(will be monitoring your blog).
Link
Rizo Isrof wrote:
Excellent initiative! Waiting for project advances!
Link
Abdel wrote:
Can you share the source code on github? I’m interested in helping with development.
Link
romel wrote:
Hi, what happened with the project, I think pretty super.
see this: http://arstechnica.com/business/2012/04/exclusive-a-behind-the-scenes-look-at-facebook-release-engineering/
best regards
Link