Comments (10)
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):
https://marketplace.visualstudio.com/items?itemName=ahmad2smile.cpx-language
Repo:
https://github.com/ahmad2smile/cpx-language
from asm-dom.
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?
from asm-dom.
Hi @dmattia,
that's definitely an interesting idea! That was also my first thought before writing gccx, as you said, a macro is the right tool to do that without an additional build step, that is the main issue of gccx.
However I think that the problem with this approach is that the parsing is evaluated at runtime, so we might have a performance disadvantage, also, we have to include the parser in the bundle that we'll send to the client.
I think that we can develop both the solutions, gccx and the macro. A compiler written in C/C++ might also be very useful in the future, we'll be able to do a lot of things that are not possible right now.
Please feel free to experiment and contribute! I'm very interested to see the implementation 😄
from asm-dom.
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:
from asm-dom.
Hi @lastmjs,
This is certainly an interesting field of study. I've to learn a little bit more about that to understand if it is compatible with asm-dom and how we can do that in C++. I think that I'll read the source code of lit-html as soon as possible and I'll do some research on github (for example I've found this issue). If you have some tips, idea about the implementation, or if you want to contribute please let me know 😄
from asm-dom.
@ahmad2smile awesome! 😄
I'll try it tonight! Thank you so much for contributing and making asm-dom even better!
from asm-dom.
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.
from asm-dom.
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.
from asm-dom.
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!
from asm-dom.
Hi @webern,
thank you a lot for your feedback!
Yeah, we should definitely preserve the possibility to write asm-dom without cpx
. Indeed, gccx
represents just an additional step to compile only its syntax to plain C++ code.
Both of them have some advantages and disadvantages, the user should be able to decide freely the right one for his use case 😄
from asm-dom.
Related Issues (20)
- Support for web components HOT 6
- Benchmark comparison to major SPA (react, vue, etc.) libraries? HOT 2
- Is this still an active project? HOT 2
- Could there be a browser that supports cpx? Or is this entirely out of scope?
- WebGL, WebGPU etc. for rich graphics?
- What are the preferred ways to add interactivity to SPAs with asm-dom?
- Why doesn't WASM make this project obsolete?
- Any input, if I'd wish to see an usability comparison of asm-dom to existing JS frameworks?
- C++ for production web development? HOT 9
- Featuring asm-dom in Docusaurus HOT 1
- Question: Using CLion, Compiling to Native HOT 3
- git submodule init fails. HOT 1
- Regression: children aren't displayed when appended manually to a parent with no child. HOT 3
- Compilation fails because of undefined behaviour catched by `-Wunsequenced` HOT 7
- HTML parser from cobalt
- Shared logic for desktop/mobile and web browser
- VNode reuse HOT 24
- SVG Support is broken HOT 1
- Inline Example in README.md is missing a closing parenthesis. HOT 2
- Support SSR(Server Side Rendering)? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from asm-dom.