New fun project: a C++ Web Framework

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:


#include <clapp/cgi_stream.h>
#include <clapp/controller.h>

namespace clapp {
	template <class C>
	class Dispatcher {
			void dispatch();

			CgiStreamFastCgi * cgiStream;
			CgiStream * cgiStream;

			void execute();

template <class C>
clapp::Dispatcher<C>::Dispatcher() {
	this->cgiStream = new CgiStreamFastCgi();
	this->cgiStream = new CgiStream();

template <class C>
clapp::Dispatcher<C>::~Dispatcher() {
	delete this->cgiStream;

template <class C>
void clapp::Dispatcher<C>::dispatch() {
	FCGX_Request request;

	FCGX_InitRequest(&request, 0, 0);

	while (FCGX_Accept_r(&request) == 0) {

template <class C>
void clapp::Dispatcher<C>::execute() {
	C *controller = NULL;

	try {
		controller = new C();


		delete controller;
	} catch(...) {
		if (controller != NULL) {
			delete controller;


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!

Leave a Comment

17 Comments to "New fun project: a C++ Web Framework"

  1. Feb182009 at 7:57 am

    Nao [Visitor] wrote:

    Cakephp to c++ version :
    Great initiative, I look forward to more!

  2. Feb182009 at 8:00 am

    Nao [Visitor] wrote:

    The best is to create php module named php_cakeFramework : Speed of c++ and simplicity of php for developper!

  3. Mar232009 at 8:06 am

    Coward [Visitor] wrote:

    Check out http://fastcgipp.com/

  4. Mar232009 at 8:07 am

    Coward [Visitor] wrote:

    And also http://cppcms.sourceforge.net/

  5. Mar232009 at 12:22 pm

    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 ;)

  6. Mar312009 at 7:17 pm

    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.

  7. Mar312009 at 7:20 pm

    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.

  8. Mar312009 at 7:34 pm

    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.

  9. Mar312009 at 8:26 pm

    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.

  10. Aug102009 at 7:30 am

    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?

  11. Aug102009 at 7:34 am

    juicer [Visitor] wrote:

    Oh yeah, almost forgot…
    What do you think about Felspar’s Frost 4 framework?

  12. Jan052010 at 9:18 pm

    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?


  13. Jan052010 at 9:25 pm

    mariano wrote:

    I plan to start updating it very soon, and publish its code in github. Stay tuned!

  14. Jun032010 at 9:41 am

    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).

  15. Jun182010 at 6:27 am

    Rizo Isrof wrote:

    Excellent initiative! Waiting for project advances!

  16. May182011 at 11:22 am

    Abdel wrote:

    Can you share the source code on github? I’m interested in helping with development.

  17. Dec112012 at 11:56 am

    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

Powered by Wordpress and MySQL. Clauz's design for by Cricava