Live data from Hacker News

C++17 Standard Published

iso.org

81–85 of 85 posts

Re: C++17 Standard Published

#81
post #80
post #75

Earlier quoted context omitted.

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 real…

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

Re: C++17 Standard Published

#82
post #55
post #35

Do any of the standard's people read HN, or is there a way of submitting requests? The STL could seriously use some improvements. std::string doesn't do most of the stuff you want with a string; updating it to an interface like Python's string would be nice. Having a std::vector::append() would be really nice, so I don't have to remember that C++ uses something completely different from every other language. Convenie…

Why Python string class? The Python 2 one or the Python 3 one? ;-) String classes are fickle things. It's very hard to get them right. Still, std::string, for all of its age, does let you do a lot of what Python does with manipulation of bytes, particularly when combined with locales (admittedly painful to use) and iostreams (also a bit painful at times). Python does have a LOT of other functionality tied into string…

Python only because it's the string class that I've used that always has everything I need. QString from Qt is pretty good, too. std::string is, like you say, painful. Since QString exists, works great with a long history, so why is std::string so limited? Design-wise, I'd say the few changes which QString has had demonstrates the solidity of the design.

Off the top of my head, what I use frequently (and which is unavailable in std::String) is:

- replace(search, new). std::string can do it, but first you have to find the index of the start, then you call replace() to replace a set of bytes. Too low level.

- endswith() and beginswith() are surprisingly helpful. endswith() in particular. s.index("prefix") == 0 is pretty clear, but s.index("suffix") == s.size() - "suffix".size() is not very clear.

- toupper()/tolower()/isspace()/isslanum()/isupper()/etc. are not something you use every day, but you really don't want to have to write proper handling of every language's idiosyncracies yourself, and it's not worth it to find a library, so probably only European languages will work initially.

- proper unicode handling. std::wstring (UTF16) is not it (to be fair, that wasn't clear at the time of design), plus I don't think it works well with either Microsoft's or Apple's UTF16

- making a string from a number. QString does this well, Python 2's str(num) is not really flexible enough. I don't want to have to create a stringstream just because I need a numeric string.

- create a string from a printf list. I know stringstream is supposed to do that, but I never seem to be able to do exactly what I want (e.g. %.3f), and regardless, I never can remember the correct syntax for the modifiers (e.g. hex(), precision()), despite it appearing like it ought to be obvious.

I pretty much expect all the above in a string. std::string is basically a veneer over an array of bytes. Maybe that was okay in 1998 when it was designed, but the first thing I have to do is add all that in now, every time I do anything UI-related with text.

I also would like split(), it makes simple parsing a lot easier.

Re: C++17 Standard Published

#83

Can someone kindly post links or books for a beginner to dive into learning C++? It is a bit intimidating to approach fresh.

I'd recommend to choose one of these two books: Programming: Principles and Practice Using C++, 2nd Ed., Bjarne Stroustrup https://www.amazon.com/Programming-Principles-Practice-Using... C++ Primer, 5th Ed., Stanley Lippman https://www.amazon.com/Primer-5th-Stanley-B-Lippman/dp/03217... For a very brief introduction: A Tour of C++, Bjarne Stroustrup https://www.amazon.com/Tour-C-Depth/dp/0321958314/ref=sr_1_1...

Here's more info regarding book recs: https://isocpp.org/wiki/faq/how-to-learn-cpp#best-book

Re: C++17 Standard Published

#84

Seems like the meta-language (compile-time expressions) is now pretty much full fledged. Long gone days where template meta-programming was the only way to do compile-time code generation and constant checks.... at least that's my impression of the latest language-level features. I have not worked professionally with c++ for a few years now, but his piece from the article, just seems rather powerful incarnation of th…

Can you explain what your code example would be used for (instead of just plus)?

Re: C++17 Standard Published

#85
post #47

The way coroutines are implemented in C++17 is just beautiful. Minimal language changes, compatible down to C function pointers and void*, and extensible to almost any existing asynchronous library via trait specialisation.

Didn’t coroutines get pushed out to at least c++20?

Yeah, technically it's a TS, but it's live in MSVC 2015/17 and Clang 5.0
Post reply on HN