Deno is apparently good for scripts!
I've been trying Deno for a while and it looks promising. It got a lot of features for scripting compared to other languages. Before we get into why Deno is good, I'd just list the language/interpreter/tool I've used, in order of my personal usage:
- sh (maybe POSIX)
- bash
- python
- javascript
- lua
- go
- kotlin script (kts)
- rust
- ruby
Type and Structure
If you ever wrote shell scripts, be it for bash or POSIX sh, a lot of problems is because it doesn't have data structure. Forget structs, you can't even have a list. I think there's even a saying:
If you need arrays in your bash script, use real programming language.
Having type means I think about data flow more. I could parse command line output and be certain that it'd be the correct object. I could write smaller and composable functions around this structs.
Deno beats: sh, bash, js, python, perl
Single-entry file and command
No more separate package.json/requirements.txt/Gemfile file and no more npm/pip/bundle install. Having just a single entry file for the script means there's less hurdles and requirements just to run your scripts. To be fair, there's npx and pipx now, but both needs you to publish your package first.
Yes, I could've compiled my tool, but then it wouldn't be cross platform.
On top of that, we could execute remote scripts. Yeah, not really secure, but people been piping to sh without reading it. I don't see this as different.
Deno beats: python, js, lua, kotlin, ruby
Interpreted
Not needing to build is such a big plus. If I want to hack the script, I could open the file and make modification. Yes, it might be a bit slow, but we're talking 1 user script here. Performance isn't the top priority.
Deno beats: go, kotlin, rust
Version manageable dependency
Deno support loading npm libraries. We can even specify which library version we're going to use.
import _ from "npm:lodash@4"
And we doesn't need to worry about our scripts breaking when lodash released v5. We even get security updates for free.
Deno beats: sh bash
Quite fast
Too often tooling scripts take significant amount of time. Thanks to v8, Deno is quite performant.
Deno beats: python kts
Readable
This might be the most important one? The ability to just pick up and read the script. JavaScript is simple, and you don't need much more to understand TypeScript. This helps lower the barrier of entry and encourage people to read, learn and contribute.
Deno beats: sh inside yaml
Conclusion
This list is just my personal highlight. Deno have a lot more good things. Try it for your tooling. You'd be pleasantly surprised.
View this page on gemini! (Same content, just different protocol.)