★ TouchArcade needs your help. Click here to support us on Patreon.

PHP and C++ how far apart

12-04-2009, 09:56 AM
#1
Joined: May 2009
Location: Japan
Posts: 173
PHP and C++ how far apart

Ok, I've been toying around with the idea of throwing my hat in the ring. How much work am I going to have to do to get my C++ straight? I'd rank myself as a high intermediate with PHP. Is there any specific resources that'd help me bridge the gap? I've heard the two aren't worlds apart.

I'm not planning a game at this point, just a educational app. And even then only because I can't seem to buy what I'm looking for and I'd like to be able to study better.

Basically, I'm looking to make flashcards and quizzes for Japanese.
12-04-2009, 10:51 AM
#2
Joined: Sep 2009
Location: Georgia
Posts: 314
I work with a zillion developers. They all seem to agree that moving from PHP to C++ isn't all that difficult and that the languages are quite similar. I'd say dive into the C++ stuff and see for yourself. In the end only you can judge how easy or difficult the transition will be for you.

Q

Quorlan

12-04-2009, 10:58 AM
#3
Joined: Feb 2009
Location: San Jose, CA
Posts: 546
Syntactically, they are similar. However, there are some hurdles you need to get through:

1. PHP is a scripting language, C++ is compiled
2. C++ is a strongly typed language (eg: you need to declare and type all your variables)
3. I don't recall how extensively pointers are used in PHP but in C++, they are used a lot
4. Depending on how extensively you used classes/object-oriented features of PHP, classes in C++ may or may not be confusing

Also, the 'flow' of writing an application is much different than writing a webpage. All of a sudden, you have to deal with all sorts of things that didn't even occur when writing web pages (assuming your PHP experience is with web pages).

That said, the PHP experience definitely helps. Things like conditional statements, loops and your understanding of arrays and other data structures will transfer easily. Having done C++ first, it was easy to then learn PHP. I think the reverse is much trickier (PHP -> C++) but it'd be worth learning.
12-04-2009, 11:52 AM
#4
Joined: Sep 2009
Location: Brampton, Ontario
Posts: 344
Why would you go to C++ not Objective-C? I think you'll find it's easier to get into Obj-C than just straight C++.
12-04-2009, 12:17 PM
#5
Joined: Apr 2009
Location: San Francisco, CA
Posts: 1,680
Send a message via AIM to dogmeat
Quote:
Originally Posted by jonlink View Post
Ok, I've been toying around with the idea of throwing my hat in the ring. How much work am I going to have to do to get my C++ straight? I'd rank myself as a high intermediate with PHP. Is there any specific resources that'd help me bridge the gap? I've heard the two aren't worlds apart.

I'm not planning a game at this point, just a educational app. And even then only because I can't seem to buy what I'm looking for and I'd like to be able to study better.

Basically, I'm looking to make flashcards and quizzes for Japanese.
they are extremely different and are not similar in any way other than they are programming languages. You will have a difficult time learning the syntax of C++ or objC if that's what you're going to use.
12-04-2009, 12:29 PM
#6
Quote:
Originally Posted by ElectricGrandpa View Post
Why would you go to C++ not Objective-C? I think you'll find it's easier to get into Obj-C than just straight C++.
C++ is not really any harder to learn, and has wider application outside of the world of iPhone development (basically only Apple do it), it's also faster and has various features Obj-C doesn't. If you're planning on using OpenGL for your iPhone app you can basically avoid having more than a tiny smattering of Objective-C.

On the other hand, all the example code you're likely to find for the iPhone is in Objective-C, Cocoa is an Objective-C API, if you want to use the interface builder... etc, etc.

Alien Swing is available from the App Store now!
Follow my development blog at Mr Jack Games
12-04-2009, 02:05 PM
#7
Joined: Sep 2009
Location: Vancouver, Canada
Posts: 977
Send a message via MSN to MindJuice Send a message via Skype™ to MindJuice
Quote:
Originally Posted by dogmeat View Post
they are extremely different and are not similar in any way other than they are programming languages. You will have a difficult time learning the syntax of C++ or objC if that's what you're going to use.
I'm not sure how you can say that they are "not similar in any way". If you ignore the HTML stuff around it, the core syntax of PHP is totally based on C. if(), for(), while(), switch(), array syntax, comments, operators, assignment syntax, etc. are all the same. This carries over to C++ and Objective-C too.

Of course there are differences, but I don't think someone who really understands PHP, including PHP classes, would have that much challenge learning the basics of C++.
12-04-2009, 02:49 PM
#8
Joined: Apr 2009
Location: San Francisco, CA
Posts: 1,680
Send a message via AIM to dogmeat
Quote:
Originally Posted by MindJuice View Post
I'm not sure how you can say that they are "not similar in any way". If you ignore the HTML stuff around it, the core syntax of PHP is totally based on C. if(), for(), while(), switch(), array syntax, comments, operators, assignment syntax, etc. are all the same. This carries over to C++ and Objective-C too.

Of course there are differences, but I don't think someone who really understands PHP, including PHP classes, would have that much challenge learning the basics of C++.
Sure, they're similar in the sense that they're programming languages that use if statements and whatnot, but that's about it. If you don't know how to lay down the syntax for these things in objC, what's the point?
12-05-2009, 10:04 AM
#9
Joined: May 2009
Location: Japan
Posts: 173
Thanks for the replies everyone, you've given me a lot to consider. I appreciate all the input!

While I'm not totally comfortable with classes, I understand their theory. I did manage to write a pretty robust chess program in php, so I hope it won't be as impossible as dogmeat (nice name btw) suggests.

thanks again.