Hacker News new | ask | show | jobs
by cominous 3114 days ago
C++17 is a slight disappointment, I hope C++20 will be the real deal - concepts could really be a game changer and move semantics needs more fixes :/.
5 comments

It's not as major of an update as previous releases, but there are a lot of little convenience features.

String views, same-line nested namespaces, [[fallthrough]], if with init (I'm sure Google single-handedly got this included; it's very Go-reminiscent and really nice when not using exceptions), structured bindings, maybes with std::optional (occasionally useful), and even just something as simple as emplace returning a reference.

What fixes do you think std::move needs, out of curiosity?

Its not std::move, but the complexity coming with it. Its a hassle applying move semantics correctly and there is not the one goto solution for simple things. Im not aware of a proposal to change that issue, but at least there should be better defaults.

This talk explains the pain quite well: https://www.youtube.com/watch?v=PNRju6_yn3o

The amount of prayer I have put into RVO and moves happening "right"... As someone who isn't a C++ programmer, is there anything better than looking at annotated asm? Templating everything and trying it with something that isn't copyable? (Actually, would that even work with RVO?)
> As someone who isn't a C++ programmer, is there anything better than looking at annotated asm

put a debug breakpoint in the move constructor and run your tests :p

std::move should extend the lifetime of a temporary like static_cast does. (Or else not accept temporaries). Otherwise, no new features necessary. But that one bites sometimes.
D has had concepts for quite a while. They call them template constraints:

https://dlang.org/concepts.html

You should give D metaprogramming a try. It's a whole new world, a new fantastic point of view.

D is in a tough situation right now

I think its good all around and balanced languages, but, there is always a better language for any use case, where D is an alternative

Ocaml, if you want performance close to C/C++ plus and high level abstractions

Rust, if you want manual memory managment

C# and Java, if you want large ecosystems and advanced features

Also C++ is now moving and improving fast Even Ada is sort of making a come back

I'm curious about the Ada comeback - do you have any examples? I know it is still used in space & defense, but I thought those were legacy code bases.
Well, I would recommend you search for Spark, and check the website of AdaCore

But, I would suggest that investing in Rust might be more valuable for one's career I am learning a bit of ADA, only for educational purposes and to scratch an itch, it is very different from anything I used, and I like that

I'd argue D is better than all of those in some ways.

D development is lively and active. I enjoy the language, and I plan to keep using it as long as I keep enjoying it.

That looks really interesting. Is this all done at compile time or runtime? After further reading the answer seems to be compile.
Definitely compile time. D has a somewhat similar feature called contracts (https://dlang.org/spec/contracts.html) which happen at runtime, but don't influence function/template resolution.
For me, the parallelism TS is the Big F*ing Deal: http://www.bfilipek.com/2017/08/cpp17-details-parallel.html
It still is pretty sweet for polyglot developers.
How so?
There aren't a lot of languages that combine functional programming/generics & OO together quite so extensively. There's a lot of power you can unlock there if you can just manage the cognitive load of the syntax.
I really like how D combines these two. The functional programming tools are a lot easier to use than C++ and a lot more practical than Haskell or OCaml. I absolutely adore the idea of purity in D: no side effects. That's all it should be, really. What this means is that it allows you to write pure functions in dirty, imperative ways as long as all the mutation is confined to the function and doesn't leak out.

I really like it.

D is a very nice language, just needs a better GC implementation and more community love.
D is, in a lot of ways, C++ without the syntactical compatibility with C.
Absolutely agreed.

D is kind of the C++ I always wanted. It's familiar, I can see the C++ lineage, and it's so much nicer to write than C++.

I'm currently having fun writing Advent of Code in D:

http://inversethought.com/hg/aoc/file/tip/2017

On my case, C++ only gets used to do low level stuff as library to integrate into Java and .NET applications.

So modules and concepts were nice to have, but C++17 is already a very good improvement to write such kind of libraries.

What are concepts? Is it like java/golang interfaces or rust traits?
It’s sorta like traits but also different.