16 ms·
C++ 17 is Done
- pjmlp 10y agoCongratulations to everyone involved, pity we still haven't got concepts and modules into it, but there is still hope for the next round. :) Until of one the more secure alternatives gets more mainstream adoption, thus starting to be requested by our customers, C++ is going to be the tool to go to, when I need to step out of JVM and .NET languages to something more low level.
- Athas 10y agoIs there an overview of what kind of challenges prevent the inclusion of modules? I don't do much C++ anymore, but I've done a fair bit of work on module systems, and they've never seemed that complicated to me. (I worry that the answer will mention the preprocessor...)
- lomnakkus 10y agoTL;DR: It has a lot to do with the preprocessor, macros specifically.
- kensai 10y agoLovely! But the real champagne opener is when certain mainstream compilers completely support all features. PS. Please don't forget to show some love for C2x now. :D
- pjmlp 10y agoMy utopic dream for C2x would be official data structures for safe arrays and strings, alongside some standard way to enable bounds checking on processors like Intel and Sparc ones. The security annex is worthless, as pointers and lengths are still used separately.
- deleted 10y ago[deleted]
- shakna 10y agoGCC [0] is pretty much done. Clang [1] needs a couple more things. MSVC [2] hasn't done as much, but shouldn't be too far away. [3]. Considering how long C++11 took before it was fully implemented, this seems so fast! [0] https://gcc.gnu.org/projects/cxx-status.html#cxx1z https://gcc.gnu.org/projects/cxx-status.html#cxx1z [1] http://clang.llvm.org/cxx_status.html http://clang.llvm.org/cxx_status.html [2] https://msdn.microsoft.com/en-us/library/hh567368.aspx https://msdn.microsoft.com/en-us/library/hh567368.aspx [3] https://blogs.msdn.microsoft.com/vcblog/2016/01/22/vs-2015-update-2s-stl-is-c17-so-far-feature-complete/ https://blogs.msdn.microsoft.com/vcblog/2016/01/22/vs-2015-u...
- wmu 10y agoIt's too late for C++ to regain popularity. C++17 features will become widespread in next 3-4 years (C++14 isn't a common standard yet). Moreover, the language has become incredibly complicated and sadly doesn't provide anything that would reflect modern needs.
- koko775 10y agoRegain popularity? It never lost popularity in the areas it was a good fit for. It's still a great fit for certain kinds of code that requires high performance or low overhead.
- wmu 10y agoI meant that despite the claim that C++ is a general purpose language, it is not popular among average developers. People would choose for a new project C#, Java, Go, Python, Scala or Javascript, but not C++.
- pjmlp 10y agoUntil they need to call into OS APIs, launch a GPU job, or do some kind of critical optimizations.
- gumby 10y ago> I meant that despite the claim that C++ is a general purpose language, it is not popular among average developers. People would choose for a new project C#, Java, Go, Python, Scala or Javascript, but not C++. ...despite claim that the light truck is a general purpose vehicle...people would chose for a new vehicle a bicycle, car, aircraft, motorcycle, or tank... Use the right tools for the job. C++ is intended to be a general purpose systems programming language. An excellent tool for a wide variety of tasks, but not the be all and end all. I am right now working on a library built in C++ and although I also have written some utility programs for the system in C++, its main interface is intended to be through (swig-enabled) Python and Common Lisp.
- 10y ago
- asitdhal 10y agoFor those who wants to know c++17 features http://stackoverflow.com/questions/38060436/what-are-the-new-features-in-c17 http://stackoverflow.com/questions/38060436/what-are-the-new... std::optional and std::any are one of the good things. std::apply and std::invoke can help you write better functional c++17 code. Anyway thanks for C++17. For sometime, I thought I will learn Rust.
- stinos 10y agoThat SO question has barely any code examples but mostly links to sometimes quite technical documents. I'd really love to see a comprehensive list of all features (if possible c++11, 14 and 17) together with small explanation + code samples: even though I am already using a lot of the new features I still feel like I'm missing out on certain things just because I don't know they exist and because the information is shattered. (e.g. I'm fairly sure SO has Q&A on like every new feature, but it would take an insane amount of time to go through every question tagged [c++17]).
- asitdhal 10y agoI don't know if similar things existed for C++11/14. But, it doesn't exist for C++17. I faced the similar problem. I invested some money in Effective Modern C++(Scott Mayer). It covers the language part. I borrowed a book for C++11 concurrency. But, modern C++ lacks high-quality material at one place like Golang/Rust(the language guys have very good documentation, not boring and good enough to learn quickly). There are tons of scattered example.
- surye 10y agohttps://github.com/tvaneerd/cpp17_in_TTs/blob/master/ALL_IN_ONE.md https://github.com/tvaneerd/cpp17_in_TTs/blob/master/ALL_IN_... This comes pretty close to what you're asking for I believe.
- stinos 10y agoYes, thanks, that's bascially the sort of thing I was looking for!
- faragon 10y ago"Perhaps the most exciting thing was that we decided to add the std::byte type" So "std::byte" is not a character ("std::char") nor arithmetic ("std::int8_t/uint8_t"), but allows bitwise operations. It was really necessary? Anyone knows if that type allows defining the byte size in bits per instance?
- jtsylve 10y agoNope, the spec seems to suggest it's unsigned char. This is also what gcc has done. https://patchwork.ozlabs.org/patch/737032/ https://patchwork.ozlabs.org/patch/737032/
- fnj 10y agoCan anyone express plainly what is the point of the std::byte circle jerk when we already have uint8_t?
- Koshkin 10y agoThis is analogous to adding uint8_t when we already had unsigned char. In C these would be exactly the same; in C++ they are different types. Same with uint8_t vs. byte: the former is an integer type, the latter is not. (Thus, a better question would be, why introduce byte when we already had unsigned char. I think, the answer to that is in a general tendency of moving away from the C way of looking at types and making code better reflect the intent and do it in a more type-safe manner.)
- andreyv 10y agostd::uint8_t is not required to exist on a particular implementation, for example, if the machine byte is not 8-bit. std::byte still seems pretty useless, though. There already is a built-in type for designating bytes: unsigned char.
- evanmoran 10y agoIt's for clarity about fixed size bitwise operations. Here's how the spec doc describes it's motivation: (http://open-std.org/JTC1/SC22/WG21/docs/papers/2017/p0298r3.pdf http://open-std.org/JTC1/SC22/WG21/docs/papers/2017/p0298r3....) Motivation and Scope: Many programs require byte-oriented access to memory. Today, such programs must use either the char, signed char, or unsigned char types for this purpose. However, these types perform a “triple duty”. Not only are they used for byte addressing, but also as arithmetic types, and as character types. This multiplicity of roles opens the door for programmer error – such as accidentally performing arithmetic on memory that should be treated as a byte value – and confusion for both programmers and tools. Having a distinct byte type improves type-safety, by distinguishing byte-oriented access to memory from accessing memory as a character or integral value. It improves readability. Having the type would also make the intent of code clearer to readers (as well as tooling for understanding and transforming programs). It increases type-safety by removing ambiguities in expression of programmer’s intent, thereby increasing the accuracy of analysis tools.
- systems 10y agoAs a matter of personal taste, I prefer big complex languages over simple ones And I do consider, that some of the strongest criticism of C++, and that is, "that most people use a subset of it, so it feels like many different languages glued into one", is actually a strength .. it means you can ignore some the complexity .. until you want it, or need it I am very happy, that C++ is adding new features every 3 years .. and I do plan to invest more time in C++ Complexity is good
- pjmlp 10y agoThe history of computing is full of programming languages that started as a cry against complexy, only to discover that complexity has a reason to be and then they either adapted, becoming themselves as complex as their enemy, or faded out of the computing scene.
- fauigerzigerk 10y agoNothing against personal preferences, but one side-effect of overwhelming complexity is that only very few people can be trusted to write safe C++. The better you know C++ the more suspicious you become of C++ code written by others. At least that is my personal experience. And I think that's a major reason why C++ usage is gradually becoming a niche thing used only where absolutely necessary. As evidence for that claim I submit this chart (you need to scroll down a page): https://www.itjobswatch.co.uk/jobs/uk/c++.do https://www.itjobswatch.co.uk/jobs/uk/c++.do C++ used to be required for over 30% of all permanent programming jobs in the UK back in 2005. Now it's down to 8.5% and falling. That's in stark contrast with all the enthusiasm created by the features added since C++11, features that I very much welcome.
- sun_n_surf 10y agoThis is not as bad as it sounds. You need to consider the absolute numbers than the relative percentages for languages like C++. Programming is more accessible than ever before, more jobs require some element of programming than ever before, and more things are getting created using code. This means that people who have never written code before are writing code as a job of work, and are writing it in simpler-to-learn languages. Newer, simpler programming jobs are acquiring programmers in other languages, not necessarily that C++'s complexity is driving people away from it into the arms of other languages or that C++ is not acquiring newer programmers at the same rates (on existing base) as before.
- hsivonen 10y agoI’m annoyed that the migration to “byte is uint8_t” from the “is a byte char or unsigned char?” mess is disrupted with std::byte.
- mr_overalls 10y agoDumb question: How popular is C++ as a systems programming language in 2017? Does anyone have data on the popularity of various languages (C, Rust, Go, etc.) when web and application development are excluded?
- guessmyname 10y agohttp://githut.info/ http://githut.info/ > GitHut is an attempt to visualize and explore the complexity of the universe of programming languages used across the repositories hosted on GitHub. > Github is the largest code host in the world, with 3.4 million users. It's the place where the open-source development community offers access to most of its projects. By analyzing how languages are used in GitHub it is possible to understand the popularity of programming languages among developers and also to discover the unique characteristics of each language.
- steveklabnik 10y ago> GitHut.info Carlo Zapponi 2014
- lossolo 10y agoC and C++ are the most popular "systems programming languages", C is king in embedded, kernels, C++ is a king in everything else. Go is not strictly "systems programming language", as to Rust popularity this is the most pragmatic answer I've seen lately: "... Let's see Rust for what it is: the latest attempt at a C++ replacement. These have come and gone over the years, and it's by no means clear that Rust will succeed. As an example, Rust is currently 43rd of the 50 languages monitored in the Tiobe index. For comparison with languages of a similar vintage, Swift and Go are 10th and 17th respectively. C++ is 3rd. To put it bluntly: almost nobody is using Rust in the real world yet. So please, ease up on the hype, Rust users. Have a little humility. You've got a nice little language with some really good ideas, and having a static analyser built into your compiler is cool. But there's a long way to go yet."[1] [1] https://www.reddit.com/r/cpp/comments/611811/have_you_used_rust_do_you_prefer_it_over_modern_c/dfb924w/ https://www.reddit.com/r/cpp/comments/611811/have_you_used_r...
- faragon 10y agoC++ is becoming Java.
- Koshkin 10y agoThis is one of the nicer things one could say about C++. Indeed, it is possible now to write C++ almost as if it was Java and still produce a reasonably efficient code!
- faragon 10y agoSure. That was my point, no pun intended.
- humanrebar 10y agoThat's not really possible without modules and a first-rate dependency injection framework.
- tathougies 10y agoCare to explain? Aside from garbage collection, C++ has basically always had all Java language features. If anything, I would argue that C++ is mostly a superset of Java, since it includes strictly more -- for example, much better support for type-generic programming.
- faragon 10y agoJava had built-in many features that C++ didn't (e.g. threading, mutexes, timers, sockets, etc.)
- oblio 10y agoIs there any plan, anywhere, to try to provide a standard, modern subset of C++? Sort of like Perl and Javascript have strict mode. Something that could be enforced by all the compilers.
- pjmlp 10y agoYes, C++ Core Guidelines. Many of the suggestions are supported in VC++ and clang-tidy. Other commercial vendors are slowly adopting them on their linters. Strangely, gcc seems absent from this effort.
- deleted 10y ago[deleted]
- codebeaker 10y agoEvery time there's something that comes up for C++ I get excited, I've always wanted to use the language, but it's like tap dancing in a mine field. C++ needs a linter that rejects code that doesn't meet a certain standard ala Rubocop.
- pjmlp 10y agoMost C++ compilers have them, the problem is the macho coders that think that know best. The same that micro-optimize every single line of code they write without ever running the code through a profiler.
- 0xFFC 10y agoMy rule of thumb : never optimize your code, instead optimize your algorithm as much as you can. After you finish, you can profile your code to see where you made mistake.
- gigatexal 10y agoI'm just glad to see languages as old* as C++ evolve and continue to have improvements made. It's a good time to be a programmer: our tools just keep getting better. *Old but close to metal and fast and versatile.
- Coding_Cat 10y agoStill no concepts unfortunately (or reflection). Bit disappointed really, I'm far from a guru but to me this seems like another 'tick' upgrade where c++11 was a big 'tock', c++14 was mostly polish to c++11.
- bonzini 10y agoEight years passed between C++03 and C++11, so I think it's okay to have nine years before the next big release---but with two iterations of polishing in between. The coroutines, ranges and concepts TSs alone are making C++20 pretty interesting, and some of the features will be available in compilers before 2020.
- wrsh07 10y agoIf you don't think of it as building a specific version and more just as a snapshot of what is currently 100% ready-to-go, you'll maybe feel differently. They did much of the work needed to get modules, concepts, ranges, reflection, parallelism, etc ready to go, but this snapshot doesn't include them. Nonetheless, many of those features will be finished soon and may be available by compilers before c++20
- deleted 10y ago[deleted]
- lukaszjb 10y agoI feel like we need some c+ not c++...
- humanrebar 10y agoI share this desire, but it's important for end-users to remember that even if a feature seems arcane and unneeded, you're likely using it indirectly through the libraries you use. Take variadic template parameters for example. The average developer doesn't use these. But very popular library features like make_shared would be at least an order of magnitude more code. And by making library code easier to write, understand, and maintain, we make it more likely that the more obvious features (like filesystem operations, database abstraction layers, new kinds of data structures, etc.) can be written and maintained. All that being said, there are completely unecessary warts in C++ that need to be cleaned up. The best thing in-the-trenches C++ developers can do to help with this is to improve the software development lifecycle tooling and practices on the projects they are responsible for. Good automation, static analysis, and testing will make the C++ community more agile and more ready to do the much harder work of deprecating and deleting old technical debt. And it's good for the health of the project anyway.
- fauigerzigerk 10y agoI agree. C + RAII.
- DSMan195276 10y agoIf that's all you want, you might take a look at the `cleanup` attribute for C. It's non-standard, but it is supported by `gcc` and `clang` and is fairly effective.
- jug 10y agoBoy... Would be a nice time to learn C++ again. I mean modern C++, with all lessons learned, all revisions thus far assumed to be supported, officially and unofficially deprecated coding styles marked in helpful tidy little "Don't do this and this is why!" red warning boxes. Bjarne Stroustrup himself said C++11... _11_ almost felt like a new language, and here we are already! C++ is so big, and not only that, changing so much. I have a hard time catching up and a distilled "sum of knowledge" C++ programming language guide would be immensely helpful. C++17 including all its predecessors almost feel more like D at this point, soon enough only missing GC compared to that, which by itself have alternatives in modern C++ that some argue is even better. I also think there's a disconnect in how people perceive C++ today. Many seem to think of an archaic language, Quora questions "Are C++ worthwile to learn today?" abound... Another argument for a high visibility language guide being useful? Documents like these are helpful but not very easy to digest: https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md https://github.com/isocpp/CppCoreGuidelines/blob/master/CppC...