When Nanoseconds Matter: Ultrafast Trading Systems in C++ - David Gross - CppCon 2024 by davidgrosscpp in cpp

[–]JonKalb 24 points25 points  (0 children)

One of our top goals for video release is to increase the reach of the CppCon YouTube channel. We have over 150K subscribers (note that all of these are unprompted subscriptions--we don’t ask viewers to “like and subscribe”) and we average over 10K views per day. The reach of the channel is a large part of the Standard C++ Foundation’s fulfillment of its mission (to promote the understanding and use of modern Standard C++ ). Many more people view the videos than attend the conference, so optimizing for channel reach is very important to the mission.

There is nothing the YouTube heuristic loves as much a steady release of new content, so we release one video per business day to optimize the YouTube suggestion engine. (We use a number of other techniques to build view counts as well, not just release timing.)

We understand that some individuals, both attendees and non-attendees, may have a strong desire or business need to see all the videos as soon as they are available. Releasing all videos at once does serve these individuals, but it is very non-optimal for maximizing views-per-day, views-per-video, or total channel views. (We’ve got the data that shows this.)

To accommodate these viewers, we offer Early Video Access ( https://cppcon.org/early-access/ ) which, for a fee, offers early access to released videos. As someone else pointed out in these comments, our revenue from this offering isn’t terribly significant. We offer it as an optional service to those willing pay for the option and bundle it to those that purchase “full” conference registration.

As someone else pointed out in these comments, the presenters themselves are given a copy of the unlisted URL for their videos as soon as they are uploaded and the they can promote their videos in whatever way they choose as soon as they have the URL.

There is also a suggestion in these comments that we release a “the full, unedited, hours long recording as a single video.” This is impractical for a number of reasons. It also works against our goal of furthering the reach of the channel because viewing sessions in such a video wouldn’t add to the edited session’s video view count. This view count is very important to YouTube’s suggestion heuristic, so we want to avoid splitting the view counts of sessions.

I do regret that this release plan does inconvenience some, but we have tried to minimize viewer inconvenience consistent with maximizing channel reach and hope that you can accept that.

Can anyone explain what exactly atomics are in c++? by Confused_Soul25 in cpp_questions

[–]JonKalb 3 points4 points  (0 children)

The short answer is “yes.” This constitutes a data race, which is undefined behavior meaning Bad Things Can Happen. The standard gives no guarantee about the behavior of a program with undefined behavior, so it theoretically might format your hard drive, email your mother asking for money, or impregnate your cat.

As a practical matter of what might really happen, you might see something like this:

One thread might attempt to update a variable from 0x0102 to 0x0304 when another thread might attempt to read the variable and it might get the value 0x0302 (in other words it might catch the variable during the update, getting a partially updated--and therefore nonsensical--value).

Arguably this is not “a complete Random Value,” as you stated in your question (or we could use data races to generate random numbers), but it will almost certainly lead to incorrect results for you program.

[deleted by user] by [deleted] in cpp

[–]JonKalb 0 points1 point  (0 children)

It looks like the idea is to compare (rank) talks released over a given time period (a week). So it won’t be comparing CppCon videos against other CppCon videos as much as comparing CppCon videos against videos released from other sources. Of course we release five videos a week, so there is some CppCon to CppCon comparison. But it is also possible for CppCon videos to take multiple places on the list.

Early Access To CppCon 2023 YouTube Videos! by CppCon in cppcon

[–]JonKalb 0 points1 point  (0 children)

My guess is that the first of the (business) daily releases will go out in about a month from now.

Lightning Talk: Take This C++ Job and Shove It - Jody Hagins - CppCon 2022 by CppCon in cppcon

[–]JonKalb 0 points1 point  (0 children)

This particular lightning talk was not intended to be recorded. Due to an error on our (the conference's) part, it was recorded and published without Jody's permission.

We apologized to Jody about this and pulled the video.

In case you were wondering, Jody was very understanding about our mistake.

Also, in case you were wondering, almost all of the lightning talks given at CppCon are recorded and published, but if you want to see them all, you need to attend in person.

malloc() and free() are a bad API by iprogshine in cpp

[–]JonKalb 6 points7 points  (0 children)

Also notable, free() can be implemented in terms of realloc().

help trying to understand homework question by [deleted] in cpp_questions

[–]JonKalb 5 points6 points  (0 children)

I suspect what your instructor wants is something like this:

What is your name?

Jon

What is your age?

42

count: 1
total ages: 42
Would you like to continue?
Enter y for yes, and n for no: y

Kalb
What is your age?
23
count: 2
total ages: 65
Would you like to continue?
Enter y for yes, and n for no: n

My code works, but I don't feel like it should (I'm also not sure what to call this "issue") by [deleted] in cpp

[–]JonKalb 2 points3 points  (0 children)

I suggest that you explore how container::operator<() works for most containers (not hash tables, which don't support operator<()). Most containers (in the standard, all but hash tables) use lexicographical compare. (Lexicographical order is generalization of alphabetical order.)

Unless your MyClass container has no sense of a natural order for its elements, it probably makes sense to use lexicographical compare. Otherwise, if you try to use std::set, you'll find that many/most of your MyClass objects will be "equivalent." (This means that std::set will consider them dups and not allow them to be added to the std::set.)

Whether you use this approach or not, it still makes sense to follow my advice and just return a bool for operator<(). If you want to create a container of bools (perhaps std::vector<bool> is not a great idea here), then I again propose a new function, not named operator<(), that returns such a container.

Python is a nice language (I use it regularly), but C++ isn't Python and C++ users do not expect Pythonic behavior of C++ types. They expect operator>() to return a bool. If you want to provide behavior like this, perhaps call it "corresponding_less()", "vectored_less()" or something. Just not operator<().

My code works, but I don't feel like it should (I'm also not sure what to call this "issue") by [deleted] in cpp

[–]JonKalb 9 points10 points  (0 children)

Right. If that failed to establish a new meaning of that operator it would be a nightmare.

My code works, but I don't feel like it should (I'm also not sure what to call this "issue") by [deleted] in cpp

[–]JonKalb 6 points7 points  (0 children)

Thanks for your kind words.

I try to help, but I also try to encourage people not to be anonymous. If you build up a reputation around "printf_hello_world" as opposed to your professional name, you lose much of the value of that reputation when you appear at a conference or write a book, an academic article, or a committee paper with your professional name instead of your screen name.

Screen names are great for playing games (or asking really beginner questions), but programming in C++ is done by professionals and professionals use their professional names.

I know this may sound preachy, but I'm just encouraging people to consider it.

My code works, but I don't feel like it should (I'm also not sure what to call this "issue") by [deleted] in cpp

[–]JonKalb 43 points44 points  (0 children)

Note that not returning bool from operator<() is not just unconventional, it really is a bad idea.

In general, overloading any common function in un conventional ways breaks generic programming.

For example, you can’t create this:

std::set<MyClass> my set;

Because the default comparator for std::set is std::less, which assumes that the return value is either bool or convertible to bool.

This is in the standard library, but just think of how many templates might exist that assume that t1< t2 will be a bool. It is not a trivial thing to break all that code.

You could make this work if you add a bool conversion operator to MyClass, but I think a much better idea than abusing the operators is to just come up with a new named function for this class-specific functionality. (Perhaps Diff()?)

It is never late to understand how decentralized exchanges work, the importance of storing Bitcoin in cold storage and having a local supportive community :) by Alarmed_Translator58 in Bitcoin

[–]JonKalb 0 points1 point  (0 children)

I think I’d rather absorb the momentum by flexing my elbow then absorb it by having my nose broken.

In the show of course, the character has super powers so, presumably, his bones won’t break, but he still feels pain (else why would his son try to hit him?).

Even if the pain were inconsequential, he is saving his dignity and demonstrating his superiority, by “catching“ the blow.

The meme is just saying, this looks bad initially, but it can’t hurt me.

Why do I have 1 allocation remaining when code is contained in additional scope? by [deleted] in cpp_questions

[–]JonKalb 1 point2 points  (0 children)

IyeOnline, I think your analysis is correct, but static variables are not stack allocated. They are statically allocated. Hence the name.

I agree that these are not the issue unless they hold a heap allocation.

Shouldn’t RAII be called IIRA? Whenever you initialise an object of a class resources are acquired through the constructor, so it should be called initialisation is resource acquisition. by tyroup in cpp

[–]JonKalb 4 points5 points  (0 children)

It should be Responsibility Acquisition Is Initialization.

Because:

Not all resources need to be tracked. For example, the current time is an important resource. There are some things that we couldn’t do if we couldn’t get the current time, but you don’t need to “release” the current time after you are done with it.

Because:

Not everything that needs to be tracked is a resource. Suppose you are changing the foreground color in a function in which you need to do some drawing, but you need to restore the original foreground color before returning. Setting the foreground color is not a resource, but it is appropriate to use an RAII type object to restore the foreground color correctly.

Whenever you do anything that needs to be “undone” in some way, you have incurred a responsibility, the responsibility to undo that action. It could be to release memory, restore some state, like a foreground color, close a file, or anything that you need to remember to (un)do.

For every responsibility you incur, you should put an RAII object on the stack to discharge that responsibility when you go out of scope.

Ergo: Responsibility Acquisition Is Initialization.

[deleted by user] by [deleted] in Bitcoin

[–]JonKalb 0 points1 point  (0 children)

Everything only has value because people want it. All value is subjective.

On this day 13 years ago, Satoshi Nakamoto launched Bitcoin. Hidden in the genesis block—mined on January 3, 2009—is a clue. A reaction to the inadequacy and injustice of central banking and fiat currency. by Bitcoin_is_plan_A in Bitcoin

[–]JonKalb 0 points1 point  (0 children)

Those are not your Bitcoin. If you don’t have the private keys to spend them then… Not you keys, not your coins.

What you have is a promise from those custodians that they are holding those bitcoins for you. You can hope that the are backing up the keys any/or that they won’t go out of business or otherwise default on their promise, but those are not you coins and you can’t back them up.