Learning C++ as a Perl programmer

Don't bother with learning C unless you want to know C. Programming in C++ is nothing at all like programming in C. I realize most books and teachers claim otherwise, but they're wrong. You should be looking for the exceptions, such as the previously mentioned, "Accelerated C++."

You won't find any books that will help you write code like the code you've just shown. Perl is a very weakly typed language and C++ is exactly the opposite: a strongly typed language. There are, however, ways to get kind of what you're showing in your post in various boost constructs such as variant and tuple.

I would suggest though learning C++ as a totally independent language before stepping into that kind of thing. Don't learn C++ as a Perl Programmer, learn it as a complete newb. You may be bored with the first few chapters but in the end you'll have a better grasp of the style and powers unique to C++ vs. those unique to Perl. I haven't seen any "Xlanguage for Ylanguage" book that will get you there.


"C++ For Perl Programmers" is a pretty specific request. Given that Perl abstracts away more of the machine than C++ does, I think that a good way to start would be to forget what you know about Perl and get a regular C++ book.

For example, it seems reasonable to you that you should be allowed to have multiple data types in an array, because a Perl array is a higher-level construct than just a series of contiguous words in memory. If I were going to go from an array in C++ to one in Perl, I would say that a Perl array is like a C++ array that holds pointers to data instead of data (if that is even true - I am not a Perl programmer so it may not be. Maybe a Perl array is more like a linked list data structure. In any case, you get the idea.) Going backwards, IMO, is not quite the same.

As far as the book I'd recommend - there are a lot of good ones, so it depends on the style and depth you're looking for. I think Accelerated C++ is great for ramping up - its thorough and covers a lot of ground without inundating you with the tedious details.

Tags:

C++

Perl