Thread: Web application structure

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    124

    Web application structure

    Hi all,

    I want to use C++ to develop a Web Application where performance is pretty much everything...Would just like to know how someone goes about using C++ in such an environment...e.g. how does Google use C++ for google.com...

    I briefly considered using Ruby with the Rails framework but given that I've coded in C++ before, I really would like to work with it...

    Thanks,

    Farooq

  2. #2
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    Do you want us to tell you about C++ network programming or do you want us to hypothesize where C++ fits into Google's master scheme to take over the world? Some more details about what you want to do can help us to help you.

  3. #3
    Registered User
    Join Date
    Sep 2004
    Posts
    124
    ha ha...sorry about that...

    I require maximum server side processing of image data...so like with html and scripting: I would execute a script on the server side using a POST...

    I want to know how something similar might be done, where my browser actually executes a C++ programme on the server (which does all my processing) and returns the data back to the browser...

    I guess I'm looking for defined ways of structuring such a web application, not a hack to accomplish it...like I said, performance would mean everything here and I dont' think PHP etc will be able to handle it...

    Thanks!

    Farooq

  4. #4
    semi-colon generator ChaosEngine's Avatar
    Join Date
    Sep 2005
    Location
    Chch, NZ
    Posts
    597
    you could use C++ for this, but generally it'd mean writing a mod for apache or something similiar. To be honest, you'd be better off with a language/library that's designed for this purpose (e.g. Ruby, mod-Python, ASP.net)
    "I saw a sign that said 'Drink Canada Dry', so I started"
    -- Brendan Behan

    Free Compiler: Visual C++ 2005 Express
    If you program in C++, you need Boost. You should also know how to use the Standard Library (STL). Want to make games? After reading this, I don't like WxWidgets anymore. Want to add some scripting to your App?

  5. #5
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    Perl CGI ftw.

  6. #6
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    You actually can just write CGI programs in C++, whatever others here tell you. But it's tiresome, as nearly no support libraries exist.

    I think the best thing to do is write the application in the scripting language of your choice, then, if it's not fast enough, write an extension to that language in C++ that provides the performance-critical functionality. For example, extending Python with Boost.Python works pretty well.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  7. #7
    Registered User
    Join Date
    Sep 2004
    Posts
    124
    thanks a lot for your replies...so basically I could do all of the front-end work in one of the scripting languages and then call C++ functions for computationally intensive tasks....i just wanted to see if there was a framework already available that helped in such a setup...

    On another note, I would very much like to code the server side in C++ not only because I've worked in it a bit before but also because it has a reputation for producing the fastest applications (the usual developer competency disclaimers apply)

    Thanks!

    Farooq

  8. #8
    Registered User
    Join Date
    Oct 2005
    Posts
    88
    I've tried the same thing, although tried to just make all the CGI 'scripts' in straight c++. It took me a while to get going as I was trying to learn c++ at the same time, but it's not that more complex than writing it in a scripting language that you don't already know.

    Once you have written yourself a CGI class (I couldn't find any decent ones on google - and that wasn't that long ago - so I emulated the perl cgi class since it has such a useful interface) and have a regex class (PCRE is good; Boost.Regex is better then that's pretty much it. Database interaction is a bit of a pain though (at least it is on Windows - I still can't get mysql++ working on it): that's the only real stopping ground since I'm still deciding on what the most efficient way of getting to the DB via c++ is, but it's by no means impossible to make your own interface (I got stuck on prepared statements for a short epoch, mind).

    I'm still working on figuring it out, but IMHO some useful classes are a User class (to handle all user stuff - possibly by accessing lower-level classes, like a UserOptions class); a chrono namespace (for script timing, formatting of dates/times, etc); a Session class (db-based artificial persistent connections - logging, usage limiting, etc); a crypto namespace (for all the obvious important security stuff) and a Contact class (for e?mailing users, etc).

    There's a billion more possibilities, but the stuff I put in the code sections above are all completely generic so they (seem to) work with all applications. With them I honestly don't even think it's that hard (read: any more complex than using php/perl/python, maybe even easier) to code apps and to me it seems far cleaner to be doing it in c++.


    Then again, you could just listen to everyone else and just give up on the idea altogether.

  9. #9
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    For DB access in C++, the SOCI library is a modern and nice approach.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  10. #10
    Registered User
    Join Date
    Jan 2006
    Location
    Europe/Belgrade
    Posts
    78
    Cgicc library is small free library for CGI programming, can be downloaded from www.freshmeat.net.

  11. #11
    Registered User
    Join Date
    Sep 2004
    Posts
    124
    thanks a lot all of you...I guess I am influenced by my previous work in C++ and it's high performance reputation...The best way now would be to use Python or Ruby on Rails to structure the web app. and then use C++ for any functions I feel cannot be handled by the respective languages...

    Thanks a lot again for all the suggestions...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. pthread question how would I init this data structure?
    By mr_coffee in forum C Programming
    Replies: 2
    Last Post: 02-23-2009, 12:42 PM
  2. Consuming same Web Service multiple times
    By cfriend in forum C# Programming
    Replies: 2
    Last Post: 01-10-2006, 09:59 AM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. Structure Problem
    By Generator in forum C Programming
    Replies: 5
    Last Post: 07-28-2003, 11:54 PM
  5. Further developing C for the web
    By bjdea1 in forum C Programming
    Replies: 24
    Last Post: 12-25-2002, 01:49 PM