Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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"

share|improve this question
25  
C++ is easy once you know assembler. –  spoulson Nov 8 '10 at 13:42
4  
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 '10 at 14:05
5  
@spoulson: Is that so? Then what in assembler prepares you for the shock of template-meta programming? –  sbi Nov 8 '10 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 '10 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 '10 at 14:21
show 8 more comments

closed as not constructive by Yannis Rizos Aug 15 '12 at 0:04

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.If this question can be reworded to fit the rules in the help center, please edit the question.

7 Answers

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.

share|improve this answer
1  
PHP is written mostly in C, IIRC. –  Nathan Osman Nov 10 '10 at 23:57
    
@George Edison: You're correct, my mistake. I'll update my post to reflect that. –  EricBoersma Nov 11 '10 at 13:42
3  
How does the fact that PHP is written in C conclude that they have ANYTHING in common? –  Karim Agha Jul 11 '11 at 20:02
    
@KarimA. How does the fact that the original C++ compiler was written a bit in C? –  Cole Johnson Aug 15 '12 at 3:28
1  
@KarimA. exactly. Thats what I was getting at. –  Cole Johnson Aug 16 '12 at 3:16
show 3 more comments

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.

share|improve this answer
1  
You nailed it. "he does not know how much he does not know." This a bug for most C++ beginners. –  Armando Jun 24 '11 at 4:52
add comment

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... :)

share|improve this answer
add comment

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.

share|improve this answer
    
yeah, at first i thought he was making a joke, which is why i laughed... –  gprime Nov 8 '10 at 15:37
add comment

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!
share|improve this answer
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 '10 at 13:50
1  
@Roger: What's in the swap function? Does it need to be a separate function? If so, why? –  Larry Coleman Nov 8 '10 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. –  Larry Coleman Nov 8 '10 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 '10 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. –  Jerry Coffin Nov 8 '10 at 16:45
show 9 more comments

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

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