News for hackers. Stuff that matters.
Re:Master C++ Programming with Open-Source Books by criddell on Thursday February 16, 2017 @08:52AM (#13659829)
Can you ever really master C++? I've been at it more than 20 years and I'm still delighted to learn new things about the language and the library.
Re:Master C++ Programming with Open-Source Books by bluetomcat on Thursday February 16, 2017 @09:13AM (#13659958)
And that's the real problem with C++. You can spend 20 years solving real problems with it and still feel like a noob when you take a look at "idiomatic" template code from the standard headers.

On the other hand, people like Scott Meyers have spent their lifetime and careers explaining its intricacies, without solving any real problems.

Re:Master C++ Programming with Open-Source Books by twoodfin on Thursday February 16, 2017 @01:45PM (#13662414)
You can spend 20 years solving real problems with it and still feel like a noob when you take a look at "idiomatic" template code from the standard headers.

It can be misleading to think of standard header code (especially template code) as "idiomatic C++". It'd be better described as "idiomatic standard-library-implementor C++", since the folks implementing stuff in std are operating under a whole set of constraints that don't affect ordinary C++ programmers. Arbitrary user-defined symbols that could be in scope, user-provided types that could have overloaded operator-comma, etc.

Re:Master C++ Programming with Open-Source Books by aseipp on Thursday February 16, 2017 @02:35PM (#13662857)
Yes, and I think this same principle is roughly true for a lot of programming language implementations. It's one of the reasons it pays off to know some details about your implementation -- People should always keep this in mind.

Designers and implementors are traditionally under a very different set of constraints than "average users" (who in this case are programmers), though their goals do align. But this leads to very different set of assumptions, optimizations, and tools being available. Things that would generally be overkill are suddenly very viable and worthwhile goals to achieve (e.g. micro-optimizations add up repeatedly so they're very worth it, vendoring is much more useful to control dependencies/scope of bugs), and vice versa.

So I wouldn't be extremely miffed if you look at libstdc++ or libcxx or <whatever> and find it somewhat unkempt or gross compared to average code. It's often very much not-average. In fact it's likely given careful understanding of the constraints that code exists under -- you'd come up with similar results.

Re:Master C++ Programming with Open-Source Books by criddell on Thursday February 16, 2017 @10:31AM (#13660626)
Problem? On the contrary, it's one of the wonderful things about the language and community. It's alive and evolving.

And what's with the Scott Meyers ding? I think of him mostly as an educator and in that respect he's very accomplished.

Re:Master C++ Programming with Open-Source Books by bluetomcat on Thursday February 16, 2017 @11:35AM (#13661241)
I think it boils down to a wider philosophical question that deserves some discussion in software development circles. The question basically is "Should we get obsessed with our constantly evolving tools at the cost of devoting significantly less time to understanding the intrinsic problems we are trying to solve?".

Each time I hear a discussion between programmers, it is always these arguments of whether build tool A is better than build tool B, or whether VCS A suits their workflow better than VCS B, or how cool is the latest language feature. I never see programmers discussing the merits of their solutions, regardless of the language or environment.

Re:Master C++ Programming with Open-Source Books by criddell on Thursday February 16, 2017 @11:58AM (#13661464)
We talk about tools all the time because it's fun and it's something we all have in common. Every once in a while something like clang comes along and it can change everything.

What we don't have in common are the exact problems we are trying to solve. That's where design patterns and other higher level concepts become useful. Because the problems and solutions are so context specific, they happen on mailing lists. Tool discussions, on the other hand, are more generic and I think that's why you see them in more places.

Re:Master C++ Programming with Open-Source Books by pjmlp on Thursday February 16, 2017 @12:15PM (#13661640)
Unless we are speaking of Go, all programming languages are like that.

Sometimes people think they know their favorite language, but most would fail a language puzzle quiz.

Re:Master C++ Programming with Open-Source Books by mi100hael on Thursday February 16, 2017 @01:26PM (#13662254)
> Unless we are speaking of Go, all programming languages are like that.

Right, I'm sure Go is the one and only language out there without a single pitfall or quirk.

Re:Master C++ Programming with Open-Source Books by bluetomcat on Thursday February 16, 2017 @12:30PM (#13661804)
> Sometimes people think they know their favorite language, but most would fail a language puzzle quiz.

But that is especially true for C++. People who are confident in knowing it often lack the fundamental C knowledge (i.e. pointer arithmetic, the complete C type system, the subtle conversion and promotion rules, etc.), but would insist on knowing C++ very well just because they know how to define classes, virtual functions and throw a shared_ptr or a vector or a map at every problem.

Re:Master C++ Programming with Open-Source Books by pjmlp on Thursday February 16, 2017 @12:43PM (#13661904)
And most people that say that they know C and how simple the language is, cannot differentiate between their compiler extensions and what is written in ANSI C.

Nor can they correctly point out all the cases of expected semantics, UB and implementation specific behaviour.

Regarding the fundamental C knowledge, part of it just leads to bad C++ code.

Re:Master C++ Programming with Open-Source Books by alextooter on Thursday February 16, 2017 @09:51AM (#13660220)
Yep,the language it self became a problem.The designer and experts should(Which I hope) make the language easy to use without any mental burden.
Re:Master C++ Programming with Open-Source Books by andrepd on Thursday February 16, 2017 @10:21AM (#13660525)
Make the language easy to use without any mental burden? But you do realize programming is not easy, especially when you're aiming for high performance. How can you make a language easy to use "without any mental burden"? Programming is hard, programming well and with performance in mind is even more so. Some things you just can't magically make easy.
Re:Master C++ Programming with Open-Source Books by bluetomcat on Thursday February 16, 2017 @10:24AM (#13660553)
You can program with "performance in mind" in C and the big difference will be that the problem itself will be the obstruction, not the language.

In C++, you fight with the language first and then face the problem.

Re:Master C++ Programming with Open-Source Books by bstamour on Thursday February 16, 2017 @11:03AM (#13660953)
I actually feel the exact opposite when I program in C. C is so bare that most of my time is spent building the correct constructs I need to solve my problem. C++ on the other hand has a decent set of high level features that makes it easier for me to focus on the problem.
Re:Master C++ Programming with Open-Source Books by adrianN on Thursday February 16, 2017 @11:41AM (#13661280)
You can write a C++ program to solve a problem that looks almost exactly like the C program you would write. But C++ brings a couple of nice features, like resource management with constructors/destructors and type-safe data structures that you just can't have in C.
Re:Master C++ Programming with Open-Source Books by andrepd on Sunday February 19, 2017 @10:25AM (#13680107)
How can that be true, if C++ is (almost) a superset of C? Surely you can do anything in C++ identically to C, in the worst case scenario.
Re:Master C++ Programming with Open-Source Books by criddell on Thursday February 16, 2017 @10:40AM (#13660716)
What fight are you having with C++?
Re:Master C++ Programming with Open-Source Books by erikbye on Thursday February 16, 2017 @09:13AM (#13659964)
What do you use it for?

It's such a complex language brimming with idiosyncrasies that I'd be inclined to really test anyone claiming to be a master. The standard is one thing, then there's the compiler you're using...

Re:Master C++ Programming with Open-Source Books by deong on Thursday February 16, 2017 @09:51AM (#13660224)
I claim on my CV to be an "expert" C++ programmer, but I'm quick to point out the curve that I imagine being graded on. At least in my head, there's an implied context around someone's C++ proficiency. An expert Java programmer should be able to answer most questions about Java. An expert C++ programmer should simply get to the "I have no idea" answers when the questions get interesting.
Re:Master C++ Programming with Open-Source Books by pjmlp on Thursday February 16, 2017 @12:19PM (#13661685)
I do Java, .NET and C++ consultancy and I bet an Java expert would fail most Java Puzzle questions.

Also a programming language is not used alone and C++ standard library is quite tiny when compared to Java's standard library.

Re:Master C++ Programming with Open-Source Books by deong on Thursday February 16, 2017 @01:05PM (#13662092)
That's true, but there's virtually no aspect of the C++ language or library that doesn't have a wealth of "gotcha" questions one could ask.

Even parts of C++ that are "normal user" features can be remarkably tricky. I know tons of C++ programmers who I'd happily trust to write code for me who would fall flat on their faces if asked to explain some detail of what std::forward does with an rvalue reference parameter bound to an lvalue argument.

There's a reason why a very common recommendation is to pick a subset of C++ and stick to it, and I've never heard of such a recommendation for any other language (outside of perhaps for portability reasons).

Re:Master C++ Programming with Open-Source Books by pjmlp on Thursday February 16, 2017 @01:25PM (#13662244)
> I know tons of C++ programmers who I'd happily trust to write code for me who would fall flat on their faces if asked to explain some detail of what std::forward does with an rvalue reference parameter bound to an lvalue argument.

That is true.

I can also remember other ones like differences between auto and decltype, or between auto and template parameter deduction across language revisions.

However, Java puzzles like the ones presented at Java ONE, or .NET changes in how native error handling changed on .NET 4.0, among many other examples, are also interesting as quiz questions.

Re:Master C++ Programming with Open-Source Books by criddell on Thursday February 16, 2017 @01:21PM (#13662216)
> explain some detail of what std::forward does with an rvalue reference parameter bound to an lvalue argument

std::move?

Re:Master C++ Programming with Open-Source Books by joshuata on Thursday February 16, 2017 @01:03PM (#13662074)
I was reminded of this yesterday: I work on a research-oriented C/C++ compiler with several people who would certainly be considered C++ "experts". We came across a bizarre bug introduced by static destructor ordering. Even with the lines of code highlighted and a detailed paragraph explaining the error, it took us almost 30 minutes to figure out how the undefined behavior was causing the bug we saw.
Re:Master C++ Programming with Open-Source Books by WildUtah on Thursday February 16, 2017 @10:45AM (#13660769)
I've been at it more than 20 years and I'm still delighted to learn new things about the language and the library.

And it's under active revision and improvement. There are great new things to learn every few years.

Re:Master C++ Programming with Open-Source Books by digler999 on Thursday February 16, 2017 @10:56AM (#13660891)
I feel like I'm slowly marching toward a mirage. In a way, I dread the c++14/17 changes because it means that much more that I'm going to have to learn. Even if they stopped revising the language today, I'm probably going to learn my last C++ factoid on my deathbed.
Re:Master C++ Programming with Open-Source Books by btschaegg on Thursday February 16, 2017 @12:42PM (#13661900)
For me personally, that would be a positive statement. I don't think any good programming language can stay good unless it keeps evolving (and yes, to me, C++ counts as one despite the occasional gotcha it comes with). That is - any language except for Lisp :-)

And to be frank: I'd say that anyone opposed to continue to learn new things is entirely in the wrong field if he/she works on any technology-related job.

Re:Master C++ Programming with Open-Source Books by digler999 on Thursday February 16, 2017 @03:21PM (#13663224)
I mostly agree with you. However, there's something to be said for being conservative and not always tweaking things. C++11 is amazing. I'm still working to solidify my knowledge in it and haven't even peeked into c++14 or higher yet.

However, constantly learning and updating things has its drawbacks. One of the rare times I tried to be hip and use the latest stuff, I tried rewriting parts of a small Android app of mine using java 8 and lambda closures. I made it work, but it required upgrading my minimum build version (locking out older devices), the compiler could barely handle it (gave some strange indecipherable errors relating to lambdas), and ultimately it was just a step backward. That kind of thing really frustrates me, because it's wasted (at best, deferred) effort.

Re:Master C++ Programming with Open-Source Books by btschaegg on Thursday February 16, 2017 @04:48PM (#13663833)
On one hand, I'd agree with you on that; I think we all know the urge to "modernize all the things!", whenever a language implements something new and shiny. And there's definitely much merit to resist that urge to some degree. However, it also is rarely really necessary to do this all in one go; one can also polish things up with strategies like the boyscout rule. And if there is no test for a piece of code - maybe leave it until you have corrected that.

Being conservative with new additions to your codebase seems a bit backward, though. Why not use the new, improved shiny language feature™ if you can?*

Of course, if you are prohibited by business requirements (e.g. missing modern compilers for a certain target platform) that's another story. Basically, it always comes down to practicality.

* A prime example would be the new way you can implement Singletons with C++11. Once you've used that, you realize how horrid pretty much all C++98-based attempts at this are.

Yes, I realize Singletons are often a bad idea.

Re:Master C++ Programming with Open-Source Books by dragonwriter on Thursday February 16, 2017 @03:22PM (#13663239)
Learning the shortfalls of new technology isn't wasted effort.
Re:Master C++ Programming with Open-Source Books by BeetleB on Thursday February 16, 2017 @10:29AM (#13660605)
For me, that's the standard argument about C++ having unnecessary complexity.

You don't keep learn new stuff because C++ is super, uber, powerful. It is because it is not designed well and there are far too many dark corners.

Re:Master C++ Programming with Open-Source Books by criddell on Thursday February 16, 2017 @10:48AM (#13660811)
As I answered in another comment, I keep learning new stuff because the language is alive and evolving. IMHO it's getting safer and easier to use and understand.