mbasso / gccx

Transforms CPX (JSX like syntax) into asm-dom Virtual DOM
MIT License
262 stars 13 forks source link

gccx and Inferno (React alternative) #3

Open IngwiePhoenix opened 5 years ago

IngwiePhoenix commented 5 years ago

General Information

Description

Hello there :)

With the strong influence that WebAssembly is having, Web apps may no longer just be written in JavaScript, but also C, C++, Rust, Go or many others. Basically, "the web" is crossing borders between languages in more or less successful ways.

However, some libraries are written in JS and were started before the uprise of WASM and they might still want to be used - and a lot of them use JSX (namely React, but there are a lot more alternatives).

This is why I really like the sight of GCCX - A "JSX for C++" syntax enhancement which looks really promising to me! However, that still leads me to a question:

Will GCCX only work with asm-dom, or will it also work with other libraries like Inferno, Preact or any other JSX/Hyperscript based application?

In my case, I am very used to C++ and would like to utilize WASM/ASM.js for my application. But due to what I want to achieve, I'd like to utilize, partially, server-side rendered content by using Inferno's .hydrate() method.

Kind regards,

Ingwie!

mbasso commented 5 years ago

Hi @IngwiePhoenix, thank you for opening this issue 😄 at the moment gccx works only with asm-dom in C++. Do you want to use asm-dom server side and inferno client side? In this case you are going to write the logic to render the page in both C++ and JS. What kind of functionality are you expecting from gccx in this scenario?

IngwiePhoenix commented 5 years ago

Hey :)

Well first, let me tell you what I would like to do - and more precisely, why.

I am very used to writing C or C++. I started as a PHP developer and used type hinting wherever I could and went from there to C++. So, typing feels natural...but it only really does on the left: vector<string> v;. When I look at TypeScript, Swift, Rust and Go, the syntax confuses me quite a lot since I am very much trained to look backwards to find the types of things when manually tracking calls within source.

So, when I saw that JSX was possible with TypeScript, I was a little bit upset and actually avoided learning it for the simple reason that I just did not feel confortable with it. Picky it may be - but not the end of the world either :) I then had a three-year-long break due to a hospital visit (issues with my eyes) and came back and... WebAssembly happened.

Right now, I am trying to look for a setup in which I can use C++ with either Emscripten or Cheerp in order to write both front- and backend in a unified language. And when I saw gccx, I was quite sure I had found that! :)

My goal is to use WebAssembly to perform business logic (Controllers, Components, Models, ...) and ES6 to perform serving logic (HTTP server bootstrapping, WS server bootstrapping, process watching, ...). Now, for frontend development, there is a gazillion of libraries to use - with the most known ones being React, Vue and a few of their of their alternatives (Preact, for instance). I (kind of) decided to use Inferno for the frontend, since it allows me to do pre-rednering on the server, is lightweight in code-size and gets the job done quite well.

So, what I was looking out to do, is to customize the calls being generated by gccx to match those of Inferno's h function.

Is that possible? :)

I know that me being picky about the language of choice is a little bit over the top... But, that's just me, really. I want to reach a point where I can use one language for everything and get the most speed out of it - which I could definitively do with C++.

If I stay with Inferno or go to asm-dom alltogether, server-side included, is not ruled out either. For now, I am just trying to find me a setup and ways to customize gccx for the case in which I may settle in.

Sorry for the long post, by the way... ^^;

Kind regards, Ingwie.

mbasso commented 5 years ago

Hi @IngwiePhoenix, I'm sorry for my late reply but I'm a little bit busy in this period. Let me try to explain if I understand well: do you want to write your frontend app in C++ using gccx syntax? But instead of asm-dom you are thinking to use inferno, so you want to modify gccx to call javascript and in particular, to build an inferno vdom tree. Is this right?