News for hackers. Stuff that matters.
Re:We have C++14 by daenz on Monday August 18, 2014 @03:58PM (#8194304)
When 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.
Re:We have C++14 by PopsiclePete on Monday August 18, 2014 @07:38PM (#8195280)
Too bad it's a mirage. No, really. "Modern C++" doesn't exist outside of blog posts, books, and tutorials.

Real-world C++ is an array of sometimes mututally-exclusive dialects, patterns, rules, sub-dialects.

Reading MFC is nothing like reading Qt which is nothing like WxWidgets which is nothing like Boost which is something (but not quite like) the STL which is way different from Apache C++ libs which is way different from what Google's C++ libraries are...

This is what happens when a language is "un-opinionated", throws everything including the kitchen sink at the language, tries to compile C and legacy C++ while introducing new features oh and also can't break existing code.

It's on its way out, no doubt about it. And we'll be better off as an industry for it, I'm sure of it.

Rust, Go, and others will be there to fill in the gap in a much better, saner, safer, maintainable way.

Re:We have C++14 by jonstewart on Monday August 18, 2014 @08:12PM (#8195385)
As a counterpoint, I write "Modern C++" for my job. I know several others who do, too. I'm overjoyed at how much the C++11 features have improved my code (and I'm still learning how to deploy them effectively), as well as how good the compiler support is.

MFC was the vilest, most horrible abuse of C++ from the day it was released. Anything that involves MFC should just be rewritten with C# or turned into a webapp. I wouldn't take a job that involved programming MFC.

Re:We have C++14 by _pmf_ on Tuesday August 19, 2014 @04:42AM (#8196458)
> MFC was the vilest, most horrible abuse of C++ from the day it was released.

MFC's greatest benefit was that it made returning to plain win32 C programming without MFC a pleasurable experience.

Re:We have C++14 by pjmlp on Tuesday August 19, 2014 @12:32PM (#8198245)
Funny thing is that MFC iw like that because of Win16/Win32 C developers.

Microsoft team made a prototype OO framework even more OO that what OWL and others offered. MFC was the result from the feedback over the said framework.

Re:We have C++14 by dicroce on Monday August 18, 2014 @08:29PM (#8195442)
Me too. RAII ftw!
Re:We have C++14 by sillysaurus3 on Monday August 18, 2014 @08:42PM (#8195486)
Good luck making your RAII class exception safe. It's extremely difficult, to the point that writing a simple class becomes an hours-long exercise in reasoning about exceptions.

And of course, if you admit that exceptions aren't worth worrying about, then you'll start to question the entire "C++ way," which usually ends in disillusionment.

Alternatively, instead of disillusionment, you may still kind of enjoy C++. But suddenly you find that it's been three years since you've worked with C++, and on reflection, you haven't really been missing out on much of anything at all by not using C++.

It doesn't seem like C++ solves the right problems, even with the new dialects. Programming languages should be convenient to think in. By immersing yourself in the C++ mental model, it becomes difficult to keep a large-scale architecture entirely in your head.

Re:We have C++14 by eropple on Monday August 18, 2014 @11:00PM (#8195864)
> Good luck making your RAII class exception safe. It's extremely difficult, to the point that writing a simple class becomes an hours-long exercise in reasoning about exceptions.

In my experience, this is literally backwards. RAII is the only way to make exception-safe classes that aren't a gigantic mess.

> It doesn't seem like C++ solves the right problems, even with the new dialects. Programming languages should be convenient to think in.

No, some progrmaming languages should be convenient to think in. Some need to be uncompromisingly fast. C++ is in the latter set and nothing more convenient to think in is faster.

Re:We have C++14 by halfcat on Monday August 18, 2014 @11:32PM (#8195932)
>Some need to be uncompromisingly fast. C++ is in the latter set and nothing more convenient to think in is faster.

Yes, and C++11/14 make significant strides toward being more convenient to think in as well, without compromising speed. In fact some improvements also improve speed in some cases.

Re:We have C++14 by sillysaurus3 on Tuesday August 19, 2014 @12:18AM (#8196001)
Yes, RAII is the only way to make an exception-safe class. Good luck doing it. It's not easy. I know; I've tried. There are all kinds of corner cases and special considerations that you have to take into account. People have written huge tomes about that exact topic detailing exactly why it's a hard problem and why you're probably not going to solve it correctly by accident. You're far more likely to introduce a memory leak than to make your class exception safe on the first try. That's my point. That's why C++ is overly cumbersome unless you ignore most of its capabilities, like exceptions. And that's why you can simply ignore C++ and not miss out on much. If performance is your only reason for rigorously sticking to a mental model, it's likely that your mental model is a premature optimization.
Re:We have C++14 by chetanahuja on Tuesday August 19, 2014 @04:02AM (#8196364)
"Good luck doing it. It's not easy. I know; I've tried" Completely unsupported assertion (no pun) without evidence. Other people have tried it, and have succeeded. I could start listing all the software written in C++ that you use in your everyday life, perhaps 100's of times a day... but that'll quickly exhaust my word limit for this post.

"That's why C++ is overly cumbersome unless you ignore most of its capabilities, like exceptions."

Complete non sequitur. Exceptions are not "most of C++ capabilities". In fact, you can refuse to catch or throw exceptions for 99% of your (millions of lines) of code and still end up with a very large, stable code base running a large portion of the internet. Ask Google.

Today, there's pretty much no viable alternative to C++ for writing large scale, high performance systems with reliable performance guarantees. You could do it in C if you have a religious anti-C++ agenda but that would be like cutting off your nose to spite your face, and you'll end up in a horrible mish-mash of macros and generated code all over the place for a project with any level of complexity. Rust or D might get there some day if they manage to attract a solid community and big corporate backing. But they are certainly not there yet.

Re:We have C++14 by vog on Tuesday August 19, 2014 @08:33AM (#8196954)
> Exceptions are not "most of C++ capabilities".

To add to this point: There are C++ frameworks such as Qt who don't use exceptions at all! And what impressed most: When writing a Qt application, you don't even miss exceptions. You don't have to resort to C-style return value checking all over your code. How is that? It took me some time to figure this out, but I believe it is because Qt applies the "Null Object" pattern consequently - down to the deepest depth of their framework,

Re:We have C++14 by wfunction on Tuesday August 19, 2014 @01:44PM (#8198706)
Actually that statement has a point. Have you ever tried implementing std::vector and java.util.ArrayList and comparing the two implementations? One of them is trivial, the other one is most certainly not. One of the reasons is exception-safety guarantees. I'll leave it for you to figure out which is which.
Re:We have C++14 by lmm on Tuesday August 19, 2014 @07:51AM (#8196839)
> you can refuse to catch or throw exceptions for 99% of your (millions of lines) of code and still end up with a very large, stable code base running a large portion of the internet.

The point is that these features are infectious. If you don't want to throw exceptions, how do you handle a failure in a constructor? And then if you abandon constructors, other C++ features are unusable without them. And so on.

Re:We have C++14 by rozim on Wednesday August 20, 2014 @01:37AM (#8201211)
Googler here. We avoid doing "work" in constructors as per the style guide: http://google-styleguide.googlecode.com/svn/trunk/cppguide.x...
Re:We have C++14 by lmm on Wednesday August 20, 2014 @04:39AM (#8201543)
Yeah, that's pretty much what you have to do, and go back to a C-style init method. But then you've lost the benefits of RAII, and you can't necessarily use those types with templates (which won't know about your init method).
Re:We have C++14 by sillysaurus3 on Tuesday August 19, 2014 @10:10AM (#8197339)
You could do it in C if you have a religious anti-C++ agenda but that would be like cutting off your nose to spite your face, and you'll end up in a horrible mish-mash of macros and generated code all over the place for a project with any level of complexity.

Have a look at Tarsnap's source code.

Re:We have C++14 by jonstewart on Tuesday August 19, 2014 @02:18AM (#8196195)
What were these corner cases and special considerations you ran into?

I wouldn't call Herb Sutter's _Exceptional C++_ a huge tome and it seems to be the standard treatment of exception safety.

Re:We have C++14 by sillysaurus3 on Tuesday August 19, 2014 @11:55AM (#8198002)
It's 240 pages of knowledge that you can completely do without, and it's a book called "47 engineering puzzles." The puzzles, of course, are entirely exception-related.

I'm not saying it's impossible to write exception safe code. I'm saying that you can write code without exceptions without being worse off for it.

Re:We have C++14 by jonstewart on Tuesday August 19, 2014 @09:21PM (#8200704)
We're talking about the same book, _Exceptional C++: 47 Engineering Puzzles, Programming Problems, and Solutions_, by Herb Sutter. The takeaway I had from reading that book (a long time ago) was just to use RAII religiously, which also tends to make other things easier.

So I'm curious about why you think RAII makes writing exception-safe code difficult?

Re:We have C++14 by sillysaurus3 on Tuesday August 19, 2014 @10:36PM (#8200862)
Sorry for the confusion. I meant that writing exception-safe code is difficult, not that RAII makes it difficult to write exception-safe code. I should have been clearer about that.

The book is excellent. For anyone who wants to use C++ exceptions, it should be required reading. But as someone who has gone through that gauntlet, I feel that I probably would've been better served by spending my time on something other than mastering the finer points of exceptions.

The reason I started talking about C++ exceptions in the first place is because, in my experience, when someone is very pro-RAII (like the original commenter I responded to), they also tend to be pro-exceptions. This isn't always true, but on average, it seems like either people prefer both or prefer neither.

Writing exception-safe code is certainly one of the hardest challenges available in C++, so if you enjoy a good challenge, then it's hard to do better. But if you're just looking to design large-scale systems, it seems like exceptions are unnecessary, as Google has demonstrated by banning the use of exceptions in their codebases.

In my experience, by refraining from using exceptions, it's possible to design large codebases more quickly, with fewer bugs, and without losing any safety or extensibility. However, this is simply my personal experience, and it may be mistaken to generalize this into a claim that all codebases among all C++ teams should refrain from using exceptions.

So, that's all I meant. I was also in excruciating pain yesterday due to a certain tooth that decided to segfault in my mouth, which may have contributed to the adversarial nature of my writing style. I feel bad about how I came across, and I sincerely apologize for it. No excuses, though: I should've done better.

Re:We have C++14 by cubbimew on Wednesday August 20, 2014 @09:08AM (#8202158)
> either people prefer both or prefer neither.

exceptions (specifically, exceptions from constructors) are part of what RAII is, so it's only natural that people "prefer both".

As another personal anecdote, in my experience working with a large (175MLoC at last count) mostly-C++ codebase, I can't imagine how painful it would have been if the code didn't use exceptions.

Re:We have C++14 by prodigal_erik on Thursday August 21, 2014 @05:44AM (#8206572)
Their style guide http://google-styleguide.googlecode.com/svn/trunk/cppguide.x... is sheepish about it. The authors seem to believe using exceptions would have been better, except they found themselves beyond a critical mass of bad code that would fail or leak on a throw, and now they can't fix it all or throw it away.

I can't understand how a correct init method could be easier to write than a ctor, given that the compiler is required to generate code that knows which of your base classes and fields are already initialized at any point they could fail, which you would have to do yourself after moving to an init method, as well as losing the guarantee you can't silently ignore an error by forgetting to check for it.

Re:We have C++14 by jonstewart on Monday August 18, 2014 @09:48PM (#8195684)
Huh? RAII is basically the only way to write exception-safe code in C++.
Re:We have C++14 by pjmlp on Tuesday August 19, 2014 @03:14AM (#8196283)
> But suddenly you find that it's been three years since you've worked with C++, and on reflection, you haven't really been missing out on much of anything at all by not using C++.

True on my case, now using the language mainly on hobby projects, although we are very good friends since 1993.

Personally I would like safer systems programming languages from Mesa branch of languages had more use in the industry, but OS vendors decided to embrace C instead, and we ended up in the exploits everywhere that we enjoy nowadays.

C++ is not perfect, but it surely is way better than C in terms of safety.

Until a big OS vendor decides to push another systems programming language, we won't see any major adoption from the alternatives.

Re:We have C++14 by eps on Tuesday August 19, 2014 @03:55AM (#8196351)
RAII is hardly a trait of modern C++.
Re:We have C++14 by leoc on Tuesday August 19, 2014 @08:47AM (#8197000)
Is your meaning that it's not a distinctive trait of modern C++?
Re:We have C++14 by 72deluxe on Tuesday August 19, 2014 @04:15AM (#8196392)
Eh? How do you mean that?
Re:We have C++14 by vidarh on Tuesday August 19, 2014 @04:25AM (#8196415)
Presumably that it's nothing new. The term RAII dates to the mid to late 80's sometime, and you could hardly find any book about C++ from the 90's onwards that wouldn't be espousing RAII as the One True Way.

RAII has been with C++ almost from the beginning.

Re:We have C++14 by deong on Tuesday August 19, 2014 @09:26AM (#8197112)
Yes, but "modern" doesn't imply that no feature is older than Twitter. "Modern C++" refers to the way that C++ is written today, and some of that is new additions to the language, some has been there for ages.
Re:We have C++14 by 72deluxe on Tuesday August 19, 2014 @04:18AM (#8196399)
I have furniture at home made of wood. Oddly, my table looks nothing like my broom handle, so does this mean that wood is a terrible choice for both items? "The industry would be better off without wood!!"

Surely libraries in other languages have the same problem? They don't look anything like each other.

wxWidgets and Qt look nothing like each other but it isn't a problem at all. The signalling mechanism / event handling between the two just hides function pointers, so it isn't a headache. In fact, MFC looks like wxWidgets to me. Not sure what the problem is?

EDIT: Not sure why the downvote(s)? Do people get downvoted here because someone points something out that is true on a subject/language that they like/dislike? Or was it the tone or supposed tone that the person read the comment in? Please let me know!

Re:We have C++14 by kelvin0 on Tuesday August 19, 2014 @08:13AM (#8196897)
It`s the down vote pigeon, hitting randomly and savagely.
Re:We have C++14 by 72deluxe on Tuesday August 19, 2014 @08:43AM (#8196988)
Sure is a vicious beast! Must have got into a bit of a flap. Pigeons have tiny brains don't they?
Re:We have C++14 by abdulhaq on Tuesday August 19, 2014 @01:48PM (#8198740)
Forget about the downvotes, if you're not trolling then know they are a red herring.
Re:We have C++14 by Iftheshoefits on Monday August 18, 2014 @08:32PM (#8195454)
People have been saying this about C and C++ for decades. Not to say C++ will always be "on top", or even that it currently is, but your comment isn't really substantive or persuasive that "it's on its way out."

I'm also not convinced that Rust or Go are better or saner.

Re:We have C++14 by beefsack on Monday August 18, 2014 @09:06PM (#8195568)
I can understand the few controversial design choices in Go which limit it's use cases, but would be interested to hear why you claim Rust isn't saner than C++.
Re:We have C++14 by Pacabel on Monday August 18, 2014 @10:08PM (#8195715)
When it comes to Rust, there's no stable version of the language at this point. There's no stable version of the standard libraries. There's no reliable production-grade compiler available. As the Rust home page itself states, "Rust is a work-in-progress and may do anything it likes up to and including eating your laundry."

Maybe Rust will offer such stability in the future. But that's of no use to people and organizations who need to develop software today, and who need to be able to trust that the code they write now will compile and work tomorrow, a month from now, a year from now, and perhaps even decades from now.

C++ does offer stable, standardized, well-supported versions of the language. C++ does offer stable, standardized, well-supported standard libraries. There are numerous high-quality free and commercial C++ implementations available, for just about every platform imaginable. It provides a robust and predictable platform that serious and massive software systems can be built upon.

The theoretical benefits that Rust may bring are pretty much irrelevant as long as it isn't a production-ready language in the way that C++ is.

Re:We have C++14 by zxcdw on Monday August 18, 2014 @11:41PM (#8195949)
But now you aren't talking about Rust the Language but Rust the Ecosystem.

Not that I am disagreeing with your points, I am not. However, when people talk about C++'s problems, I immediately assume they talk about C++'s problems as a language rather than it's ecosysem.

Rust isn't out there to tackle C++'s ecosystem, tooling, legacy code or professional workforce, but rather Rust aims somewhere near C++ and fixes many of the language flaws which are inherent in C and C++, while still being competitive in performance and low-level control.

Re:We have C++14 by CountSessine on Tuesday August 19, 2014 @12:50AM (#8196060)
Ecosystem really is the whole problem, though. You can never make it big without having lots of friends.

Rust is a pretty cool language, but I can't help being reminded about another very well-designed but ultimately unsuccessful C++ challenger, D. The parallels are really hard to ignore.

D, like Rust, had great syntax and was a breath of fresh air after coding with C++98. Neither Rust not D has a sponsor with really deep pockets to encourage adoption. Neither came out of a standards process. Both have had compiler and standard library issues. The big difference between the two at this point seems to be momentum and where the two are in their parabolic trajectories.

Re:We have C++14 by danieldk on Tuesday August 19, 2014 @01:23AM (#8196115)
There are important differences: D threw away one of the most important features of C/C++ (for the target audience): usability of the language without a garbage collector.

Also, Mozilla has much deeper pockets than Digital Mars.

Still I agree with you that it is very likely that Rust will follow a parabolic trajectory. The advantages as perceived by the industry compared with C++11/14 will be too few. At the same time it does not have the ecosystem.

Go succeeded because of Google's deep pockets and, perhaps more importantly, because it filled a large niche that even the authors did not anticipate: a faster language for Python and Ruby aficionados.

Re:We have C++14 by pcwalton on Tuesday August 19, 2014 @02:45AM (#8196238)
> Still I agree with you that it is very likely that Rust will follow a parabolic trajectory. The advantages as perceived by the industry compared with C++11/14 will be too few.

Rust is memory- and type-safe (as in: the compiler will not let you write a dangling reference, invalidate an iterator, or write exception-unsafe code without opting into an unsafe dialect). The security benefits alone of that are enough to justify the language for our use cases, and, from what we've seen, for many others. Safe zero-cost abstractions are a niche to its own.

Re:We have C++14 by eco on Tuesday August 19, 2014 @01:30PM (#8198628)
Could you be specific about what in D isn't useable without the GC? You can use manual memory management in D. It has Unique (unique_ptr) and RefCounted (shared_ptr). It has Array. It has malloc and free. None of these use the GC.

People complain about the GC being available to use while simultaneously complaining that to avoid it you have to manage your memory yourself. You can't have it both ways. There is no memory allocation strategy that works best in every situation. Sometimes ref counting is best, sometimes stack allocation, sometimes RAII, sometimes memory pools, sometimes its the GC.

Rust has done some cool work with memory but even it doesn't free the programmer from having to consider and choose which memory allocation/ownership option is going to deliver the best performance on a case-by-case basis.

You're right about Rust and Go having much deeper pockets. D isn't backed by any corporation. It's 100% a community project. Maybe it won't ever gain a significant market share because of this. I don't know.

Re:We have C++14 by infinite8s on Wednesday August 20, 2014 @06:26AM (#8201760)
It took python (which also doesn't have a deep-pocketed company backing it) about 15-20 years before it saw widespread adoption.
Re:We have C++14 by deong on Tuesday August 19, 2014 @09:43AM (#8197191)
I would also say that D did itself irreparable harm with the whole v1-v2 standard library debacle. Right when it was receiving the most attention, it came right out and said to anyone who might have considered it, "we have two incompatible versions of the standard library: one which we don't support anymore and one you can't use yet."
Re:We have C++14 by eco on Tuesday August 19, 2014 @01:48PM (#8198735)
Yeah, that certainly hurt D's reputation. People still bring it up even though it's been resolved for years.
Re:We have C++14 by abdulhaq on Tuesday August 19, 2014 @01:47PM (#8198729)
That was then and this is now, there is one standard library and the language has come on leaps and bounds. D is a great language.
Re:We have C++14 by deong on Tuesday August 19, 2014 @09:48PM (#8200764)
I'm not arguing otherwise. But as the saying goes, you only get one chance to make a first impression, and D's first impression was of a train wreck.
Re:We have C++14 by jnbiche on Tuesday August 19, 2014 @07:37AM (#8196806)
>At the same time it [Rust] does not have the ecosystem

Try watching new projects pop up at Rust CI [0] for a few days. With the possible exception of Node (which is not even a PL), I've never seen a language ecosystem grow this vast, and I'm a PL afficionado.

I think in a year's time, the question of Rust's stability and ecosystem will be entirely moot. It's a tough wait meanwhile, but I'm still investing the time in learning Rust (and it's a significant investment).

0. http://www.rust-ci.org/projects/

Re:We have C++14 by Pacabel on Tuesday August 19, 2014 @08:06AM (#8196874)
Is Rust CI really the best evidence to use in this case?

When I last looked at it, probably 40% to 50% of the projects listed had builds that were in the "failing" or "error" statuses.

That indicates that one or more of at least a few things are happening:

1. The Rust language and its standard libraries are changing at a pace that results in previously-compiling code needing to be modified before it will compile again with a newer version of the language/implementation, perhaps a very short time after the code was initially written.

2. The Rust compiler or other tooling is crashing or failing in some way while compiling these projects.

3. The projects themselves aren't being maintained on an ongoing basis.

4. The projects themselves were never building properly in the first place.

5. The projects' developers are targeting different versions of Rust (which probably means there will be interoperability problems for anyone trying to use them in a larger projects, especially when it comes to libraries).

And while there may be a lot of these projects, I've never found the quality to be very good. Many of them are extremely limited or incomplete. Many of them are little more than casual experimentation. Many of them are only developed by a single person, who often has appeared to have lost interest.

Those factors are disconcerting, especially for somebody who wants to use Rust for serious product development. It does no good if there are hundreds of libraries available for use, but half of them don't even build, and the ones that do are very incomplete.

Re:We have C++14 by jnbiche on Tuesday August 19, 2014 @09:09AM (#8197059)
>Many of them are extremely limited or incomplete. Many of them are little more than casual experimentation. Many of them are only developed by a single person, who often has appeared to have lost interest.

Yes, I completely agree, and this is an entirely normal part of the language ecosystem development cycle. Rust is at the tail end of the experimentation stage, and as it converges on 1.0, more people will undertake serious projects.

I'm not at all worried about the quality of Rust projects. I'm just happy to see so much enthusiasm. I have no doubt that all this enthusiasm will transfer into some powerful libraries as Rust continues to stabilize and reaches 1.0.

But yes, it's still to early to use Rust for production unless you're willing and able to write your own libraries.

Then again, the "batteries included" approach of Rust's standard library leaves not much to be desired outside of domain-specific libraries.

Re:We have C++14 by pjmlp on Tuesday August 19, 2014 @02:37AM (#8196229)
Given the Mesa/Cedar system a Xerox PARC, Oberon at Swiss Federal Institute of Technology and Modula-3/SPIN at Olivetti, doing OS work in GC enabled systems programming languages is quite possible.

The problem is how to move OS vendors away from C's influence.

Re:We have C++14 by fithisux on Tuesday August 19, 2014 @09:07AM (#8197055)
Use micro-kernels.
Re:We have C++14 by loup-vaillant on Tuesday August 19, 2014 @09:53AM (#8197238)
Exo-kernels might be a better alternative.

https://en.wikipedia.org/wiki/Exokernel

Re:We have C++14 by pjmlp on Tuesday August 19, 2014 @10:13AM (#8197351)
It is a matter of willingness, not technology.
Re:We have C++14 by Zardoz84 on Tuesday August 19, 2014 @06:45AM (#8196694)
Facebook have deep pockets ... Yep, Facebook is using D for some stuff.
Re:We have C++14 by Pacabel on Tuesday August 19, 2014 @08:19AM (#8196919)
A large or well-known company merely using a programming language, and maybe even contributing back to it and its community, isn't the same as the company truly supporting or championing it.

What you describe is very different from, say, how Sun pushed Java, or Microsoft pushed C#, or how Apple will likely push Swift, or how a huge portion of the entire software industry pushed C and C++.

Facebook's Hack language is probably a much better example than D is of a language that they're actively supporting. It's a creation of theirs, rather than just a creation of somebody else's that they find useful in some limited cases.

Re:We have C++14 by pcwalton on Tuesday August 19, 2014 @02:49AM (#8196247)
> Both have had compiler and standard library issues.

What are the compiler/standard library issues with Rust? Sure, it's taken time to get to a high level of quality, but no language compiler and library is going to spring out of thin air fully complete. In particular, I'm confident that the Rust compiler is of high quality for its age, especially in the quality of the generated code.

Re:We have C++14 by LeonidasXIV on Tuesday August 19, 2014 @07:25AM (#8196775)
> In particular, I'm confident that the Rust compiler is of high quality for its age

I'd like to concur. I've used the Rust 0.10 compiler and the only bug I encountered was that generating debug binaries was somehow broken. Apart from that, it was one of the smoothest experiences ever and the error messages are amazing.

Re:We have C++14 by jnbiche on Tuesday August 19, 2014 @07:40AM (#8196812)
Rust error messages are perhaps the best thing about the compiler. For me, it's a new experience altogether. Instead of having to Google obscure error messages, Rust error messages actually tell me how to solve the problem!
Re:We have C++14 by EpicEng on Tuesday August 19, 2014 @12:50AM (#8196061)
I don't think that the two can be separated in any meaningful way. Of course they're different things, and we can discuss each on their own, but when it comes to which language to use as a business decision then the line becomes blurred if not completely transparent.
Re:We have C++14 by stormbrew on Tuesday August 19, 2014 @03:04AM (#8196268)
Rust is really the only language that's actually targeting the same niche as C++ primarily occupies, system level programming where reasoning about memory management and performance is part of the actual work being done. Go, let alone others, simply do not allow you to do this.

It shows a distinct lack of understanding of why people still use C or C++ to raise languages/environments like Go as viable alternatives.

Re:We have C++14 by PaulFreund on Tuesday August 19, 2014 @04:37AM (#8196450)
Don't forget D
Re:We have C++14 by jnbiche on Tuesday August 19, 2014 @07:32AM (#8196793)
D is fine language and a pleasure to program in, but with it's required garbage collector, it's not really in the same niche as C/C++/Rust. I think the hallmark of this niche is the ability to run without a garbage collector penalty and the accompanying lack of determinism.
Re:We have C++14 by fithisux on Tuesday August 19, 2014 @09:06AM (#8197048)
Oh not again the GC argument.

D is the one true C++ without pretending being a superset of C. Rust is more modern than C++ and better in programming in the large. But D is really for low level programming and a good target for code generation. For me it is a good replacement for C++ and Delphi. It is even a good fit for areas touched by Java and C# like desktop and scientific apps. But it is not there yet because of lack of serious tooling and lack of bytecode but for the second disadvantage you earn performance. Nimrod for example could address this (with D as a code generation target).

Re:We have C++14 by eco on Tuesday August 19, 2014 @12:58PM (#8198417)
You can use D without using the GC. I'm not sure why this myth keeps coming up. It's always supported manual memory management. You have to sacrifice some language features that aren't even available in C++ and some parts of the standard library use the GC but that is easy to avoid with yesterday's 2.066 release and the @nogc attribute. 2.067 should also have a lot of the standard library switched to using lazy algorithms where possible which means the caller gets to determine the allocation strategy (and can often avoid allocation entirely).

void main() @nogc { /* ... */ } // this program doesn't use the GC

Re:We have C++14 by loup-vaillant on Tuesday August 19, 2014 @09:45AM (#8197199)
Ordinary C++ with good old RAII do use something akin to garbage collection: many classes, when constructed, allocate memory on the heap, then free that memory when they fall out of scope.

Malloc() and free() aren't exactly predictable. If you really want guarantees, you need to write your own custom allocator, and if you don't need those guarantees, garbage collection is probably enough for your purposes.

Basically, if you're using C++ without real manual management, with custom allocators, pools, and all, you probably didn't need C++ in the first place.

Re:We have C++14 by stormbrew on Thursday August 21, 2014 @02:12AM (#8206105)
RAII is a form of automatic resource management, it's true. It is, however, a deterministic form of automatic resource management.

This is not to say that the underlying allocator is necessarily deterministic, but you're making a false dilemma here by putting it in opposition to making decisions about custom allocators and pool allocators. You can use RAII with custom allocators. You can use RAII with memory pools.

And that's where C++ really does shine. It's a niche that hasn't even really been attempted much, let alone that it's been surpassed in.

Re:We have C++14 by Cyther606 on Tuesday August 19, 2014 @09:56AM (#8197255)
With Nimrod, you can manage your own memory, or use the Boehm GC. It compiles to C/C++ with native code generation not dependent on a VM, and the Pythonic syntax makes writing such code as easy as common scripting languages [1].

1: https://github.com/def-/nimrod-unsorted

Re:We have C++14 by pjmlp on Tuesday August 19, 2014 @12:35PM (#8198277)
You mean like Mesa/Cedar at Xerox PARC, Oberon at ETHZ, Modula-3 at Olivetti...
Re:We have C++14 by davvid on Monday August 18, 2014 @10:48PM (#8195819)
Too bad it's a mirage

I hate to spoil your worldview, but modern C++ is very alive and well in the scientific computing communities. Disney Animation implemented a new renderer using it, and our next movie is currently being rendered using the new renderer, so I highly doubt it's on its way out in the these areas.

Re:We have C++14 by rootbear on Tuesday August 19, 2014 @12:11PM (#8198097)
Is this a replacement for RenderMan? Interesting...
Re:We have C++14 by fithisux on Tuesday August 19, 2014 @09:13AM (#8197069)
How much time/money did it take to be implemented? What is the maintenance cost? Which version of C++? What percentage was written from scratch? Does it run in a networked environment? These are the real questions.

Pharao Inc. built pyramids in ancient Egypt. It cost many lives of slaves but it was cheap them. Nowadays we make big buildings without slaves.

Re:We have C++14 by Tloewald on Tuesday August 19, 2014 @10:03AM (#8197299)
It's not like C++ programmers are poorly paid.

And hey, don't knock the Pharaohs!

First off, it's been known for some time that the Pyramids were built by paid workers:

http://www.boston.com/news/world/middleeast/articles/2010/01...

(Literate too, since they left graffiti)

http://www.bbc.co.uk/history/ancient/egyptians/pyramid_build...

The conditions that migrant workers endure building World Cup facilities in Qatar seem to be worse than those endured by Egyptian construction workers:

http://www.theguardian.com/world/2014/may/14/qatar-admits-de...

Re:We have C++14 by enraged_camel on Monday August 18, 2014 @11:47PM (#8195962)
I don't see how that refutes the parent's comment. The areas you listed are very small niches. Frankly, very few people care about scientific computing or even animation rendering. Generally speaking, using C++ is like wearing jeans and white sneakers: popular in the 90s, but definitely out of fashion now.
Re:We have C++14 by EpicEng on Tuesday August 19, 2014 @12:52AM (#8196065)
Exactly. It is out of fashion, but fashion is fleeting. Fashion is a twenty year old wearing skinny jeans; style is James Bond in a Tuxedo, and it's timeless. What's in fashion today may very well be out of fashion tomorrow. I will likely still be writing C++ to get shit done.
Re:We have C++14 by CountSessine on Tuesday August 19, 2014 @12:42AM (#8196048)
Oh goodness - C++ is out of fashion? But I was so productive! And my code ran so fast! Well, I guess I should go read up on node.lang or er-rust, or whatever it is those kids are into...
Re:We have C++14 by bstamour on Tuesday August 19, 2014 @09:27AM (#8197115)
Very few people care about any kind of computing - they care about the end result. Between embedded systems, servers and systems programs, and infrastructure, the modern world basically runs on C and C++.
Re:We have C++14 by 72deluxe on Tuesday August 19, 2014 @04:19AM (#8196400)
Why do you need to be fashionable to be productive? Do people really ask what your finished software product is written in?
Re:We have C++14 by sumsumne on Wednesday August 20, 2014 @06:07AM (#8201734)
Whats your problem?
Re:We have C++14 by EpicEng on Monday August 18, 2014 @11:53PM (#8195975)
So "Modern C++" is a mirage, but Rust and Go are the surefire winners? Do you have any substance to add to your post?

I don't know, I've been writing C++ for about a decade and the code I write is "modern" as far as I can tell. I just started a new project. It is C++, it is "modern", and Rust and Go simply aren't options.

Rust is an infant and not yet ready for prime time, and Go simply wouldn't be considered by management. Not because they're ignorant, out of date curmudgeons, but because they want a larger pool of talent to draw upon and a language that is well known, well understood, and has decades of work invested around tooling. I can't say that I blame them.

Re:We have C++14 by loup-vaillant on Tuesday August 19, 2014 @10:07AM (#8197316)
Why do people keep assuming that they need an X programmer, or a Y programmer? Go is a garbage collected imperative and OO language, right? It's not like Java and C++ programmers wouldn't be able to learn the basics in 3 days, and be proficient in a couple weeks.

Why does the "pool of talent" even matters?

Re:We have C++14 by pjmlp on Tuesday August 19, 2014 @12:38PM (#8198292)
Companies don't want to pay for training.
Re:We have C++14 by yohanatan on Wednesday August 20, 2014 @03:41AM (#8201432)
So don't publicize the fact that you are 'learning' while you 'practice'. Just show the end result and it will likely be better than their language 'experts' could have done in any comparable [or infinite] time frame.
Re:We have C++14 by loup-vaillant on Tuesday August 19, 2014 @12:49PM (#8198362)
Not even 4 weeks worth of semi-productive self-learning? That sounds quite pathetic.

There must be something else, like fear of the unknown, risk aversion, "nobody got fired for choosing IBM"…

Re:We have C++14 by pjmlp on Tuesday August 19, 2014 @12:56PM (#8198411)
I know consulting companies that bill the customer the hours developers spend getting up to speed with a given technology.

In the cases the customer is not willing to pay, developers get asked to learn off work hours, if they want to stay on the project.

Re:We have C++14 by loup-vaillant on Tuesday August 19, 2014 @06:30PM (#8200176)
Now this is just abusive. I understand that as an individual I have to live with this, but collectively, it looks like we should rise up.
Re:We have C++14 by Mister_Snuggles on Monday August 18, 2014 @10:48PM (#8195817)
I think you could say the same thing about any language where there are big frameworks and libraries that handle a lot for you.

In the Java world, a Java EE CRUD application is a LOT different than a Swing application that does the same thing. Likewise, a Python Django application is a completely different beast than a console application.

Re:We have C++14 by danieldk on Tuesday August 19, 2014 @01:31AM (#8196121)
But there is less variation: Java provides only one paradigm (OO) and frameworks use different flavors of that: beans, POJOs, heavy classes, etc.

In C++ you can have such variations, plus all the other paradigms, including:

* C with classes (people programming in this style often still use C strings, do deletes and frees in destructors).

* C++ as the full-blown OOP language, with extensive multiple inheritance hierarchies.

* Nearly functional, STL-driven C++. In this code you see nearly no loops at all, <algorithm> is the control structure.

* Template-driven programming, with policy classes, dozens of specializations, only header files.

Etc. Java does not have the legacy to 'embed' another language. Java does not do multiple inheritance, avoiding heavy-inheritance-based projects, Java does not claim to be a semi-functional language (though Java 8 brings Java closer in that direction), and Java does not provide a turing-complete template language that is a world on its own.

Re:We have C++14 by Vaskivo on Tuesday August 19, 2014 @07:15AM (#8196750)
That's the problem I have with C++. It is a mish-mash of paradigms, features and techniques. It is not consistent in use-cases and philosophy (unless you count "all and everything" as use cases and philosophy).

As much as I try to find "my" general purpose language of choice, and forr all of my inertia in learning yet another programming language, I believe languages should have narrower scopes. And there should be more languages. Specialized for specific use-cases.

And, as a pythonista, the "you can do/use it in many different ways" just irks me.

Re:We have C++14 by jonstewart on Tuesday August 19, 2014 @08:32AM (#8196951)
One core part of C++'s philosophy where it's very consistent is that you only pay for what you use and the performance guarantees (e.g., STL) are explicit.

Another consistent part of C++ is that it gives you absolute control over memory, both allocation and layout. It's really this control that makes C++ unbeatable in performance. The good VMs can JIT their languages to match CPU performance on small routines, but they can't match C++ when it comes to manipulating big, complicated data structures.

Re:We have C++14 by lmm on Tuesday August 19, 2014 @07:56AM (#8196847)
I thought much like that (and was a huge Python fan) until I found Scala. There are cases people cite as "more than one way to do it", but they're usually superficial syntax differences. You do have to choose between passing around objects and passing around functions, but that's a choice you make in Python as well. It can handle high-performance calculation or high-level scripting, but it never feels like these are separate languages; it has a bunch of orthogonal features but any two of them combine in exactly the way you would expect (and often that combination forms something very useful).
Re:We have C++14 by danieldk on Tuesday August 19, 2014 @02:11PM (#8198863)
Scala is different than C++ in the sense that Scala at its core is a simple language compared to C++ and most abstractions are built from that. That said, there are different Scalas to, Scala the 'a better Java' is a very different language from scalaz/shapeless Scala.

This seems to be the curse of any powerful core language (Scala, Haskell, ...) - on the one hand they allow you to make all kinds of useful abstractions that you can't make with e.g. Java. On the other hand, their abstractions are so powerful that they create seemingly different languages.

One could apply the same rule as C++ - stick to a subset of the language/abstractions. However, if you look at e.g. Haskell, a large number of libraries now depend on a library such as lens [1], so often it's not that much of a choice.

Re:We have C++14 by lmm on Wednesday August 20, 2014 @11:31AM (#8202738)
I think it's good that a library can become sort-of "standard" without having to be part of the language standard library (where, as the python folk say, modules go to die). We're starting to see this come together in Scala-land - if you want a Monad typeclass you use the Scalaz one, if you want a HList you use the Shapeless one, and if you want HTTP you build on top of the spray-http abstractions (I'm particularly pleased that Play intends to port to run on top of Spray). That's something that you don't really get in C++, with the possible exception of boost; there are still multiple ways to do threading, multiple ways to do event-driven, all with their own conventions.
Re:We have C++14 by 72deluxe on Tuesday August 19, 2014 @04:20AM (#8196403)
That's a pity. My code appears to be a mix of the first three.....

any recommended reading?

Re:We have C++14 by eropple on Monday August 18, 2014 @11:01PM (#8195870)
> "Modern C++" doesn't exist outside of blog posts, books, and tutorials.

That you aren't used to doing greenfield development doesn't mean others are likewise impaired.

Re:We have C++14 by stinos on Tuesday August 19, 2014 @03:02AM (#8196265)
While a bit harsh sounding, this is actually spot on. What I write nowadays vs 5 years ago: hard to believe it is the same laguage.
Re:We have C++14 by eropple on Tuesday August 19, 2014 @09:32AM (#8197150)
Exactly. I only write greenfield C++ and I dig it a whole bunch.
Re:We have C++14 by p0nce on Tuesday August 19, 2014 @10:05AM (#8197312)
Good for you. It would be harder to dig if you had to do some maintenance like less lucky lifeforms.
Re:We have C++14 by gurkendoktor on Tuesday August 19, 2014 @03:26PM (#8199261)
I have only worked on one legacy C++ code base, and it was a student job, but I've enjoyed it a lot. Most of "modern C++" can be applied to an old code base step by step, all the way up from C with classes. As long as nobody decides to introduce the project's first "const" somewhere in a core class... :)
Re:We have C++14 by eropple on Tuesday August 19, 2014 @11:54AM (#8197994)
I hope you didn't take that to mean that I don't maintain my own code. But I can choose when to refactor and when to put up with it. C++ isn't a tool to use when you can't own the project.
Re:We have C++14 by shmerl on Monday August 18, 2014 @09:33PM (#8195650)
My recent project uses standard C++11. No dialects, no restrictions. Gcc 4.8.x. It's not a mirage, it's all up to those who want to use it or not.
Re:We have C++14 by eps on Tuesday August 19, 2014 @04:04AM (#8196368)
You are missing the point. No project uses all features of C++ at once, only a subset, and this forms a dialect. It's not that infrequent to see the dialect change when going from one team to another even in the same organization. Some use multiple inheritance and exceptions, some don't. Some swear by STL, some won't touch it with a long pole. That's why internal coding guidelines exist and that's why they are particularly detailed and thick for C++ shops.
Re:We have C++14 by shmerl on Tuesday August 19, 2014 @11:54AM (#8197993)
The commenter above claimed that "modern C++ doesn't exist" because normally only a subset of the language is used. I disputed that, and I got his point clearly. No one is using all features of the language just for the sake of it. That doesn't make used C++ not modern.
Re:We have C++14 by humanrebar on Tuesday August 19, 2014 @11:27AM (#8197820)
> No project uses all features of C++ at once, only a subset

Many features of C++ are targeted at library authors. Even if a given project won't allow template metaprogramming, it probably uses vector, which certainly does. And for good reason.

Re:We have C++14 by mariodiana on Monday August 18, 2014 @09:03PM (#8195559)
Could you name a book that focuses on Modern C++, that isn't one of these 1200 page tomes? I ask because sooner or later at my job I will probably have to code in C++. It will undoubtedly be a greenfield project, so I don't have to worry about anyone else's horror show (only my own).
Re:We have C++14 by helmut_hed on Monday August 18, 2014 @09:59PM (#8195701)
There's no better place to start than Alexandrescu's eponymous Modern C++ Design http://www.amazon.com/Modern-Design-Generic-Programming-Patt.... Scott Meyers will soon come out with "Effective C++11" which from the table of contents looks like it will do a great job of covering the new language features.

As for coding standards, I suggest a book by the same author plus the current chair of the standard committee: http://www.amazon.com/Coding-Standards-Rules-Guidelines-Prac.... Another commenter has suggested the Google C++ Coding Standards, but despite their popularity they do not conform very well to "Modern C++" as I understand it.

Re:We have C++14 by octopus on Tuesday August 19, 2014 @12:21AM (#8196007)
Try "A Tour of C++" by Bjarne Stroustroup it has less than 200 pages.
Re:We have C++14 by 72deluxe on Tuesday August 19, 2014 @04:21AM (#8196406)
Or just get Stroustrup's "The C++ Programming Language" and read the intro bit - it covers the language in fleeting detail but then you still have the rest of the book to look at if you are having a hard time understanding the section at the beginning.
Re:We have C++14 by octopus on Tuesday August 19, 2014 @07:21AM (#8196765)
I have both, "The C++ Programming Language" as a physical book and "A Tour of C++" as an ebook. "A Tour of C++" is self contained.
Re:We have C++14 by colin_mccabe on Monday August 18, 2014 @09:06PM (#8195569)
I would use the Google Coding standard. The best book to read is Effective C++ (get the latest edition, since they have changed a lot.)
Re:We have C++14 by panzi on Monday August 18, 2014 @09:16PM (#8195599)
Doesn't the Google coding standard use uppercase function names (like Microsoft)? Brrr. Classes are nouns -> uppercase, functions are verbs -> lowercase. Well, alt least if you speak German that is the logical choice.
Re:We have C++14 by MereInterest on Monday August 18, 2014 @09:57PM (#8195696)
It also completely forbids the use of exceptions. I can understand that for their stated purpose of working with non-exception-safe legacy code, but it shouldn't be extended to other circumstances.
Re:We have C++14 by millstone on Monday August 18, 2014 @10:04PM (#8195708)
Exceptions have a significant performance impact, and making code exception safe distorts your interfaces. Insisting on no exceptions is reasonable for these and other reasons, even for new code.
Re:We have C++14 by bodyfour on Monday August 18, 2014 @10:14PM (#8195729)
Depends on if you need to gracefully handle malloc failures or not. Otherwise any write operation on an STL type (like appending to a string) will potentially throw an exception that you need to care about.

In the C world this is extremely arduous since need to bubble the allocation-failure down through every level of code, adding cleanup to just about every function call. If you're using C++ and RAII you can just catch std::exception in one place to cover a huge number of places that an allocation can fail.

Re:We have C++14 by millstone on Monday August 18, 2014 @10:35PM (#8195782)
Do you work on systems that handle this? I'd like to know if any still exist.

In modern systems I'm familiar with, malloc only reports failure on bogus inputs like -1, or address space exhaustion. Your process is likely to be killed before exhausting your address space (think iOS OOM handling, or Linux overcommit), especially on 64 bit. So checking for allocation success just isn't that useful any more.

Re:We have C++14 by jjnoakes on Monday August 18, 2014 @10:47PM (#8195809)
Two examples come to mind.

The first is process limits.

The second is exhausting kernel data structure space for things like page mappings. I've seen this recently in AIX when allocating lots of memory that alternates mprotect permissions.

Re:We have C++14 by nanidin on Tuesday August 19, 2014 @12:24AM (#8196018)
I worked on an embedded system that aggressively cached images in memory dedicated to the GPU. It wasn't uncommon for gl texture allocation errors to occur - and in addition to that, we needed to decompress images packed in various formats into whatever format the GPU supported (typically from png to rgba32). In low memory situations, it also wasn't uncommon to not have enough contiguous memory to perform that decompression - in which case malloc would fail.

Gotta love putting forth every effort in software to keep the BOM down :)

Re:We have C++14 by bodyfour on Monday August 18, 2014 @11:18PM (#8195912)
As @jjnoakes points out, you'll get malloc()==NULL if your ulimits are set. For a long-running program you definitely want to have a ulimit that will kick in before the OOM killer does.

Even in the absence of the OOM killer (i.e. the old days) you had to do this -- otherwise the machine might be swapping itself unresponsive for ages before you ever get malloc()==NULL

Re:We have C++14 by wfunction on Tuesday August 19, 2014 @12:42AM (#8196049)
> Exceptions have a significant performance impact

Are you talking about enabling exceptions, or throwing them?

Re:We have C++14 by helmut_hed on Tuesday August 19, 2014 @12:48AM (#8196056)
Can you elaborate on the "significant performance impact"? If used properly, they should have no runtime overhead - they are predicted "not taken" in modern compilers.
Re:We have C++14 by yaantc on Tuesday August 19, 2014 @04:50AM (#8196474)
Early C++ implementations used setjmp/longjmp to support exceptions, and then each try block would lead to settting the setjmp context. So there definitely was a runtime overhead, even with no exceptions thrown.

I don't think it's very popular today. Modern implementation don't use this anymore and do not incur run-time overhead when no exception are thrown. However, they do incur some space overhead: the implementation need to maintain pretty large tables to know what needs to be unwound (which destructors to call, in which order) when an exception is thrown. In most environment this space overhead shouldn't be a problem (PC, server). But for embedded development it may be a problem. And then disabling exception to save space brings back the issues with error checking (or the lack of it...).

For more details, search for C++ exception implementation and you should find all the info you need. Or look into G++ documentation for example, this topic is covered somewhere.

Re:We have C++14 by pjmlp on Tuesday August 19, 2014 @02:40AM (#8196231)
> Rust, Go, and others will be there to fill in the gap in a much better, saner, safer, maintainable

For business applications? Sure.

For system programming?

Only if they get an OS vendor godfather that pushes the language into their SDK, like any other systems programming language that got widespread use.

Re:We have C++14 by DSingularity on Tuesday August 19, 2014 @12:18AM (#8196002)
And what exactly does that mean? So what if the libraries are all written differently? I hardly see how thats a negative thing. The language is flexible. I was very impressed with c++11 features and I am looking forward to c++14.
Re:We have C++14 by PeterisP on Tuesday August 19, 2014 @11:30AM (#8197845)
It means that the language as such - the codebases written in it - have a readability problem. If every project is written differently with opposing coding standards and practices, then it adds a significant switching cost when moving to a different project, debugging systems that includes libraries from various sources or reusing code.

For ecosystems where there is a "one way to do it", then picking up a random project or library from github and using or changing it is easy, as it is understandable in the same way as my own code; for C++ it is, well, different.

And this is directly caused by the language - the technical details of the language significantly influence the code ecosystem that grows around it. Lisps are another example of this - because it's simple to define commonly used stuff yourself, it results in every project doing the same things differently, adding a serious cost in readability and maintenance for anyone that's not the original author.

Re:We have C++14 by banachtarski on Tuesday August 19, 2014 @03:36AM (#8196320)
What experience are you speaking from?
Re:We have C++14 by tdees40 on Monday August 18, 2014 @04:17PM (#8194407)
This 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.

Re:We have C++14 by wfunction on Monday August 18, 2014 @04:44PM (#8194564)
> 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 do the same thing. Not because I can't write C++11, but because I still encounter systems with older compilers that I want to run programs on. What, is this surprising?

Let's face reality: it's a little unreasonable to expect every system you work on to have a compiler less than 3 years old.

Especially true on older Linux systems, it's sometimes a massive pain or even pretty much impossible to upgrade the existing compiler in a package-manager-friendly way (try upgrading Ubuntu 12.04's compiler to GCC 4.9, for example), so you'd have to compiler the compiler from scratch. Which is a pretty massive PITA and more or less requires a PhD of its own for GCC (Clang is a little better). And on Windows VC++ isn't always exactly following the correct standard. It's not necessarily outright impossible, but it's pretty impractical.

Re:We have C++14 by Guvante on Monday August 18, 2014 @06:35PM (#8195087)
> Let's face reality: it's a little unreasonable to expect every system you work on to have a compiler less than 3 years old.

If you are running Linux, this is one thing that Windows gets right. (Although as you say VC++ has some catching up to do still).

Re:We have C++14 by adrusi on Monday August 18, 2014 @07:27PM (#8195248)
Linux is on all parts of the spectrum here. Ubuntu LTS and Slackware are going to remain outdated by design. Arch Linux almost always have the most recent stable releases of GCC and clang, and you can even build development snapshots from AUR
Re:We have C++14 by shmerl on Monday August 18, 2014 @09:35PM (#8195658)
You don't need to use the compiler from the distro to release for that distro. There is such thing as cross compilation after all. Most do it out of habit and because distros don't offer such services out of the box. But if you build the cross compiler, you can use the newest one even if the distro ships the older.

For example I had a building machine running RHEL 5 which was building for both RHEL 5 and RHEL 6 while using gcc 4.8.2 for both (cross compilers).

Re:We have C++14 by wfunction on Tuesday August 19, 2014 @12:05AM (#8195988)
You say "if you build the cross-compiler" as though it's as simple as "if you cross the street". Have you ever tried building GCC? I've wasted days on it and in the end still failed to make it work.
Re:We have C++14 by shmerl on Tuesday August 19, 2014 @12:55AM (#8196070)
It is hard if you do it all manually. There are helpful tools like Crosstool-NG for example which make it easier.

See also https://en.wikipedia.org/wiki/Cross_compilers#External_links

Re:We have C++14 by exDM69 on Tuesday August 19, 2014 @10:18AM (#8197379)
> Have you ever tried building GCC? I've wasted days on it and in the end still failed to make it work.

I've hand-built GCC for half a dozen of different target architectures over the years and it's perhaps one of the most stable pieces of software when it comes to building it. I've only had one build failure over the years and that was unstable from git (even that usually works no problem).

To build GCC, follow the simple steps on the GCC manual. With a modern fast computer, it's all done in an hour or two (of mostly waiting).

Re:We have C++14 by wfunction on Tuesday August 19, 2014 @01:32PM (#8198643)
I don't know how you manage it, but I can tell you it is not reasonable to expect people to compile every compiler they want to use on every system they want to use it.
Re:We have C++14 by exDM69 on Wednesday August 20, 2014 @05:52AM (#8201702)
> I don't know how you manage it, but I can tell you it is not reasonable to expect people to compile every compiler they want to use on every system they want to use it.

If you're dealing with bare metal projects (kernel programming or micro controllers), building binutils and gcc for cross compiling from source is pretty much required. There are scripts that help and some distros have cross compilers in their package managers.

But building GCC is not difficult and it pretty much works first time, every time.

Re:We have C++14 by tshepang on Tuesday August 19, 2014 @03:17PM (#8199217)
No one implied people are expected to compile every compiler they want to use on every system they want to use it. Point was it's not hard. Maybe link to a message where you detailed your troubles?
Re:We have C++14 by 72deluxe on Tuesday August 19, 2014 @04:24AM (#8196414)
Heh! I am stuck on VC++ 2010 at work. I gaze longingly at C++11 features but can't use them. A pity, as the same codebase is also built under XCode and Clang.
Re:We have C++14 by sitkack on Monday August 18, 2014 @07:12PM (#8195207)
> upgrade the existing compiler in a package-manager-friendly way

This is your problem.

Build a new compiler using the old compiler and install the entire new toolchain in /opt/my-gcc-4.9-0xfoof . rsync this new compiler to any machine you want. The package managers (people and code) a here for our suffering.

Re:We have C++14 by jevinskie on Monday August 18, 2014 @05:47PM (#8194903)
When LLVM started to require C++11 (which we use as a library), my team decided to statically link libstdc++ into our product on Linux. Now we just depend on glibc (and we use symbol versioning to keep the required version to a minimum). It sounds like you ship source though, so it may not be an option for you.
Re:We have C++14 by dfan on Monday August 18, 2014 @04:44PM (#8194558)
Also, 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.
Re:We have C++14 by kyllo on Monday August 18, 2014 @07:00PM (#8195164)
Like Google for example? Their C++ style guide is pretty restrictive, here's an expert C++ programmer's takedown of it: https://www.linkedin.com/today/post/article/20140503193653-3...
Re:We have C++14 by yongjik on Monday August 18, 2014 @08:44PM (#8195499)
FWIW, things like range-based for loops, "auto", and unique_ptr are pretty standard in Google these days.

Still no exceptions, though.

The thing is, when you have a single codebase that is maintained by thousands of engineers, you have to make concessions. There is no place for "rockstar programming": everything must be, in a sense, bland, so that it blends seamlessly into the work of thousands of others.

Re:We have C++14 by Silhouette on Monday August 18, 2014 @09:14PM (#8195594)
Not that I disagree with your real point about writing maintainable code rather than "clever" code, but if you have a single codebase that is maintained by thousands of engineers then I would argue that you're probably doing something horribly wrong already, and using exceptions is hardly exclusive to so-called rockstars.

I don't really understand organisations that still use C++ in 2014 but then knock out such fundamental parts of its functionality, but then looking at the design priorities for Go, clearly at least some people at Google have very different preferences to my own, so YMMV etc.

Re:We have C++14 by yongjik on Tuesday August 19, 2014 @01:04AM (#8196083)
I agree that using exception is hardly noteworthy these days, but consider that in the context of a codebase that has evolved for more than a decade. I guess, ten years ago, "let's not use exceptions; they aren't worth it" was more justifiable.

In any case, the decision was made, and we have millions of LOC where every single API is built with the assumption "No exceptions here." In that context, introducing exceptions seems suddenly a lot more trouble than its worth. Well, YMMV, and in any case I'm not a decision maker so what do I know.

* BTW, I think "a single codebase maintained by thousands of engineers" is the single best thing I found in Google, as it opens up infinite possibility of learning new tricks, new APIs, and sometimes new projects. (Of course, everybody complains that every API is implemented at least three times, but imagine how worse it would have been if every project had its own codebase.)

Re:We have C++14 by claudius on Tuesday August 19, 2014 @03:37AM (#8196325)
This is of course a valid reasoning to forbid the use of some features at this particular company. However, it renders advocating the Google C++ style guide as an ubiquitous style guide for all C++ programming rather moot.
Re:We have C++14 by yongjik on Tuesday August 19, 2014 @02:50PM (#8199080)
Completely agree. I hope nobody's naive enough to say "Well, if this style guide works for Google, it sure should work for our company...!"
Re:We have C++14 by Game_Ender on Tuesday August 19, 2014 @02:49AM (#8196246)
Not adding much value here, but it is a lot worse. You get 5+ implementations everything, and every project is different just because.
Re:We have C++14 by p0nce on Tuesday August 19, 2014 @10:14AM (#8197363)
Perhaps you would have less millions of LOC if you could reuse third-party libraries which happen to use exceptions?

Also no exceptions implies no failing constructors which is plain ugly as a constraint.

Re:We have C++14 by srj on Monday August 18, 2014 @09:04PM (#8195560)
This article is a bit strange. Complex initialization in a constructor can make it more difficult to unit test a class. Copy constructors aren't prohibited, it's just recommended that you remove the implicit versions when your class shouldn't be copied. Some of the C++11 features were blacklisted because Google has had its own implementations. In some cases these C++11 features are now allowed and the previous implementations have been deprecated, it's just that the conversion process took time.

In general if you're going to work with other people I believe you need to be a bit flexible on coding with them rather than trying to be hard headed about your own style. It's important that people not be surprised when they work with your code.

Re:We have C++14 by cubbimew on Wednesday August 20, 2014 @11:25AM (#8202709)
The guide that's publicly available says "If your class needs to be copyable, prefer providing a copy method, such as CopyFrom() or Clone(), rather than a copy constructor" I think that's insane. Or, at the very least, surprising to encounter when working with someone else's code.
Re:We have C++14 by tdees40 on Monday August 18, 2014 @05:29PM (#8194806)
Oh 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.
Re:We have C++14 by jsmeaton on Monday August 18, 2014 @06:02PM (#8194961)
It's not just C++ either. "What do you mean you want to use LINQ (in C#)? No one understands that rubbish".
Re:We have C++14 by voltagex_ on Monday August 18, 2014 @07:11PM (#8195202)
* Don't use LINQ

* Don't use var

* Don't use dynamic

or even better,

"You've only got .NET 2/3 installed"

Re:We have C++14 by guiomie on Monday August 18, 2014 @07:27PM (#8195247)
I can't look at code without var's anymore.
Re:We have C++14 by mhd on Tuesday August 19, 2014 @05:09AM (#8196513)
"We haven't vetted anything other than Java 1.4 on our BigAutoCorp PCs, so if you want to write a desktop app..."
Re:We have C++14 by jahnu on Tuesday August 19, 2014 @06:00AM (#8196607)
And should Go or Rust achieve widespread adoption the same thing will happen to them. So the point is moot.
Re:We have C++14 by Nursie on Monday August 18, 2014 @07:24PM (#8195242)
The main downside I can see with it is how much implicit behaviour there is. Sometimes it's very hard to figure out what's actually going to happen with a line of code.

That said it's quite expressive now, you can do a lot with a little code, which is always nice.

Re:We have C++14 by blt on Tuesday August 19, 2014 @11:15AM (#8197731)
Yes. As much as I love C++, I sometimes get very scared by the implicit behavior. This is why I don't understand the hate on exception-free, more C-like C++. You can still reap huge benefits from std::algorithm, iterators, classes, templates, while stepping back to a more manual approach for allocation and lifetime management.
Re:We have C++14 by JoeAltmaier on Tuesday August 19, 2014 @11:19AM (#8197759)
You definitely have to pick and choose from C++ based on environment, your staff's experience, what kind of problem you're solving. Allocation in particular is problematic in every language (even GC languages) especially when latency is an issue, so that's probably what I manage 'manually' most often.
Re:We have C++14 by sdegutis on Monday August 18, 2014 @04:56PM (#8194631)
Meh, breaking backwards compatibility isn't all that bad. It will be a bit rough for a few years, but it's worth it to clean things up for a brighter future.
Re:We have C++14 by ChuckMcM on Monday August 18, 2014 @06:12PM (#8195004)
The weird thing is, why not just call it something new? I've always wondered if they called Perl 6 "Smeebly" or something would it get a better reception? C+++ ? My personal taste is that if you break backwards compatibility that is when you have a 'new' language and you just just name it as such.
Re:We have C++14 by tshepang on Tuesday August 19, 2014 @03:27PM (#8199268)
People would, on the surface, see a different beast, even though it remains 99% the same language. Not worth it.

With this argument, every release that adds a new keyword (for example) would have to be given a new name, since it will very likely break some code. Question that remains is how much must the changes be before the thing deserves a new name.

Re:We have C++14 by untog on Monday August 18, 2014 @05:08PM (#8194680)
The example of Python 3 is a good one. "A bit rough for a few years" might be an underestimation.
Re:We have C++14 by sdegutis on Monday August 18, 2014 @05:18PM (#8194741)
I don't think Python 3 is a good example. Unlike other cases where languages broke backwards compatibility, the Python community actively discouraged upgrading for years, constantly saying "don't use Python 3" for years, and Python 2 was actively maintained in parallel to Python 3, with features constantly being back-ported. It would have been much smoother overall if they'd just dropped Python 2 altogether, even if a little more painful up-front.
Re:We have C++14 by pmelendez on Monday August 18, 2014 @05:47PM (#8194902)
I believe he was being sarcastic. And breaking backwards compatibility can be really bad. Imagine if the next version of C would break the previous one. How many operating systems and critical software would have to be rewritten in order to be maintained.
Re:We have C++14 by cwyers on Monday August 18, 2014 @06:05PM (#8194974)
Python is in a different boat than C++. If the Python language leaders decides to make a version that breaks backwards compatibility... well, they also make the most popular Python interpreter. The group responsible for the C++ standard isn't in the same position at all, they have to convince the different compiler groups (GCC,LLVM,Intel,Microsoft,etc.) to implement it for them.
Re:We have C++14 by pmelendez on Monday August 18, 2014 @06:22PM (#8195037)
Agreed but even there were a monopoly for the interpreter/compiler you would see people marrying with a specific version and having the implementer to maintain two different branches of the compiler for security reasons.
Re:We have C++14 by Silhouette on Monday August 18, 2014 @09:24PM (#8195626)
Imagine if the next version of C would break the previous one. How many operating systems and critical software would have to be rewritten in order to be maintained.

I don't think the idea is to force existing software to be rewritten. It's to provide a clean break so that new software isn't saddled with the baggage of the old. Over time, most of the older software is retired or replaced, and the industry migrates to use the better tools with more and more projects.

This seems a very reasonable strategy, as long as your ABI or equivalent interface specifications can remain compatible for the common subset of functionality, so that programs built using the new language can still use libraries written in the old one. (See also: Every successful general purpose programming language in decades has offered a FFI for C.)

It doesn't work so well if you don't have proper formal standards for your old and new languages. It's also much harder to achieve in practice if your code is effectively running on some sort of virtual machine so you can't have that clean break at the ABI level, which might be one reason why several languages have failed to make a convincing big jump in recent years (Perl 6, Python 3, etc.).

Re:We have C++14 by bluetech on Monday August 18, 2014 @06:39PM (#8195102)
Maybe they can use something like javascript's and perl's "strict" annotations.
Re:We have C++14 by ixtli on Monday August 18, 2014 @04:43PM (#8194555)
I _completely_ agree. I think people need to start talking about how, when combined with the right tools and compilers, you can achieve nearly anything you can with another "modern" language more expressively and faster, all while being compatible with decades of massive c, c++, and objective-c libraries.

Perhaps we should start with dispelling the old notion that one "shouldn't use" the STL.

Re:We have C++14 by 72deluxe on Tuesday August 19, 2014 @04:25AM (#8196417)
Do people really not use the STL? It's incredibly useful, and portable!
Re:We have C++14 by ixtli on Friday August 22, 2014 @08:02PM (#8214491)
(Sorry for the late reply.) But yes, I find that people who've made careers out of programming in non c++ languages never revisit it when planning a project because they have this weird notion that it "slow" or "poorly implemented." I really don't know where this is comes from but I've heard it from many people i've worked with over the years.
Re:We have C++14 by adamnemecek on Monday August 18, 2014 @05:21PM (#8194756)
You should check out what's planned for C++17 https://isocpp.org/std/status if you haven't yet.