-
-
Notifications
You must be signed in to change notification settings - Fork 119
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
Fornjot models as serialized data #1722
Comments
I'm actually working on this right now. Most of my idea is explained here. I'm working on a proof of concept that will still use a C ABI (I will expand it to other interfaces later). instead of calling into a host object and passing a model, it will call a function in your client to produce a byte array of a serialized model. I think it will be a big step toward what you want. It is still very subject to change. |
Thank you for opening this issue, @ahdinosaur, and not least for the kind words! As @IamTheCarl mentioned, this is an idea that has come up recently. So it's timely that you opened this issue, because we don't yet have one yet to track this work 😄 So this whole topic is subject to change, and what you're trying to do will be affected by those changes. In the meantime, I have some thoughts about what you wrote, based on the current situation and possible future directions.
First, we should gain some clarity on what you're trying to do: Do you want to add support for JavaScript as a second language to Fornjot (or work towards a situation where that would be a possibility), or do you personally want to use Fornjot to write models in JavaScript? If the former, then we should have a discussion about that somewhere. I think supporting some kind of scripting language at some point is inevitable. If JavaScript/Deno is the right choice for that, I don't know (and I have my doubts). If we decided to go ahead with that approach, then it would be best to coordinate your efforts with @IamTheCarl here in this issue. If the latter, I think trying to use So which crates would you choose?
As I said above, unless your goal is specifically to make Fornjot more flexible, I'd avoid
Totally agree. I can imagine having an add-on system long-term, where the I think the first steps would probably be to untangle the various things Sorry for the large brain dump! I hope it's helpful. |
I'm keen to see Fornjot support JavaScript / TypeScript. In the long-term I'd like to use Fornjot for my own project, but in the meantime I wanted to try a proof-of-concept to help push Fornjot in a useful direction, explore some ideas. I personally don't have enough time or energy to dedicate towards the complete adventure, but I enjoy playing around and showing what's possible. Here's my proof-of-concept, which works: https://github.com/villagekit/fornjot-sandkit 🌟 I went with an approach using For the viewer, I just made something basic with Currently only handles a subset of the Another approach would be to not have any v8 -> Rust -> v8 ops, the user API is defined completely in JavaScript, and instead the model's
I'm aware I'm a bit early here, I'm happy to wait until there's a stable kernel API, with enough examples on possible user APIs. No rush from me, I'm in for the long game.
Yeah for sure, if not for me directly, is always helpful for other wandering adventurers, thanks! |
I have a working proof of concept for the serialization based ABI here. It worked on the first try which has me feeling... suspicious of it. I'm not ready to make a merge request with it yet as there's still a lot of vestigial code remaining of the old ABI and broken tests, but I thought it may be good to let both of you see how it currently works and provide some opinions. |
Thank you for your work, @IamTheCarl! I've taken a quick look and have no comments so far. This concept is still relatively new to me, and I assume I'll need some time to form strong opinions on how to do things. For now, I'm happy to merge whatever works and see where it goes from there.
The broken tests need to be fixed, but the vestigial code is not a blocker for merging. It would be better if it weren't there, of course, but it's not something we need to delay merging a pull request for. |
Okay, I'm axing the documentations examples around this macro because the macro no longer exists in this version. I'm just pointing that out so you know I'm not just deleting tests as a convenient way out of this. And as far as I can tell, those were the only tests I broke so that's good to go. |
I'm just going to brain dump a few of my next plans. |
Thank you, @IamTheCarl, I agree with both of your comments. |
This issue is no longer applicable. The affected code has been removed. See A New Direction for context. Thanks for all the input here! But as of now, a model system that goes beyond using the kernel as a library, is no longer in scope. |
Hi,
Lovely to follow along with the great work on Fornjot, is exciting. 😺
I'm playing with a way of writing Fornjot models in JavaScript / Typescript using
deno_core
.Here might be the main example model in JavaScript:
But I'm having trouble figuring out how to use the existing
fj-app
andfj-host
interfaces.As far as I understand, a shape is comprised of
fj
values, which thankfully are serializable withserde
. A model is some (serializable) metadata (like parameter definitions) plus a shape function that is given parameter values and returns (serializable) shape data. I like this, yay code as data.But then I see
fj-app
andfj-host
, and I'm not sure what to do.fj-app
expects aModel
struct, that seems very restrictive in how it works. I would much rather implement aModel
trait and provide the necessary interfaces (get_parameters()
,get_shape(parameters)
, etc) by serializing and deserializing data between Rust and v8 (JavaScript), and ignorefj-host
altogether.As another layer I could also imagine a "loader" trait that is given model ids (paths or urls) and returns models, and some such to track when models have changed. Then we could have a Rust loader, a WASM loader, a JavaScript loader, a Rhai loader, etc.
But I know this topic has been discussed before, e.g. #71, #804, etc, so is very possible I'm missing something important.
Thanks 💜
The text was updated successfully, but these errors were encountered: