![]() |
|
![]() |
|
Oh, he switched to QT for the GUI chapter. That's a significant change from FLTK. Should be well received as QT is popular in industry. Not sure how the learning curve will be affected.
|
![]() |
|
Know what I like about Stroustrup's code? "using namespace std;". The typical convention of sticking std:: in front of std::every std::last std::bloody std::thing drives me std::insane.
|
![]() |
|
I miss my days working with C++. It's moved further down the development stack than where it used to be. We used to handle UI, API parsing, and pretty much everything using C++.
|
![]() |
|
I felt some nostalgia for Fortran a while ago. Spent half an hour programming in it, cured. Maybe take a shot at parsing JSON in C++ and see if the nostalgia survives the process.
|
![]() |
|
Gotta have those "readfile()", "replace_substr()", "split()" etc! I do have a copy paste string util header. .. I really wish there were more string util functions in Cpp. I mean C had strtok()! |
![]() |
|
The current project I’m working on has tons of resource caches (for performance), with tons of non-owning pointers sharing cache references. I’d hate to do this in opinionated languages like Rust.
|
![]() |
|
Have you tried it? How would you know that Rust is the wrong tool. I'm indifferent when it comes to Python vs Rust for scripting, but I'd take Rust over a shell script (of any variety) any day. |
![]() |
|
poetry with poetry2nix with nix flakes will do magic in terms of setup. if stick with pyright(inference) it is as modern as rust. python speed increases heavily in all directions. |
![]() |
|
> You can end up having many copies of the same template logic, which blows up your instruction cache. linkers have been able to perform identical-code-folding optimizations for a few decades now |
![]() |
|
https://www.tiobe.com/tiobe-index/ Without having to squint, 12 of those languages are easily categorized as OO languages. Given the mindshare of those 12 languages, I don't think it makes sense to say that "OO programming is mostly frowned upon." [emphasis added] Maybe it's frowned upon by some, maybe even many, but if it's mostly frowned upon then a lot of people must hate their work. |
![]() |
|
Could be missed if there was a mix of typed by hand and auto-inserted by IDE headers, plus maybe a setting that collapses (folds) imports by default... and clang-format wasn't run on save? ;-)
|
![]() |
|
Great but I am unable to find an IDE or compiler that supports C++ 20 and every one of them complains about import std; Any recommendations? |
![]() |
|
Did you use it to learn programming as a novice to the field? I have always wanted to learn programming as a hobby, but never really found the right entry point. Would you recommend this?
|
![]() |
|
For hobby programming, Python is the best (unless you want to do web development in which case JavaScript is what you want). For Python, a really good book for beginners is Python Crash Course.
|
![]() |
|
> I have never seen any program slow down over a move I'm sure, and yet the people who care have noticed that C++ is slower, that's what P1144 and P2786 and so on are trying to solve, without quite saying "destructive move" out loud. Here's the current iteration of P1144: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p11... Like pointer provenance this is something WG21 would prefer not to think about because it's embarrassing, so it has hung around like a bad smell for quite a few years but I suspect (unlike provenance work) it'll get into C++ 26 in some form. > Reserve reserves the amount that you give it. This isn't hard or complicated. What exactly do you think it should do differently It's OK, after all Bjarne Stroustrup didn't see this either, but you've missed something quite important The whole idea of this type is amortized constant time growth, typically via doubling although any fixed ratio would work and there could be a benefit to choosing other ratios in principle (Folly has a long paper about this). For this purpose it's crucial that capacity doesn't grow linearly. But if our only reservation mechanism is Vec::reserve_exact (aka C++ reserve) we end up with linear growth. Bjarne's solution is to abandon use of reserve for performance, but we can do much better by just bifurcating the API as Rust did (and as some other languages do) I started writing a program to illustrate this, but it's probably easier to just spell it out with an example. Suppose we receive Doodads over the network, they arrive in groups of say up to 20 Doodads at a time, and we don't know in advance how many there will be, until the last group indicates it's the end of the Doodads. Typically in total there's maybe 40-50 Doodads, but there can be as few as five (one group of just five) or as many as a thousand. We're going to put all the Doodads in a growable array as we receive them. Let's walk through receiving 19, 14, 18, 12 and finally 6 Doodads. Bjarne says don't bother with reservation as in C++ this doesn't work for performance, so we just use the "natural" doubling. Our std::vector allocates space for 1, 2, 4, 8, 16, 32, 64 and finally 128 Doodads (eight allocations), and does a total of 127 copy Doodad operations. Surely we can do better knowing what's coming? If we ignore Bjarne's advice and use C++ std::vector reserve to reserve for each group, we allocate space for 19, 33, 51, 63 and finally 69 Doodads (five allocations), and we perform 19 + 33 + 51 + 63 = 166 copy operations. Fewer allocations, more copies. If we have the bifurcated API, we allocate space for 19, 38 and 76 Doodads (three allocations) and we do 19 + 33 = 52 copy operations. Significantly better. > This isn't a performance limitation it's a convenience you want integrated into the language I disagree and the results speak for themselves. > There is one that does this, it's called ISPC. Is that what you use? I've never used ISPC. It's somewhat interesting although since it's Intel focused of course it's not actually portable. > This seems to me like you've gone down some sort of anti C++ rabbit hole where people who don't know what they're doing get worked up about things that don't matter. It's always funniest to read about what "doesn't matter" right before it gets fixed and suddenly it's important. The growable array API probably won't get fixed, education means that Bjarne's "Don't use reserve" taints a whole population so even if you fix this today it'd be years before the C++ programming community use reserve where it's appropriate but I expect "relocation" in some form will land, and chances are in a few years you'll be telling people it's why C++ has "extreme performance"... |
Writing this on a debian machine, and trying "g++ --std=c++23 -fmodules-ts" does not work, and from https://en.cppreference.com/w/cpp/23 looks like the "paper" for this is P2465R3, for which clang++ 17 has "partial support". I apt installed clang++17, and it still didn't work, complaining "module 'std' not found"
I understand that "import std;" is a very new feature and not "finalized" or whatever, but this book is supposed to be for beginners to C++; I wonder how the average beginner would react to that?
(I found the same thing a year or two ago when reading "Tour of C++")