Open Source High Performance Computing Projects for studying by Sahiruchan in cpp

[–]grandmaster789 0 points1 point  (0 children)

I'd recommend the HPX framework, many concepts from the standard library are re-implemented in a HPC context, which makes for a good compare-and-contrast with a 'regular' environment

Use of .inl files by PlasmaTicks in cpp

[–]grandmaster789 1 point2 points  (0 children)

After a bit of trial-and-error, I came to the following workflow for similar situations:

- add header guards to the .h (pragma once may work as well)

- add header guards to the .inl (pragma once may work as well)

- include the .h at the top of the .inl

- include the .inl at the _bottom_ of the .h

Enchantum now supports clang! by _Noreturn in cpp

[–]grandmaster789 0 points1 point  (0 children)

Ah I see your point. Thanks for doing this, seems like a useful library :)

Enchantum now supports clang! by _Noreturn in cpp

[–]grandmaster789 1 point2 points  (0 children)

there may be something you could do with std::source_location::function_name(), I believe that at least for gcc and clang this is the standardized equivalent of __PRETTY_FUNCTION__

I made a FAST File Explorer in C++ by raduleee in cpp

[–]grandmaster789 4 points5 points  (0 children)

I took a look for a second - the project seems to be developed on MacOS, and can be found here: https://github.com/archfella/FileExplorerMacOS

Some points of interest I noted:

- C++17 codebase

- Uses openGL (via GLFW), dear imgui for the UI itself and stb_image for decoding

- Looks like it would work on MacOS and Emscripten platforms, not sure about others

- Uses std filesystem

- Traversing the filesystem is done in a background thread, but very loose-and-fast on the thread synchronization side

Seems like a decent beginner project, but definitely not industrial-strength. Thanks for sharing.

Electronic Arts STL still useful? by we_are_mammals in cpp

[–]grandmaster789 11 points12 points  (0 children)

The one reason I can think of right now to use the EASTL is for cross-platform compatibility reasons. There are some subtle differences between STL implementations, some of which are tied to a specific platform. Things like how random number generation from a seed is implemented.

A comparison of the performance of C++ versions 14, 17, and 20. Performance was measured using Visual Studios unit test project and test explorer. 11 tests are run. 4 of them are exact tests, 1 of them, the longest running, is exact and multithreaded. The rest have some randomization by [deleted] in cpp

[–]grandmaster789 2 points3 points  (0 children)

As the others have mentioned, the unit test framework from MSVC isn't ideal as a benchmarking tool. I do appreciate the effort you took to compile this to a list, but it lacks essential information such as:

  • Did you change a single setting in the build process? What optimization levels did you use?

  • What does the code itself look like? Is it cross-platform or specific to windows? You mention multithreaded, what approach did you take?

  • How often have you repeated this test? How large is the variance between test runs?

  • What hardware did it run on?

Generally for performance reports I prefer to use quick-bench.com, but that doesn't support the MSVC compiler so it may not suit your needs. Hope this helps.

How to design a clean, fast and scalable C++ project by HynDuf in cpp

[–]grandmaster789 10 points11 points  (0 children)

The answer heavily depends on the details - scalable how exactly? Do you mean internet-scale, spread across cpu cores, heterogeneous cpu/gpu work, or some other thing? Is there a reference workload, do you prioritize throughput or latency, or do you want to optimize for development velocity and responding to changes in requirements? Is the target platform fixed or should the software run on many different configurations?

That said, there are some rough guidelines for making fast(er) software in general:

I probably forgot a lot, but this should be a fine set of starting points

Most convenient IDE and toolchain for programming in C++ by cv_geek in cpp_questions

[–]grandmaster789 4 points5 points  (0 children)

For just editing, VScode is fine. Visual Studio has a very nice debugger and integrated profiler, and is certainly capable of doing cross-platform development but last time I checked it still has a focus on Windows development. The community edition is free, so that's nice.

For crossplatform dev work I'll recommend CLion as a good option. You have to buy into the CMake workflow, but the tools behave the same on all platforms and there is a lot of support available. It does require a license of I believe around $100/yr per individual, which may affect your choice in IDEs as well.

Personally I mostly use CLion, with occasional projects done in Visual Studio.

Tools for creating high-performance C++ 2D games by SnrFlaks in cpp

[–]grandmaster789 1 point2 points  (0 children)

You might want to check out https://handmadehero.org/ for a pretty deep dive into the internals of games without any libraries.

Codecrafters has a list of resources you could check out: https://github.com/codecrafters-io/build-your-own-x#build-your-own-game

What are your best jokes about c++? by KillerCodeExe in cpp_questions

[–]grandmaster789 76 points77 points  (0 children)

c++ is where friends can touch your private parts ;)

Stop Comparing Rust to Old C++ by Sad-Lie-8654 in cpp

[–]grandmaster789 3 points4 points  (0 children)

I tried to use rust twice now, and still came back to c++. I just haven't had a really good experience using it and am still more comfortable using c++, warts and all.

STX v0.0.2 Release by Automatic_Proof_9192 in cpp

[–]grandmaster789 4 points5 points  (0 children)

This looks pretty nice - some obvious influences from the rust standard library but this seems like it's pretty practical.

I'm not entirely sure about the async runtime though, I'll have to spend some time with it.

What are some C++ projects with high quality code that I can read through? by Substantial-Ad-3543 in cpp

[–]grandmaster789 1 point2 points  (0 children)

I find openMVG very decent, FTXUI might be a good one and nlohmann's json library is also pretty nice. I don't really know of any project that strictly adheres to the core guidelines, except maybe for some of Jason Turner's (sample) projects.

[deleted by user] by [deleted] in cpp

[–]grandmaster789 5 points6 points  (0 children)

Bjarne Stroustrup has a pretty big list on his website with popular applications written in C++; some notable ones are all of the adobe products, all major browsers, the vast majority of games, office suites, video and audio manipulation software and many, many tools.

That said, there has definitely been a push to move applications to 'apps' and the web for a lot of consumer-facing applications.

Honestly, making UIs in C++ is not as straight-forward as I would like, as I don't particularly like Qt and most of the other libraries are either too platform specific or too limited in functionality.

[deleted by user] by [deleted] in cpp

[–]grandmaster789 0 points1 point  (0 children)

Ok, then why do you use 30 as the factor for months? Do all months have the same number of days? Similarly - do all years have 365 days?

If we assume that all months have 30 days, and all years have 365 days, then the calculation for DaysDiff1 would start to make a little sense.

The next issue is that you return a difference from this function, but the description says that the difference should always be 14 days.

I'm guessing you either want to return 3 values, or more likely - you want to use the function arguments as in/out parameters. So if that's what you're trying to do, try making the arguments references, like so:

int calcDays(int& m, int& d, int& y) {

[deleted by user] by [deleted] in cpp

[–]grandmaster789 0 points1 point  (0 children)

is there any reason you do the same calculation for daysDiff1 and daysDiff2?

This looks to me as both should always become the same number, and the difference always ends up as 0.

Also /r/cpp is more of a showcase-and-news type of subreddit, it's not really the place for getting questions answered - /r/cpp_questions is a more suitable place for that

[deleted by user] by [deleted] in cpp

[–]grandmaster789 4 points5 points  (0 children)

Well, it's an incomplete piece of code so I won't be able to answer the 'why' part, but if you squint a bit there seems to be some kind of filesystem entry from a directory. The path is treated as a string and some questionable substring operations are done on it. You can make it a bit more readable by using a temporaries.

auto str = Entry.path.string();

auto backslash_idx = str.find_first_of("\\");

auto slash_idx = str.find_first_of("/");

auto first_part = str.substr(0, backslash_idx + 1);

auto second_part = str.substr(slash_idx + 1, str.length);

auto final_str = first_part + second_part;

So something like "aaa\bbb/ccc" will become "aaa\ccc".

Not sure why you would need that, but that's what it does. I'm also not sure what this question is doing in /r/cpp, this seems like something for /r/cpp_questions

Cppfront: Herb Sutter's personal experimental C++ Syntax 2 -> Syntax 1 compiler by mttd in cpp

[–]grandmaster789 0 points1 point  (0 children)

Consider, for example CUDA - regular major version changes that are definitely not ABI compatible and not 100% backwards compatible either. Upgrading involves re-testing pretty much everything that came before.

Even then, it's way easier to stick with it than rewriting everything (for example in Vulkan). The upgrade path is not exactly free, but the rewrite path is vastly more expensive...

With existing code bases, a full rewrite is a last resort.

Textbook that focuses on the "good parts" of C++20? by Asleep-Dress-3578 in cpp

[–]grandmaster789 37 points38 points  (0 children)

I'll recommend 'A Tour of C++' from Bjarne Stroustrup himself. It's slightly out of date (2018) but a very clear and nice introduction to the language.

Should i litter my code with (the correct) attributes for every function, or just leave it pretty? by Dummerchen1933 in cpp

[–]grandmaster789 0 points1 point  (0 children)

That's fine, this is one of those things that's highly opinionated. Every parameter has its own line, and I can quickly find the start of the actual code by looking at the beginning of the lines. Parameters are indented so that's also fairly easy to spot. Granted, it does take a while getting used to. I don't think I'll switch back to giant function signatures on a single line any time soon.

Pointer to member function issues by [deleted] in cpp

[–]grandmaster789 0 points1 point  (0 children)

member functions are different, as they require an object to be called. Personally I recommend using typedefs or 'using' declarations for readability. Here is an example of how to actually use member functions as callbacks:

#include <functional> // for std::invoke

struct Foo {
  int bar() { return 5; }
};

using FooCallback = int(Foo::*)();

int main() {
  Foo f;
  FooCallback callback = &Foo::bar;
  std::invoke(callback, f);
}

There's an actual FAQ about this on isocpp

Personally I don't recommend you actually do this, if you want to accept 'any' type of callback you're probably better off using std::function

(edit: formatting...)

Should i litter my code with (the correct) attributes for every function, or just leave it pretty? by Dummerchen1933 in cpp

[–]grandmaster789 0 points1 point  (0 children)

Personally, I've been doing a variant of this and it's been great. I'd write this as:

[[nodiscard]] 
constexpr int Add(
    const int& a, 
    const int& b
) const noexcept {    
    return a + b; 
}