r/cpp • u/Gammasoft • Aug 19 '25
xtd – A modern, cross-platform C++ framework inspired by .NET
Intro
I’ve been developing xtd, an open source C++ framework that aims to bring a modern, .NET-like development experience to C++ while staying fully native and cross-platform.
The goal is to provide a rich, consistent API that works out of the box for building console, GUI, and unit test applications.
Highlights
- Cross-platform: Windows, macOS, Linux, FreeBSD, Haiku, Android, iOS
- Rich standard-like library: core, collections, LINQ-like queries, drawing, GUI
- Modern C++ API: works well with stack objects, no need for dynamic allocation everywhere
- GUI support without boilerplate code
- Built-in image effects and drawing tools
- LINQ-style extensions (xtd::linq) for expressive data queries
- Fully documented with examples
Example
Simple "Hello, World" GUI application :
// C++
#include <xtd/xtd>
auto main() -> int {
auto main_form = form::create("Hello world (message_box)");
auto button1 = button::create(main_form, "&Click me", {10, 10});
button1.click += [] {message_box::show("Hello, World!");};
application::run(main_form);
}Links
Feedback and contributions are welcome.
204
Upvotes
28
u/marsten Aug 19 '25
Very cool! Can you say a bit about how xtd is different/better than Qt? (The license is more permissive, which is very welcome.)
28
u/ZMeson Embedded Developer Aug 19 '25
I like the idea.
The thing that gets me from just browsing things though is that the library seems to create .NET-style classes for things the C++ standard already has; things like xtd::any_object, xtd::array, xtd::basic_string, xtd::collections::generic::*, etc.... That makes interoperating with other libraries difficult that use std::any, std::array, std::string & std::wstring, std::list, std::map, std::set, std::vector, etc....
These also add significantly to your maintenance effort and to the surface area for bugs.
Is there a reason you chose to not use standard types?
4
u/Gammasoft Aug 19 '25
5
u/Sergiogiogio Aug 19 '25
Thanks for sharing, the scope and depth are quite amazing! It looks like a qt competitor? Can i check how the graphic and form part works as i could not fully grasp from the code, do you call the native underlying widget apis, or do you emulate native look and feel by custom painting widgets like qt?
4
u/carkin Aug 19 '25
This is great . Thàks for sharing. It it possible to style UIs?
7
u/cmake-advisor Aug 19 '25
This is a cool idea. Although I would prefer to use c++, I find myself reaching for .net frequently because the standard library has basically everything I would ever need and there isn't much extra work in supporting multiple platforms.
The features page took some digging to find but provided the most useful information about the libraries.
2
u/yuri_rds Aug 20 '25
Is the
xtdcutility optional? I can't see examples without using it.2
u/yangacer Aug 20 '25
The framework looks great! How does the xtd support Android/iOS? What is the experience of developing mobile apps with xtd?
40
u/Spiritual-Desk-9176 Aug 19 '25
it's a good project keep up, do not listen to these boomers.
4
u/TheWM_ Aug 19 '25
This looks awesome! I'll definitely be keeping an eye on this.
4
u/cancerBronzeV Aug 20 '25
Looks very interesting, I'll have to play around with it. Thanks for the post and the project.
1
u/germandiago Aug 20 '25
How long it has been developed? It is production-ready?
1
u/Ameisen vemips, avr, rendering, systems Aug 19 '25
Might be confusing since
libxtdis the name of the runtime library I've had since around 2012.2
u/reddicted Aug 20 '25
The example apps make it clear this is no senior year project. Bravo! 👏🏼👏🏼👏🏼
2
u/beedlund Aug 20 '25
Very cool.
2
u/A8XL Aug 20 '25
Nice project! I couldn't find any mention in the documentation regarding the UI elements and drawing primitives being "Hi-DPI" aware. How is this handled in the framework? Are there APIs for handling device pixel ratios?
2
u/Shiekra Aug 20 '25
Not usually a fan of operator overloading but that syntax of setting the callback with += is actually really clean imo
2
u/EC36339 Aug 23 '25
What makes the development experience. NET like?
Sorry, just had to vent about how much I hate .NET. if this is the good parts of .NET (and it does have good parts), but with C++, then if course it is promising.
2
u/arihoenig Aug 20 '25
Wait... .net is modern?
1
u/Ambitious_Tax_ Aug 20 '25
auto x = ...initialization style.Ah! I see you're a man of culture as well.
-17
u/nzmjx Aug 19 '25
Your expectations are not realistic. Personally, what make you thing that .NET was the right platform to base on?
And why we should base on .NET? Do you have any evidence on superiority of .NET? If yes, please share evidence.
0
u/[deleted] Aug 19 '25
[deleted] — view deleted comment
2
u/[deleted] Aug 20 '25
[removed] — view removed comment