News for hackers. Stuff that matters.
Re:C++ 17 is Done by systems on Saturday March 25, 2017 @07:47AM (#13955151)
As a matter of personal taste, I prefer big complex languages over simple ones

And I do consider, that some of the strongest criticism of C++, and that is, "that most people use a subset of it, so it feels like many different languages glued into one", is actually a strength .. it means you can ignore some the complexity .. until you want it, or need it

I am very happy, that C++ is adding new features every 3 years .. and I do plan to invest more time in C++

Complexity is good

Re:C++ 17 is Done by fauigerzigerk on Saturday March 25, 2017 @09:46AM (#13955600)
Nothing against personal preferences, but one side-effect of overwhelming complexity is that only very few people can be trusted to write safe C++. The better you know C++ the more suspicious you become of C++ code written by others. At least that is my personal experience.

And I think that's a major reason why C++ usage is gradually becoming a niche thing used only where absolutely necessary. As evidence for that claim I submit this chart (you need to scroll down a page): https://www.itjobswatch.co.uk/jobs/uk/c++.do

C++ used to be required for over 30% of all permanent programming jobs in the UK back in 2005. Now it's down to 8.5% and falling. That's in stark contrast with all the enthusiasm created by the features added since C++11, features that I very much welcome.

Re:C++ 17 is Done by sun_n_surf on Saturday March 25, 2017 @10:42AM (#13955882)
This is not as bad as it sounds. You need to consider the absolute numbers than the relative percentages for languages like C++.

Programming is more accessible than ever before, more jobs require some element of programming than ever before, and more things are getting created using code. This means that people who have never written code before are writing code as a job of work, and are writing it in simpler-to-learn languages.

Newer, simpler programming jobs are acquiring programmers in other languages, not necessarily that C++'s complexity is driving people away from it into the arms of other languages or that C++ is not acquiring newer programmers at the same rates (on existing base) as before.

Re:C++ 17 is Done by fauigerzigerk on Saturday March 25, 2017 @12:03PM (#13956235)
>This means that people who have never written code before are writing code as a job of work, and are writing it in simpler-to-learn languages.

It would be interesting to know if the share of developers with formal training has risen or fallen in the past 12 years. I would have guessed it has risen in spite of a large number of JavaScript wielding web designers.

There used to be quite a lot of DIY programming using VB6, VBA, Excel, MS-Access, dBASE, FoxPro, etc, at a time when professional IT departments and cloud services were not as widespread as they are today. In my opinion these technologies were a lot more accessible than the current web platform.

Re:C++ 17 is Done by overgard on Saturday March 25, 2017 @12:48PM (#13956446)
C++ has been getting a lot safer though. Modern C++ generally has you using shared_ptr and unique_ptr and references, which cut down on a lot of common pointer mistakes. There's also a lot of const mixed in, which I think helps. Debuggers have also gotten a lot more reliable (I remember one crash bug that I couldn't find after like three days of looking in an old visual studio version, whereas newer visual studio caught it immediately). Not that the language isn't a minefield, but if you walk in the modern part there's a lot less mines buried in the ground.

As much as I complain about C++, I just don't think there's a viable alternative, and I somewhat reject the notion that writing performant code is a niche thing. Like, sure, there are common contexts where you can get away with wasting CPU, but IMO part of being a skilled professional programmer is getting the most out of the machine, and you just can't do that with most other languages.

Re:C++ 17 is Done by pjmlp on Saturday March 25, 2017 @02:49PM (#13956979)
> I somewhat reject the notion that writing performant code is a niche thing.

It surely isn't, otherwise we wouldn't be getting wind back into going native sails, with Swift, Rust, Go, Crystal, D, .NET Native, CoreRT, Java 9 (just a little bit, more with 10)....

Re:C++ 17 is Done by duneroadrunner on Saturday March 25, 2017 @07:56PM (#13958148)
> I just don't think there's a viable alternative

Fyi, when safety is important and C++ is the only viable alternative, there's SaferCPlusPlus[1].

And wrt new C++17 features, I'll just point out that the SaferCPlusPlus library provides a version of std::any (and std::variant) geared specifically for pointer/iterators. That is, you can, for example, dereference the contained pointer/iterator without needing to know its actual type. And for those that need it, it also provides the "recursive_shared_timed_mutex" that's notably missing from the standard library.

[1] shameless plug: https://github.com/duneroadrunner/SaferCPlusPlus

Re:C++ 17 is Done by progman on Sunday March 26, 2017 @08:26AM (#13960419)
> I just don't think there's a viable alternative

If C++ is your only hammer then every problem looks like a nail to you. Of course, there are viable alternatives. At least Ada which is still used in avionics and other safety critical systems.

Re:C++ 17 is Done by imron on Tuesday March 28, 2017 @04:49AM (#13975078)
> At least Ada which is still used in avionics and other safety critical systems.

Like Ariane 5? :->

The crash was caused in part by failing to catch an exception in Ada.

http://sunnyday.mit.edu/accidents/Ariane5accidentreport.html

Re:C++ 17 is Done by progman on Tuesday March 28, 2017 @04:56AM (#13975109)
This was not Ada's fault but the developer team's fault since it used a working Ariane 4 software for Ariane 5 without exhaustive testing. They made the mistake, and blamed Ada for that. The Ada software worked perfectly for which it was written for.

http://compgroups.net/comp.lang.ada/ariane5-faq/1406823

And yes, Ada is still used today.

http://www.ada2012.org

Re:C++ 17 is Done by imron on Tuesday March 28, 2017 @05:02AM (#13975130)
So how many crashes that happen in programs written in C++ are the development teams fault rather than the C++'s?

Ada is an interesting language (we were taught it as our first language at uni), but it's not free from safety issues.

Re:C++ 17 is Done by progman on Tuesday March 28, 2017 @05:52AM (#13975305)
Crashes due to the language implementation's fault are much more likely in C++ than in Ada. Ada compilers are 100% verified, otherwise they are not allowed to call themselves "Ada compiler". There is no such thing for C++. The safety gap between C++ and Ada is actually so big that we don't even need to talk about that.

The flaws C++ were the reasons why Rust was invented. Mozilla wanted a safe language for the next generation of browsers, and they realized that C++ is not a good choice for safe programming.

Quote: "Mozilla intends to use Rust as a platform for prototyping experimental browser architectures. Specifically, the hope is to develop a browser that is more amenable to parallelization than existing ones, while also being less prone to common C++ coding errors."

Source: https://www.quora.com/Why-is-Mozilla-developing-the-Rust-lan...

Re:C++ 17 is Done by userbinator on Saturday March 25, 2017 @11:15AM (#13956036)
it means you can ignore some the complexity .. until you want it, or need it

That's true if you work alone. If you work in a team, it's almost guaranteed that someone will love using advanced features just for the sake of using advanced features, creating insanely verbose and abstracted behemoths which are bad both for the human developers and the machines to read.

I suppose it's good for job security...

Re:C++ 17 is Done by pjmlp on Saturday March 25, 2017 @11:57AM (#13956210)
And since they don't have access to said features you get some crazy framework libraries as poor man's replacement for language features, like doing OOP in Motif, all those byte code manipulation and aspect oriented libraries in Java or now the pile of code generation tools in Go.
Re:C++ 17 is Done by paulddraper on Saturday March 25, 2017 @02:44PM (#13956960)
Yep.

Having poorly thought out complexity and no complexity often result in similar ends.

Re:C++ 17 is Done by progman on Sunday March 26, 2017 @08:37AM (#13960446)
> I suppose it's good for job security...

Honestly, I've seen C++ code so muddled and obfuscated that I actually wondered if those devs just wanted to make themselves indispensable. I really dislike such an attitude.

Re:C++ 17 is Done by pjmlp on Saturday March 25, 2017 @09:41AM (#13955577)
The history of computing is full of programming languages that started as a cry against complexy, only to discover that complexity has a reason to be and then they either adapted, becoming themselves as complex as their enemy, or faded out of the computing scene.
Re:C++ 17 is Done by sbmassey on Saturday March 25, 2017 @10:09AM (#13955702)
Complexity in a programming language is fine if it is just you, but a group of developers working together with different ideas of what to use can make for cacophony.
Re:C++ 17 is Done by bogomipz on Saturday March 25, 2017 @01:30PM (#13956650)
>""that most people use a subset of it, so it feels like many different languages glued into one", is actually a strength .. it means you can ignore some the complexity .. until you want it, or need it"

This is also in my case anywyay a barrier to entry or at least a point of intimidation. Where do I start? Which subsets are essential? Which version should I start with if I am learning today?

Re:C++ 17 is Done by ovao on Saturday March 25, 2017 @02:38PM (#13956942)
The C++ Core Guidelines[0] specify — albeit kinda verbosely — how to write modern C++. Implementation support to enforce these guidelines is ongoing, but MSVC and clang-tidy offer some support.

There are some domains and industries that break from these guidelines (or similar subsets) for various reasons, but generally speaking this is the sensible approach to take.

[0]: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines

Re:C++ 17 is Done by bogomipz on Saturday March 25, 2017 @02:57PM (#13957019)
Thanks for the link. Do you have any recommendations about which subsets of the language to learn or what is considered "core" or "essential maybe ?
Re:C++ 17 is Done by progman on Sunday March 26, 2017 @08:21AM (#13960398)
> Complexity is good

I believe in exactly the opposite. I always try to follow the KISS principle (Keep it simple, stupid) whenever possible since it always turned out to be the most reliable and maintainable solution.

It is funny that the first Ada versions (93 and 95) were considered vastly more complex in comparison to C++ in those days. Today it's the opposite. Ada looks like a clean mature language which only adds features which are actually needed. C++ wants to copy everything, attempting to squeeze every new feature into its narrow syntactic framework while still suffering the legacy of C and old C++ for reason of compatibility.

The only reason (IMHO) to learn C++ today is for maintaining legacy code in business. In all other cases there are better typed languages - Ada, Rust, and Nim for instance.

C++ may look nice at the basic level. As soon as things get serious C++ devs have a tough time. How does the experienced C++ dev fight that? He looks into his long list of tips and nostrums which hie collected in all his years to avoid all the pitfalls and minefields of C++. I don't believe that will change significantly with C++17.