Abstract
C++ has always been considered a language for mission-critical server-side functionality. Web development, although in part server-side based, is done using different software development languages. I try to analyse what caused this situation. Possibility to provide a portable pure C++ web development framework is explored.
Target audience
This article is for people, who believe that C++ can be successfully used to build sophisticated web applications and are frustrated by the lack of basic tools to do so. It doesn't provide any kind of definite plan on how to create a C++ web development framework, but rather tries to share some thoughts, give an inspiration and some guidelines.
This article is also an invitation to dialogue – please share your thoughts and ideas, using the comments form below or my contact details page.
What this article is not?
To make things clear, this article definitely does not claim, that C++ is better than other software development languages, or that it should be used for every project, or that it doesn't have problems of its own. It rather tries to describe a niche set of requirements and applications, where using a C++ web development framework would make more sense, despite all the issues involved.
Current status
Available solutions
Today there are 3-4 most popular platforms to do server-side web development. These include:
-
Java and Java-based technologies, such as Servlets/JSP, Java Face, Struts and so on. The multitude of Java-based frameworks is a little bit dizzying
-
ASP (legacy) and ASP.NET, together with all Microsoft-related technologies (ADO.NET and other .NET libraries, legacy COM+ etc.)
-
PHP (for smaller sites)
-
Perl (CGI – legacy, mod_perl)
I don't want to describe in detail all these and other frameworks, available on the market. Just to mention, the last two entries are actually scripting languages and their performance is even worse than that of bytecode-compiled ones, like Java. In terms of functionality, all of them provide enough tools to create flexible and powerful web applications. They can and have been used to solve real life problems. However, in my opinion, for some extremely demanding sites they are simply aren't good enough.
There are a few frameworks, using C++, most notably Microsoft's ATL sever. They are either Windows-only or quite limited in their functionality or both. Their specifications have not been updated for years and most of them do not enjoy any vendor or community support.
Why C++ is not used?
One of the main reasons C++ is not actively used to do web development is the lack of standard tools and libraries. There is simply no feature rich library, which includes all the necessary boiler-plate code needed to write web applications.
The numbers of new C++ programmers, trained in universities and by the industry are falling, and some existing developers are converting to other more popular technologies.
Why a new framework?
C++ is an extremely advanced and flexible language. Its performance is still unmatched by other languages, popular today – likes of Java and C# (for an interesting point of view on why many benchmarks, claiming that Java is faster than C++ are not applicable to the real world look here). Even more important, it can be tightly integrated in most widespread web servers (Apache, IIS) to run in-process, and not as an external service, thus eliminating inter-process communication.
One of the main advantages of C++ is its tight management of resources, such as memory allocation. And indeed, although doing explicit memory handling properly can be a nightmare for an unexperienced developer, by using modern programming paradigms, it can be exploited to give a powerful and safe control over resource allocation and destruction. The predictable nature of C++ memory management, as opposed to concurrently run garbage collectors, is an important feature when squeezing every single flop from your CPU.
Also, using C++'s template system and rather sophisticated techniques, based on it, such as meta-programming, can help in creating sets of highly decoupled components, which can be assembled into complicated pieces of software easily.
Economics: isn't hardware cheaper than development time?
This is the question, usually asked by project managers and those, who pay the bill. The idea is – take whatever solution is available already on the market, and if it is a little bit too slow, throw in a bigger iron or two and your bottom line will still be better than if you wrote the staff from ground up yourself.
This is a perfectly legal argument and it is actually applicable to many real projects. Hardware, especially Intel-compatible is quite inexpensive, so throwing in an extra G of RAM or a faster hard disk is usually a matter of few hundreds of dollars.
However, when we start talking about doubling performance of a very busy web site, with a lot of heavy activity, things could look a little bit different.
For example, imagine you are running an extremely successful advertising campaign. As an outcome, your current farm of 30 2U IBM xSeries servers does not provide you the performance you want anymore, and you think that it needs at least doubling. Therefore, in the end you will have 60 servers. Let's ignore their acquisition cost for a minute (but it will be a hefty $60,000-$100,000 or more). What if you don't have enough floor space in your data center to accommodate them? Will you have to move to a new one, increasing your rent bill, incurring the cost of removals and suffering service disruption? What about extra system administrators you might need to hire in order to support them? There are other components in your system, which might require upgrade, databases for instance.
The conclusion is that doubling a large computer farm is not as simple as buying two servers instead of one. Therefore, for large and business-critical application it makes sense to consider investing into performance, even if it means using less popular technologies.
Potential adopters
I have already stated, that not every single web application should be written in C++. My intention is to give a powerful and flexible framework to those entities, which need to run extremely busy sites and which are prepared to invest in development of such sites a little bit more, knowing that the result will be much more powerful and scalable than any other alternative.
I consider high profile web sites, such as popular portals (Yahoo!, MySpace, AOL), blogging communities (LiveJournal, Blogger), relationship building (LinkedIn, OpenBC), popular on-line shops and others, receiving millions of visits regularly and delivering dynamic content to the users.
Naturally, I don't believe that all of them will ditch their current platforms and switch to the new toy of the month. But if a successful platform existed, over the time some of them would evaluate it and use it for some projects.
The following would be key factors, which could make a C++ web development framework attractive for potential users:
-
Highly dynamic site – large portions of the content cannot be cached effectively and need recreating on every view
-
Huge number of visits
-
Availability of necessary resources – developers, administrators and so on
-
Good project management procedures in place
How to succeed?
I don't believe in writing code without well defined and detailed plan. Not only software design and implementation are important in such a project, but also the whole management of the development process and proper PR are essential in order to achieve success.
Learning from other projects
It is important to learn from others and analyse their mistakes and achievements. A very interesting example of a successful major project is Subversion.
For years the only realistic option, available for version control in the open source world had been CVS. Although robust and well tested, it had a long list of shortcomings, which were never addressed by newer releases. A few attempts to build an alternative failed. Nonetheless, a few developers from CollabNet made an effort and created a hugely popular Subversion system. It fixes many problems in CVS, adds new features and provides a flexible and easy to use platform for extension and embedding.
One of distinctive features of the Subversion project is their superior documentation, good development plan and reliable release schedule. Also, they deploy an interesting business model, discussed later in the text.
Learning from other frameworks
From technology point of view we shouldn't ignore experience, gained by other frameworks. Many of them were created by listening to real world feedback from web developers, and learning which issues were raised and how they were resolved is important.
Of particular interest would be the J2EE and ASP.NET platforms since a lot of serious and complex applications are built on them and they were designed by dedicated and highly experienced teams.
External applications and libraries
Wherever possible, existing libraries and tools should be used. Examples include:
-
Apache/IIS – HTTP server platform
-
ICU – Unicode and locale library
-
Apache apr library – for platform-independent functionality, when not provided by boost or others (DB and other stuff)
-
Boost (threads, regular expressions, general C++)
-
log4cplus (or log4cxx from apache) – logging
-
Adobe open source – extra algorithms
Orthogonal components
The following components are essential pieces of any modern web development platform:
-
Integration into containing HTTP servers/application servers, such as Apache/IIS
-
Abstracted HTTP request/response framework – handles of different HTTP request types
-
Configurable session management – preferably using cookies. Session storage should be easily changeable (shared memory, file, DB etc.)
-
Configurable authentication (reuse server’s services)
-
Centralized resource configuration (database connectivity, start-up parameters, logging)
-
Simple template system – for clear separation between business logic and visual representation
-
Common DB layer (using existing libraries like arp), an ORM library, similar to Hibernate
Business models
When developing such a project, it is important to look at the whole picture. This includes the business approach, taken by the development team. There are basically two approaches, which can be considered.
Volunteer development
Development is done on voluntary basis – the code is open source, and people who find the project interesting join and contribute. This is a powerful approach, and a lot of popular projects have been developed this way or are being developed as you read this article. The problem, of course, is in keeping enough high quality developers and other professionals interested in the framework. Many good open source projects died because of lack of interest.
Sponsored
Under this topic I would file any form of development, done by salaried or otherwise paid developers. The result can be closed source or open source and in later case can even enjoy contributions from voluntary developers. However, there is always a dedicated core, willing to develop and support, for money if not out of love of writing software.
Subversion project is developed using this approach and is quite successful. Other major software packages include Sendmail, Fedora Linux distribution and many others. This model is quite flexible and allows some cost saving by using voluntary contributions, high popularity and trust due to the source being open and also income in form of money contributions, consulting services and paid-for support.
Project management
Whatever business model is eventually selected, I believe that there must be centralized leadership for the project, be it in form of core open source development team or management of the sponsoring company. Otherwise the project will never succeed due to never ending arguments.
Design needs to be clear and flexible, and there must be an organized development plan with release schedule. As much as possible and realistic, the code should be covered by automated tests. And no releases should be made without documentation, otherwise no one will know how to use the software.
Applications
It is important to provide applications together with the framework. Also, it would be very important to actually try the ideas, built into the platform in some real world code, so it would be nice to see some of the applications listed below, being created in parallel with or as part of the main development process.
Message board
A real-world example – should be extremely fast and robust. I would think about using Berkeley DB as the data storage, as opposed to a conventional relational database. This way the application would be really fast, especially if proper caching is built into it.
The data storage layer should be abstracted, so can be easily replaced.
Another nice feature would be single installation – multiple independent message boards, so one could provide hosting to different unrelated boards, all configurable and manageable independently.
Blog
Feature-rich and fast – the application should share a lot of code with Message board.
Web Mail
Feature-rich, similar to Gmail, Yahoo! beta e-mail system. Such application can be used to provide free or commercial web mail services for large communities.
C++ Web Toolkit
http://www.webtoolkit.eu
I think I've seen this one
I think I've seen this one already. So far a number of toolkits for web development in C++ have been developed. Unfortunately, they enjoy almost zero exposure, tiny communities and no serious enterprise backing. Thus they are quite doomed.
TreeFrog Framework
TreeFrog Framework is a high-speed and full-stack C++ framework for developing Web applications.
http://www.treefrogframework.org/
You should checkout the Hip
You should checkout the Hip Hop compiler which compiles PHP scripts into C++ binaries. It was developed by Facebook and is open source and downloadable from github.
PHP is a scripting language,
PHP is a scripting language, therefore it has both advantages and disadvantages of such. I believe, that for large systems the later outweigh the former, therefore it doesn't matter if PHP is eventually compiled into C++, which may or may not give performance improvements.
I have used AtoZed's
I have used AtoZed's Intraweb C++ environment along with TMS's web controls....but they are not well integrated and need a lot of attention...
I would die for a C++ web development environment---where do I send the check????
I would also volunteer mightily.....
I have been working since
I have been working since quite a time now on such an idea and have successfully implemented it in the form of ffead c++ application framework (http://code.google.com/p/ffead-cpp/). It has a lot of other features like in-built Reflection ,Serialization, Interpreter, Controller pattern, Ajax, Web-Services to name a few.
Is there any progress about
Is there any progress about the proposed project?
I do believe it'll be a great thing if most of the ideas can be realized and I'm looking forward to the good news.
Sean W. Liu
No, not much at the moment
No, not much at the moment
> Another issue one should
> Another issue one should consider is licensing. Last time I looked into it QT had no free license for its Windows version
Mmmm... that last time was in 2005 or before.
ppC++ is another framework
ppC++ is another framework for embedding C++ in web pages.
- Erik
Why not take a good, decent
Why not take a good, decent scripting language and then build:
- a C/C++ translator
- a command-line tool that "compiles" the script
- a mode that allows auto-compilation in real-time of scripts that have been changed
You could probably start with PHP pages (or whatever) and compile each page into a ".so"
Oh wait... after I wrote that I saw that it's been done.
http://www.phpcompiler.org/
So you *can* have your cake and eat it too.
Sigh, now I need to write a compiler for my favorite language (SMX).
You make some interesting
You make some interesting points, and I agree that C++ would not be the choice in all situations. I would extend this to say that it would mostly only be really efficient to use in transactional applications. In other words, when you need ultra high performance transactions of information that may bubble to high bandwidths. An example of this would be Twitter's usage of the Scala programming language (which runs on the JVM) in replacement of Ruby for the queuing system which transacts data between the front end and the server daemons [Twitter Uses Scala]. Although they did consider C++ for this responsibility, in the end they went with a language that had a "better feeling" to them, if for no other reason. For those who feel most comfortable with C++, it would make an excellent choice for these types of transactions.
On the other hand, an ordinary scripting language or framework like PHP, RoR, Django, etc, is fine for most situations, even massive sites, because content can be statically cached, served straight from the file system or a simple SQL query, bypassing all or most of the business logic altogether. No amount of C++ power will be faster than a static page. This type of optimization is very easy to implement, and requires so little code it doesn't matter what is used to write it. The only trick is knowing when to clear the cache so that users are seeing the newest available content. C++ might be handy if there is a portion of a page that has a constantly updating portion via a recurring AJAX call, and this page has a huge amount of requests being made to it. This is a simple example of what I mean by transactional data.
Other than these points, most of the slowness on a website happens on the client-side, not on the server-side. If a framework addressed front-end issues like Rails does, it would have to be very sensitive to the many things that can slow down the user, since there are so many factors, from the number of HTTP requests to the nature of JavaScript being requested, to whether JavaScript is being kept externally, etc, etc. I don't see C++ as being of any particular advantage on the front-end, since serving a web page is so straightforward. If a framework like this is to succeed it needs to first do what it should be able to handle best: In addition to making SQL calls, it should be able to handle simple HTTP requests with ease, send headers, then return data in widely accepted mediums; JSON and XML should be standard options for output. If you start with a core transactional framework you can move to other things later, like a template system.
PHP or Python with C++ transactions would be very cool.
"most of the slowness.." its
"most of the slowness.."
its about server energy expenditure not the speed.
in the long run humanity faces labour surplus and energy shortage.
I know only c++.My friends
I know only c++.My friends learned languages like PHP.But I had doubt that why don't we use c++ for webdevelopment.I searched on Google and came across your site.It's really fantastic.Thanks!!!
It is - in theory - possible
It is - in theory - possible to make a JIT compiler that runs code faster than native C++. (eg. it can optimize for the characteristics of the current CPU) We are not quiet there yet, but I think we are going that direction. Right now C++ is typically faster than eg. Java or C#. I managed to get 10x speed improvements using C++ over C# in some cases. But these were in special cases, where SIMD optimizations could be used. In typical web applications there won't be too much of a difference. Also, garbage collection can be done very efficiently - capable of competing with smart pointers and typical memory handlers in C++.
So, I think little would be gained by such a C++ framework, considering the current trends.
Although I'm not a .NET /
Although I'm not a .NET / Microsoft patriot, but what makes their framework intuitive to use is the development environment (IDE) they sell. Again, although highly priced & full of MS specific conventions - VS 200x series have helped .NET web developers become children again & sit on a couch with legs on the desk & code :-). If we can also have custom wizards to create a C++ Web App Project - just like in Visual Studio 200x series, maybe we can configure NetBeans / Anjuta to use our wizards. That ways the popularity of our framework would be widespread.
Maybe you should also check
Maybe you should also check - http://www.codeproject.com/KB/mcpp/helloworldmc.aspx
If I understand the problem correctly, than this is similar to what you are discussing here.
My take on - http://www.micronovae.com/CSP.html
haven't we already decoupled the client HTML code & server side code that actually is glued to the HTML markup. Frameworks / environments like ASP.NET + C# (or C++ - as the link mentioned above proves the point), already provide a decoupled environment for developing more robust web-apps. Not to mention that is we are to start a C++ Web Framework project, we should not overlook the idea of extensibility & portability.
You are looking for CppCMS.
You are looking for CppCMS. It is a C++ web framework including some basic applications such as a wiki, blog and CMS.
I'm aware of the product.
I'm aware of the product. It seems pretty new and not mature yet, but there is definitely a promise.
Actually, this framework
Actually, this framework already released as stable version, it has quite complete documentation and high
perofrmance applications. More important that it is much more apropriate in terms of salability and web oriented
design in comparison to Wt and others.
Thanks for the update, maybe
Thanks for the update, maybe I will revisit it
You know, you could just
You know, you could just write an apache module with the above functionality. You would definitely run into portability issues with IIS and other servers, but it would certainly make the task easier
I am happy finally someone
I am happy finally someone is seeing things my way! I have been advocating using C/C++ for everything as it just requires a one time learning curve for developing any kind of application.
For web programming in c/c++ i use HTML/CSS/JavaScript AJAX/JSON with C/C++ server side programs. Once again Javascript is a one time learning effort.
Writing a small client side framework for boiler pate AJAX coding is very easy.
For an ORM I use OODBC //http://www.garret.ru/oodbc/readme.htm
For GUI programming I use the FOX toolkit http://www.fox-toolkit.org
For other cross platform stuff I use BOOST http://www.boost.org
My two cents!
Hi Andre, Thanks for an
Hi Andre,
Thanks for an interesting article.
I don't entirely agree.
I think C++ is best kept isolated to speed/efficiency critical sections of a web application. I think overall program workflow is not a processor or memory intensive task. I think a dynamic language such as Python is more appropriate for workflow expression because it is more flexible and therefore allows more time to be spent on defining the logic concisely.
I have to disagree with you
I have to disagree with you on some points. You are right, that many times web applications don't consume much resources, or hardware costs are lower, then development. In such cases a simple language similar to Java or C# would be more suitable. The tasks I have in mind are extremely busy web sites, where the cost and logistics of running a computer farm of required size becomes an obstacle.
As to using Python, or any other scripting language, I must tell you I don't believe in using them for large-scale projects. Compile-time verification is, in my experience, a valuable check reducing the number of bugs considerably. Unit tests are not an adequate replacement.
Hi Andre, Many big sites
Hi Andre,
Many big sites including google, youtube, yahoo, facebook and sourceforge would disagree with you in that they attract massive traffic but use C++ only in components whilst relying on dynamic languages for workflow and to glue components together. YouTube was written largely in Python. FaceBook and SourceForge in PHP.
I think its a different story with P2P applications or servers running on an embedded device. C++ is standard in these areas. Even with ultra high performance web apps chances are the most memory used is for caching and most processing is carried out around the database.
Emir
Yes, Google and many others
Yes, Google and many others use scripting language, mainly because they were developed from ground up to be suitable for web development (PHP) or have an extensive set of appropriate libraries added (Python, Perl). That by itself doesn't mean they wouldn't do it in pure C++ if the right framework was available and they had the skills in-house...
Also, think about YouTube and Facebook - they were developed as "hacks" - get out something quick and working, think about performance later. So now they just have legacy, maybe they would have chosen a different technology under different circumstances.
This is what I have been
This is what I have been waiting for.
Why re-invent the wheel?
As far as I can see, the easiest is just to copy Qt. Just make it all renders as html elements. Keep the Signal Slot concept.
The second best would be to copy Ruby On Rails. It rocks. It is the best framework for web applications the world has seen. But the speed of Ruby sucks.
Just imagine: The ease of Qt or the speed of development of Ruby, both with the runtime speed and possibilities of C++.
If we don't do anything now, C++ will loose it high time. I will guess that 80% of all new applications developed now and in the future will be web applications. C++ could win back its popularity with an easy to use framework. We need this to be able to continue promoting C++ as a great programming language. We have no rich company behind us to hype C++. We can only proof C++ greatness by what is produced by C++.
Take C++ to the web and C++ will be among the main choices for coming generations of programmers.
There are many ways to
There are many ways to create the framework. I don't know how easy it would be to adapt QT for the purpose, after all there are substantial differences between what can be done on the desktop or on the web.
As to Ruby-on-Rails - I don't know much about the technology. But many frameworks can be a source of inspiration for this one.
currently a CS and software
currently a CS and software engineering student. Willing to help in anyway if the project were to be started by experienced programmers! just the idea gets me excited
Have you considered Wt
Have you considered Wt ("witty")?
Here's a synopsis, taken directly from their website (http://www.webtoolkit.eu/wt):
Wt (pronounced 'witty') is a C++ library and application server for developing and deploying web applications. It is not a 'framework', which enforces a way of programming, but a library.
The API is widget-centric, and inspired by existing C++ Graphical User Interface (GUI) APIs. To the developer, it offers complete abstraction of any web-specific implementation details, including event handling and graphics support.
Page-based frameworks (such as based on PHP or JSP/JSF (+ servlets + struts)) for developing web application do not make abstraction of the peculiarities of the underlying technologies (HTML/XHTML, JavaScript, CSS, AJAX, Forms, DHTML, SVG/VML/Canvas). As a consequence, a developer must gain familiarity with all of these (evolving) technologies. Moreover, when choosing to use a technology (such the currently popular AJAX), the developer is responsible for graceful degradation when AJAX or JavaScript are not available or disabled. The structure of the application follows mostly the page-centric paradigm of early day HTML. This means that when using advanced AJAX techniques, as a developer you will need to design and maintain manually your client-server communication.
Generating HTML code or filling HTML templates is prone to security problems such as XSS (Cross-Site-Scripting), by unwillingly allowing JavaScript to be inserted in the page. But this cannot be avoided by template frameworks, because as a developer you need to be able to insert self-written JavaScript to improve your web application.
In contrast, a web application developed with Wt is written in only one compiled language (C++), from which the library generates the necessary HTML/XHTML, Javascript, CGI, SVG/VML/Canvas and AJAX code. The responsibility of writing secure and browser-portable web applications is handled by Wt. For example, if available, Wt will maximally use JavaScript and AJAX, but applications developed using Wt will also function correctly when AJAX is not available, or when JavaScript is disabled, reverting to a plain HTML/CGI mechanism for communication between browser and server.
Yes, I'm aware of its
Yes, I'm aware of its existence, thanks to previous comments, submitted to the article.
i'm on the same wavelength
i'm on the same wavelength as what is being described here. what comes to mind is Qt, since it is a robust C++ framework designed to be portable to all the major OS', along with embedded environments as well. in my view, this page describes Qt for the browser (and server). not so much literally, but conceptually. such a framework should allow widgets to be drawn, an event model to trigger actions, database support, threading, ... most importantly, it could reuse existing c++ libraries, be type-safe, be portable and run close to the metal (in-process, if desired).
QT is definitely a
QT is definitely a possibility. I've never used it, so can't say whether it is more suitable for this task than, say, plain boost, which also contains many useful classes. The GUI part of QT won't be very useful since its all "direct" PC-based GUI and not related to web.
Another issue one should consider is licensing. Last time I looked into it QT had no free license for its Windows version, which is not very good for my project.
Why not to start with WT
Why not to start with WT (Witty) ?. It is open source project and widget centric c++ library (also has application server ).
It completely provides abstraction from underlying tehnologies such as HTML .XML, AJAX, Java Script.
It sounds similar to QT but as you said QT renders GUI which is PC-BASED whereas QT renders in form of HTML/JAVAScript.
At least , some ideas can be taken from WT and some can be taken from C++ Server Pages.
Further more , need to start with some ideas from WT and C++ SP at earliest.
Project can be keep on evolving as time goes and will get more support.
Need to form forum . message board related to starting project.
I'd be interested in
I'd be interested in developing this, though I have other priorities (mainly school), which limits my time severely. However, I'd be available to do code review, for example, or other isolated tasks.
Is there a development page or wiki set up for this project?
Andrew, at the moment there
Andrew, at the moment there is no active development going on, related to the project. I'm interested in gathering opinions from a wide range of developers, as well as observing the current state of the web development frameworks.
I won't start any development until I have a solid core team of at least 3-4 high-level C++ programmers with considerable Web experience, otherwise the project is doomed from the start. Any extra part-time involvement is, obviously, more than welcome.
Unfortunately, you are going
Unfortunately, you are going to fail.
Why? Because the developers you tap will come from desktop UI programming. They first thing they are going to do is develop a set of widgets, a widget hierarchy, and attempt to make the entire project C++ only, with no XML, HTML or JavaScript.
You're going to be so busy working on abstracting these concepts, that you're always going to be behind the people who are actually developing these concepts using Ruby, PHP and Perl.
Java, no, Javans have the same problem. Wicket is this up and coming framework for Java who's stated goal is to solve the problem of statelessness, as if this was 1996 and statelessness was still considered a problem. By trying to hide statelessness, the developers of the framework are unable to use design patterns that design for the stateless experience of the web. I want to carefully maintain state on the server side.
As a developer, I want to be aware of the fact that a visitor left with a full shopping cart after his credit card number was incorrect. Maybe he went to find his reading glasses. Maybe he left them at his office. Maybe he forgets about my website until a month later. I still want him to pick up where he left off.
Treating HTML, XML, JavaScript as a problem to be solved has already been posited in this thread, which takes it even further than the statelessness. This potpourri of different languages is the enabling technology of the contemporary Internet. Why would you want to shield yourself from it? Why would you want to express JavaScript in C++? I'm sure you could try, and come up with some marble-mouthed, inflexible frameworky class library, that renders web interfaces like a mittened four-year old with a box of crayons.
If you do build this, give C++ the job where it can excel. Create an action framework. Create a class to respond to a particular RESTful action and generate a streaming result. Use a templating language to generate your HTML and XML, but write out these templates in their own language, HTML or XML. Look at Java's Stripes for an example of a Java framework that knows it's place and does what it does extremely well.
I'd happily use a C++ framework, if someone would develop one that didn't require that I write HTML in C++.
Thanks for your detailed
Thanks for your detailed comment.
While you have a valid point, trying to explain, why previous attempts to create a C++-based framework failed, I think you are making wrong conclusions from my article. I definitely don't want to eliminate HTML/JavaScript/CSS from the development lifecycle. The framework should not dictate a single approach to the creation of the web GUI, therefore a variety of paradigms is possible.
One could be indeed a rather rigid C++ only hierarchy of widgets, which would generate some simple tight HTML, probably not giving you much options in creating pretty looking AJAX interfaces etc., but which will abstract all the weirdness of modern web development from an uninterested programmer. Such set of widgets might be extremely useful in, say, embedded world - when you want to create a simple GUI for your router or other device, where nothing fancy is required, but memory/CPU constraints are tight.
Another library on top of the framework could be much more flexible, doing something along latest versions of JSP tags (or whatever they are called).
Yet another one could follow Google's approach of compiling Java into HTML/JavaScript.
All in all, I don't see my framework as an all-purpose one, it fits more in different niches, such as either exceptionally high loads or constrained hardware.
I would kill to be able to
I would kill to be able to write a web application using only C++
I would love to help with this, but (without going into the boring and obvious details) my current employment prohibits this.
That being said, I've been thinking about the same things mentioned in the paper and I would like to offer a couple of thoughts:
1. Although I am a fan of the major frameworks mentioned under "learning from other frameworks", one thing I would change about ASP.NET would be a way to use much of the "base" functionality and ditch the page model in favor of a "more" template-based system. Essentially, I would like to get Apache to port Velocity to ASP.NET :)
2. Code-generation and/or reflection/introspection are going to be needed for things like ORM. I would also suggest that one or both will be needed for a "full" URL-based MVC framework. E.g. http://foo.com/bar/add?a1=100&b2=hello translates to something like (new bar())->add(100, "hello"). When you consider leveraging open source, you might want to look at Qt. Obviously, the GUI widgets would be completely ignored, and you would be introducing a compile step, but you would be getting introspection and some cross-platform help.
Just my .02 - which isn't worth much with the current exchange rates :)
You've got interesting
You've got interesting ideas. However, I don't think a URL-based MVC, the way you describe it, is a good idea, since I don't see any obvious dividends and the security exposure could be significant.
Code generation is another matter. Using something like Aspect C++ is, probably, the only way to implement reasonable ORM framework. QT is an option, but I've never looked into it's pre-compiler.
I've been working on a web
I've been working on a web framework in C++ for the past few months in my spare time. It's based on a lot of ideas from Django, but tries to migrate all repetitive coding into code generation. It uses a YAML configuration file to keep track of all the models (ie, tables in the database) and views.
There's no documentation yet, it's not done, and plenty of the code is ugly, but if you're interested in seeing something, you can look at the git repository: http://git.snoyman.com/cppweb.git. Let me know if you like it (or even if you don't).
so i was looking to see if
so i was looking to see if there was a C++ based web framework and found this article. this is very wel written and a great read. i used to be a C++ developer and went over to PHP because it was less hassles. right now though i am planning to go back because of speed, power and performance.
you propose some great ideas. mostly that it was the tools and the specifications that made Java great for web programming. C++ would be immensly faster and it is what i would rather use. i am writing some documentation on writing my own C++WF but wanted to see other implimentations, writeups or white papers. very little is what i found and it is dumb founding once you realize how many OPEN SOURCE C++ libraries there are out there. putting them together as an ad hoc WF would work but a complete and concise WF would be best.
thank you for this write up. it was a great read and i thoughly enjoyed it.
-Taters
Thanks for your comment
Thanks for your comment
Stumbled upon this post when
Stumbled upon this post when I started thinking about using C++ to create a web framework largely based on the principles of Rails. I've been doing Rails for almost a year and absolutely love the motivations behind Rails - MVC, Convention over Configuration, Plugins, Generators, etc. And I totally agreed that its the TOOLS behind a web framework that makes life easier for the developer..although the language plays a part too.
But this is a really interesting initiative and I'm looking to contribute if this gets more traction.
I think, this project may
I think, this project may interest you
http://cppcms.sourceforge.net/
Development blog: http://art-blog.no-ip.info/cppcms/blog
Thanks, looks interesting
Thanks, looks interesting indeed. However, very little information about the actual design is given. Hopefully we will see more documentation in the future.
Beta version of CppCMS
Beta version of CppCMS Released: http://art-blog.no-ip.info/cppcms/blog/post/25
I think this may interest you
Thanks, I'll have a look
Thanks, I'll have a look