Scribble at 2022-08-20 09:39:58 Last modified: 2022-08-20 16:00:33

添付画像

dwheeler says: One thing I appreciate about this talk is that it emphasizes "the shell is not a general purpose language, it's a special purpose language for running commands". / I see a lot of people complaining about shell and wanting to replace all shell uses with other languages like python or ruby. Yet when you try to do that, you often end up with long sequences of code that shell can do in a few much clearer lines. Invoking a command is trivial in shell, that is what it is optimized to do. / Shell is good for some things, and terrible for others... just like any other programming language.

The Shell Hater's Handbook (2010) [video] (youtube.com)

紹介されているのは10年以上も前のカンファレンスで発表された、シェル・スクリプトの批評というトークなのだが、Hacker News で最初に投稿された上記のコメントと僕の意見は同じである。しばしば、シェル・スクリプトなんて使いたくないという人は、"the shell is not a general purpose language, it's a special purpose language for running commands" などと理由を言うのだけれど、これは全く馬鹿げた理屈だ。では、その代わりに Ruby や Python や Go を使うのかというと、大抵の用途については牛刀で鶏肉を捌くのと同じだし、実行効率も悪い場合もあり、そして何より処理系への依存度はシェル・スクリプトと比較して優劣を語れるようなものではない。つまり、いわゆるプログラミング言語でシェル・スクリプトを置き換えるにしても、"it's a special purpose language on a running interpreter" と言えるのだから(逆に、general purpose であることの必要条件がチューリング完全性であれば、シェル・スクリプトの多くも同様である。シェル・スクリプトが PHP や Perl に比べて "special purpose" だと言う正当な理由はない)、結局は〈ブーメラン〉を投げている状況でしかない。

  1. もっと新しいノート <<
  2. >> もっと古いノート

冒頭に戻る


※ 以下の SNS 共有ボタンは JavaScript を使っておらず、ボタンを押すまでは SNS サイトと全く通信しません。

Twitter Facebook