Just one data point, because I have to get it off my heart. I loved Modern C++ when it meant C++11, but I've become more negative with each new language standard reaching my workplace.
Using string_view over string by default is probably the #1 cause of memory errors that landed on my desk. I also keep hearing that "int x{0}" is preferable to "int x = 0" which allows for super dangerous implicit conversions, but then the same people rewrite push_back into emplace_back, which is much more lenient w.r.t. type conversions. It is also much easier to litter every function with [[nodiscard]] constexpr nothrow than it is to argue for readability.
My best explanation is that "Modern C++" is making developers biased towards whatever language feature is newer, instead of making good decisions. I wish the community gave up on the moniker.
`string_view` (and `std::span`) is great! Finally I don't have to use concrete types like `const std::string&` or `const std::vector<float>&` as function parameters when all I really want is just something that behaves like a string or array/vector type.
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)
I have no problem with any of these features, only with the culture surrounding them. The point should be to write maintainable, safe, and efficient code, but sometimes that is at odds with writing "modern" code because the boring old C++11 way works just fine. In my anecdotal experience (YMMV), "modern" then often trumps other concerns when it should never have been a goal in itself.
Most of the features I have listed make the code more readable, which I would count as more maintainable. None of them have a runtime overhead.*) In fact, `<format>` and `<charconv>` are significantly faster than their counterparts.
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.
We may be in agreement, so I'm sorry to split this hair: These features don't make the code more readable. They _can_ make it more readable.
You can also replace a simple overloaded function with an implicit template that uses modern "if constexpr" to distinguish between input types. Or you can "modernize" a legacy function that takes a const string& to take string_view instead, even if the very first thing the function does is to turn it back into a string to pass its c_str() to a C API (leading to more net allocations). And so on.
I always found the fashion trends of the C++ community counter-productive, and that is what I personally associate with the term "modern C++" nowadays (since around C++20). It was the same with iterators after C++98 - cool, now we can express algorithms with all the clarity and safety of C pointer arithmetics. With all due respect to the original STL, std::erase_if(cont,pred) is a godsend in its simplicity, but I suspect it would have been against the zeitgeist for a long time.
> IME, taking a string_view as an argument is pretty unproblematic. Two areas where I have seen problems
I've seen a few problema with automatic conversion of const std::string& arguments to std::string_view.
They arised when the argument was later captured by value in a lambda and passed as an argument to e.g. std::thread.
Instead of safely passing copy of the string now you pass refwrence to a memory owned by a different thread, which may be deallocated at any moment.
> all I really want is just something that behaves like a string or array/vector type.
What does behave like a std::string/std::vector but is not std::string/std::vector, respectively? In my experience, if you want a flat array behind a T* (or std::dequeue<T> at the worst) — so that the autovectorization can kick in — then that's precisely what you want, and no generalization to e.g. a linked list, or a heap, or a red-black tree is really possible.
> What does behave like a std::string/std::vector but is not std::string/std::vector, respectively?
`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.
To be fair, string_view has one very attractive feature over const ref string. String's char constructor is not explicit. With string view, you are guaranteed to not allocate by accident.
Understood, and I also use string_view where it makes sense. But while overusing std::string can cause unnecessary and hidden allocations, overusing string_view often leads to memory errors.
I also love C++11 "auto", but overusing it then makes the string/string_view bugs harder to find.
I am perfectly happy with with idiomatic C++11 plus features from recent standards, but I don't feel like that counts as "modern C++" anymore. A sibling comment put it better: idiomatic C++20 has become its own separate thing, and I personally don't love it, and it is certainly not more robust in my experience.
When I've had a coffee too much, I notice the 120 Hz flicker even more. But even when I'm tired and don't, my mood still noticeably increases when I leave flickery spaces. (I sometimes test my hunch with the slow-motion cam as I am leaving.)
I've tried looking for studies to prove or disprove my experience. They should be easy to find, right? Humanity is replacing the entire planet's lighting with LEDs after all! Comment sections have been busy with people arguing about PWM flicker for years, probably longer. What is the best study you can find? For me, it is always the one from 1989 about pre-LED 60 Hz office lighting (that said it had adverse effects). Seriously...?
I wish I was a Bitcoin billionaire, for many reasons, but doing another study on flickery LED lighting seems like the lowest-hanging fruit of our entire civilization. I live in a country that is regulated to hell and back, and yet even our street lights flicker visibly, not to mention classrooms, children's bedrooms, and the screens that people stare at for hours every day. I don't get it.
When I'm tired or had too much coffee I feel the same effect: it's like my brain / eye framerate drops overall but at the same time noticing flicker more. It's especially noticeable at night.
I think it could also be related to the muscles in the eyes not stabilizing the vision as well. Those muscles work extremely hard, even correcting rotation partially. It's really cool to see in slow motion, and I bet you'd see a difference in the jittery or tired state under PWM light too.
I'd have preferred the inverted-T layout of recent MacBooks too. But because this keyboard does not have a numpad, it could be easy enough to find the bottom left corner of the keyboard with your fingers.
system76 does not develop special Nvidia drivers, but they do work on integrating GPU switching etc. in the Linux desktop: https://github.com/pop-os/system76-power/
I don't think this is necessarily about Linux nerds. For any kind of work laptop, time saved tinkering easily worth the extra $$$.
Plus PopOS hasn't been doing great lately , Cosmic has issues.
Linux must remain a FREE alternative to Windows. If I need to pay an extra 1400$ for a specific Linux laptop with the same specs it's vastly less competitive.
They did still overpromise and that should not be the way Apples does things (although it was hardly the first time; the AirPower mat was announced in 2017).
To be fair, all tech companies do this. Sell first, implement later, hype hype hype. Of course we’d like to think Apple was better, but well.. it isn’t.
Google certainly shipped Magic Cue as their tentpole new AI feature on the Pixel 10 despite it not working.
> “The right info, right when you need it.” That’s how Google describes Magic Cue, one of the most prominent new AI features on the Pixel 10 series. Using the power of artificial intelligence, Magic Cue is supposed to automatically suggest helpful info in phone calls, text messages, and other apps without you having to lift a finger.
However, the keyword there is “supposed” to... even when going out of my way to prompt Magic Cue, it either doesn’t work or does so little that I’m amazed Google made as big a deal about the feature as it did.
Many gamers are married to Windows exclusive games like Fortnite etc., but gamers are also more rebellious than corporate IT staff and many have actually built their computers from parts, so they are not scared of flashing a USB drive. I'm optimistic that this group is the next one to break away from Windows.
Gaming is the biggest thing that keeps me on Windows, followed by the fact that I use an Nvidia GPU, followed by a very localized case of inertia where I have so much data, settings and programs concentrated in my OS install that migrating it all over is going to be a monumental pain in the ass. But luckily, Linux gaming has gotten way better and I don't play the kind of games that categorically refuses to run there (anything with highly involved anti-cheat systems), so once my version of Windows becomes unsupported, I'll bite the bullet and make the Linux install into my primary one.
I think people like me are the real first line that's most likely to switch - techy people who play games (which had so far kept them on Windows) and that suffer firsthand at Microsoft's attempts to get them directly in addition to already being treated horribly by default. This group is less afraid of changing things up and has more incentives to switch. But if we talk of gamers in general, it may take a while until a meaningful number of them switch over, even though they are far more motivated than the average PC user. Even though they're the prime candidates, it's going to be a very, very steep uphill battle.
> ... localized case of inertia where I have so much data, settings and programs concentrated in my OS install that migrating it all ...
Your first step is start swapping out Windows-specific programs for cross-platform alternatives. Eventually you'll have to just cut the rest loose and make the jump though. Don't bother dual-booting either or you'll just delay it further.
I made the transition a few years ago and it was far less dramatic than I imagined.
Luckily, there's not that much Windows-only software I must use. Unluckily, it's pretty essential:
- Fusion 360 (the only alternative seems to be learning a different, likely far more involved CAD)
- Paint.NET (a simple, quick, no-nonsense image editor - while there are image editor alternatives, as far as I can tell there's nothing quite like it)
The bigger issue that might keep me dual-booting are graphical features. Things like VR and HDR are already known to be janky on their "native" Windows implementations, so I'm scared to imagine what any of that is going to be like on Linux. Neither are common use cases, but I still want to hold onto those where possible.
I feel that pain. I was using Lightroom since 2009 or so and I it took me many hours over many Saturdays to extricate myself from its grasp. That being said, my efforts to abandon it was the only thing that exposed a lot of problems (metadata, duplicates, etc.) so... it worked out in the end.
I don't have a replacement at all but this coincided with a reduced desire to tinker with and touch up my photos in general. I'm currently working on a modular Unix-y/CLI-focused way to safely ingest photos (archive originals with PAR2; then move from source and rename), reject/rate as needed, ensure timestamps are correct (UTC for DSLRs), geotag with whatever GPX I have, and then eventually some sort of LLM-based tagging. Exif will do a lot of heavy lifting here.
All I really need now is a way to rate my photos and I'll probably use Digikam for that. Raw processing doesn't have a CLI solution that I like so I'll probably have to use RawTherapee or something as well.
Right. I said that when Windows loses the gamers, its monopoly will eventually collapse. Office-use is another area where Windows has a stronghold, but the gamers are typically quite clever people, whereas elderly people often have physical problems and grew up in a time where computers weren't so dominating.
This is just a personal anecdote, but I was speaking from past experience. Perhaps things have improved now, but back when I seriously used Linux on my own PC, the 2-3 times when the system randomly stopped booting properly and had to be tinkered with for me to be able to do anything with my computer, all of these issues were caused by something (Nvidia) GPU-related.
The situation is much better now. I've never had any issues with using the proprietary drivers on Arch on wayland in the past few years. If anything, AMD's drivers are noticeably more buggy.
Not just battery life, but also webcams and mics. Sure, you can use additional gadgets...but being able to open your MacBook and just talk to your coworkers is reason enough to keep an M1 Air around for the next years.
(That's just one genre of brainrot I came across recently. I also had my front page flooded with monkey-themed AI slop because someone in my household watched animal documentaries. Thanks algorithm!)
Using string_view over string by default is probably the #1 cause of memory errors that landed on my desk. I also keep hearing that "int x{0}" is preferable to "int x = 0" which allows for super dangerous implicit conversions, but then the same people rewrite push_back into emplace_back, which is much more lenient w.r.t. type conversions. It is also much easier to litter every function with [[nodiscard]] constexpr nothrow than it is to argue for readability.
My best explanation is that "Modern C++" is making developers biased towards whatever language feature is newer, instead of making good decisions. I wish the community gave up on the moniker.
reply