LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   What is programming like? (https://www.linuxquestions.org/questions/linux-newbie-8/what-is-programming-like-4175606057/)

justmy2cents 05-16-2017 11:24 AM

What is programming like?
 
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!

r3sistance 05-16-2017 11:29 AM

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.

justmy2cents 05-16-2017 11:35 AM

Quote:

Originally Posted by r3sistance (Post 5711470)
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?)

pan64 05-16-2017 12:07 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.

ntubski 05-16-2017 12:10 PM

Quote:

Originally Posted by justmy2cents (Post 5711465)
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.

sundialsvcs 05-16-2017 12:23 PM

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.

dave@burn-it.co.uk 05-16-2017 12:38 PM

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.

justmy2cents 05-16-2017 12:40 PM

Quote:

Originally Posted by ntubski (Post 5711485)
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!

justmy2cents 05-16-2017 12:44 PM

Quote:

Originally Posted by sundialsvcs (Post 5711494)
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..

justmy2cents 05-16-2017 12:48 PM

Quote:

Originally Posted by dave@burn-it.co.uk (Post 5711504)
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

BW-userx 05-16-2017 12:54 PM

Quote:

Originally Posted by justmy2cents (Post 5711465)
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.

uber_nerd 05-16-2017 01:06 PM

what is programming like?
 
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.

Hope I didn't muddy the waters too much.

UN

justmy2cents 05-16-2017 01:15 PM

Quote:

Originally Posted by BW-userx (Post 5711514)
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..

BW-userx 05-16-2017 01:18 PM

Quote:

Originally Posted by justmy2cents (Post 5711533)
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.

dave@burn-it.co.uk 05-16-2017 01:27 PM

Quote:

so forth and so on
Pun intended??

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.


All times are GMT -5. The time now is 10:55 PM.