cda-group / arc

Programming Language for Continuous Deep Analytics
https://cda-group.github.io/arc/
44 stars 6 forks source link

RFC: Workflow of Arc programs #341

Closed segeljakt closed 1 year ago

segeljakt commented 2 years ago

This issue is about improving the workflow of writing Arc programs.

Current solution

Currently, writing an Arc program first requires creating a Rust-crate. The Rust-crate contains an Arc-file, containing the application logic, that translates into a Rust-file. The crate can then import the generated source into a Rust module.

Pros:

Cons:

Alternative solution 1

This solution takes inspiration from DDlog (Differential Datalog). DDlog resembles Arc in that programs compile to Rust. If you write a program such as:

// example.dl
input relation Parent(a: string, b: string)

output relation Ancestor(a: string, b: string)

Ancestor(x, y) :- Parent(x, y).
Ancestor(x, z) :- Parent(x, y), Ancestor(y, z).

You can compile it into a crate using the ddlog compiler:

ddlog -i example.dl

Then you need to build the crate with:

(cd example_ddlog/ && cargo build)

The result is a command-line interface that can be executed using:

./example_ddlog/target/debug/example_cli

Inside the CLI, you can write commands to ingest data into the program.

>> start;
>> insert Parent("A", "B"),
>> insert Parent("B", "C"),
>> insert Parent("C", "D").
>> commit;
>> dump Ancestor;

In Arc, we could also generate a crate that includes a CLI for feeding data into pipelines defined inside the script. This should not be too difficult if we use a clap parser generator.

Pros:

Cons:

Alternative solution 2

In the previous solution, an individual CLI is generated for each program. A different approach could be to have a CLI for all programs. Each program thus translates into a process that communicates with the CLI using sockets.

segeljakt commented 2 years ago

Alternative solution 3

Another approach is to encapsulate Arc-Lang programs completely into the source code and start the control-flow from a main-function, or by evaluating the top-level.