Replies: 1 comment
-
rdmd is an interesting prior art for this. It has |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Background: this originated in the Learnability of Rust blog post.
Vision
Rust has harmonized several apparent dichotomies, including
Following in those footsteps, this project seeks to offer
Roles of exploratory programming
Impediments
Thought exercises:
Friction within the existing process that gets in the way includes:
Cargo.toml
andsrc/main.rs
with common dependencies (arg parser, json support, etc) added toCargo.toml
, commonly with a version-requirementcargo run --manifest-path <abs-path> -- <args>
to try the idea (need for--manifest-path
depends on the experiment)We do have https://play.rust-lang.org/ which can help. Compared to
cargo new
,git2
)Note: we are going to narrow our scope to the project-management side of this. See Learnability of Rust blog post and xshell for ideas on the language side.
Prior Art
Bash allows (#4)
bash
to get an interactive way of entering codebash file
will run the code infile,
searching inPATH
if it isn't available locally./file
with#!/usr/bin/env bash
to make standalone executablesbash -c <expr>
to try out an idea right now--rcfile <path>
Python allows (#12)
python
to get an interactive way of entering codepython -i ...
to make other ways or running interactivepython <file>
will run the file./file
with#!/usr/bin/env python
to make standalone executablespython -c <expr>
to try out an idea right nowgorun
attempts to bring that experience to a compiled language, go in this case (#13)gorun <file>
to build and run a filescriptisto
(#10)nix-script
Existing Solutions
cargo-script
(Investigate cargo-script #1).crs
extension) rust codecargo
doc comment code fence or dependencies in a comment directiverun-cargo-script
for she-bangs and setting up file associations on WindowsCARGO_TARGET_DIR
, reusing dependency builds--expr <expr>
for expressions as args (wraps in a block and prints blocks value as{:?}
)--dep
flags since directives don't work as easily--loop <expr>
for a closure to run on each line--test
, etc flags to make up for cargo not understanding thesefiles--force
to rebuildand
--clear-cache`cargo-scripter
(Investigate cargo-scripter #2)cargo-eval
(Investigate cargo-eval #7)rust-script
(Investigate rust-script #4).ers
async main
(different implementation than rustdoc)--toolchain-version
flagcargo-play
(Investigate cargo-play #9)main
//# serde_json = "*"
cargo-script
s functionalitycargo-wop
(Investigate cargo-wop #3)cargo wop
is to single-file rust scripts ascargo
is to multi-file rust projectsrunner
(Investigate runner #14)Cargo.toml
with dependencies added viarunner --add <dep>
and various commands / args to interact with the shared crate-e <expr>
support-i <expr>
support for consuming and printing iterator values-n <expr>
runs per lineevcxr
:
are repl commandsirust
:
are repl commandsProposal
Add to rustup a new command that learns the lessons from the past to reduce the barrier to exploratory programming
Phase 1
--force
and--clear-cache
flagsCargo.lock
) for reducing cache misses--update
flag to update shared versionsmain
for both (no specialized behavior for script expressions)-loop
,--iterator
, etc support (switch to a script file)cargo new
or the script runner have a flag to explode a script into an idiomatic rust project for scaling up(
rust-script
seems like the closest base)Phase 2
--manifest-path
(test
,build
, etc)--manifest-path
like-m
or-M
to make this less cumbersomeFuture Exploration
-c <expr>
behind the scenesCargo.lock
, intermediate, and final build artifactsOpen Questions
Next Steps
Reach out tocargo-script
-like tool authors for feedbackFAQ
Why a new command instead of one of the existing implementations?
Why ship this in rustup?
cargo test
Beta Was this translation helpful? Give feedback.
All reactions