digitalmars.D - [OT] C++ tips for a D programmer
- Lars T. Kyllingstad (17/17) Aug 31 2011 I am starting in a new job on Monday, in which the primary programming
- Paulo Pinto (29/46) Aug 31 2011 Hi,
- Jacob Carlborg (6/23) Aug 31 2011 I think Scott Meyers' "Effective C++" is a good book.
- Andrei Alexandrescu (3/29) Aug 31 2011 Accelerated C++.
- dsimcha (5/22) Aug 31 2011 1. Use C++11 if your boss will let you. You'll feel like there's a lot...
- Trass3r (3/5) Aug 31 2011 Yeah, especially boost foreach and smart pointers save lives (and nerves...
- =?UTF-8?B?QWxleCBSw7hubmUgUGV0ZXJzZW4=?= (4/21) Aug 31 2011 Whatever you do, avoid multiple inheritance like the plague. It will
- Simon (31/34) Aug 31 2011 I that's a little overly simplistic:
- Paulo Pinto (8/34) Aug 31 2011 That's a bit too much.
- Mike Parker (5/22) Aug 31 2011 If you find yourself using the standard library a lot, the book "C++
- Lars T. Kyllingstad (3/13) Sep 01 2011 Thanks for all your advice, folks! :)
- Jose Armando Garcia (5/17) Sep 02 2011 Most important -- find another job. Just kidding. Good luck.
- Lars T. Kyllingstad (4/23) Sep 03 2011 Hehe. I'm very excited about this one, so I think I'll stick with
I am starting in a new job on Monday, in which the primary programming language is C++. For the past four years I've had the privilege of being able to use D both professionally and privately, and consequently my C++ skills (which were intermediate to begin with) are now a bit rusty. Since I know there are a lot of extremely talented C++ programmers in the D community, I thought I'd ask here for some tips. Firstly, can you think of any pitfalls to avoid? In particular, I am interested in the ones that stem from subtle differences between the two programming languages. I believe I am already aware of the most obvious stuff (such as for example array bounds checking, or lack thereof). Secondly, can you recommend a good C++ book? I am looking for one that targets an audience with good general programming skills, and which can act as a language reference. Hopefully, my adventures in the world of C++ will give me new perspectives on things, allowing me to contribute even better to the improvement of D. ;) -Lars
Aug 31 2011
Hi, assuming that you are not working on a legacy code base, which might bring its own set of quirks. Use the standard library as much as possible. Later on you can always optimize with help of a profiler. Avoid C strings, prefer the standard library one. Don't scatter new/malloc and delete/free everywhere. Keep a proper allocation patter, or better yet, used shared pointers in the code parts where performace hit won't matter. Make good use of forward declarations and PIMPL edioms to speed up compilation speed. Always compile with all warnings enabled, or enabled as error. Disable the false positives in places you are sure what you're doing. My C++ language reference is always Bjarne's book, The C++ programming language but there a few other ones worthwhile reading Modern C++ Design: Generic Programming and Design Patterns Applied Effective C++ series The Design and Evolution of C++ Accelerated C++: Practical Programming by Example Ruminations on C++: A Decade of Programming Insight and Experience Good luck on your new job, Paulo "Lars T. Kyllingstad" <public kyllingen.NOSPAMnet> wrote in message news:j3ksua$2nv2$1 digitalmars.com...I am starting in a new job on Monday, in which the primary programming language is C++. For the past four years I've had the privilege of being able to use D both professionally and privately, and consequently my C++ skills (which were intermediate to begin with) are now a bit rusty. Since I know there are a lot of extremely talented C++ programmers in the D community, I thought I'd ask here for some tips. Firstly, can you think of any pitfalls to avoid? In particular, I am interested in the ones that stem from subtle differences between the two programming languages. I believe I am already aware of the most obvious stuff (such as for example array bounds checking, or lack thereof). Secondly, can you recommend a good C++ book? I am looking for one that targets an audience with good general programming skills, and which can act as a language reference. Hopefully, my adventures in the world of C++ will give me new perspectives on things, allowing me to contribute even better to the improvement of D. ;) -Lars
Aug 31 2011
On 2011-08-31 10:55, Lars T. Kyllingstad wrote:I am starting in a new job on Monday, in which the primary programming language is C++. For the past four years I've had the privilege of being able to use D both professionally and privately, and consequently my C++ skills (which were intermediate to begin with) are now a bit rusty. Since I know there are a lot of extremely talented C++ programmers in the D community, I thought I'd ask here for some tips. Firstly, can you think of any pitfalls to avoid? In particular, I am interested in the ones that stem from subtle differences between the two programming languages. I believe I am already aware of the most obvious stuff (such as for example array bounds checking, or lack thereof). Secondly, can you recommend a good C++ book? I am looking for one that targets an audience with good general programming skills, and which can act as a language reference. Hopefully, my adventures in the world of C++ will give me new perspectives on things, allowing me to contribute even better to the improvement of D. ;) -LarsI think Scott Meyers' "Effective C++" is a good book. For references, I would go with Bjarne Stroustrup's "The C++ Programming Language". -- /Jacob Carlborg
Aug 31 2011
On 8/31/11 6:56 AM, Jacob Carlborg wrote:On 2011-08-31 10:55, Lars T. Kyllingstad wrote:Accelerated C++. AndreiI am starting in a new job on Monday, in which the primary programming language is C++. For the past four years I've had the privilege of being able to use D both professionally and privately, and consequently my C++ skills (which were intermediate to begin with) are now a bit rusty. Since I know there are a lot of extremely talented C++ programmers in the D community, I thought I'd ask here for some tips. Firstly, can you think of any pitfalls to avoid? In particular, I am interested in the ones that stem from subtle differences between the two programming languages. I believe I am already aware of the most obvious stuff (such as for example array bounds checking, or lack thereof). Secondly, can you recommend a good C++ book? I am looking for one that targets an audience with good general programming skills, and which can act as a language reference. Hopefully, my adventures in the world of C++ will give me new perspectives on things, allowing me to contribute even better to the improvement of D. ;) -LarsI think Scott Meyers' "Effective C++" is a good book. For references, I would go with Bjarne Stroustrup's "The C++ Programming Language".
Aug 31 2011
On 8/31/2011 4:55 AM, Lars T. Kyllingstad wrote:I am starting in a new job on Monday, in which the primary programming language is C++. For the past four years I've had the privilege of being able to use D both professionally and privately, and consequently my C++ skills (which were intermediate to begin with) are now a bit rusty. Since I know there are a lot of extremely talented C++ programmers in the D community, I thought I'd ask here for some tips. Firstly, can you think of any pitfalls to avoid? In particular, I am interested in the ones that stem from subtle differences between the two programming languages. I believe I am already aware of the most obvious stuff (such as for example array bounds checking, or lack thereof). Secondly, can you recommend a good C++ book? I am looking for one that targets an audience with good general programming skills, and which can act as a language reference. Hopefully, my adventures in the world of C++ will give me new perspectives on things, allowing me to contribute even better to the improvement of D. ;) -Lars1. Use C++11 if your boss will let you. You'll feel like there's a lot less missing from it than D. 2. Use Boost if your boss will let you. C++'s standard library is a joke. 3. Pray.
Aug 31 2011
Am 31.08.2011, 14:31 Uhr, schrieb dsimcha <dsimcha yahoo.com>:2. Use Boost if your boss will let you. C++'s standard library is a joke.Yeah, especially boost foreach and smart pointers save lives (and nerves) :)
Aug 31 2011
On 31-08-2011 10:55, Lars T. Kyllingstad wrote:I am starting in a new job on Monday, in which the primary programming language is C++. For the past four years I've had the privilege of being able to use D both professionally and privately, and consequently my C++ skills (which were intermediate to begin with) are now a bit rusty. Since I know there are a lot of extremely talented C++ programmers in the D community, I thought I'd ask here for some tips. Firstly, can you think of any pitfalls to avoid? In particular, I am interested in the ones that stem from subtle differences between the two programming languages. I believe I am already aware of the most obvious stuff (such as for example array bounds checking, or lack thereof). Secondly, can you recommend a good C++ book? I am looking for one that targets an audience with good general programming skills, and which can act as a language reference. Hopefully, my adventures in the world of C++ will give me new perspectives on things, allowing me to contribute even better to the improvement of D. ;) -LarsWhatever you do, avoid multiple inheritance like the plague. It will bite you, especially if you use pointers. - Alex
Aug 31 2011
On 31/08/2011 13:41, Alex Rønne Petersen wrote:Whatever you do, avoid multiple inheritance like the plague. It will bite you, especially if you use pointers. - AlexI that's a little overly simplistic: Avoid multiple inheritance from classes with actual data members; do use multiple inheritance as a stand in for template mixins. Also as others have mentioned, do use boost. It's a massive time saver, though there's so much in it, it can be a bit hard to find the bit which does what you want. Things to check out specifically: format: http://www.boost.org/doc/libs/1_47_0/libs/format/index.html foreach: http://www.boost.org/doc/libs/1_47_0/doc/html/foreach.html property tree: http://www.boost.org/doc/libs/1_47_0/doc/html/property_tree.html (it's got a small and useful xml library built in) signals: http://www.boost.org/doc/libs/1_47_0/doc/html/signals.html smart_ptr: http://www.boost.org/doc/libs/1_47_0/libs/smart_ptr/smart_ptr.htm static_assert: http://www.boost.org/doc/libs/1_47_0/doc/html/boost_staticassert.html string_algorithms: http://www.boost.org/doc/libs/1_47_0/doc/html/string_algo.html Have a poke through those and you'll find they cover a big chunk of D's real time savers. And if you need to do some template programming: mpl: http://www.boost.org/doc/libs/1_47_0/libs/mpl/doc/index.html -- My enormous talent is exceeded only by my outrageous laziness. http://www.ssTk.co.uk
Aug 31 2011
That's a bit too much. I think at least for mixins and to implement what other languages call interfaces it is ok. For more than that it is better not. -- Paulo "Alex Rønne Petersen" <xtzgzorex gmail.com> wrote in message news:j3la80$lh4$1 digitalmars.com...On 31-08-2011 10:55, Lars T. Kyllingstad wrote:I am starting in a new job on Monday, in which the primary programming language is C++. For the past four years I've had the privilege of being able to use D both professionally and privately, and consequently my C++ skills (which were intermediate to begin with) are now a bit rusty. Since I know there are a lot of extremely talented C++ programmers in the D community, I thought I'd ask here for some tips. Firstly, can you think of any pitfalls to avoid? In particular, I am interested in the ones that stem from subtle differences between the two programming languages. I believe I am already aware of the most obvious stuff (such as for example array bounds checking, or lack thereof). Secondly, can you recommend a good C++ book? I am looking for one that targets an audience with good general programming skills, and which can act as a language reference. Hopefully, my adventures in the world of C++ will give me new perspectives on things, allowing me to contribute even better to the improvement of D. ;) -LarsWhatever you do, avoid multiple inheritance like the plague. It will bite you, especially if you use pointers. - Alex
Aug 31 2011
On 8/31/2011 5:55 PM, Lars T. Kyllingstad wrote:I am starting in a new job on Monday, in which the primary programming language is C++. For the past four years I've had the privilege of being able to use D both professionally and privately, and consequently my C++ skills (which were intermediate to begin with) are now a bit rusty. Since I know there are a lot of extremely talented C++ programmers in the D community, I thought I'd ask here for some tips. Firstly, can you think of any pitfalls to avoid? In particular, I am interested in the ones that stem from subtle differences between the two programming languages. I believe I am already aware of the most obvious stuff (such as for example array bounds checking, or lack thereof). Secondly, can you recommend a good C++ book? I am looking for one that targets an audience with good general programming skills, and which can act as a language reference. Hopefully, my adventures in the world of C++ will give me new perspectives on things, allowing me to contribute even better to the improvement of D. ;) -LarsIf you find yourself using the standard library a lot, the book "C++ Standard Library Practical Tips" by Greg Reese should come in handy. I rarely use C++, but this has been quite useful to me for those times when I've stumbled through the C++ muck.
Aug 31 2011
On Wed, 31 Aug 2011 08:55:38 +0000, Lars T. Kyllingstad wrote:I am starting in a new job on Monday, in which the primary programming language is C++. For the past four years I've had the privilege of being able to use D both professionally and privately, and consequently my C++ skills (which were intermediate to begin with) are now a bit rusty. Since I know there are a lot of extremely talented C++ programmers in the D community, I thought I'd ask here for some tips. ...Thanks for all your advice, folks! :) -Lars
Sep 01 2011
On Thu, Sep 1, 2011 at 5:57 AM, Lars T. Kyllingstad <public kyllingen.nospamnet> wrote:On Wed, 31 Aug 2011 08:55:38 +0000, Lars T. Kyllingstad wrote:Most important -- find another job. Just kidding. Good luck. I currently use Scala for my current job. For now, I would probably only code in either Scala or D...I am starting in a new job on Monday, in which the primary programming language is C++. =A0For the past four years I've had the privilege of being able to use D both professionally and privately, and consequently my C++ skills (which were intermediate to begin with) are now a bit rusty. Since I know there are a lot of extremely talented C++ programmers in the D community, I thought I'd ask here for some tips. ...Thanks for all your advice, folks! :)
Sep 02 2011
On Fri, 02 Sep 2011 12:09:49 -0700, Jose Armando Garcia wrote:On Thu, Sep 1, 2011 at 5:57 AM, Lars T. Kyllingstad <public kyllingen.nospamnet> wrote:Hehe. I'm very excited about this one, so I think I'll stick with it. ;) Thanks! -LarsOn Wed, 31 Aug 2011 08:55:38 +0000, Lars T. Kyllingstad wrote:Most important -- find another job. Just kidding. Good luck.I am starting in a new job on Monday, in which the primary programming language is C++. Â For the past four years I've had the privilege of being able to use D both professionally and privately, and consequently my C++ skills (which were intermediate to begin with) are now a bit rusty. Since I know there are a lot of extremely talented C++ programmers in the D community, I thought I'd ask here for some tips. ...Thanks for all your advice, folks! :)
Sep 03 2011