andrjohns / QuickJSR

R interface for the QuickJS lightweight javascript engine
Other
18 stars 0 forks source link

Future plans for QuickJSR? #7

Open wch opened 7 months ago

wch commented 7 months ago

Hi, I'm curious: what are your future plans for QuickJSR?

The reason I ask is because I have been experimenting with using JS in R packages, and quickjs has some important advantages over V8 for use with R.

Some background: the sass package wraps the C libsass library, but libsass has been deprecated for several years now, and we are looking for a way forward.

I believe that the only Sass compiler implementation that's being developed these days is Dart Sass, which can be compiled to JavaScript. I wrote a JS wrapper for Dart Sass (compiled to JS), which can be run from the command line using the qjs runtime: https://github.com/wch/sass-quickjs

Then I used qjsc to generate a C file for this, and put that in an R package, so that it can be used from R: https://github.com/wch/sassy

This is OK, but result is fairly large -- the built binary package is a 2.2MB tarball, and the vast majority of that is the QuickJS runtime. If we were to use JS in any other R package and embed it this way, it would be another few megabytes for each packge.

That brings me to QuickJSR. I can see that QuickJSR can be used to evaluate JS code, but if we were to use it, we would want to be sure that it would be developed and supported in the future. Are you planning on continuing development on QuickJSR?

andrjohns commented 7 months ago

Great to hear that the package could be useful!

I do have plans to expand the package's functionality, with the end goal of being a drop-in alternative for V8 (where possible), as well as improve the documentation and vignettes.

Unfortunately I'm a bit short on spare time at the moment, so it will be another month or two before I'll be making any large changes.

I'm happy to take a look at any smaller bugs/issues/requests in the interim, so feel free to let me know if anything comes up

andrjohns commented 7 months ago

Also as an aside, you could avoid bundling the quickjs sources/engine by just adding LinkingTo: QuickJSR in your package description.

This will save you some headaches with CRAN, since the QuickJS C code causes several -Wpedantic warnings. The bundled sources/headers here have several patches for these. I have them all in a fork here, such that they're only applied when the -DSTRICT_R_HEADERS flag is passed

wch commented 7 months ago

Good to hear that you're planning on continuing work on this package.

Some thoughts:

andrjohns commented 6 months ago

@wch Thanks for all of these suggestions, and I agree! I'll be starting on updates this week, so will be working through these.

What do you think about changing the name to all lowercase, like quickjsr? Or maybe even just qjs?

I wouldn't mind renaming to quickjsr, but is that possible with CRAN? I didn't think they allowed renaming packages?

wch commented 6 months ago

That's great to hear!

I guess renaming it to quickjsr might not be worth the trouble, and could cause problems for users with case-insensitive filesystems (Mac and Windows), if they try to install the old and new packages. Although, the name qjs might be good. I don't feel very strongly about it either way.