43 ms·
I think the best way to write things safely is to not write them in Bash in the first place. Better pick a strongly typed language of your choice.
by hutrdvnj 6y ago
I think the best way to write things safely is to not write them in Bash in the first place. Better pick a strongly typed language of your choice.
- macintux 6y agoHow many strongly typed languages are: + Installed everywhere + Even within 20% as concise as bash
- deleted 6y ago[deleted]
- effie 6y agoIndeed. Python does not win over bash in either category, and it is slower. I wish there was a super-fast shell-like scripting language everywhere that could serve as a general programming language. Like Perl, but simpler rules and readable syntax. But there is nothing. Who would have thought, I may have to learn Perl eventually.
- drran 6y agoIMHO, we need more than one language in the shell: one to orchestrate launching of applications, plumbing, and processing of their inputs and outputs, another one for computations with integers, floats, complex values, arrays, matrices, another one for text processing and parsing, another one for argument parsing and default values, another one for error handling and recovery, another one for pattern matching and state machines, another one for object-oriented programming, another one for network programming, another one for record-oriented programming, another one for security and debugging, another one for container management, another one for system manipulation, upgrading, recovering, another one for documentation, and so on, with advanced way to share variables and data between these languages (environment variables on steroids). It's not possible to implement such monstrosity as one simple, portable, small, fast, and secure binary.
- effie 6y agoWhy not? Busybox is an example of how to pack diverse capabilities into one binary.
- kaba0 6y agoHow is it slower/matter at all? Goddamn bash calls an external process in if branches, so if a bash script is enough for a given process, than running python inside a vm inside a vm inside a vm will be still fast enough. Scripting doesn’t require performance.
- effie 6y agoIt is slow because the process of interpretation is slow (conditions, number and string operations) and because to achieve anything nontrivial in shell/bash, one _has_ to call external processes, which is slow. In Perl one calls external processes much less because of large amount of capable libraries and Perl is indeed much faster.
- kaba0 6y agoThis doesn’t make sense. How would python be slower? Bash is indeed the prototypical do what each line says. And there is absolutely no optimizations here. Python while not the fastest thing out there, basically every implementation does a quick parse phase and run some optimized form.
- effie 6y agoI meant bash is slower than perl. Python is also slower than perl. Python is quicker than bash in number/string operations in process, but much slower than bash in startup. 'Quick parse phase' is exactly the reason; it is not quick. Try to execute 1000 python processes and then 1000 bash processes that do something simple like add numbers given as command line arguments. Python is order of magnitude slower to finish.