Shell script and programming language

For many tasks that I have to perform, I have to choose between creating a program using the Script shell in Linux or in a programming language such as Java or Groovy. Does anyone know how I should choose one after another and why?

+4
source share
3 answers

Shell scripts are great for concise file system operations and writing combinations of existing functions in filters and command line tools through pipes.

When your needs are greater - be it functionality, reliability, performance, efficiency, etc. - then you can switch to a more fully functional language. They usually offer some combination:

  • security type
  • more advanced containers
  • better control over the lifetime of variables and memory usage
  • thread-cutting
  • advanced IPC, such as shared memory and TCP / IP
  • Full binary I / O, access to memory files, etc.
  • access to the OS API and many powerful libraries
  • improved readability and maintainability as the size of the project increases.
  • support for more advanced programming paradigms: object orientation, functional programming, generative programming, etc.
  • better error checking before your program starts, therefore, less dependent on the coverage of the test case.
+9
source

@Tony provides an excellent list of pros and cons. I would add another common scenario - shell scripts, because it is so convenient that it might seem that โ€œthere is nothing longer than a temporary solutionโ€, which is typical for all the attendant maintenance problems when someone else needs to use it.

+2
source

Shell script is the most intuitive way to have glue on your system. However, it does not have some useful concepts, such as inheritance and modulation, that languages โ€‹โ€‹such as Python (which are very used to "gluing" systems) have.

True, the use of the language depends mainly on the task you are trying to do. In most cases I worked, the shell script worked well, although I use a lot of Python to perform system-related tasks. I don't think Java would be an alternative in this case. Groovy will probably be, but not Java (I mean Java as a language, not Java as a platform.)

In sysadmin view, I think Python and Ruby are amazing languages. Not only because of the dynamic typing and the lack of the need to compile, but also because tools such as Fabric , Capistrano , Puppet and many others, which greatly simplifies the life of the system administrator :-)

+1
source

Source: https://habr.com/ru/post/1339162/


All Articles