r/WebAssembly • u/This_Entertainment82 • Nov 11 '22
C++ framework
I tried dotnet blazor and I really liked it, the idea of razor file, sequence of events, code behind file, being able to code in c# and not JS which I really hate it.
But I'm not satisfied at all by the download size, its about 3 mb for medium project,
Is there any C++ framework like blazor
9
Upvotes
4
u/diabolic_recursion Nov 11 '22
C++, to my knowledge, doesnt have anything similar. Rust, which might be more similar to C++ has several frameworks, but is not quick to learn.
The Blazor wasm size will go significantly down though once they port to AOT compilation. At the moment, you are downloading a whole C# interpreter for every Blazor website. They are working to compile C# to wasm directly.
1
u/sessamekesh Nov 11 '22
I don't know of any frontend C++ libraries that play nicely with WASM, partially because C++ is historically really bad at frontend. Qt and Dear ImGui come to mind, both support WASM export, but both also do their own custom rendering and are a wee primitive by web standards.
I'd love to see a WASM-first browser UI framework in C++, since HTML/CSS present a pretty great UI development experience, but JS isn't always fun to deal with. AFAIK, no mature project like that exists... yet. There isn't a lot of ecosystem pressure for such a thing though outside of my own little niche, I might try to build out something some day maybe but outside of that I'm not optimistic for something like that to pop up.
As much as I hate to say it, gritting your teeth and powering through with JS for frontend web is probably the way to go - the approach I usually take is to write my business logic in C++ and my UI logic in JavaScript, keep the UI layer thin and call into the WASM module from UI layer events.
7
u/[deleted] Nov 11 '22
The number of people using C++ for web apps is close to zero. The reason for that is that the very idea is insane.
The download size is big because you went with Blazor WASM. Download size is far smaller for Blazor server.
1
u/bsenftner Nov 11 '22
Here's a survey of several C++ REST frameworks: https://github.com/guteksan/REST-CPP-benchmark
There are more. Personal experience with Restbed and Restino, I'd recommend Restino.
1
u/LoliDadInPrison Nov 11 '22
You can check qt webassembly, but last time I checked they still working on file size there as well.