3,569 karma · joined May 28, 2017 (9y ago) · 1,790 submissions
comment 1w ago · link · parent
Personally, I don't use any modern C++ features just for the sake of it. That would be silly indeed! For example, I have never used ranges/views because I don't find them particularly compelling, at least for things I do.
*) Creating a coroutine frame typically requires a heap-allocation, but so does the old ASIO callback style.
comment 1w ago · link · parent
`std::span` works with all vector/array-like types: `std::vector`, `std::array`, C-arrays and third-party vector/array types.
Similarly, `std::string_view` works with `std::string`, C-strings and third-party string types.
> so that the autovectorization can kick in
It's not even about vectorization. Often you just have a function that takes a string-like or array-like thing, but you don't care about the exact container. Yes, you could make the argument a template (and constrain it with concepts), but then you have to put everything in headers.
comment 1w ago · link · parent
In fact, `std::string_view` can lead to very elegant and efficient (zero-allocation) string parsing code.
IME, taking a string_view as an argument is pretty unproblematic. Two areas where I have seen problems:
1. returning a string_view from a function. Think twice before doing that.
2. calling data() and passing the result to a function that expects a null-terminated C strings. (std::string_view is not guaranteed to be null-terminated.)
---
Apart from that, there are so many great features and libraries in C++17 and C++20 that I use on a regular basis and that I would really miss:
- structured bindings
- if-statement initializers
- fold expressions
- inline variables (very useful for handling global state in header-only stuff)
- if constexpr (replaces many uses of SFINAE)
- concepts (replaces all of the remaining uses of SFINAE)
- coroutines (really nice to use with ASIO)
- std::optional
- std::variant
- std::filesystem
- std::format (although I personally stick to fmt::format)
- from_chars() and to_chars() (fast, local-independent string-number conversion routines)
- std::bit
- std::apply, std::invoke, std::bind_front
- etc.
comment 1w ago · link · parent
Subscriptions or API pricing? There is no doubt that the subscriptions are heavily subsidized. They just milk it with their API pricing.
And of course we have to assume that they didn't use any dubious accounting tricks to make them look more profitable.
comment 2w ago · link · parent
Another note: some software has a history of multiple decades. In fact, I happen to work on such software. IMO it would be irresponsible to turn the code into an incomprehensible slop fest just because some AI boosters want me to believe that "coding is solved" or "software is dead".
comment 2w ago · link · parent
For me there is almost nothing more grating than obvious AI illustrations. It makes it near impossible for me to take the content seriously. I'm wondering: do these people just have no taste? Or do they think nobody cares? Or they just don't care themselves?
comment 2w ago · link · parent
The version could be useful if some members change their meaning across versions. But this would mean that you couldn't use a struct made from a future version because you wouldn't know about potentially changes.
Personally, I have only seen version or size, but not both. Do you have an example?
> It also helps if you only append to the end of the struct for newer fields.
This is actually required because changing or reordering existing members is an ABI break. Unless every version has its own dedicated struct. (This is often done in COM like APIs where interfaces are extended by adding a new interface. The client queries the must recent interface it knows about; if not supported, it tries the previous interface, and so on until it succeeds.)
comment 2w ago · link · parent
Generally, automation does not make us work less because the expectations rise equivalently.
comment 2w ago · link · parent
And keep in mind we're talking about a damn chat client, not some complex video editing or CAD app.
comment 2w ago · link · parent
There's absolutely no reason why a simple chat client should take more than a fraction of a second to start. If you need to fetch data from the web, just do it progressively. Not to mention that 290 MB is still way too much.
It's ridiculous how over the last 20 years simple apps became slower and slower while computers became faster and faster.
At the same time, REAPER (a full digital audio workstation) opens in less than a second.
These so-called software engineers seem to have completely lost the baseline of what is possible on modern computers. Or they just don't care.
comment 2w ago · link · parent
If you have structs that might need to be extended, you can use "versioned structs". One popular technique is to include the struct size as the first field. The struct size is set to `offsetof(mystruct, lastmember) + sizeof(lastmember)` and the receiver of the struct can use this to check if a member exists. The ARA API is a good example: https://github.com/Celemony/ARA_API/blob/65ec5c43b943a48cb54...