Skip to content

Comment on BASH as a Modern Programming Language [ppt]

Comments

Oh please, don't get me started on this.

Bash is much more powerful than it's usually thought of (I wrote a decent chunk of bash code, there are middle-sized projects like DKMS written in bash, etc), but still it's a language for a narrow niche (file-management and gluing other tools) with a lot of limitations:

- very weak data structures support: no trees, no decent maps (`declare -A` seems to be searched in linear time), no arrays-in-arrays;

- no typing at all, everything is a string;

- it does not have a complete standard, very much behavior is implementation-specific;

- heavy dependence on external tools (they're like libraries in modern languages);

- stunning amount of pitfalls in syntax and corner cases, escaping hell (e.g.: `scp host:"File\\ name\\ with\\ spaces" .`).

Although I have to say that multiple jobs orchestration is amazing for a language from 70ths.

The syntax corner cases are the killer, hard to debug in some cases too. And it's really really slow...

I know there would be religion issues but I'm sort of surprised there isn't a dsl and repl loop shell in ruby or python or even node that hasn't taken hold among hipsters.

Bash/sh/zsh family is brilliant at intense interaction with humans. Aliases, short built-in commands, oneliner-oriented nature, keyboard ergonomics, really concise file/process handling - all of this makes it _the shell_.

I think it's hard for a language to be both suited for interactive and scripting programming, Python/Ruby/Node explicitly are languages for "heavy" scripting, they're poor choices for spending all day long with in a shell. Conciseness and obscurity of bash makes it a poor choice for "heavy" scripting. Also I think that Perl would be a nice shell and maybe that's why it's so often blamed for write-only code.

One attempt which comes close, I think, is Shelly[1]. It's in Haskell and it's definitely not quite right for interactive(!) human interaction, but I'd use it for any remotely non-trivial scripts where quoting might be an issue.

[1] http://hackage.haskell.org/package/shelly

- very weak data structures support - no typing at all, everything is a string - it does not have a complete standard - stunning amount of pitfalls in syntax and corner cases, escaping hell

Sounds like the next JS. I better create Node.sh before anyone else thinks of it so I get all the credit.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.