Skip to content
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

C++ for production web development? #17

Open
rygo6 opened this issue Sep 26, 2018 · 9 comments
Open

C++ for production web development? #17

rygo6 opened this issue Sep 26, 2018 · 9 comments

Comments

@rygo6
Copy link

rygo6 commented Sep 26, 2018

I found this after much googling for the possibility of making a website entirely with C++ and webassembly. So far it's quite impressive, everything I have seen so far I would have done the same way. I am trying understand it a bit more. I am really interested in pushing to create a full C++ tooling to do production web apps, hopefully being a complete alternative to react and node.

This project seems to be the only thing I've seen so far that has taken seemingly a correct step in that direction. So I am curious to almost like brainstorm on this. Where do you see asm-dom going? Are you hopeful for comprehensive C++ web tooling? Is such a thing plausible or ideal? What missing components do you think are necessary?

@mbasso
Copy link
Owner

mbasso commented Sep 29, 2018

Hi @rygo6,
first of all thank you for the compliments and for your interest in this project! I really appreciate it! 😄
Regarding asm-dom, I'm thinking to implement something like snabbdom's thunks and other simple features like that. I'd like to maintain it simple and performant.

Where do you see asm-dom going? Are you hopeful for comprehensive C++ web tooling? Is such a thing plausible or ideal? What missing components do you think are necessary?

asm-dom is a minimal virtual dom that can be easily used to build a framework, just like snabbdom. It would be interesting to develop something similar to react, class components with lifecycle and so on. Here is a simple example of that.
I think that we can use it to build something bigger but I'd like to leave this package simple and reusable without transforming it into a framework. I don't want to force people to use a big framework if they don't want, we can just fork or import it as a dependency.
We certainly need other helper packages that call JS when needed to hide to the user complex mechanisms like routing etc. I think that we can develop modular code in this way and then aggregate them to build a framework.
A lot of work needs to be done but I'm really hopeful.
What do you think about it? Do you think that this is the right way to do that?

@talentlessguy
Copy link
Contributor

@mbasso, I like this project too! Very upset this isn't in GitHub trending :(

About "complex mechanisms". You can just create a lot of plugins for asm-dom and we will be able to use them like usual c++ libraries.

Some example names

asm-dom-plugin-component
asm-dom-plugin-state

And so on.

And we will be able to use it like this:

#include <asm-dom-plugin-state>

@rygo6
Copy link
Author

rygo6 commented Apr 23, 2019

Sorry for not responding to this for so long. Went on a bit of detour in my personal life and projects. But started looking at this again.

I agree with the approach of keeping this repo as simple as possible. How do you think we would deal with pulling together all the different modular pieces of a large project? Could we rely on NPM for modular pieces? Can you distribute C++ through NPM?

I read through some more of your cpp code, and also some of snabdom. I realize I am actually kind of naive on all the thinking behind the design of a virtual dom. I was curious, did you by chance base this implementation off of a description of virtual dom in a book, or article, somewhere which I could also read to get a better understanding of the thinking behind it?

@webern
Copy link

webern commented May 3, 2019

asm-dom is a minimal virtual dom that can be easily used to build a framework, just like snabbdom. It would be interesting to develop something similar to react, class components with lifecycle and so on. Here is a simple example of that.

Do you think most of the foundation is available such that a framework (like React) could be written in C++? Or is there more JavaScript integration that's needed?

@mbasso
Copy link
Owner

mbasso commented May 6, 2019

@rygo6

Sorry for not responding to this for so long. Went on a bit of detour in my personal life and projects. But started looking at this again.

Don't worry 😄 We all have our personal life

I agree with the approach of keeping this repo as simple as possible. How do you think we would deal with pulling together all the different modular pieces of a large project? Could we rely on NPM for modular pieces? Can you distribute C++ through NPM?

At the moment asm-dom needs both C++ and JS imports to work properly... I'm planning to remove the last ones in order to improve the public API and have only C++ files. However, at the moment I'm not able to identify the right package manager, indeed, I'm not sure about the decision to use NPM...
Have you some suggestions to distribute modules in a convenient way?

I read through some more of your cpp code, and also some of snabdom. I realize I am actually kind of naive on all the thinking behind the design of a virtual dom. I was curious, did you by chance base this implementation off of a description of virtual dom in a book, or article, somewhere which I could also read to get a better understanding of the thinking behind it?

I based the implementation of asm-dom on snabbdom simply reading thorugh the source code... I've also read the implementation of preact, which is a really performant virtual dom with the same APIs of React, and inferno that is also interesting too. preact uses a DOM recycler and inferno uses bitwise operations to speed up the critical path, as asm-dom does.
I've read also some articles and watched some videos, for example:

@webern

Do you think most of the foundation is available such that a framework (like React) could be written in C++? Or is there more JavaScript integration that's needed?

I'm not an expert of the internals of React but I know that the core module and the one to interact with the DOM are well separated. The second is just a renderer of the first one that I think it could be easily written in C++. We should try to confirm it but I suppose it's possible.

@rygo6
Copy link
Author

rygo6 commented May 6, 2019

In terms of managing modules, I personally never saw what was so terrible with git modules. The only big issue I see is that it doesn't automatically clone all dependencies for a module. But honestly thats one of the things I kind of hate about npm, you add a module to draw a bar graph, then it adds 50 more modules to node_modules. Maybe manually having to git submodule add each depdency would make people conciencious of what their dependencies are.

But maybe it could warrant an expansion to git? Perhaps 'Git Dependencies". A repo would have have an extra .gitdepedencies file that would list all the dependencies for the repo. Once it clones a repo from .gitdependencies, it would check for .gitdependencies in that repo and do the same. But it would clone all repos in .gitdependencies under a single folder in the root, in a single "dependencies" directory that would be akin to node_modules.

@rygo6
Copy link
Author

rygo6 commented May 14, 2019

On the subject of my last post. have you guys seen this?
https://nxxm.github.io/

Looks to be the exactly perfectly alternative to npm that would work well for something like this.

@rygo6
Copy link
Author

rygo6 commented May 14, 2019

Some more reading, this seems more popular:
https://conan.io
Im thinking I am going to try to get this set up with Conan.

@mbasso
Copy link
Owner

mbasso commented May 19, 2019

Some more reading, this seems more popular:
https://conan.io
Im thinking I am going to try to get this set up with Conan.

Cool, sounds good.
Keep me updated if you experiment something with it 😄
We can publish it on both npm and conan for now. In a project with a lot of js interaction npm is certainly needed, the same conan but for C++...

At the moment I'm modifying a little bit the internals of asm-dom (and a few public api, but something really small) in order to continue with the multithreading smoothly... I'll open a "Work in progress" PR one of these days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants