Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Im just starting to get into shell scripting and it's fun, but I hear a lot of people say that shell scripting is not programming. So im wondering how different is programming compared to shell scripting? The main thing I want to know though is, is there a plethora of commands you have to memorize like in Linux? I accumulated (learned) I feel a nice set of Linux commands, but it took me awhile to do so and really understand them and their options. Will that process repeat for leaning something like Ruby/Python or Lua? Thanks in advance!
Programming is structured syntax like scripting but the technically the difference is that a Programming language uses a compiler whereas a scripting language uses an interpreter. But as there are languages that can use both... it's kinda murky. Thus I'd say the difference is do you end out with a script (human-readable file that is interpreted when called) or a program (binary file that can be executed directly).
Generally speaking scripts are usually easier to write/maintain/use but as they are interpreted each time, are more CPU intensive and can give slightly less consistency (as an interpreter on one machine may not give the same results as the interpreter on another.). I'd switch to a program when getting over 1~2K lines of coding, personally.
Last edited by r3sistance; 05-16-2017 at 12:32 PM.
Programming is structured syntax like scripting but the technically the difference is that a Programming language uses a compiler whereas a scripting language uses an interpreter. But as there are languages that can use both... it's kinda murky. Thus I'd say the difference is do you end out with a script (human-readable file that is interpreted when called) or a program (binary file that can be executed directly).
Generally speaking scripts are usually easier to write/maintain/use but as they are interpreted each time, are more CPU intensive and can give slightly less consistency (as an interpreter on one machine may not give the same results as the interpreter on another.). I'd switch to a program when getting over 1~2K lines of coding, personally.
Understood, the interpreter being the shell and the compiler being gcc (for C and C++).. But the main point I need to know is do programming languages have commands or just a very rich syntax? (if that makes sense?)
Last edited by justmy2cents; 05-16-2017 at 12:36 PM.
programming means something like that:
you have a goal what you want to reach and you instruct your computer to do that.
There are difficult goals and simple goals. And also there are different languages to implement your wish(es) and logic.
I hear a lot of people say that shell scripting is not programming.
The distinction between these is rather fuzzy. Programming in Ruby, Python, or Lua is often called scripting too. I would say scripting is programming.
Quote:
So im wondering how different is programming compared to shell scripting? The main thing I want to know though is, is there a plethora of commands you have to memorize like in Linux? I accumulated (learned) I feel a nice set of Linux commands, but it took me awhile to do so and really understand them and their options. Will that process repeat for leaning something like Ruby/Python or Lua? Thanks in advance!
Languages usually come with "standard libraries", a set of functions. The standard libraries of Lua or C are small enough to feasibly learn entirely, but for Ruby and Python they're generally too big to memorize. You just look things up as needed.
Actually, I would make a different distinction with regards to Bash shell scripting, and it has to do with the sophistication of the language being used. Bash's scripting engine really wasn't designed to be used for all of the purposes that it is used for. Other programming languages are designed for serious work – whether they are interpreted or compiled.
You can add a one-line "shebang" line as the first line of your script ... say #!/usr/bin/env php, and write the rest of your script in PHP. You can do the selfsame thing for many different scripting languages and do the same thing. Bash will load the specified command-interpreter to run your script. The end-user will never know.
Personally, I cringe when I have to dissect "a wad of bash-scripting" and sometimes I have found it more expedient just to replace the damned thing using a far more powerful language.
As implied, it very much depends on what level of code you are going to be using.
High level languages tend to be relatively easy to learn because they are closer to everyday language.
Low level languages like Assembler and perhaps C are vastly different and take a very special mind set to use correctly and efficiently.
High level is:
Type a "x"!
Low level is:
Think about typing an X
turn your eyes to look at the keyboard. Scan it for the leter that looks like X
fix its locaction in your brain.
work out what movement is needed to put a finger on it
decide which finger to use
.
.
The distinction between these is rather fuzzy. Programming in Ruby, Python, or Lua is often called scripting too. I would say scripting is programming.
Languages usually come with "standard libraries", a set of functions. The standard libraries of Lua or C are small enough to feasibly learn entirely, but for Ruby and Python they're generally too big to memorize. You just look things up as needed.
Thanks for the clarification.. So I just need to memorize the libraries and functions for the relatively simple languages like Lua.. And I take it the reason why Ruby has so many frameworks is because it's big, so that makes sense.. Thanks!
Actually, I would make a different distinction with regards to Bash shell scripting, and it has to do with the sophistication of the language being used. Bash's scripting engine really wasn't designed to be used for all of the purposes that it is used for. Other programming languages are designed for serious work – whether they are interpreted or compiled.
You can add a one-line "shebang" line as the first line of your script ... say #!/usr/bin/env php, and write the rest of your script in PHP. You can do the selfsame thing for many different scripting languages and do the same thing. Bash will load the specified command-interpreter to run your script. The end-user will never know.
Personally, I cringe when I have to dissect "a wad of bash-scripting" and sometimes I have found it more expedient just to replace the damned thing using a far more powerful language.
That's cool and yeah I hear that a lot as well, that once you know Python then there's no reason to shell script. I just want to learn still for the admin type job roles, and to understand what the pre-built shells scripts on my system are doing..
As implied, it very much depends on what level of code you are going to be using.
High level languages tend to be relatively easy to learn because they are closer to everyday language.
Low level languages like Assembler and perhaps C are vastly different and take a very special mind set to use correctly and efficiently.
High level is:
Type a "x"!
Low level is:
Think about typing an X
turn your eyes to look at the keyboard. Scan it for the leter that looks like X
fix its locaction in your brain.
work out what movement is needed to put a finger on it
decide which finger to use
.
.
..
and so on. And even that is high level coding.
Haha thats interesting, I never put 2+2 together to understand why people say C or C++ is hard to learn, but now I get it
Last edited by justmy2cents; 05-17-2017 at 12:23 PM.
Im just starting to get into shell scripting and it's fun, but I hear a lot of people say that shell scripting is not programming. So im wondering how different is programming compared to shell scripting? The main thing I want to know though is, is there a plethora of commands you have to memorize like in Linux? I accumulated (learned) I feel a nice set of Linux commands, but it took me awhile to do so and really understand them and their options. Will that process repeat for leaning something like Ruby/Python or Lua? Thanks in advance!
BASH Scripting is scripting
Java Scripting is scripting
they are not programming languages. They are scripting languages.
But they will carry over into a programming language or visa versa. The logic that is. Because everyone has conditionals, loops, boolean logic operators (for the most part) bit shifting etc...
it is like learning any language. You will just need to learn how to speak it for that programming language you want to learn. Then when you go to another one the meaning is the same just said differently.
Code:
if [ condiston = true ]
then
do something
fi
if ( true )
do something
if ( true ) {
do something
}
do{
}while ( true )
while (true) do
so forth and so on. The logic is the same, and it all acts on truth.
That is a good question. I liken shell scripts to the OLDE days of writing .bat or .sys files in Windows OS (think 3.1 and '95). To me, a script is a single line (or several lines) that performs a function and does not require any compiling. Programming, on the other hand, involves running the source code through a compiler and linker to get a binary output called an executable. The 'executable' is a stand alone (doesn't need any extra items to run - you simply call its name and the program runs).
Back in the day, when BASIC was the 'go to' (no pun intended - sorry..) for programming, it was simply run via an interpreter (no compiling needed). The machine parsed each section of code for accuracy and correctness. To me - scripts are kind of like that.
BASH Scripting is scripting
Java Scripting is scripting
they are not programming languages. They are scripting languages.
But they will carry over into a programming language or visa versa. The logic that is. Because everyone has conditionals, loops, boolean logic operators (for the most part) bit shifting etc...
it is like learning any language. You will just need to learn how to speak it for that programming language you want to learn. Then when you go to another one the meaning is the same just said differently.
They all share the same core concept which is relief, I was just nervous on how many "commands" they may have and how many I'm expected to know, in order to "know that language". I remember Larry Wall (the author of Perl) said that a programmer should know at least 5 languages, and I was wondering how achievable is that.. Then again I remember someone saying that learning a programming language is just like learning any natural language..
Last edited by justmy2cents; 05-16-2017 at 02:19 PM.
They all share the same core concept which is relief, I was just nervous on how many "commands" they may have and how many I'm expected to know, in order to know that language. I remember Larry Wall (the author of Perl) said that a programmer should know at least 5 languages, and I was wondering how achievable is that.. Then again I remember someone said learning a programming language is just like learning any natural language..
that is his option, and what do they say about options?
learn one really well, then you can move to a different one. But that is just (my) an option.
as far as remembering all of the function calls you will be using - you will learn them as you learn - some you will remember some you may not remember, but that is what the api docs and books are for.
Well yes you did a little, but that is only because BASIC is a poor example because it is both interpretative AND often compiled - but that is probably true of most interpreted programming languages.
I suspect a (only slightly) better way of distinguishing them is that a script is often written by the user for his specific requirements whereas a program is pre-written and is more generic. I would also say that scripts are written to control programs.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.