Is it possible to combine C/C++ with web languages? [duplicate]

I would like to create a web application (meaning that will run from browser). The point is that I want to write just the UI in HTML5 + CSS + JS (or maybe even some PHP). On the other hand, I want to write the functionality of the application in C or C++. Then, I want to combine the code about the UI and functionality. Therefore, I would like to ask, whether it is possible to combine C/C++ code with web markup/programming languages?

8

There are a couple ways of using C or C++ in the web world.

The ancient method is CGI. With this approach you have a web server that is configured to launch CGIs fork and exec the CGI when requested. The problem with this is that the fork and exec is rather heavy weight. If you have 1000 simultaneous connections, it means you have 1000 processes running – not ideal.

Moving a step closer to the web server, in particular apache this time, one could write a module for it in C which handles the code. This lives within the web server as a library and is much faster, though it means tightly integrating with the apache environment which isn’t always trivial. The most recent book for this approach was published in 1999 and is likely a bit dated.

Other web programming languages and stacks have moved to an application server structure. With this approach, it is designed for hosting lightweight (rather than the heavy fork and exec) processes, often with a focus on a web facing interface for the applications.

Wikipedia lists a few C++ application servers:

  • Tuxedo – Based on the ATMI standard, is one of the original application servers.
  • Tntnet – Includes a template engine which allows embedding C++ code in HTML pages. Templates are compiled before run-time, and thus
    very fast. Multi-threaded, supports object lifetime via scoped
    variables.
  • CPPSERV – C++ servlet container.
  • Wt – A web toolkit similar to Qt permitting GUI-application-like web development with
    built-in Ajax abilities.
  • POCO C++ Libraries – A collection of open source class libraries including Poco.Net.HTTPServer.html
  • CppCMS

The key point with this is you likely need to work within another framework. Writing a multithreaded scalable web application is beyond the means of most programmers.

Do realize that hosting may be an issue. Nearly every web host offers php, and many offer tomcat (java). You would have to do some digging to find one that offers one of the above application servers (very few offer cgi now days and even fewer would allow for random application just to run).

One of the advantages of languages that were coupled to an application server early in their development is that the structure of the application is consistent (java has the .war file which is the same no matter what container you deploy to – unless you’ve written container specific code). C++ containers appear to be incompatible between each other (I welcome any corrections on this matter).

3

What about developing your app functionality as a separate server and communicate with your UI using REST (or SOAP)? JS can process these messages and update UI. IMHO it is a better option.

Is this solution viable to you?

You can use tools like emscripten too, this converts LLVM bitcode into javascript. You can combine this with clang or clang++ to run your C or C++ in the browser. (Actually on the client side, unlike CGI)

(Unreal did their html5 port this way!)

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật