9 ms·
Writing Good C++14 by Default [pdf]
- Tobu 11y agoA direct link might work better: https://github.com/isocpp/CppCoreGuidelines/raw/master/talks/Sutter%20-%20CppCon%202015%20day%202%20plenary%20.pdf https://github.com/isocpp/CppCoreGuidelines/raw/master/talks...
- adamnemecek 11y agomy reasoning was that people prefer to read things in the browser over downloading them. afaik there is no way of achieving this only client side without installing a plugin.
- nosnos 11y agoThank you! That pdf renderer is unbearably slow on firefox.
- progman 11y ago"As clean and direct as any other modern language ..." LOL Honestly I needed to read the C++98 code to understand the modern one. Yes, C++ has advanced but the inherited waste is obvious. Do other modern languages still operate with pointers? http://words.steveklabnik.com/pointers-in-rust-a-guide http://words.steveklabnik.com/pointers-in-rust-a-guide
- adamnemecek 11y ago> Honestly I needed to read the C++98 code to understand the modern one. Was that your first time reading C++14? If so are you surprised that there was some learning curve? > Do other modern languages still operate with pointers? As much as I'm rooting for Rust to succeed, C++ will be around for quite a while longer so it might be a good idea to make it a bit friendlier.
- progman 11y agoThe problem with modern C++ is that people stick to their programming styles. Many will use some of the new good features but they will also use the old ones (pointers!) because it's so easy to use them. Rust however forces people to accept new programming styles because the legacy ones (pointers!) are not appreciated.
- pmlnr 11y agoPointers are great for resource saving, eg. embedded. Don't underestimate them.
- progman 11y agoIn embedded systems pointers make some sense but not in usual applications. This is the way how Rust can work: http://mainisusuallyafunction.blogspot.de/2015/01/151-byte-static-linux-binary-in-rust.html http://mainisusuallyafunction.blogspot.de/2015/01/151-byte-s...
- okamiueru 11y agoWhat do you mean by having to "read the C++98 code to understand the modern one"? Isn't this how "here is the new way of doing it"-examples work? Until you don't know it, of course you will need to read whatever version you do know. The point is that once you do learn it, you can use it. And "inherited waste is obvious"? If you mean to say that it carries a lot of historic luggage, and you feel encumbered by it, then geez, the document in question was almost tailored for you. C, D, Go also have pointers available. And, to be honest, thinking that pointers are "obsolete" suggests lack of understanding. You know what, all your points seem to be against C++. A typical language evangelist.
- kamac 11y agoIt's good that C++ is evolving, but I'm not sure if it evolves in the right way. Basically, consider a ball of meat. The meat is rotting, nobody would eat it anymore, so fresh meat is slapped on it. And the process repeats numerous times, for years. In the end, you'll have a giant ball of meat, that'll look fresh, but once you poke the ball, you'll be hit by the stench of the rotten meat inside. I'd prefer if they started anew, rather than keep slapping fresh meat on the ball.
- flohofwoe 11y agoThis looks to me like making C++ more "rusty" which is a good thing IMHO, exactly for the reason that I don't need to bring all my existing code to a new language but instead can make it 'safe' in incremental steps. There are many good reasons to evolve a language instead of inventing a new one, the situation is a little bit like with OpenGL: 'modern OpenGL style' has nothing in common with the original OpenGL, and many ideas have been introduced in past versions which are now considered bad or dead. Still I can take the OpenGL Gears sample (which is who-knows how old) and run it on a modern GL driver. This is both a good and bad thing. The bad is that it is confusing to learn OpenGL if you haven't been following its entire history. Googling OpenGL questions will give you 10 different answers, all correct, but only for a specific time in its history. The good thing is that this approach allows me to bring a large piece of GL code incrementally to modern standards without having to rewrite everything. Of course there are the new fancy 3D APIs (just like there are fancier statically typed, compiled languages compared to C++), but in general, people are underestimating the risks of rewriting a large piece of code (this is still just as true as when it was written 15 years ago: http://www.joelonsoftware.com/articles/fog0000000069.html http://www.joelonsoftware.com/articles/fog0000000069.html) What I would like to see in C++ is to have very detailed control over language features and enforce coding guidelines in my own code base. The more fine grained this control, the better. Something like 'don't allow pointer arithmetics', 'don't allow C arrays', 'don't allow multiple inheritance', etc... Going with your example: as soon as the rotten meat layer is reached, the compiler would no longer accept the code unless you specifically allow it with an exception to the 'modern rule-set'. A combination of such rules could result in a 'safe subset' which would have the same compile-times guarantees as Rust, and if the rules are violated, the compiler will complain (I think/hope this is what the presentation is mainly about).
- tmaly 11y agomaintaining the legacy code written in the late 90s is the hardest part. It would be great if we could just press a button and the old code is now magically C++14
- neuromancer2701 11y agoMy problem is that I work with a bunch of 90s era engineers and they still want to code that way. It is what they know and they don't want to spend the time to learn any of that new fangled C++11. Most of them are 5-10 years from retirement if not working a shorten week already so why waste their time.
- lorenzhs 11y agoI haven't actually tried it, but clang's C++ Modernizer tries to automate some of the boring manual tasks in bringing old code up to speed (such as using nullptr instead of NULL or 0, or more the for(T x : c) loop construct). See http://clang.llvm.org/extra/clang-modernize.html http://clang.llvm.org/extra/clang-modernize.html (integrated into clang-tidy now)
- tempodox 11y agoUsing C++ well has always been a question of judiciously selecting the feature subset that does what you need the sanest way. Looks like cognitive load for selecting that subset is increasing while the sane subset is getting smaller in relation to the bulk of the language. In other news, downloading a single PDF from GitHub is an atrocious pain in the abdomen. I had to edit the HTML to get at that progenitrix-penetrating URL.
- rsam 11y ago> In other news, downloading a single PDF from GitHub is an atrocious pain in the abdomen. I had to edit the HTML to get at that progenitrix-penetrating URL. I've usually found clicking on "raw" triggers the download; but possibly doesn't work across all browsers?
- tempodox 11y agoYup, works in Safari. I'll have to remember that.
- criddell 11y agoEvery time C++ is discussed here, I feel like I might be the only person on the planet that likes C++ and enjoys working in it. I get excited when Sutter publishes an article about some proposed new feature. I enjoy talking about code with new hires and giving them a set of Scott Meyers' books to read. I'm in awe of what the clever Boost contributors wring out of the language. I don't think it's a stinking ball of meat. It's a living language with a deep history that's getting better all the time. It's a wonderful tool that I use daily.
- flohofwoe 11y agoAs the old saying goes: "There are languages that everybody complains about, and there are languages that nobody uses" ;)
- tonyarkles 11y agoLet's be friends! I did a lot of C++ back in the late 90s/early 2000s, and it kind of sat on the shelf for me for a while. I've recently come back and am discovering all of the joys of modern C++(11/14). I'm really really impressed. The first project was a cross-platform library on top of libusb. With all of the great concurrency things built-in now (std::thread/mutex/lock, etc), I managed to write the whole library without a single #ifdef! Generates Linux .so, OS X .dylib, and Windows DLLs. Amazing!
- CuttlefishXXX 11y ago>I managed to write the whole library without a single #ifdef! Generates Linux .so, OS X .dylib, and Windows DLLs. Amazing! Could you expand on how you are doing this? You're still using a Makefile or a similar tool with some kind of platform detection for the build itself, right?
- flohofwoe 11y agoNot sure whether the parent does it like this, but you can use cmake to describe the build, and then (for instance) run cmake --build to build the project in a 'cross-platform' way using the platform's native compiler toolchain, it works the same on Windows, OSX and Linux. I think what the parent meant with 'no #ifdefs' is that the C++11 std lib comes with more modules that make a lot of platform-specific code-paths unnecessary (for instance std::thread, std::atomic for threading, and std::chrono for high-resolution time-measuring).
- corysama 11y agoComparisons of full-spectrum C++ vs Rust or some theoretical C++ that drops support for the old stuff are subtly unfair. If you are using a new language then you are by definition not maintaining/upgrading old code. If you are starting a new project in C++, you can follow the modern style guidelines and get most everything you are asking for. At this point, someone usually says "but nothing prevents my horrible coworkers from using horrible features." If your coworkers are horrible, they will find ways to be horrible no matter what language you chain them to.
- steveklabnik 11y ago> If your coworkers are horrible, they will find ways to be horrible no > matter what language you chain them to. While this is true in some sense, it's also a relative degree of difficulty. While you _can_ obviously write bad Rust code, like in any language, you have to go really far out of your way to disable the compiler's assistance. Of course, there are other kinds of 'bad code' than just unsafe...
- corysama 11y ago> Of course, there are other kinds of 'bad code' than just unsafe... Exactly. Many languages make it hard to be unsafe. But, every language makes it easy to be horrible in one way or another.