4 ms·
I've found that it works better to use a 'real' programming language for scripts and use a UNIX shell for interactive REPL-like use. The syntax of the command l
by mike_hearn 3y ago
I've found that it works better to use a 'real' programming language for scripts and use a UNIX shell for interactive REPL-like use. The syntax of the command line is hard to beat one you master it because it's so terse and for one-to-ten line programs like you get in a REPL maintainability doesn't matter. For anything else, it's better to write a script file and execute it. The tradeoffs are different and what works well for a program meant to stick around doesn't work well interactively. The downside of course is that if you perfect a bit of logic with a repl, you then have to translate to the other language.
My company uses an in-house variant of Kotlin Scripting which has replaced bash and python for us. It's got a lot of neat features, like you can echo markdown to the terminal and it'll be rendered nicely, it has a built in progress tracking framework, it has a UNIX-like shell API for working with files and processes, you can import libraries from Maven and use them directly and so on.
The only real downsides are that it's slow to compile, and currently Kotlin Scripting is still in a (very long) beta period. Hopefully when they finally release version 2 of the compiler it'll be faster and they can finally nail down the scripting support a bit better.
But I have to say, it's really enjoyable to use. I used to dread shell scripting tasks because shell is just so persnickety. Now I don't. Java has something similar with jbang and jshell, but the Java syntax is perhaps a bit too verbose still. They're improving it a lot though!