-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSX support #5
Comments
I have been looking into doing this via a C macro, something to the effect of #define JSX(...) create_jsx_from_string(#__VA_ARGS__) that would take the line VNode* vnode = <h1>Hello world!</h1>; from your gccx library and allow it to look something like VNode* vnode = JSX(
<div>
<h1>Hello world!</h1>
</div>
) while still being compiled as C++. This has the benefit of needing one less build step, but would require the compiler to be written in C/C++ itself. This would be something I would be interested in working on. What are your thoughts? |
Hi @dmattia, |
Instead of using a JSX syntax, why not use the template literal syntax of JavaScript, which is already a standard JavaScript syntax, instead of an entirely new and non-standard syntax? Though JSX is very popular with React and its community, other solutions based on template literals are arising: |
Hi @lastmjs, |
For Language format support in VS Code I've put together an extension taking feature from Babel Language extension for JSX like tag formats and C++ Reloaded extension for C++ part. CPX Language (alpha): Repo: |
@ahmad2smile awesome! 😄 |
Its not any joy. It doesn't do any formatting just shows colored syntax and allows you to format the document. Working on adding a formatter so vs code auto format can work. |
Ok. I've looked into problem with lang support extension but can't figure out anything. If anyone else would like to take a stab at it let me know, as I don't have time right now I can't be further assistance. Even if someone would like to replace this with their own work on vs code marketpalce I'll be happy to take down mine. |
It seems you have this implemented already via gccx. Just a side note here to let you know about an alternate type of brain using your software. The first thing I did to get a feel for asm-dom is to eliminate the csx from the boilerplate example I'm a 'backend' programmer (C++, iOS, Golang, C#, etc) that has struggled to get a foothold in web frontend. For me JSX has always felt like a train wreck of two languages; a bug, not a feature. I tend to prefer verbosity over convenience if it helps me understand what's happening. My goal with a wasm dom integration will be to make the dom disappear from my mind and write, strong statically typed code with a C-based syntax. The options that seem to be emerging for this, that I am aware of, are Blazor, Rust Yew, and now asm-dom. Anyway, I imagine I am in the minority, but preserving the ability to write asm-dom code without csx is important for me! |
Hi @webern, |
Use asm-dom with the
h
function is a little bit verbose, for this reason we have to develop a parser that allows us to write a JSX like syntax in C++:At the moment there is a work in progress command line interface (cli) called gccx. However, other ideas and implementations are welcome.
After that we have reached a good point, we have to add a section to asm-dom docs that links the right tool to do this.
The text was updated successfully, but these errors were encountered: