PHP and C++ how far apart

Discussion in 'Public Game Developers Forum' started by jonlink, Dec 4, 2009.

  1. jonlink

    jonlink Well-Known Member

    May 26, 2009
    173
    0
    0
    Sasquatch
    Japan
    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.
     
  2. Quorlan

    Quorlan Well-Known Member

    Sep 5, 2009
    314
    0
    16
    Game Designer
    Georgia
    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
     
  3. lazypeon

    lazypeon Well-Known Member
    Patreon Bronze

    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.
     
  4. ElectricGrandpa

    ElectricGrandpa Well-Known Member

    Sep 5, 2009
    344
    0
    0
    Game Developer
    Brampton, Ontario
    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++.
     
  5. dogmeat

    dogmeat Well-Known Member

    Apr 6, 2009
    1,680
    2
    0
    Information Security Engineer
    San Francisco, CA
    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.
     
  6. Mr Jack

    Mr Jack Well-Known Member

    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.
     
  7. 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++.
     
  8. dogmeat

    dogmeat Well-Known Member

    Apr 6, 2009
    1,680
    2
    0
    Information Security Engineer
    San Francisco, CA
    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?
     
  9. jonlink

    jonlink Well-Known Member

    May 26, 2009
    173
    0
    0
    Sasquatch
    Japan
    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.
     

Share This Page