Writing C++ for the Web [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 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?

Related

How to measure the SNMP performance of C when compared to other languages?

Iam looking at software that opens up a data set and grabs a list of server ips and pings them. Someone familar with this software packge says there is nothing else faster because the software is built on C++. Short of rebuilding the app in java is these anyway i can confirm what is the best language when building an app around snmp?
I know the question of C performance is posted all over the place but I do not see anything related to SNMP. When your core application is somthing like snmp is there a prefered programing lang?
The performance of an SNMP client isn't likely to have much to do with the implementation language. The network and the responsiveness of the server are the rate-determining steps.

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

language and database suitable for data driven game like football manager [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I have a Cricket management game (like Football Manager) written in VB 6.0 long back. It uses MS-Access as it's back-end and win-32 API calls to draw UI screens. It's a reasonably big game with 90,000+ lines of code.
Now, I want to re-write the game using other technologies like Java, Python, C++ etc. Basically I want to get out of Microsoft technologies (and preferably move to technologies that are available for free).
So, please help me out in choosing right technologies for Application-Logic, UI and Database. Below are my broader requirements regarding the three layers.
Application-Logic:
The game needs to make 1000s of calculations on in-memory data and constantly write that data to text files (Save game files). It also needs to do very fast database operations.
UI:
The UI need not be very robust. The only requirement is to be able to develop good looking screens with minimal animation effects. Below are the links to current screen images for your reference.
http://imageshack.us/g/148/89832593.png/
I might also add 2D graphics in the future.
Database:
The database contains around 20 tables with the larger tables containing up to 300000 records. Again, I want to use a free database like MySQL or flat text files. I am very curious to know about the database used by games like "Football Manager" or "Cricket Coach 2011"
Note: Please don't consider the efforts required to learn the proposed technologies. I will take care of them.
Update:
Now that I have decided to go ahead with C++ and SQLite, please direct me regarding the IDE and basic Tools/Libraries I should be using to start with.
I am already experienced in working with "Visual Studio" and "Eclipse". Can I use one of them? or can I go with QT (I read that QT is cross platform, but, is it just for mobile development or can I use it for desktop apps too)?
And,
How critical is the IDE selection initially?
Can I move to a different IDE at a later stage?
If I use Visual Studio, am I getting bound to Microsoft technologies?
If possible, please give me links to any examples to develop screens as in the links I provided above.
[I see now that an "online game" was an assumption on my part. So keep that in mind as you read this.]
I would take into consideration your hosting options. If you want to open-source this or operate it on a shoe-string budget, and run it on the widest array of available hosting services, then you probably want to go with LAMP technologies. This would rule out my favorite language, Java, as the underlying choice of language. PHP is almost always available on inexpensive hosting options. Perl and then Python are also available on many hosts, but PHP is practically guaranteed these days.
If however, you'll be hosting this in a "whatever it takes" environment, I'm a big fan of Java, Tomcat, JBoss, etc. But those technologies, while powerful, take a lot of time to ramp up to use, but more importantly, to use effectively and efficiently.
MySQL is a great choice these days for databases. Postgresql is another free option (in some ways, maybe free-er than MySQL, given MySQL's Oracle connection.) But MySQL is likely to be more readily available on a lot of inexpensive hosts. MySQL also qualifies under "very fast operation."
Regardless of database choice, do what you can to abstract your database code so that should you want to change (or need to change) you can do it with minimal fuss. PHP and Java both have well worn ORMs to help you in this regard.
It'd be interesting to see what kind of data models are used in a game like a * Manager title. I suspect it maps well to a relational database. But I'm personally on the lookout for a good reason to dabble with a NoSQL solution.
HTML and CSS for the client to start.
For a database, I would recommend SQLite: http://sqlite.org/
It's free, fast, and serverless. Serverless being key. There are some drawbacks that you can read about on their website, but for a stand-alone application, it should be much better than using text files.

What is the best way to develop a C++ web 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 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...

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.