5 ms·
Hm, this seems to be more advice on how to use C++14 as if it were its own language, or as if it were Java, or as if it were Scheme. One problem I have with th
by xigency 11y ago
Hm, this seems to be more advice on how to use C++14 as if it were its own language, or as if it were Java, or as if it were Scheme.
One problem I have with the advice to use the newest language features in C++ is that it sacrifices one of the biggest advantages to writing code in C++: the ability to compile for multiple platforms. It's extremely unlikely that one has a compiler for every platform that supports all of these features. Additionally, each of these language features adds a small bit of convenience to the developer, while making the compiler substantially more complicated (and hence, more prone to errors).
To summarize the points made in the first 10 slides, which is far as I read (sorry)-
1) Always use auto.
2) Use for-each.
3) Don't use new or delete.
4) Use STL for everything.
5) Use smart pointers.
- Arelius 11y ago> it sacrifices one of the biggest advantages to writing code in C++: the ability to compile for multiple platforms. Is that really one of the biggest advantages to C++? Both of the other languages that you mention, can target a huge amount of platforms. Java, Scheme. In fact, I think that's a feature of very many modern languages, And specifically of C, which may be a much better choice if compatibility is your preference. It seems that the choice to use C++ is not likely motivated primary by platform support for most developers.
- deleted 11y ago[deleted]
- pjmlp 11y ago> biggest advantages to writing code in C++: the ability to compile for multiple platforms. It's extremely unlikely that one has a compiler for every platform that supports all of these features. Do you have war wounds from the C++ ARM or K&R C days? I have. That was one of the reasons many of us enjoyed using Java. It was much easier than dealing with all compiler and OS compatibility issues. The situation with C++14 compatibility is way better than on those days.
- hermanhermitage 11y agoI agree strongly with these comments. I used template heavy C++ back in the late 1990s, rolling container classes implementing smart pointers it was tricky to get good code compatibility across a range of compilers: Edison Design Group, icc, MSVC++, gcc. Ultimately I found myself reassessing the tradeoffs in using C++ for many projects. Fast forward to 2015 and the situation is much better - even for "soft" embedded scenarios. GCC and clang have good reach and MSVC++ is evolving with the language. Engineering decisions are often about making tradeoffs and with the state of C++14 and things like C++ Core Guidelines and good support for RVO/move optimisations I find the appeal of C++ has broadened again. And there is good support for modern C++ on many platforms. Of course there are platforms out there where C++ is still not suitable. For example I'm currently doing a lot of 8086 real mode work, where due to external constraints all the code has to be written in assembler. Neither C or C++ are candidates for me in this work. These platforms will always exist. But many embedded platforms with smart phone level of processing power are solid targets for modern C++.
- deleted 11y ago[deleted]
- WesternStar 11y agoOf the listed features he suggests. All of them are C++11 features that are supported in Clang,GCC and VS. Which gets you the 3 major platforms for computing,mobile and cloud computing and through ARM the vast majority of cost effective embedded hardware.
- deleted 11y ago[deleted]