Basics of Building a website in C++ with POCO or CSP

I learned php a few months ago, built a high volume trading application. two weeks ago, it was hacked. for a while i've been feeling discouraged, but i've realized that i was never meant to be a php programmer, because you can't write anything securely without a framework, which seems like a huge waste of time to learn. I thought of trying ROR, then i thought of node js, but i keep coming back to a burning desire to write C++. it has a similar syntax to php, and i find it extremely easy to read and understand however, my knowledge of C++ consists of some minor dicking around with bitcoin's source code and compiling it under windows/unix.

So, my question really is more of a crash course of what i need to learn, but haven't necessarily found anything descriptive on the internet.

i need to know:

1. a crash course on creating a website with either POCO or CSP, something that will allow me to avoid pointers and memory management, atleast until i have gained the basic understanding of C++.

2. i need to learn simple ways to accomplish the following tasks:

a. for loop i use in php often to render results to the view(webpage)

for(i = 0;  i < mysql_num_rows(query); i++){ 
//script here 
foo = mysql_result(query, i, "foo");
bar = mysql_result(query, i, "bar");
echo foo."</br>".bar."</br>";

b. while loop

while(row = mysql_fetch(query){ 
//script here

c. connection to a mysql db.

d. a mysql query

e. building a real time websocket(for a chat, or a real time orderbook display, etc.)

f. handling get requests and post requests in POCO or CSP.

g. passing variables to jquery/javascript with C++

h. working with arrays( php equivalents of: array(), in_array(), array_sum(), print_r()etc.)

i. database transactions( i dread learning this again but its a must)

j. equivalent of php's switch() function if possible.

k. equivalent of php's `hash` function which roughly would look like

hash('sha512', variable . salt);

l. best way to generate randomness(numbers, strings, etc.) for password salting/csrf tokens etc.)

m. how to properly construct functions and classes in C++.

n. if its possible to wrap cout>> in a function, to making printing things in html simpler(like echo and print do in php).

additionally, a quick run down of syntax rules/common pitfalls would be appreciated. the bitcoin code is so complex i really haven't gained much knowledge of C++ other than the basic things(if statements, type casting(for integers, though i really don't understand all the differences), basic syntax rules like braces, semicolons.)

aside from this knowledge, about the only thing i would need help with is library linking, file inclusion rules, and general compiling help for POCO/CSP. thanks!

admin, feel free to move as necessary, though i suppose beginners is the most fitting forum for me
Last edited on
What is CSP?

Yes, PHP is similar to C. Most underlying actions such as sockets for communication are done in C because PHP would be far to slow.

The first thing in C++: you have to learn that it's strongly typed unlike PHP. I'd suggest to take look at the tutorials and references on this site for first steps.

i was never meant to be a php programmer, because you can't write anything securely without a framework
Hm, frameworks are the PHP equivalent for the libraries in C/C++.

You can do everything you mention with C++. You may take a look at Wt:

Appart from that POCO comes with several examples. So I suggest take a look at them.
Also take a look at MySql homepage to get the library and documentation.
That's relatively impressive that you knocked out a high-volume trading app with only a few months of PHP. Kudos to that!

I have been evaluationg Wt and Poco for a short time. I've been working with PHP for 10 years or maybe more and have similar short term requirements from a C++ framework.

I started with Wt while keeping the Boost libraries in mind, and I am now looking at POCO. I am not a super wiz-bang with C++, and I'm finding I need to drop back to learn some C++ concepts I've never truly worked with.

From my perspective, both libraries use what I see as advanced abstraction, and Wt uses quite a bit of templating. With the time I'll spend getting up to a comfortable point in C++ to use these libraries properly, I almost could drop back a notch and spend some time learning Boost, and maybe build some of this myself.

Both communities, while helpful, have slightly less patience for lack of C++ skills as opposed to general library implementation, so Jumping to a C++ web app is going to take some commitment (again, my perspective).

I need to check out CSP now.

Oh ya, installation and compiling.. Probably a good idea to get comfortable with Make as well.
Last edited on
coder777, you're my hero. Witty sounds amazing, particularly since it has its own DBAL and all of the things i mentioned in my post. thank you good sir.
Topic archived. No new replies allowed.