Is shell script a programming language?

This is my first question in UNIX:

I started with shell scripts 2 days ago.

But I have a question: is a shell script a special programming language for a specific shell?

Asked By: MUE

||

If you know of any command, say, ls, you type it, and then hit return, the shell will know where that program (ls) is, invoke it, and show you the result. This is the “non-script” shell usage.

But, if you order a couple of such commands in a sequence, say A, B, C, D, and then put it (the sequence) in an executable file, you’ve got a program. The program has a name and location, so it can be referenced, and invoked; it has code, so it can be executed, one command at a time, by the CPU.

(The program is not compiled – like, for example, C source would have been – and this makes it a script. But it is a program nonetheless.)

That is, in some aspect, already at this point you are programming, because you are instructing the computer what to do.

Furthermore, you are, again at a very basic level, also using a programming language, because you can’t just type anything (and expect it to work); at the same time, whatever you type you’ll get activity from the computer that corresponds exactly to what you wrote.

There are rules how you should say things, and there are rules how the computer will react to those things.

That said, with “programming”, you typically associate somewhat more expressive power than just piling commands on top of each other. At the very least, you’d like branching (if ... then ... else), iteration (loops: while, for, etc.), and probably some other things as well. But that’s OK as the scripting languages have those things and more.

The shells have different languages, yes, but some may overlap to a great extent because of convention (why change a good way to say something?), or to be compatible with earlier versions (or some standard).

Answered By: Emanuel Berg

Bash is a scripting language:

From wikipedia:

A scripting language or script language is a programming language that
supports the writing of scripts, programs written for a
software environment that automate the execution of tasks which could
alternatively be executed one-by-one by a human operator. […]

The term script is typically reserved for small programs (up to a few thousand lines of code).

Scripts are typically quick and dirty. Say, a bash script to make your life easier. Whereas a ‘programming’ language is meant to be much more thought out and deliberate.The thing with ‘programming’ languages is that they are usually faster, and offer more control over low-level things if you want.

‘programming’ languages are typically used in scenarios where the code will be around for a long time. If you want to write something quickly and then never use it again, ‘scripting’ languages are what you want.

You can find an interesting article here.

Answered By: Marius Cotofana
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.