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

JS in Percival / Percival in JS #18

Open
justjake opened this issue May 1, 2022 · 1 comment
Open

JS in Percival / Percival in JS #18

justjake opened this issue May 1, 2022 · 1 comment

Comments

@justjake
Copy link

justjake commented May 1, 2022

Percival makes Datalog so much more accessible! Now instead of needing to pick an implementation, install it, read the manual, figure out syntax highlighting in your editor, etc etc etc - we can just visit https://percival.ink. There's a bunch of examples, syntax highlighting, and a quick syntax to fetch data. That's great.

But though you've broken the barrier to access a Datalog implementation, there's more we can do to make Datalog useable.

  1. Bring JS into the Percival notebook: We should add JS code blocks that can consume relations and emit new data to the DAG. This will allow learners to use Percival for analysis even if they're Datalog beginners. The user can attempt analysis in Datalog, and bail out to JS if they hit a roadblock. As they gain fluency, users gradually transition to Datalog.

    If we allow cells to return Promise, Percival becomes end-user extendable via ES6 modules. We can now import anything from NPM - not just CSV & JSON data.

    The simplest implementation of this idea would be to parse plot cells of the form output_name = (more, than, one, arg) => ....

  2. Bring Datalog rules out of Percival into the wider JS world: publish percival-wasm and/or src/lib/** as experimental packages on NPM. Advanced users can build on top of the work here incentivizes further contribution. The risk of publishing to NPM a backwards compatibility burden. But, given the niche nature of Datalog today, I don't expect this to be a substantial issue if we publish using alpha tags like 0.0.0-alpha001

For both (1) and (2), I'm personally excited to explore integrating Percival <--> ObservableHQ.

  • We use Plot already. We could also use @observablehq/inspector and @observablehq/stdlib in plot/JS code blocks.
  • Observable's runtime is open source. We could investigate replacing the notebook toposort engine with @observablehq/runtime. This could allow importing Observable notebooks into Percival.
  • If we publish runtime.build to NPM, we can import Percival and run datalog within ObservableHQ notebooks. But, we won't have syntax highlighting :(
@justjake
Copy link
Author

justjake commented May 2, 2022

There's no official support for custom cell modes in Observable, but there's a hacky way to replace the TeX cell mode with a user-defined language: observablehq/feedback#106

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

1 participant