yazz.com
yazz.com

Reputation: 58786

Shell scripting vs programming language

For alot of the tasks I have to do I find myself having to choose between making the program using a Shell Script in Linux or a programming language such as Java or Groovy. Does anyone havce any experience about how I should choose one over the other and why?

Upvotes: 12

Views: 16281

Answers (3)

Herberth Amaral
Herberth Amaral

Reputation: 3539

Shell script is the most intuitive way to have a "glue" on your system. However, it does not have some useful concepts, like inheritance and modularization, that languages like Python (which is very used to "glue" systems too) have.

True, the use of language depends basically on the task you are trying to do. For the most cases I've worked, shell script worked well, although I'm using a lot of Python to accomplish system related tasks. I don't think that Java would be an alternative in this case. Probably Groovy would be, but not Java (I mean Java as a language, not Java as platform.)

In a sysadmin view, I think Python and Ruby are awesome languages. Not only because of dynamic typing and the lack of need to be compiled, but because tools like Fabric, Capistrano, Puppet, and a lot of others which makes a sysadmin's life a lot easier :-)

Upvotes: 2

Chris Walton
Chris Walton

Reputation: 2533

@Tony provides an excellent list of pros and cons. I would add one more general point - shell scripts, because they are so handy, risk displaying the "there is nothing more lasting than a temporary solution" characteristic with all the attendant problems of maintenance when somebody else needs to use it.

Upvotes: 2

Tony Delroy
Tony Delroy

Reputation: 106076

Shell scripts are excellent for concise filesystem operations and scripting the combination of existing functionality in filters and command line tools via pipes.

When your needs are greater - whether in functionality, robustness, performance, efficiency etc - then you can move to a more full-featured language. They tend to offer some combination of:

  • type safety
  • more advanced containers
  • better control over variable lifetimes and memory usage
  • threading
  • advanced IPC like shared memory and TCP/IP
  • full binary I/O capabilities, memory mapped file access etc.
  • access to OS APIs and myriad powerful libraries
  • better readability and maintainability as the project size increases
  • support for more advanced programming paradigms: Object Orientation, Functional Programming, Generative Programming etc.
  • better error-checking before your program starts running, hence less dependent on test case coverage

Upvotes: 13

Related Questions