20 ms·
We have C++14
- jastanton 12y agoI apologize if this is ignorant, but how is C++ versioned?
- Qantourisc 12y agoNew features like auto and shared_ptrs.
- adamnemecek 12y agoBy the year the standard was published.
- _delirium 12y agoFairly common programming language convention as well. I believe FORTRAN 66 and ALGOL 68 were the first standards widely referred to with a revision year. More recent examples include Fortran 90 (no more caps!) and C99.
- adamnemecek 12y agoI agree but it seems like newer languages adopted the 1.0, 2.0 versioning scheme so it might throw some people off.
- maxlybbert 12y agoPre-standard C++ had that scheme as well! (well, CFront releases, http://www.softwarepreservation.org/projects/c_plus_plus#cfront http://www.softwarepreservation.org/projects/c_plus_plus#cfr... ).
- Havvy 12y agoNot just new languages. Java is also versioned from Java 1.0 to 1.1 to 1.2 ... 1.8, with recent versions dropping the "1." because they never will have a true "2.0" release.
- cygx 12y agoThat's somewhat more common with languages with a reference implementation instead of a specification.
- deleted 12y ago[deleted]
- spott 12y agowhat do you mean? C++ is a language designed by committee. C++14 is meant as a "tock" release, fixing some of the things in the C++11 "tick" release. ("tick" releases are larger, and "tock releases fix some of the problems in the "tick" release). Compilers then attempt to implement the standard, and have their own versioning system.
- StephanTLavavej 12y agoTraditionally, "ticks" are small, and "tocks" are big. See https://en.wikipedia.org/wiki/Intel_Tick-Tock https://en.wikipedia.org/wiki/Intel_Tick-Tock .
- scriptduck 12y agoThe version number identifies the tonnage of crap that has been added since C++98.
- skj 12y agoOnly 14 more tons since C++98, which, of course, had 98 tons since C.
- anuragbiyani 12y agoUntil now there have been four standardized versions of C++: C++98, C++03, C++11, and C++14. And the versions have been consistently named (to be precise, "nicknamed") as "C++YY", where YY are the last two digits of the year in which that ISO standard was adopted. Note: C++03 was a very minor change (sort of a "bug fix"), so people sometime refer to C++11 as direct successor of C++98. Also in the interim (2007) there was C++-TR1 ("ISO/IEC TR 19768:2007") which was not a formal standard per se, but instead a technical report specifying bunch of standard library extensions (which were formally included in C++11) For sake of completeness: The format C++YY is the one which is commonly used almost everywhere, but the official language name follow ISO's convention. Here is a mapping: C++98: "ISO/IEC 14882:1998 Programming languages C++" C++03: "ISO/IEC 14882:2003 Programming languages C++" C++11: "ISO/IEC 14882:2011 Programming Language C++" C++14: "ISO/IEC 14882:2014 Programming Language C++" There are also language classifier like (E), (F), etc present at the end (e.g., "ISO/IEC 14882:2014(E) Programming Language C++"). I am not sure if the official standard is fixed in a particular language, or are all the different language translations equally authoritative (I suspect the latter, but it's just a guess).
- DeadClan 12y agoI'm assuming C++14 will have 1320 keywords and a bunch of weird operators to use so people can ignore it even more than it's being ignored.
- spott 12y agoI don't think there are any new keywords for C++14.
- hokkos 12y agoIf only it were true, the problem is more that c++ as to many meaning for its keywords.
- meowface 12y agoI don't know, it's kind of both. There are too many keywords and operators, and many of those keywords and operators have different semantics in different contexts.
- astrodust 12y agoSpeaking of ignoring things, have you read anything at all about C++14?
- cdelsolar 12y agoum, C++ is the most widely used language in the world.
- tormeh 12y agoOkay, that's incorrect. It's a bit hard to say whether it is Java, Javascript or C, but it's certainly not C++.
- tedunangst 12y agoIt's really neither here nor there, but every java or JavaScript engine in widespread use is written in c++, so c++ code "in use" subsumes both of them.
- spott 12y agoI really like the direction C++ is moving in. I just really don't like how incredibly VERBOSE it is (though `auto` helps).
- astrodust 12y agoIn languages like C++ "verbose" means "specific and obvious" which is something you want to have when writing certain kinds of code. It's annoying, it's a drag on productivity, but in the long run it's arguably necessary. Some other languages which reduce verbosity by making more things implicit make it harder to understand what's actually going on behind the scenes. You lose a lot of information.
- SamReidHughes 12y ago> In languages like C++ "verbose" means "specific and obvious" Whoa, no it doesn't. C++ is far more verbose than necessary for things like creating algebraic datatypes or really creating any types.
- jjoonathan 12y agoOr looping through for loops. I remember the jaw-hitting-floor moment when my C++ book tried to pass off std::vector<int>::iterator it; for (it=arr.begin(); it!=arr.end(); it++) { ... } as an improvement over for (int i=0; i<len; i++) { ... } Not entirely unrelated: I'm currently busy verbosifying a large chunk of C++11 code into C++90 code because Reasons (or so the maintainers assure me).
- ThatOtherPerson 12y agoIt's an improvement in the sense that it's more general; you can loop through any container that implements that protocol, which most (if not all) of the STL containers do. For example, template <class T> void foo(T arr) { for (auto it = arr.begin(); it != arr.end(); ++it) { std::cout << *it << std::endl; } } You could pass a `std::map<int>` to `foo`, or a `std::list<string>`, or a `std::vector<char>`. You could even create your own classes and give them to `foo`, as long as they implement the `begin`/`end` protocol. It's certainly more verbose than necessary, but it can be convenient.
- daenz 12y agoWhen I started writing C++ around 5 years ago, I had a perception that it was a language that is "on its way out". As I learned more and more of it, I've been super impressed at how modern it is becoming, and how it is adapting to overcome its perceived flaws. It is becoming a killer language to me: blazing fast, modern, ubiquitous, stable, and expressive.
- tdees40 12y agoThis is totally true. The downside, of course, is just how much code exists that is written in pre-C++11 dialects, and how many programmers are trained to write that sort of code. I like way more of C++11 than I liked of the prior version, but there's just so much that's accumulated over the years. I wonder if breaking backwards compatibility is the key, but then I look at Python 3 and think, well, probably not.
- dfan 12y agoAlso, how many companies are afraid of the new features and deprecate them internally (fearing compiler bugs, lack of portability, and/or unmaintainability). I still haven't had a chance to use full C++11 in a professional context.
- tdees40 12y agoOh my goodness, yes. The HN crowd probably doesn't appreciate the extent to which people who sling C++ at BigCorp are limited by the rules the company sets.
- lelf 12y agoRecent standard draft (2014-03) https://github.com/zygoloid/cplusplus/blob/master/papers/N3936.pdf?raw=true https://github.com/zygoloid/cplusplus/blob/master/papers/N39...
- yelnatz 12y agoDo you know where I can find a diff? I'd like to see whats new with 14. Edit: http://en.wikipedia.org/wiki/C%2B%2B14#New_language_features http://en.wikipedia.org/wiki/C%2B%2B14#New_language_features
- bnejad 12y agoCan anyone recommend a book on modern C++?
- ibebrett 12y agoYeah, this would be a god send. As someone who is writing more and more C++ for computer vision type stuff, a modern overview would be great. I am stuck working off of things I learned over the years and don't feel quite like I'm writing modern idiomatic C++
- SupremumLimit 12y agoIf you just want to learn about the features introduced in C++11/14, I wrote compiler-specific books about those: http://cpprocks.com http://cpprocks.com
- dfan 12y agoScott Meyers' Effective Modern C++ will be required reading once it's released in October. Until then (and even after), Stroustrup's The C++ Programming Language (4th edition) is the canonical resource. It's a reference but is also intended to be read.
- bnejad 12y agoThank you, looking forward to Meyers' release.
- tbrock 12y agoThere is an digital unedited pre-release version that available now if you pre-order: http://shop.oreilly.com/product/0636920033707.do http://shop.oreilly.com/product/0636920033707.do I'm reading the PDF and it's quite good.
- Roboprog 12y agoIronically, it was (the first edition of, I believe) Meyer's "Effective C++" that made me question "WTF? Why does anybody use this???" (given that Turbo Pascal / Delphi, or Perl, actually were much easier to understand). Maybe C++ is usable now, but back in the late 90s, nobody that I respected used C++ - all the code I saw at work in C++ was by resume padding morons who wouldn't recognize polymorphism if it walked up and bit them in the ass. (the opinion being either use C, or a high level language, but not C++) Not fair to judge the language by the fools that used it 15+ years ago, but I have no use for operator overloading, copy memory leaks and all the other C++ obfuscation. C++ would probably benefit from a "lessons learned" do-over with a new name (as referenced elsewhere in the Perl 6 / Python 3 debacles)
- pjungwir 12y agoOT question: I was playing with some C over the weekend (not C++), trying to figure out how to handle Unicode in a way that would work on Mac, Linux, and Windows. Despite a couple hours googling and reading, I couldn't answer really basic stuff, like: - Do I use char* for strings? It sounds like wchar_t is 16 bits on some systems and 32 on others, so I should avoid it? - If I want to read & write UTF-8 files, how do I turn the bytes into 32-bit wide Unicode strings? - Are there special functions I should use for handling Unicode strings? More generally, where do you go to discover C libraries you can use? I am (was) reasonably proficient in C, but I haven't used it much for over ten years. I'm surprised how many things I just don't know how to do! Sorry this is not a C++ question. I'd like to get back into that also, but I'm trying to work my way up from the basics. :-)
- wisty 12y agoLook here: http://userguide.icu-project.org http://userguide.icu-project.org You really need a library when dealing with unicode, if you are doing anything advanced. How do you split a sentence into words? Spaces, right? Oh, Chinese doesn't have spaces. How about sentences? Paragraphs? Even characters are a pain to iterate over.
- Nursie 12y agoAgreed, ICU is a good place to start looking at this stuff, used it in a few large-scale commercial projects now.
- jonstewart 12y agoIt really is abominable how bad the standard support for Unicode is. ICU is great, though the C API is somewhat limited compared to the full C++ API. ICU's build process, OTOH, leaves something to be desired, especially if you want to build it with a cross-compiler.
- zanny 12y agoWhy not just write C style C++? I never understand the arguments to use C anymore - you can write C style C++ and get on with your life, and cherry pick the features you want. In C++ unicode is as simple as: string s = u8"This is always a utf8 string.";
- phkahler 12y agoI'm a little afraid the language will go down hill from here. Too many versions - a committee dedicated to creating new versions of the language standard is going to do exactly that. Much like has happened with OpenGL.
- _pmf_ 12y ago> Too many versions - a committee dedicated to creating new versions of the language standard is going to do exactly that. Much like has happened with OpenGL. The problem with OpenGL was that they tried to retrofit an API that assumed a certain underlying hardware model to modern (i.e. less than 15 year old) GPUs. It was impossible to do in any sane manner.
- nly 12y agoYou can grab and compile the very latest draft from the committees Github page: https://github.com/cplusplus/draft https://github.com/cplusplus/draft The current version is a slender 1365 pages, including the standard library.
- cletus 12y agoI've started getting back into C++ after many years away and it's all coming back to me. Now of course it's C++11, which does have some nice features, but really I think we've reached the point where we need to start again (downvote away). Let me give you an example: I recently came across some code that was written years ago that has two size types: one 32/64 bit signed and the other 32 bit unsigned. This creates a bunch of issues when compiled on 32 and 64 bit architectures and there is a substantial amount of effort to clean it up. I point out things like this to colleagues who are very pro-C++ and I inevitably get the same response: "well that's just bad API design". Thing is, if you look at the history of this example it's a series of incremental changes, all well-meaning and reasoned, some of which are done by people who I could only call luminaries, and even they make significant and far-reaching mistakes. So what hope do the rest of us have? But my biggest problem with the C-dialects is pointers. Namely if you return or receive a pointer, it's not necessarily clear who owns it. The way this is handled is comments like "DO NOT delete this" or "you MUST delete this". I like that a language like Rust is trying to formalize the concept of object ownership. I'd really like to see that idea mature and take hold. Until now there hasn't really been a competitive alternative to C/C++. It's not Go (as much I love Go). Maybe it's Rust. We can but hope. My other big problem (and this applies to Java too) is directly dealing with low-level multithreading primitives like threads, thread groups and mutexes. I really like that Go has taken a different approach here. What I find with particularly young programmers is they don't have the appropriate fear of writing multithreaded code. It's really, really hard to write correct multithreaded code with low-level primitives. It's why (excellent) books like Java Concurrency in Practice exist. As for the feature list of C++14 [1], I wonder what all these "auto" declarations will do to the significant work required for static analysis tools, that are an essential part of modern, large-scale C++ codebases. The literal types (like "s" for std::string or seconds) are cute but at some point the STL was optional. I'm a little leery of embedding it directly in the language but hey I'm no expert. [1]: http://en.wikipedia.org/wiki/C%2B%2B14 http://en.wikipedia.org/wiki/C%2B%2B14
- Nursie 12y agoOn pointers - Like a lot of things with C, you need to handle ownership by convention. I generally try to make the actor that created the heap pointer the owner of it and responsible for its destruction - i.e. instead of allocating buffers and handing them back up the chain full of data, pass them down from the requester where possible. If the length is not known at that point, create another routine to calculate it. Using techniques like this, ownership can become easier. You can do anything with it, but that's half the problem! And personally I like threads :)
- deleted 12y ago[deleted]
- hit8run 12y agoAnd we have golang.
- Guthur 12y agoI see a lot of discussion around C++ becoming modern. I would like to know which features are actually modern? Is it lambdas? been around for literally decades. Is it type deduction? again been around for quite some time, far better type inference has been available in the likes of Haskell for quite some time. Is it addition of a particular threading model to the standard? this has always been available via some form of library, it just know means the language is truly obsolete if the model changes. Allow GC'd implementations? again decades. What is modern about any of features that have been added?
- pjmlp 12y agoThe way all those languages are used together. Not writing modern C++ means: - writing C++ as if it was plain C - doing OO programming with big object graphs - manual memory management - not using the standard containers and algorithms - writing functor objects
- tomp 12y agoHow can you not use manual memory management in C++? Say you're writing a compiler, which uses a quite complex, possibly circular, graph structure of objects for its AST representation. You can't use SharedPtrs (cycles), can't use UniquePtrs (sharing of graph nodes), can't use RAII (unpredictable lifetime). I see no better solution than a GC.
- pjmlp 12y agoWhy can't you use them? Lots of compilers written in C++ use them. Ever heard of weak_ptr?
- maxlybbert 12y agoEven Stroustrup says that there are times garbage collection is the right solution. But, some people are surprised that there are times it isn't needed, and that garbage collection always brings the burden on unordered finalization (e.g., it's possible for an object's members to be finalized before the object, so finalizes must be written in a way that assumes very little about what is valid regarding data members).
- jokoon 12y agoAre modules already kind of unofficially supported, or can they be enabled ? On what platforms ? I'm trying to make a C++ game with fat libraries like Ogre3D and bullet3D, often on a laptop, and that would really be fantastic to not wait 10s or more each time I edit a header. I've seen a presentation, basically modules would decrease compile time from M x N to M + N.
- selvan 12y agoC++ is suitable for development of cross mobile applications , since both iOS and Android tool chain has support for C++.
- pjspycha 12y agoNumber one wishlist item for next C++ is to add networking libraries to the STL. Its past time that C++ knew about the internet.