From f2325badcb860cfc72cab3513c469466c45dbfa7 Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 9 Apr 2019 10:59:51 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=89=E9=A2=98:=2020190408=20Bash=20vs.=20P?= =?UTF-8?q?ython:=20Which=20language=20should=20you=20use=3F=20sources/tec?= =?UTF-8?q?h/20190408=20Bash=20vs.=20Python-=20Which=20language=20should?= =?UTF-8?q?=20you=20use.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .... Python- Which language should you use.md | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 sources/tech/20190408 Bash vs. Python- Which language should you use.md diff --git a/sources/tech/20190408 Bash vs. Python- Which language should you use.md b/sources/tech/20190408 Bash vs. Python- Which language should you use.md new file mode 100644 index 0000000000..6d0e69d94d --- /dev/null +++ b/sources/tech/20190408 Bash vs. Python- Which language should you use.md @@ -0,0 +1,68 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Bash vs. Python: Which language should you use?) +[#]: via: (https://opensource.com/article/19/4/bash-vs-python) +[#]: author: (Archit Modi (Red Hat) https://opensource.com/users/architmodi/users/greg-p/users/oz123) + +Bash vs. Python: Which language should you use? +====== +Both programming languages have pros and cons that make them better for +some tasks than others. +![][1] + +[Bash][2] and [Python][3] are most automation engineers' favorite programming languages. Both have pros and cons, and sometimes it can be hard to choose which one you should use. The honest answer is: It depends on the task, the scope, the context, and the complexity of the task. + +Let's compare these two languages to get a better understanding of where each one shines. + +### Bash + + * Is a Linux/Unix shell command language + * Is great for writing shell scripts that use command line interface (CLI) utilities, utilizing output from one command to another (piping), and executing simple tasks (up to 100 lines of code) + * Can utilize command-line commands and utilities as-is + * Has better startup time than Python but poor execution time performance + * Does not come preinstalled in Windows; your script might not be compatible with multiple operating systems, but Bash is the default shell on most Linux/Unix systems + * Is _not_ fully compatible with other shells (e.g., csh, zsh, fish) + * Piping ("|") CLI utilities like sed, awk, grep, etc. can slow its performance + * Lacks many functions, objects, data structures, and multi-threading, which limits its use for complex scripting/programming + * Lacks good debugging tools and utilities + + + +### Python + + * Is an object-oriented programming (OOP) language, so it's more general purpose than Bash + * Can be used for almost any task + * Works on most major operating systems and is also installed by default on most Unix/Linux systems + * Is very similar to writing pseudo code + * Has simple, clear, easy-to-learn, and easy-to-read syntax + * Has lots of libraries, documentation, and an active community + * Provides better error handling features than Bash + * Has better debugging tools and utilities than Bash, which makes it a great language for developing complex software applications involving many lines of code + * Applications (or scripts) can contain many third-party dependencies that must be installed before executing them + * Requires writing more lines of code for simple tasks than Bash does + + + +I hope these lists give you a better understanding of which language to use and when to use it. + +Which language do you use more in your day-to-day work, Bash or Python? Please share in the comments. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/4/bash-vs-python + +作者:[Archit Modi (Red Hat)][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/architmodi/users/greg-p/users/oz123 +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_happy_sad_developer_programming.png?itok=72nkfSQ_ +[2]: /article/18/7/admin-guide-bash +[3]: /article/17/11/5-approaches-learning-python