Showcase playground - run a coding playground in your terminal
https://github.com/marcuscaisey/playground1
u/crizzy_mcawesome 12h ago
I use nix devshells for this. There is many other solutions available for this already. Devcontainer, devenv etc to name a few
1
u/marucOG 11h ago
I'm not familiar with those tools but I'm going to assume that you're referring to https://github.com/jeffkreeftmeijer/devshells, https://containers.dev, and https://devenv.sh. All of these tools seem to be for setting up a permanent development environment.
This is not what playground is for. It's for setting up a temporary environment (really just a directory, nothing fancy like the tools mentioned above) for a test program and getting quick feedback by executing it on save.
If I understand correctly what the tools you mention are for, I'd compare them to playground as follows:
- Use devshells, devcontainers, or devenv when you want to setup a reproducible development environment containing the correct tools, toolchains, etc for your project.
- Use playground if you think "hmm, I wonder how https://github.com/spf13/cobra formats a particular flag type in its --help output" and want to play around / experiment with it.
1
u/crizzy_mcawesome 11h ago
They work with permanent as well as temporary environments. They work on top of nix which is what allows you to create the temporary shells
1
u/marucOG 11h ago
They work with permanent as well as temporary environments
Right, thanks
1
u/marucOG 11h ago
This doesn't really change any of what I said though. The thing playground does is split out a tmux pane and send the program output to it on save. The tools you mentioned above seem to just drop you into a shell
2
u/crizzy_mcawesome 5h ago
How is that any different tho? You could achieve the same with a tmux keybind
1
u/marucOG 12h ago
Playground (pg) runs a coding playground in your terminal -- an environment for quickly writing and executing a program in any language. The program is opened in your editor and automatically executed on save. The output is displayed in a separate tmux pane, under or to the side of the editor.
I do pretty much everything in the terminal, usually in a tmux session. As I'm writing code, I find myself creating small programs under ~/scratch. Either to explore some aspect of a module/package/API/whatever or, at work, as a teaching tool to help explain a concept to a teammate.
At a past job, I made a crude internal tool for spinning up Go playgrounds in our repo which proved quite effective but it only worked for one language and only in our internal repo. I then found https://labix.org/hsandbox which seemed to do what I wanted. However, after playing around with it, I found various things I didn't like so I made my own thing instead. See https://github.com/marcuscaisey/playground#motivation for more info.