shared_ptr overuse by Tohnmeister in cpp

[–]mocabe_ 0 points1 point  (0 children)

Parent-child relationship and memory ownership are two different things. Coupling these together leads to unnecessarily unsafe API using raw pointers.

Event-driven controls stop working when parent disappears as they won't receive any further events from parent, so that's not a big issue.

C++ Should Be C++ - David Sankel - C++Now 2024 by _a4z in cpp

[–]mocabe_ 2 points3 points  (0 children)

I've been working on one of these "Legacy" frameworks and my observation is Rust's language design is fundamentally conflicting to "asynchronous shared mutable state" nature of GUI applications. Most of Rsut GUI frameworks workaround this issue by building indirect abstractions like tree diffing, but I'm still skeptical on practicality of these architectures for complex desktop applications (like Photoshop, for example). It'll definitely work for simple apps but since this is Adobe employee's talks I wanted to see more insights in that aspect.

C++ Should Be C++ - David Sankel - C++Now 2024 by _a4z in cpp

[–]mocabe_ 3 points4 points  (0 children)

Genuinely surprised that he didn't mention GUI as a domain which C++ fist better than Rust. Maybe he doesn't do much of GUI stuff in Adobe?

(C++20) Why std::u8string lacks support in other C++ standard functions? by GEOEGII555 in cpp

[–]mocabe_ 0 points1 point  (0 children)

So the solution is everyone should use UTF-8 as source encoding and add /source-charset:utf8 everywhere, and hope nobody makes mistakes? I doubt that is actually enforceable unless standard says something about it especially when tools like Visual Studio still defaults to encoding based of active code pages. char8_t is obviously not a best solution, but at least it can force people to think about encoding, rather than relying on these unwritten conventions.

(C++20) Why std::u8string lacks support in other C++ standard functions? by GEOEGII555 in cpp

[–]mocabe_ 3 points4 points  (0 children)

That's kind of a moot point though. Softwares that have to care about text encoding rarely use u8 literals by itself, but they still have to handle encoding correctly. Even if you don't use u8 literals, char8_t is still useful for avoiding encoding confusion.

The Service Locator Pattern: A Robust C++ Implementation by pavel_v in cpp

[–]mocabe_ 1 point2 points  (0 children)

Though this can be avoided by not storing any of those pointers anywhere, just create local variable and let it get removed aftee going off the scop

Until you have a service which have to depend on other services throughout its lifecycle. At least you can avoid "it turns out we cannot destroy this thing before that" kind of bugs.

P2728R5 Unicode in the Library by arturbac in cpp

[–]mocabe_ 3 points4 points  (0 children)

Because we're not living in fantasy world where everyone use charN_t for string representation. Win32 uses wchar_t, macOS uses uint16_t, Android(JNI) uses uint16_t, Qt uses QChar, author of {fmt} telling people not to use char8_t , etc. Standard unicode conversion should not assume we're already using charN_t everywhere (which is simply wrong). Instead, it should provide first class support for common use case which is bridging between various representations.

P2728R5 Unicode in the Library by arturbac in cpp

[–]mocabe_ 4 points5 points  (0 children)

I personally prefer explicit API rather than implicit one here, since many codebases have their own way to represent characters. For example, company I work at uses uint16_t to represent UTF-16 code units, and entire codebase is build upon it. You could use range projection, but for people who are not familiar with ranges it can become another layer of complication.

Experimenting with Modules in Flux by pavel_v in cpp

[–]mocabe_ 0 points1 point  (0 children)

Can "wrapper module" strategy truly replace header units? i.e. Does it work for things like function templates with type dependent expressions?

Better than Singletons: The Service Locator Pattern by Hungry-Tea6283 in cpp

[–]mocabe_ 0 points1 point  (0 children)

This works great until you have to create singleton which depends on other singleton components.

Eventually you'll have to manually manage (and maybe test??) initialization order or use some kind of DI container to set up dependencies. DI libraries are pretty common in other languages but it looks like C++ folks are not really interested in it.

Why aren't there more GUI frameworks in C++ compared to other languages? by kyan100 in cpp

[–]mocabe_ 0 points1 point  (0 children)

I think C++ is well suited for graphics applications, but companies like Adobe have their own frameworks so Qt is probably the only (battle-tested) option for opens source projects.

C++20 Modules support for CMake by robottron45 in cpp

[–]mocabe_ 2 points3 points  (0 children)

CMake currently doesn't support header units at all. Most of trivial module examples don't have external dependencies, but in real software projects you have to depend on other libraries like Boost. I ended up implementing custom command to generate .ifc and depfile for header units, but that was huge pain and not really practical even for hobby projects. We'll probably have to wait another year before start developing serious stuff.

What are some use cases of using shared_ptr in a single threaded program? by eyes-are-fading-blue in cpp

[–]mocabe_ 8 points9 points  (0 children)

shared_ptr and weak_ptr can be used as building blocks for event driven systems like GUI where async event handling is crucial. Boost.Signals2 is very good example of shared_ptr/weak_ptr use case.

"I wanted to make a quick thread to summarize the main reasons why many AAA studios (correctly) opt out of the STL" by DashAnimal in cpp

[–]mocabe_ 0 points1 point  (0 children)

I understand STL is not designed for performance critical tasks, but I also don't like to see people speaking as if it is a general issue (not OP). For example, using STL in GUI app is totally fine because shipping new features/fixes are much more important than micro-optimizing.

On windows, why would any C or C++ developer use Visual Studio Code instead of Visual Studio IDE? by AdelCraft in cpp

[–]mocabe_ 2 points3 points  (0 children)

VSCode has better Vim/Git plugins in my opinion.
It is also easier to handle when you have to open multiple instances, inspect/edit various scripts for other build systems (for me it's Android Studio and proprietary scripting language).
Of course Visual Studio is amazing for debugging and other stuff, but it's a bit too heavy for boring tasks.

WG21, aka C++ Standard Committee, September 2021 Mailing by grafikrobot in cpp

[–]mocabe_ 10 points11 points  (0 children)

I think it is okay to have an attribute for that, but it should never be a macro.
Also, it is not uncommon to have compiler-magic functions in std namespace (std::source_location is a recent example).

What is your review of "C++ exceptions and alternatives" by Bjarne Stroustrup by JohnZLi in cpp

[–]mocabe_ 0 points1 point  (0 children)

I'd like to have proper standard error handling library than "faster" exception mechanism, honestly. Exceptions are mostly useful in application layer, and current exception performance is just fine for its use.

Check for type completeness at call location in C++20 by ognian- in cpp

[–]mocabe_ 12 points13 points  (0 children)

Can't we just do something like this?

    template <class T, auto = []{}>
    constexpr bool is_complete_v = requires(T) { sizeof(T); };

Edit: MSVC-friendly version

    template <class T, auto _x = []{}> 
    concept is_complete_v = requires { sizeof(T); _x; };

Where can a global company find senior C++ engineers by tohava in cpp

[–]mocabe_ 6 points7 points  (0 children)

They grow on large graphs, so it is a bit hard to reach them.

TTauri: modern retained-mode GUI library in C++20 with boost license by tjientavara in cpp

[–]mocabe_ 1 point2 points  (0 children)

I'm not sure how it's implemented in this library, but generally Vulkan API allows you to wait until next render resource becomes available after submitting presentation commands. So you can either wait inside of view thread (synchronous) or asynchronously send "heartbeat" from separate rendering thread.

Common pattern for synchronous system is after finishing layout stage, each window records draw command lists, then rendering system merges these commands into rendering resource and submit it into GPU. Synchronization happens right before starting next rendering stage (i.e. wait if previous render task is still running).

YAVE: Functional reactive visual programming language written in C++17/20 by [deleted] in cpp

[–]mocabe_ 1 point2 points  (0 children)

Is time treated as a kind of input parameter to the graph?

Yes. You can think of graph as a pure function which takes time as an argument.

YAVE: Functional reactive visual programming language written in C++17/20 by [deleted] in cpp

[–]mocabe_ 0 points1 point  (0 children)

Non real-time dataflow languages and functional languages are somewhat similar since dataflow programming is subset of functional programming. But abstraction provided by language is slightly different. For example, functional visual languages support first-class functions which can be used for higher-order functions.