JohnCoene / javascript-for-r-comments

1 stars 0 forks source link

V8 Use Case #1

Open MayaGans opened 4 years ago

MayaGans commented 4 years ago

V8 by Jeroen Ooms is an R interface to Google’s JavaScript engine. It will let you run JavaScript code directly from R and get the result back, it even comes with an interactive console. This is the way the lawn package used in a previous example internally interfaces with the turf.js library

The example of 2+2 evaluating JS in R definitely gets the point across, but I'm wondering when and why people use V8? Specifically I think I've had issues deploying Shiny apps that use custom JavaScript code without having the V8 library available on the server. Does that make sense? If I'm missing something maybe that's worth including?

MayaGans commented 4 years ago

See Issue #2

JohnCoene commented 4 years ago

Oh, I thought my take on this was pretty good to be honest :(

If you want to bring some functionalities to R but they already exist in JavaScript why not just wrap that JavaScript library rather than rewrite the entire thing in R which is generally a yuge amount of work.

In the book I give the example of lawn.

I thought this was rather compelling but perhaps I'm wrong.

MayaGans commented 4 years ago

The "why reinvent the wheel" definitely does come across in the lawn example and the other libraries you present, I guess I'm still fuzzy on the connection between V8 and lawn?

JohnCoene commented 4 years ago

Ah, that's probably because I don't explain properly: lawn is a wrapper for turf.js using V8.

MayaGans commented 4 years ago

Ahhhh! Okay that totally makes sense, maybe consider adding or tweaking a sentence to make that more explicit? Thanks!

JohnCoene commented 4 years ago

Thanks to you! :)