News for hackers. Stuff that matters.
Re:C++17 – better than you might think by gurkendoktor on Thursday December 29, 2016 @05:25AM (#13276614)
More features, more libraries, but is there a working group that looks back at C++98 and tries to reduce complexity by removing mistakes from the language?

My pet peeve is Argument-Dependent Lookup. It's a hack that breaks the encapsulation of namespaces, increases compile times and still makes it harder to write code - try swap()ing two values of type T in a template function. But like any of C++'s warts, it will be with us forever.

Re:C++17 – better than you might think by rl3 on Thursday December 29, 2016 @05:37AM (#13276644)
>More features, more libraries, but is there a working group that looks back at C++98 and tries to reduce complexity by removing mistakes from the language?

Then you break backwards compatibility. What about static analysis to enforce a particular subset of features deemed idiomatic or otherwise best practice?

Granted, reducing complexity does make the job of future compiler authors far less miserable.

Re:C++17 – better than you might think by ktRolster on Thursday December 29, 2016 @05:54AM (#13276685)
What about static analysis to enforce a particular subset of features deemed idiomatic or otherwise best practice?

I like that idea.

Re:C++17 – better than you might think by koja86 on Thursday December 29, 2016 @06:45AM (#13276816)
You might find this project kind of interesting:

https://github.com/isocpp/CppCoreGuidelines/blob/master/CppC...

As a day-to-day C++ practitioner I like it.

...Yet I am not fully convinced that the general idea of language evolution implemented as ruleset outside of the language itself is the way to go. Seems more like band-aid to me and made me start to think about concept of programming language's life cycle in context of Darwinian evolution - once either legacy compatibility burden is too big or that particular biotope of specific problems the language solves better than others vanishes/changes the language dies out.

My particular issue with C++ is that it's complexity, longevity and evolution made possible for widespread bad-practices as not every C++ developer evolved as much as the language itself and it's general public understanding. (Some current best-practices were simply not always widely known or accepted.) I would even go as far to say that most of existing C++ code is crap (at least from standpoint of today "modern" C++).

And that's why I am both eagerly looking to "next generation" being shaped up by people who has (hopefully) learnt from past mistakes and used by people who care (itching to give Rust a ride once it stabilizes just a bit more) and also occasionally digging in the history for possible gems that I might not able to see without my current experience (platonic weekends-only relationship with Haskell, Lisp being right there at top of my TODO list).

EDIT: Removed the sir.

Re:C++17 – better than you might think by Koshkin on Thursday December 29, 2016 @10:09AM (#13277632)
> I am not fully convinced that the general idea of language evolution implemented as ruleset outside of the language itself is the way to go

I think you are right - as far as 'the' language is concerned. The complexity (and the slowness) of a C++ compiler now is mostly due to the complexity - and the slowness - of the built-in interpreter of the template meta-language. There are other, saner languages, such as Common Lisp, where the meta-language is indistinguishable from the language itself, which, in addition to its greater simplicity, greatly contributes to the reasonable compile times. In the C/C++ land, it might have been possible to use a similar approach instead of introducing a separate macro/template syntax, a good example being the approach taken in the design of ASP (active server pages), PHP, and the like.

Re:C++17 – better than you might think by rl3 on Thursday December 29, 2016 @07:15AM (#13276887)
>Sir, ...

You may want to take a quick gander at the profile of whom you're replying to. :)

>... itching to give Rust a ride once it stabilizes just a bit more ...

Likewise, though from my limited research it seems Rust has legacy baggage of its own already, and there's difficulty in coming to a consensus on what qualifies as idiomatic Rust. It seems that the same principle of cherry-picking a subset of features would apply just the same to Rust as it does to C++. The latter being far messier, of course.

Re:C++17 – better than you might think by echelon on Thursday December 29, 2016 @10:07AM (#13277618)
> it seems Rust has legacy baggage of its own already

What is considered legacy cruft in Rust? The only change I'm aware of was the introduction of the `?` operator to replace the `try!` macro. That's easy to find/replace.

Re:C++17 – better than you might think by rl3 on Thursday December 29, 2016 @03:32PM (#13279878)
The notion extends to official libraries, not just the language itself. That said, I'm not the best person to ask, but cursory research turns up a few examples.[0][1][2][3]

Some of these aren't examples of legacy cruft per se. However, as complexity is added to a language at a rapid rate, there becomes more confusion over what best practice actually is.

[0] https://www.reddit.com/r/rust/comments/2r7ttq/where_to_find_...

[1] https://users.rust-lang.org/t/rust-version-support-in-librar...

[2] https://gist.github.com/lifthrasiir/cedb5db8dbcd209c5957

[3] https://users.rust-lang.org/t/is-this-idiomatic-rust/2155

Re:C++17 – better than you might think by koja86 on Thursday December 29, 2016 @08:33AM (#13277142)
Thank you in both cases sir/madam/whatever :-)
Re:C++17 – better than you might think by adelarsq on Thursday December 29, 2016 @08:53AM (#13277230)
Some things still are on nightly builds, so will take some time to be perfect, at least for me. I have plans to use in production on next months =)
Re:C++17 – better than you might think by SomeStupidPoint on Thursday December 29, 2016 @10:04AM (#13277600)
Just to point out: biological evolution uses changes in the base features utilized (epigenetics) to speed adaptability to changing environments (or new environments).

There's every reason to think that evolving human systems should use similar masks on features of a technology to make it more suitable for a particular domain and serve as a signal to drive the base evolution.

The restricted C subset used for safety critical systems I think is a good example of this -- the restriction allows for usage in a domain where the full set of features is a disadvantage.

Re:C++17 – better than you might think by enqk on Thursday December 29, 2016 @09:16AM (#13277355)
> ...Yet I am not fully convinced that the general idea of language evolution implemented as ruleset outside of the language itself is the way to go.

What most people nowadays recommend programming in is actually not C++, and actually C++ + all compiler warnings, which is in itself an extension/evolution/restriction of the underlying language. So it's not so far out to go from there to externalizing more rules around valid programs.

Re:C++17 – better than you might think by akavel on Thursday December 29, 2016 @07:53AM (#13276994)
Is anybody aware of any compiler/tool which tries to enforce those rules? ideally, on code blocks enclosed in some special markers?
Re:C++17 – better than you might think by RossBencina on Thursday December 29, 2016 @08:14AM (#13277071)
Clang-Tidy [0], in particular see the cppcoreguidelines.* checks [1]

[0] http://clang.llvm.org/extra/clang-tidy/

[1] http://clang.llvm.org/extra/clang-tidy/checks/list.html

Re:C++17 – better than you might think by WalterBright on Thursday December 29, 2016 @08:03AM (#13277032)
The trouble with namespaces is they are not encapsulated (even without ADL). Any piece of code can open up any namespace and add symbols to it. Not being able to reliably determine what is the set of symbols being overloaded in a namespace, for example, makes it hard to reason about.
Re:C++17 – better than you might think by gurkendoktor on Friday December 30, 2016 @03:31PM (#13287177)
When writing a container, I'd actually prefer to open namespace std and overload std::begin and std::end for my_namespace::container. That way, I'd be free to use my_namespace::begin for something else, which IMHO is the point of namespaces. But having ADL and being able to re-open other people's namespaces is definitely unfortunate.

I love the Objective-C convention of just using three-letter prefixes for everything. I'll miss its pragmatic approach.

Re:C++17 – better than you might think by Arwill on Thursday December 29, 2016 @05:42AM (#13276661)
Thats is why i've given up on C++. The new features might be nice, but i don't want to deal with those old hacks.
Re:C++17 – better than you might think by jjuhl on Thursday December 29, 2016 @05:51AM (#13276679)
Nobody is forcing you to use the old stuff. You can stick to the new nice bits and mostly just ignore the fact that the old crud exists in the language.
Re:C++17 – better than you might think by mateuszf on Thursday December 29, 2016 @06:00AM (#13276698)
Unless you use libraries which are written in different styles, and have to read / fix them. Then you still have to remember / understand all the complexity.
Re:C++17 – better than you might think by petters on Thursday December 29, 2016 @07:26AM (#13276923)
But in that case you are in no position to give up on C++ anyway, as your grandparent commenter did.
Re:C++17 – better than you might think by pjmlp on Thursday December 29, 2016 @06:47AM (#13276823)
Sadly that is only true for the code that is under our control, which is seldom the case in most companies.
Re:C++17 – better than you might think by loup-vaillant on Thursday December 29, 2016 @12:05PM (#13278430)
What a wonderful world would it be… Not being forced to used legacy C++ style. Not being forced to mind the undefined minefield. Not being forced to even use C++ in the many many cases where garbage collection is obviously fine…

Sadly these days, I'm not paid to "solve problems". I'm paid to solve them in C++ —sometimes for good reasons.

Re:C++17 – better than you might think by PopsiclePete on Thursday December 29, 2016 @03:36PM (#13279910)
That only works if you're on a one-man project where you use the STL and implement everything else from scratch.
Re:C++17 – better than you might think by vl on Thursday December 29, 2016 @02:50PM (#13279567)
I know, ADL makes it impossible to refactor anything in company-scale codebase without extraordinary efforts.

Google has a team and special toolset to do just that.

Also, how to use swap correctly? (Now, with std::move is less relevant though):

  template bla-bla {
     using std::swap;
     swap(result, computed);
  }
Sure, I could have guessed this is correct way of using it by myself...
Re:C++17 – better than you might think by gurkendoktor on Friday December 30, 2016 @03:09PM (#13287000)
std::begin suffers from the same problem and will stay relevant for longer. The cppreference.com docs specifically mention the "using trick"[1], so it seems to be an established pattern now.

It's still ridiculous - calling a function should be easy :(

[1] http://en.cppreference.com/w/cpp/iterator/begin