Linux - Newbie This 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
|
|
05-16-2017, 05:12 PM
|
#16
|
LQ Guru
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,352
|
Quote:
Originally Posted by justmy2cents
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!
|
When you learn your first programming language you have to learn a lot of things that are applicable to any programming language. The things that you learn include absolute logical thinking, modular logic, providing code for every possible case, creating error correction routines and failsafe code, documenting programs, handling different type of input/output, and so on. If you learn a second language you will have to learn the new language's commands, syntax, and logic flow but there is a whole lot of carry over in the areas I described from the first language to the second language. You will learn the second language much faster than you learned the first language.
The one exception to this rule is when you learn your first assembly language. As dave@burn-it.co.uk described assembly is so much further from human thinking than a high level language that it just takes a long time to learn to solve problems the assembly way.
--------------------------
Steve Stites
Last edited by jailbait; 05-16-2017 at 06:05 PM.
|
|
|
05-16-2017, 06:45 PM
|
#17
|
LQ Guru
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
|
To put in my 2c, I consider scripting to be programming, it's just a certain subset of programming.
One definition on the interwebs states that programming is "The process of developing and implementing various sets of instructions to enable a computer to do a certain task."
So, programming is a very generic term, ranging from the use of assembly language, through low-level and high-level languages (compiled, interpreted and the many, sometimes exotic, mixtures of the two), to educational graphical systems such as Scratch.
Last edited by hydrurga; 05-16-2017 at 06:46 PM.
|
|
1 members found this post helpful.
|
05-16-2017, 09:29 PM
|
#18
|
Member
Registered: Jan 2017
Location: Manhattan, NYC NY
Distribution: Mac OS X, iOS, Solaris
Posts: 508
Rep:
|
Pascal is the historical teaching language, but nowadays I think many people just go straight to C.
|
|
|
05-16-2017, 10:15 PM
|
#19
|
Member
Registered: Oct 2002
Posts: 569
Rep:
|
Quote:
Originally Posted by hydrurga
To put in my 2c, I consider scripting to be programming, it's just a certain subset of programming.
One definition on the interwebs states that programming is "The process of developing and implementing various sets of instructions to enable a computer to do a certain task."
So, programming is a very generic term, ranging from the use of assembly language, through low-level and high-level languages (compiled, interpreted and the many, sometimes exotic, mixtures of the two), to educational graphical systems such as Scratch.
|
I agree with this completely. Guess that makes it 4c.
|
|
|
05-17-2017, 01:17 AM
|
#20
|
LQ Guru
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524
|
If you want to learn programming it's best to learn the overall purpose of object-oriented programming. Practically every language nowadays is oo. Every component of the program is an object. Objects have properties, events and methods.
Objects can use one of three ways, or any combination, to accomplish their function: sequence, selection and/or iteration. Usually, for programming, you want to use an IDE, because the IDE lays out the libraries and their objects, and tells you which properties, events and/or methods each object does.
Libraries are collections of objects you can use so everyone doesn't have to write the same code over and over. I learned programming formally, and I just don't think it's possible to program well without at least some formal instruction.
|
|
|
05-17-2017, 02:03 AM
|
#21
|
LQ Guru
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,861
|
There have been several references here to the number of commands you need to know. I think this is an important point. Programming languages like C have very few commands, mostly flow of control stuff like "while" or "if". Everything else is your own creation. You write functions in this limited language set, and they become commands for the main program to use. It's more about creativity and logic than learning.
In shell scripts, every command that the system recognises is available to you. The script is simply a cord tying them together. When people talk about learning bash, what they are actually learning is bash plus unix utilities.
|
|
1 members found this post helpful.
|
05-17-2017, 07:50 AM
|
#22
|
LQ Guru
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,820
|
Quote:
Originally Posted by Laserbeak
Pascal is the historical teaching language, but nowadays I think many people just go straight to C.
|
Even "Bash scripting" is, technically speaking, "programming." (It's just that the language sucks. )
Today, I think that most programmers routinely use scripting languages, because they are efficient. They resort to "C" only to do low-level stuff, which they access from the scripting language. Some programmers use Java, or Flash, both of which are compiled to an intermediate representation. (Python actually does the same thing, "on the fly.")
Some programming languages are non-procedural, such as Prolog. (If you're itching to solve Rubik's Cube, or a logic puzzle, or a Sudoku puzzle, and you don't know how to write a procedure to do that ... Prolog – especially gprolog – is your friend.)
Last edited by sundialsvcs; 05-17-2017 at 07:52 AM.
|
|
|
05-17-2017, 10:26 AM
|
#23
|
Senior Member
Registered: Mar 2004
Location: UK
Distribution: CentOS 6/7
Posts: 1,375
|
This is why I prefer the term "coding" over "scripting" or "programming" because they are confused terms with blurred lines between them.
One thing I would note that I forgot earlier is that BASH does error handling very different to most Scripting/Programming languages. Bash will often not terminate or die on failure whereas most programming and scripting languages will die on error if there is not specific error handling in place
Code:
# cat fail.sh
#!/bin/bash
echo "works" > /tmp/works.txt
echo "does not work" > /doesnotexist/doesnotwork.txt
echo "still executes"
rm -f /tmp/works.txt
# sh fail.sh
fail.sh: line 3: /doesnotexist/doesnotwork.txt: No such file or directory
still executes
Most languages would terminate or die on trying to write to "/doesnotexist/doesnotwork.txt" but BASH continues on to the next line, a piece of behavior to be aware of. Naturally if error handling is in place (you should try to handle your own errors), then the program would continue. Depending on the language, what stops is different, in a fully multi-threaded OOP language, then it maybe only the individual thread or function that fails.
Last edited by r3sistance; 05-17-2017 at 10:29 AM.
|
|
|
05-17-2017, 11:28 AM
|
#24
|
LQ Veteran
Registered: May 2008
Posts: 7,001
|
Quote:
Originally Posted by justmy2cents
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.
|
To be frank, I think that's mostly just language snobbery at work. Much like the derision that BASIC tended to get from some quarters in the past. If you're having fun, then good on you, just ignore the nay-sayers.
Whether something gets called a script or program seems mostly down to common convention and little more than that: - sed, awk, expect, shell, perl, python: script
- BASIC, Pascal, C, C++, Java, etc: program.
If you try and come up with some sort of hard criteria for a distinction you'll just find yourself with lots of exceptions to the rule, so best not to even try. Just have fun coding and don't worry about it.
|
|
1 members found this post helpful.
|
05-17-2017, 11:40 AM
|
#25
|
Member
Registered: May 2017
Location: U.S.
Distribution: Un*x
Posts: 237
Original Poster
Rep:
|
@Jailbait
Quote:
You will learn the second language much faster than you learned the first language.
|
That's good to know and I hear that even more so true when learning C languages like C, ++ and C+ as their all similar..
Quote:
The one exception to this rule is when you learn your first assembly language. As dave@burn-it.co.uk described assembly is so much further from human thinking than a high level language that it just takes a long time to learn to solve problems the assembly way.
|
I think that's why people use a mixture of Assembly and C, because the C makes it more feasible (or something)
|
|
|
05-17-2017, 11:43 AM
|
#26
|
Member
Registered: May 2017
Location: U.S.
Distribution: Un*x
Posts: 237
Original Poster
Rep:
|
Quote:
Originally Posted by hydrurga
To put in my 2c, I consider scripting to be programming, it's just a certain subset of programming.
One definition on the interwebs states that programming is "The process of developing and implementing various sets of instructions to enable a computer to do a certain task."
So, programming is a very generic term, ranging from the use of assembly language, through low-level and high-level languages (compiled, interpreted and the many, sometimes exotic, mixtures of the two), to educational graphical systems such as Scratch.
|
From what I now understand I think technically it is so too, but I think maybe people who program for a living don't feel the same way
|
|
|
05-17-2017, 11:46 AM
|
#27
|
Member
Registered: May 2017
Location: U.S.
Distribution: Un*x
Posts: 237
Original Poster
Rep:
|
Quote:
Originally Posted by AwesomeMachine
If you want to learn programming it's best to learn the overall purpose of object-oriented programming. Practically every language nowadays is oo. Every component of the program is an object. Objects have properties, events and methods.
Objects can use one of three ways, or any combination, to accomplish their function: sequence, selection and/or iteration. Usually, for programming, you want to use an IDE, because the IDE lays out the libraries and their objects, and tells you which properties, events and/or methods each object does.
Libraries are collections of objects you can use so everyone doesn't have to write the same code over and over. I learned programming formally, and I just don't think it's possible to program well without at least some formal instruction.
|
I was aware of OO languages like C but not gotten into depth of what that means (sounds kinda obvious though), so thank you that's a good explanation, and it helped me understand better. I plan to use emacs for IDE and leave vim for remote administration.. Also programming for Nurses sounds cool..
Last edited by justmy2cents; 05-17-2017 at 11:48 AM.
|
|
|
05-17-2017, 11:50 AM
|
#28
|
Member
Registered: May 2017
Location: U.S.
Distribution: Un*x
Posts: 237
Original Poster
Rep:
|
Quote:
Originally Posted by hazel
There have been several references here to the number of commands you need to know. I think this is an important point. Programming languages like C have very few commands, mostly flow of control stuff like "while" or "if". Everything else is your own creation. You write functions in this limited language set, and they become commands for the main program to use. It's more about creativity and logic than learning.
In shell scripts, every command that the system recognises is available to you. The script is simply a cord tying them together. When people talk about learning bash, what they are actually learning is bash plus unix utilities.
|
Thank you for further clarification of the topic!
Last edited by justmy2cents; 05-17-2017 at 11:57 AM.
|
|
|
05-17-2017, 11:54 AM
|
#29
|
Member
Registered: May 2017
Location: U.S.
Distribution: Un*x
Posts: 237
Original Poster
Rep:
|
Quote:
Originally Posted by sundialsvcs
Even "Bash scripting" is, technically speaking, "programming." (It's just that the language sucks. )
Today, I think that most programmers routinely use scripting languages, because they are efficient. They resort to "C" only to do low-level stuff, which they access from the scripting language. Some programmers use Java, or Flash, both of which are compiled to an intermediate representation. (Python actually does the same thing, "on the fly.")
Some programming languages are non-procedural, such as Prolog. (If you're itching to solve Rubik's Cube, or a logic puzzle, or a Sudoku puzzle, and you don't know how to write a procedure to do that ... Prolog – especially gprolog – is your friend.)
|
Ill keep that in mind about Prolog, and I wasn't aware that java and python can be used for similar use cases so thanks for bringing that to my attention..
|
|
|
05-17-2017, 12:06 PM
|
#30
|
Member
Registered: May 2017
Location: U.S.
Distribution: Un*x
Posts: 237
Original Poster
Rep:
|
Quote:
Originally Posted by r3sistance
This is why I prefer the term "coding" over "scripting" or "programming" because they are confused terms with blurred lines between them.
One thing I would note that I forgot earlier is that BASH does error handling very different to most Scripting/Programming languages. Bash will often not terminate or die on failure whereas most programming and scripting languages will die on error if there is not specific error handling in place
Code:
# cat fail.sh
#!/bin/bash
echo "works" > /tmp/works.txt
echo "does not work" > /doesnotexist/doesnotwork.txt
echo "still executes"
rm -f /tmp/works.txt
# sh fail.sh
fail.sh: line 3: /doesnotexist/doesnotwork.txt: No such file or directory
still executes
Most languages would terminate or die on trying to write to "/doesnotexist/doesnotwork.txt" but BASH continues on to the next line, a piece of behavior to be aware of. Naturally if error handling is in place (you should try to handle your own errors), then the program would continue. Depending on the language, what stops is different, in a fully multi-threaded OOP language, then it maybe only the individual thread or function that fails.
|
I know RMS doesn't prefer the term coder but actually, so idk.. Yeah though you right I do need ECCs in place for my current script im working on.. Wouldn't Rust make dealing with failing threads easier (im somewhat interested in Rust)..
|
|
|
All times are GMT -5. The time now is 08:52 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|