What is the best way to develop a C++ web application? [closed] - c++

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
What could be the best way of developing a C++ web application? The web app would be run on Apache HTTP server. How can you overcome challenges like sessions, persistence, context switching, multithreading etc with C++? How could one utilize C++ in best possible way to make it work like Servlets?

Take a look at 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.
It's not free for commercial use though.

Use C++ web framework like CppCMS if you like web-like
development, it is oriented for high performance and works with .
It provides:
FastCGI, SCGI and CGI interfaces.
Form processing and validation
HTML Templates system
Session management
Cache system
Transparent scale up to numerous servers.
You may give a try to Wt but it is much more
like writing GUI using browser rather then traditional web development tool.

I'm saying this as a C++ developer...
I would probably consider using Java instead. Since Java is much more commonly used for this, you'll find way more existing libraries to leverage. If you ever want to hire more people, you'll have an easier time finding web-app Java developers than web-app C++ developers.
If you insist using C++, check out:
http://rudeserver.com/

You can use Qt framework, Boost & Poco libraries to do web development in C++. Qt & Poco have DB support for various RDBMS. You may look into Axis C++ if you need to develop web services in C++. ClearSilver has C library to handle CGI and you can use C++ on top of it. Plenty of choices for you!

How can you overcome challenges like sessions, persistence, context switching, multithreading etc with C++?
The answer is what you'd expect it to be: pick libraries that handle issues when possible (multithreading) and implement libraries where necessary (generating a session key and storing it somewhere like a database).

Take a look at the Snorkel Embedded Web Server SDK. Its easy to use and produces the fastest web application solutions. http://sites.google.com/site/snorkelembedded

Try experimenting with the ffead-cpp framework, check out the home page for more information...

Related

Web Services using C++

I am building a server-client application that involves heavy signal processing (e.g. FFT). I have a working application written in C++/Qt, where everything (signal processing and other calculations) is done in client and server just sends raw data. Now I feel it would be easier to implement these features on the server. So, that maintenance becomes easier.
As I am doing signal processing, I think I should stick to C++ for performance. But I am open to new ideas.
Constraints:
I need type checking so javascript is out of discussion.
Scaling includes adding more server and each server will have at the max
10-12 users. So, Hardware cost is important. I cannot use x number of
i7 processors.
No option of using cloud services.
So, right now my question is as follows:
How can I create web services using C++ for Linux server? (Although cross platform is not important, I would appreciate if I can achieve it.)
EDIT [02:09:2015]
Right now, I think the choice is between poco and C++ Rest SDK. I feel I should go for C++ Rest SDK. Mainly because it has only those features that I need. And Also it is supported by microsoft and uses boost internally. So, I feel in future, this might be well integreated with standard.
You could use cross-platform Poco library to implement HTTP server, it is really straightforward with this framework, and they have a lot of examples. You can also use JSON serialization (like rapidjson library) to implement REST service on top of HTTP - this way your Web service will be accesable by most of the modern Web frameworks.
You might want to take a look at the C++ Rest SDK, an open source, cross platform API from Microsoft.
Like #nogard suggested, I also recommend POCO for now. It's the most serious and feature-full solution. Given you mentioned Qt, I suggest you to take a look at Tufão.
EDIT:
I forgot to mention one comparison of mine on the C++ HTTP server frameworks.
If you directly handle HTTP requests, you might loose the functionality what Web Servers does well what it was build to do. I had a similar issue, what I did was wrap up my Qt c++ code inside a PHP extension. In your case you can do the same. Wrap your logic inside what ever technology you are about to use, doesn't matter it's PHP, net , Java or anything else.

External Web Interface for a C++ Application [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I am developing a web interface for a C++ application that runs on an embedded system.
I was wondering if it was possible to make a web interface that could be used to manage (set and get values) and display data provided by the application. (Something like Nagios.)
My question is: is there any technology that allows me to "communicate" between the Web interface and the C++ application?
Keep in mind that I have to do this on an embedded system, so I can't use frameworks or other things that are too heavy.
The Web Interface has to be outside the C++ Application (I don't want to code the interface in the C++ Applicaiton).
My idea was to use HTML5 and Javascript for the Web Interface, the web server which i will use is also lightweight (nginx).
If someone could give me any pointers it would be nice. Thank you in advance.
So you need two things: a local interface your web page can use to configure the C++ app, and the web page itself.
There are a few common mechanisms for such local interfaces:
modify a config file, and send SIGHUP to make the application re-read it
advantage is that you can test (and use) it directly from a shell, independently of the web interface
also note that changes persist automatically
disadvantage is that you need some scheme for storing a "last good" config file in case the edited one is damaged
use a local streams socket and simple protocol (either a UNIX socket if supported, or a localhost:port loopback-only TCP socket)
advantage is that you don't touch (and possibly damage) the config file(s)
disadvantages are that you then need some other way of persisting changes, if you want to, and that you have to write this protocol in the first place
note that so long as the protocol is text-based and not binary, you can at least still test it with telnet or netcat, so you can still use it directly from the shell
simple protocol like set variable=value, get variable etc. shouldn't be too hard
If you really want to decouple the web and C++ applications, make sure you can query the available options, ideally giving types, valid ranges and groups for them. Then, you can avoid re-coding the web page every time you add or modify an option.
You can manage that with magic comments in a config file (make sure nothing is silently defaulted with no comment), or with a list command to the stream socket.
With a bit of effort, you can probably build your grouping, data type and validation constraints into the type system of your C++ application, so both the local interface and web app can be driven automatically.
If you drop the requirement that the web server be in a different process, there are a bunch of solutions
lightweight web servers

Writing C++ for the Web [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
Is it possible to create a C++ application that can be run trough the browser? Is there any way to link C++ application with a database (that can be used by both Mac, Linux and Windows).
It's perfectly possible to do it, back in the day (when there was no PHP around), many web applications were written in C++. There is a standard called CGI that facilitates communication between your application and your web server. This tutorial shows hot to set it up for an Apache web server, using Perl as the target language. You should be able to write a C++ program that prints out the same text and test it.
Databases can be accessed using C++ using a variety of libraries, depending on your needs and database system.
While all of this is totally possible, I'd be interested why you would do such a thing in the days of sophisticated frameworks and languages that are far more suited to web applications than C++. I'd certainly not recommend it.
CGI or FastCGI for server side C++.
NaCl for client side C++.
Database connections with things like MySql Connector.
If by "through the browser" you mean a webapp, yes - you can write CGI applications in C++, as in most other languages. See the answers to this question.
wt is a toolkit that may make it easier for you if you come from a desktop background.
About the portable database layer, take a look at these two questions. If all you need is a database that works across platforms, but don't need to be able to switch database engines across platforms, SQLite may be the way to go.
If you mean by "run through the browser" to run native code in the browser the only way I know of to execute native code in the browser is Google's NaCl.
For server side C++ no special rules apply and it's very common. All normal rules for C++ application (including databases and linking) apply here.
Any scripting langauge can run COM. You can create COM objects in C++ that you can invoke serverside from php.
Is it possible to create a C++ application that can be run trough the browser?
I'm not sure what you mean by "run through the browser" (or, for that matter, "C++ application"). pmr has already mentioned Google NaCl as one option. If "C++ application" includes C++ plugins, then "sure, you can." You can compile C++ to Javascript. If you're talking about web sites or web services, I can say "yes, it's possible; I maintain a web service that uses C++ for the backend, and Amazon was once written in C++, do you have any particular question?"
It's possible to write a lot of things in a Turing complete language. That doesn't mean it's a good idea.
Is there any way to link C++ application with a database (that can be used by both Mac, Linux and Windows).
Again, I'm not sure what you mean by "link ... with a database." You certainly can interact with a database using things like ODBC, DTL, LDAP or MongoDB. You also can embed a database in your program, using things like SQLite, MySQL embedded, Firebird embedded, Berkeley DB, LevelDB, or whatever Microsoft's calling Microsoft Jet these days. Do you have a particular question?

How does one port c++ functions to the internet?

I have a few years experience programming c++ and a little less then that using Qt. I built a data mining software using Qt and I want to make it available online. Unfortunately, I know close to nothing about web programming. Firstly, how easy or hard is this to do and what is the best way to go about it?
Supposing I am looking to hire someone to make me a secure, long-term, extensible, website for an online software service, what skill set should I be looking for?
Edit:
I want to make my question a little more specific:
How can I take a bunch of working c++ functions and port the code so I can run it server side on a website?
Once this is done, would it be easy to make changes to the c++ code and have the algorithm automatically update on the site?
What technologies would be involved? Are there any cloud computing platforms that would be good for something like this?
#Niklaos-what does it mean to build a library and how does one do that?
You might want to have a look at Wt[1]. Its a C++ web framework which is programmed more or less like a desktop GUI application. One of the use cases quoted is to bring legacy apps into the web.
[1] http://www.webtoolkit.eu
Port the functions to Java, easily done from C++, you can even find some tools to help - don't trust them implicitly but they could provide a boost.
See longer answer below.
Wrap them in a web application, and deploy them on Google App-Engine.
Java version of a library would be a jar file.
If you really want to be able to update the algorithm implementation dynamically, then you could implement them in Groovy, and upload changes through a form on your webapp, either as files or as a big text block, need to consider version control.
The effort/skillset involved to perform the task depends on how your wrote your code. If it is in a self-contained library, and has a clean (re-entrant, thread safe) API, you could probably hire a web developer (html/php/asp etc) to write the UI interface to the library for a relatively small cost. The skills required would be dependant on the technologies you wanted to use. For Windows development I would suggest C#/ASP. The applicant would require knowledge of interfacing with native libraries from a managed language. This is assuming that you dont mind the costs of Windows deployment for your application.
On the otherhand, if the library is complex or needs to be re-written to support the extensibility you are looking for, asking here will not get you much.
BTW: here is a great article on Marshalling if you chose to implement using C#/ASP
http://msdn.microsoft.com/en-us/magazine/cc164193.aspx
First, DO NOT USE PHP :D
I used it for some projects (the last one with symphony framework) and i almost shoot my self !
If you are very familiar with C++, ASP .NET could be a good solution because if you like C++ you are going to love C#.
Any ways, I personally use Ruby on Rails for 6 months now and I LOVE IT. I won't write you a book here but the framework is pure gold !
The only problem is that Ruby is a very special language. You will probably be a bit lost a the beginning. But as every one you will learn to love it.
But that was only for the server side. Indeed, there 3 technologies you won't be able to avoid if you want to start to develop web applications.
HTML, CSS and JavaScript are presents every where. This is why i'm thinking you should start by HTML and CSS then JavaScript (with jQuery).
When you've got some basics with these 3 technologies you should be able to choose the server side language.
But you've got to tell you one thing, it's not going to be easy !
PS : Ruby on Rails uses HAML and SASS. These 2 languages replaces HTML and CSS you should have a look at them quickly because they are awesome.

Should a novice programmer spend time learning to write "desktop" applications these days, or is the web where it's at? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
As a novice, I've spent time learning a smattering of C and a fair bit of PHP. I've looked at writing desktop applications for Windows, but there seems to be a fair barrier to entry due to complexity of APIs. Is it worth learning this, or will native applications become less common in the future?
The way I see it, the only desktop application I ever use is a web browser and a text editor as well as the obviously the OS itself. Everything I need is online now.
Is learning to write non-web applications a useful skill going forwards? If so, what should I learn?
I don't think it is ever a good idea to choose one side and stick with it religiously. I think a good engineer will expose themselves to as much as they can so he can make an informed decision about which is the best tool to complete a task.
In other words, don't choose a platform, OS, programming language, etc. and then ignore the others. It is best to be well-rounded in your skill set.
There will always be a market for native apps, although a lot of stuff is moving to the web and there's more scope than ever before for web based apps, native GUI applications are never going to go away entirely.
However, it's really, really hard to give you any really useful advice other than stick with what you like. If you use web stuff exclusively, it would be a bit foolish to go and become a windows GUI programmer :)
This may get modded down - but I'm going to say it anyway.
You can either program or you can't. About 18 months ago when I was looking for a new job, I was looking at the market and I was doing a lot of .NET but a few places wanted me to do JAVA.
I was doing Web Services, they wanted someone to do other stuff...At the end of the day it came down to this - if you know how to code you know how to code. If you're writing desktop apps right now and say in 6-8 months you want to move to some ASP.NET MVC, you'll be fine.
It may take you a bit of start-up time to learn the syntax and get a feel for some things - but in the end you'll be fine. I say this holds true for all the new languages...Skill is skill
Non-web applications will be very useful for the far future (as I see right now). We will not be able to do anything with the efficiency as a well written desktop application online using an interpreted scripting language that has to use a network protocol to communicate with the client.
However, if you are interested in networking, maybe you can try a little of both. Make an rss reader, a simple web browser, or an IRC client. Their all great projects.
You should learn whatever you want to learn. If you don't you'll probably find it harder going than you need to.
I personally started writing desktop applications for Windows, because I used it at the time. These days I do think that you're correct - you can produce a website / online-application without investing so much into the process.
But even writing a decent web application is going to be hard if you're new to programming. A standalone page is simple, but when you add databases, security, and administration into the mix then things can grow.
In my oppinion, a novice should conentrate on the basics and internals of the language of choice. Graphical or web interfaces should wait until you know what you're doing in the backend. I personally would suggest you start with console programs, but I guess that depends on the platform you're using. Maybe desktop interfaces are easier to start with on Windows.
The best practice (in my oppinion) is to write a solid backend with the functionality you want to provide and write it in a modular way, so you can later decide if you want to provide a desktop interface or a web interface (or both). The choice for the user interface shouldn't matter in the beginning.
Learning non-web applications will always be useful. There will always be applications that are not suited to be web apps. Even if everything moved to be a web application, the server side code and web browsers still need to be written.
At this point in time, if you're interested in the Windows platform then I would advise looking into C# and WPF. Those technologies are used in both native and web environments.
Web development is all well and good but the majority of systems even if they have a nice web front end still consist primarily below the web level, a bit like an iceberg.
End most web implementations are n-tier in design with the lower levels like data access and integration with peer servers ocurring in non web languages.
As I see it there seems to be one pervasive language that can touch all these levels and than is .Net Framework. Notice I make no specification about c#, vb etc. I consider that to be a matter of taste. However I can't remember seeing an n-tier banking website using php to do the data layer. Nor an online ordering website that would use ruby to talk to its jd edwards server.
This is where the heavyweight languages still pervade and if thats where you want to work then learning the .Net framework in whatever language variant you choose is the way to go.
Master one discipline then move to the next one.
I am also at the very infancy of learning business application development. The very step I took was to study database. Majority of the applications in the real world is data-centric. It is good to start with desktop application. Do some drag-and-drop then study the code behind. I am doing the same thing with ASP.NET. I have downloaded tons of starter kits. It all depends on your learning style. For me, I can learn more easily by "learn-by-doing" than by digesting chunk after chunk of set theories. That is why cookbook and headfirst books perfectly work for me.
I believe that the future development model for "Web" applications will more akin to the current model of desktop application development. By which I mean that tomorrow's Web apps won't be HTML/AJAX efforts that are difficult and expensive to maintain, debug and test, they'll instead be developed with compiled languages that target a platform that's already available in the browser. Flash, Silverlight, and (to a lesser degree, it appears) Chrome are the current paragons of this idea.
So maybe it's not such a waste of time to learn those "complex" APIs. My group builds WPF applications and I personally don't find those to be any more complex than the the current crop of HTML/AJAX projects.
From your background in languages, I noticed you only mention PHP and C. Neither language is strictly speaking an object-oriented/OO language. You really should learn a traditional OO language like Java or C#, as the majority of jobs are looking for those skills. BTW, read Yegge's advice on what languages a professional developer should learn, and think for yourself about what you should do.
Assuming that you're interested in enterprise application development, I would have to say that that field is transitioning from traditional web development (present stuff from a database on a web page) to rich internet applications (still present data from a database, but the front end begins to approximate a desktop application). Building a rich internet application will require concepts that desktop UI developers have known for a long time. Therefore, I don't think you have to chose between web development and desktop development.
I agree, you should learn what you want to. Once you have an understanding of Web, then learn some desktop programming to broaden your horizons a bit. You'll never know when you'll need it.
But, also, if you're looking at learning windows desktop development, then you should definitely look at C# and/or VB.NET. The .NET Framework is by far the easiest way to develop desktop app for Windows; much easy than C++ from what I understand (I actually didn't spend much time on C++ myself).
#Rich Bradshaw,
I think you can get answer on your question by looking at any job seeking site.
what should I learn?
Whatever you like and can bring you enough money.
Thats a very good question.
I know nowadays that most app development that im aware of is web apps.
But with languages such as flex , i wouldnt be suprised if the desktop apps came back again.
To be well versed you should do both. Skills in one area may or may not translate into the other very well. The lack of state for example trips up lots of desktop developers when they start building web apps. Of course, your experience may vary
A professional .NET programmer should handle both webform and winform.
Even you start from webform, but finally, you will have chance on touch winform.
Just like a topic "VB vs C#", you will not see a .net expert talk about that, because finally, you should know both of them.
There will be cases where things beyond the web can be used:
Scripting languages/console application - build scripts come to mind here for an example but also writing batch or command files to do simple tasks like handle deployment or to do some other simple task that is likely better done from within a black box rather than manually doing something over and over again.
Windows services(WCF) - These are also possibly useful for monitoring things and sending off those, "Server is down!" messages for someone to go and find out what went wrong.
There is also something to be said for middleware and back-end development where one would write web services or handle querying a database or inserting data into a DB that may not be the same of front-end web UI work, just to give a couple of other examples of software development work out there aside from the embedded systems and mobile stuff that is also non-web and non-desktop development in a sense.