I was at work last week and one of our "lead developers" (who said he has programmed C++ before, but I don't believe him) was talking about C++ and how our team of developers who only know PHP would not have a hard time at all learning C++.

My first reaction was pure shock and then I laughed at his comment. He gave me a bad look and i asked if he was serious. Me personally I program a lot of C and C++ for mostly school projects and coding competitions. I don't think it's at all like PHP. I asked him why they were the same and he could not give me an answer (he doesn't know C++ at all I was thinking). Then I said "OK, yeah they both use curly braces and have conditional statements. But C++ you have to worry about memory management and all the easy to use built in functions in PHP, for example the array functions, are non-existent in C++. You actually have to know the algorithms behind them.". There are some great C++ libraries (STL, Boost) that will make your life easier but C++ is like PHP, come on!

If you already know one language it will make it a little easier to learn another because you will already be good at boolean login (if this then that) or looping but there is just so much more to C++ than PHP. Like you have to compile the language and actually have to define what type of variable you are using and returning from functions.

What do you think?

EDIT: Actually what he said was "C++ is not much different than PHP"

  • 29
    C++ is easy once you know assembler.
    – spoulson
    Nov 8, 2010 at 13:42
  • 5
    I think, it's bullshit. Engaging in an argument with someone who is convinced of the opposite is futile. Maybe going with hiphop would be a nice compromise to avoid pointless yelling: developers.facebook.com/blog/post/358
    – back2dos
    Nov 8, 2010 at 14:05
  • 6
    @spoulson: Is that so? Then what in assembler prepares you for the shock of template-meta programming?
    – sbi
    Nov 8, 2010 at 14:46
  • 6
    I think pretty much the opposite is true -- PHP is easy after learning C++ or C, mostly because the syntax is similar and basic library functions at least look familiar.
    – tcrosley
    Nov 8, 2010 at 17:16
  • 2
    I saw this topic title and at first I was like this: O.O Then I was like this: -.-
    – Kaz Dragon
    Nov 11, 2010 at 14:21

7 Answers 7


As someone who went from PHP to C++ (though only limited C++) when I started writing C++, I often thought "Wow, this is a lot like PHP". When you consider that PHP itself is written in C, and whenever the developers faced a design decision they couldn't resolve internally, the final answer almost always ended up being "Do it like C++" it's really not that absurd a statement.

Your response about Memory Management and Array Sorting/whatever is a non-starter. That's not a PHP/C++ answer, that's a C++ with zero libraries versus just about every other popular language in existence answer. It feels to me like you're asking this question so that you can get people to agree with you -- that people who write C++ are so much better than people who write PHP.

Personally, I think that's a foolish point of view which will lead to nothing but poor decisions on your part.

  • 1
    PHP is written mostly in C, IIRC. Nov 10, 2010 at 23:57
  • @George Edison: You're correct, my mistake. I'll update my post to reflect that. Nov 11, 2010 at 13:42
  • 5
    How does the fact that PHP is written in C conclude that they have ANYTHING in common?
    – Karim Agha
    Jul 11, 2011 at 20:02
  • 1
    @ColeJohnson, if I'll write a LISP interpreter in C, will that mean that these to languages will have more in common?
    – Karim Agha
    Aug 16, 2012 at 1:30
  • 1
    @KarimA. exactly. Thats what I was getting at.
    – Cole Tobin
    Aug 16, 2012 at 3:16

Sounds like one "team lead" guy (also a PHP dev like yours) who told me that C++ "sucks, take templates for example". Much as I try not to, lines like those always flip the infamous bozo bit with me.

Your friend has a HUGE problem here, namely he is so overconfident that he does not know how much he does not know.

Saying that learning C++ is easy once you know PHP is like saying that once you can drive a Segway, it would be quite easy to learn operating an Airbus A-380, because, 'you know, they both have some wheels to stand on and are controlled by advanced embedded circuit boards.

  • 3
    You nailed it. "he does not know how much he does not know." This a bug for most C++ beginners.
    – Armando
    Jun 24, 2011 at 4:52
  • Eh, i don't know how much i agree with that. I basically know about 95% of the quirks of PHP. I was able to learn Java and Python in a single day. I jumped right in on a few C++ opensource projects and nailed some pull requests with ease, and bug free code. The thing that overwhelmed me was pointers, templates, and the seemingly endless variable types. I am able to do very simple things in C++. To master it, i can see myself spending about 3x the amount of time(6 months) it took me to master PHP.The reason i could jump write in to C++ was because of the similarity in syntax
    – r3wt
    Feb 10, 2015 at 22:03
  • 1
    @r3wt Well you basically just reinforced my arguments. Like I said, many C++ beginners have no idea how much they don't know. Jumping on the bandwagon and producing some code in a week is not so much of an issue for most of at least somewhat competent programmers. We all try out a new language once in a while. And we can jump on it rather quickly because a lot of imperative languages bear many syntax similarities. However saying that you could become a master in C++ in 6 months, no offense, shows that you too don't know how much you much you don't know.
    – Jas
    Feb 11, 2015 at 7:03
  • @Jas the estimate was 18 months 3 * 6 = 18
    – r3wt
    Feb 11, 2015 at 9:28
  • @r3wt - Sorry, it sounded as if it took you in total 2 months to learn PHP, which I wouldn't be surprised of as PHP is such a joke of a language. Anyway, let's get it rolling and let me know how you fare with C++ mastery in 18 months from now :)
    – Jas
    Feb 11, 2015 at 12:45

There is programming as a skill independent of any language, and then there is knowledge of a specific language's constructs, libraries, and conventions. You can be great at the former and suck at the latter (for a specific language) or vice versa.

Without knowing anything about your team, we can't say whether they'd be good at C++. And there are various ways to write C++ too, as some people get themselves stuck 20 years ago without the stdlib, boost, other libraries, or even without compiler features everyone else takes for granted.

However, there are a lot of problems with C++, and as someone that both loves and hates it, yet still has it for the highest count on SO, I'll be the first to admit it really sucks at times. Then again, the more you know about a language, the more you find out how it sucks. If there's any tool where you consider yourself an expert, yet you can't name at least 10 ways it's broken, inadequate, or you just hate it... :)


Sounds like you called out a bluffer (I refer to the fact that he couldn't back up his statement) :). This is no bad thing as long as it's done politely, respectfully and with technical merit.

  • yeah, at first i thought he was making a joke, which is why i laughed...
    – gprime
    Nov 8, 2010 at 15:37

I think your "lead developer" should consider another line of work. Seriously, though, this usenet post I saw a year ago about C++ says it all:

I don't know about you, but there's something really scary to me about a language where copying state from one object to another is this complicated. By now, I suspect at least a dozen or two programmers have contributed something new to this discussion. If it takes this many programmers to write a simple assignment operator, think how complicated writing code that actually does something meaningful must be!
  • 4
    I have no idea why people complicate copying in C++: T& operator=(T other) { swap(*this, other); return *this; } friend void swap(T &a, T &b) { using std::swap; swap(a.each_member, b.each_member); }
    – Roger Pate
    Nov 8, 2010 at 13:50
  • 1
    @Roger: What's in the swap function? Does it need to be a separate function? If so, why? Nov 8, 2010 at 13:53
  • 1
    @Roger: I'm not going to try explaining anything in Haskell to the average programmer, especially not monads, which is what I would normally use for managing state. Nov 8, 2010 at 14:28
  • 2
    in our company bad programmers get promoted to lead positions because the business guys think they wont be programming anymore. Good programmers always end up quiting because of this and they can't figure out why they are all leaving. Stupid office politics...
    – gprime
    Nov 8, 2010 at 15:38
  • 1
    @Larry: C++ suffers from/revels in the same kind of problems Lisp has had. Its users rarely just want the simplest answer to deal with today's problem. Rather, they're basically developing a philosophy of programming that deals with entire classes of problems. For years Lisp had similar debates: Should cons cons its arguments? (and/or should const evaluate its arguments?), lexical vs. dynamic scoping, is it good to treat nil as equivalent to false?, etc. All of these (and more) have been debated at tremendous length --by comparison, debates over C++ are fairly trivial. Nov 8, 2010 at 16:45

Just as a first thought, he could be referring to the syntactical styles. Yes there are a few differences in how certain things like string concatenation and arrays work but they are easily enough learned. Then there are pointers and things of that nature but once again, if you have solid knowledge of basic CS concepts then it shouldn't be a problem. I don't think that the statement is that far out of the ballpark, but I am by no means saying that it would be easy. C++ is a tough language to tackle.


Why is everyone always griping about memory management in php? Just because the language attempts to do garbage collection for you, doesn't mean that it's adequate, and you can forget about it. The memory you use in PHP does matter. And that's why you use functions like memory_get_usage(). Just because PHP is very forgiving and allows some awful practices to compile, doesn't mean that you should use awful practices in writing code. The biggest difference I see between php and C++ syntactically is that PHP has less brutally ugly syntax. If you compare PHP and C++ in the scenarios you would use PHP, they're very similar. You just need to remember to top load your libraries in C++, which I find annoying. C++ does appeal to my inner need to control every detail of execution, though.

Not the answer you're looking for? Browse other questions tagged or ask your own question.