CLI or non-CLI language for unexperienced puppians?

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply

What will be more useful for an unexperienced puppian?

Mastering the command line interface?
5
100%
Learning a non-command line interface language?
0
No votes
 
Total votes: 5

Message
Author
Antipodal
Posts: 253
Joined: Thu 26 Mar 2009, 16:52
Location: The other side of the world

CLI or non-CLI language for unexperienced puppians?

#1 Post by Antipodal »

After reading several (if not many) threads in Murga’s forum I have concluded that most of the experienced puppians believe that for an average unexperienced one, learning how to master Puppy’s command line interface will be more useful than learning non-command line programming languages

Do you think that this deduction is right or wrong?
Have you any comments about the subject?
Posting from a P4 3Ghz_ASUS P5G41T-M LX3_2G RAM_DVD Write desktop with no internal HDD
Saving my stuff on flash sticks and in external USB HDD

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#2 Post by musher0 »

Hello antipodal.

i would say your hunch is right. I devoted many, many hours studying bash,
urxvt, some archiving utilities, and the gnu utilities generally, and I've never
regretted it.

Those are the basis of the GNU/Linux system. You can't go wrong reading
their man files and trying them out. They open you up to a lot of the
possibilities of the OS.

Best regards.

musher0
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
6502coder
Posts: 677
Joined: Mon 23 Mar 2009, 18:07
Location: Western United States

#3 Post by 6502coder »

I gather that by "command line interface" you mean shell programming (which for Puppies means Bash programming), and that by "non-command line programming" you mean languages like C, Java, Python, etc.

I would say that learning shell programming is far more useful for most people: it applies to a much broader range of tasks. Shell programming is mostly about tricks to simplify tedious chores of the kind that crop up all the time. Moreover, these tricks tend to be easily adapted to different contexts: once you have learned how to change "foo" to "bar" in every text file in a directory, it is not hard to figure out how to execute any other operation on every file (of whatever kind) in a directory.

Do not be intimidated by the thick manuals on bash programming sometimes mentioned in this forum. The fact is, you don't need to know 5% of what's in them. I was a professional UNIX/Linux software developer for over 25 years, and what I knew about shell programming would fit on 4 PDF pages. It's a handful of tricks, used in endless combinations. [Admittedly, when I say "shell programming" I mean the shell proper. I'm excluding the system commands like sort, sed, awk, uniq, etc. which I learned in depth.]

As for C, Java, etc., the average user certainly does not NEED to learn them. In fact, if you're not sure if you need to learn them, then you don't.

Antipodal
Posts: 253
Joined: Thu 26 Mar 2009, 16:52
Location: The other side of the world

Sincere thanks

#4 Post by Antipodal »

I sincerely thank those who have participated in this thread and / or its enclosed survey.

And to those who do so in the future, my thanks in advance

User avatar
corvus
Posts: 153
Joined: Fri 12 Jun 2015, 18:00
Location: In the peninsula shaped like a boot.

#5 Post by corvus »

6502coder wrote:I gather that by "command line interface" you mean shell programming (which for Puppies means Bash programming), and that by "non-command line programming" you mean languages like C, Java, Python, etc.
If this is what you mean to ask Antipodal I believe that understanding the bash scripting can contribute more significantly to the resolution of problems and managing a Linux system, not just Puppy, than to know a "non-command line programming language".

Regards

corvus
[b]We are waves of the same sea, leaves of the same tree, flowers of the same garden.[/b]

learnhow2code

Re: CLI or non-CLI language for unexperienced puppians?

#6 Post by learnhow2code »

Antipodal wrote:for an average unexperienced one, learning how to master Puppy’s command line interface will be more useful than learning non-command line programming languages

Do you think that this deduction is right or wrong?
i think this is partially right, and the other part i would like to debate. ive had numerous hobbies over the years, but the one ive had since i started using computers (before my first school assignment) is programming.

my handle is not a snide challenge, as people seem to interpret it sometimes. it is a gentle suggestion (handles really cant be long enough for subtlety at times) and an enthusiastic one. considering the enthusiasm about puppy over the years, you *really* cant blame me just for caring.

whether you use the language i designed in hopes of making it easier for you, or bash (or basic or javascript or python 2 or 3) i hope as many people will learn to code as possible.

why? because its the shortest route to understanding computers.

a little about my background:

* no formal computer education, except a high school class when id already used basic for about a decade
* learned basic before grade school classes
* self-taught basic, js, bash, python, logo
* tried (and can probably rate) over 30-40 basic dialects, including british bbc style, puppybasic (wxbasicscript) and dos/cartridge basic/gwbasic/basica/qbasic/fb/qb64

sometimes bash is easier (for some tasks) than python or basic.

sometimes basic is easier, especially for learning.

sometimes python is easier, especially for things that are utterly tedious in bash or basic...but it depends.

where i agree with the rest of this thread is that bash will probably offer the fastest results for someone trying to get their feet wet, but not really understand how the code works.

just want to try things? snippets of bash (shell) code are excellent. i didnt just design my language for potential shell coders, but to try to help windows users see something easier than python (and more useful than batch.)

but bash isnt always easy.

its case sensitive, full of punctuation (syntax) and archaic (though respectable and worthwhile) quirks that while worth keeping for compatibility, are not exactly friendly to everyone.

so while bash and python are provably easy enough for countless students, what about those who are looking for something easier?

there are many choices. as an experiment, i tried to make a language that was easier to teach to anyone:

* not case sensitive
* helps teach/create variables to avoid one of the features of python
* helps transition to bash or python (or basic.)
* avoids most punctuation (but allows a number of syntax features to help organize / layout code, or transition to bash or python or basic.)

i believe bash is too difficult (as a first language) for some, and you can reach more people with something that at least glues snippets together.

Code: Select all

cpu = "cat /proc/cpuinfo" arrshell
forin x cpu

    now "next field: " prints
    field = split x ":"    arrget field 1    print

    now "info: " prints
    info = split x ":"    plus " "    arrget info 2    print

    nextin
if you know bash, you might hate this, but id rather explain this to an absolute beginner than:

Code: Select all

cat /proc/cpuinfo |  awk -F ":" '{print "next field: " $1 "\ninfo: " $2}'

even though i do like one-liners, and would often choose the bash version. you may know the syntax for the bash one-liner, but if you havent practiced using awk, do you always think of:

* $ in front of the field, or
* the mix of single and double quotes, or
* how to change the field separator, or
* print a newline, or
* to add the squiggle brackets?

knowing the command line is useful, but sometimes hides the complexity of your own knowledge.

but i think i wrote a pretty good bash intro, which covers a lot of this stuff.


how about a function in bash, for bigger programs like a text adventure?

Code: Select all

function give_it_a_name {
    echo hello world
    } 

Code: Select all

function give_it_a_name
    e = "hello world"    print
    fig
(given that example, you will simply have to take my word for it.)


theres lots of fun quirks about bash i wouldnt want to teach to any beginner, but the truth is, there are fun quirks in any language.

the nice thing about bash is raw power, except when its slow or unflexible. some command line utilities are faster (try writing a faster grep in a scripting language, go on) and some pipelines are so slow that 4 lines of python will increase the speed by 800%.

heres a fun one: why doesnt this work?

Code: Select all

x = $(echo perhaps this should work, but it cant) ; echo $x
bash: x: command not found

Code: Select all

x = "echo perhaps this should work, and it does"    arrshell    join x "\n"    print
perhaps this should work, and it does

simplified version:

Code: Select all

x    "echo perhaps this should work, and it does"    arrshell    print
['perhaps this should work, and it does', '']


then again, if youre comfortable with bash (i spent more than half a decade learning bash, and i think i couldve learned fig faster than proficiency with bash or python, in less than a year) then it is very likely the only language you need to learn.

but there are people (including basic users) that will never learn bash, but you can sneak a little in using the shell command.

one of the main advantages of fig over bash?

only two mandatory punctuation symbols:

"strings in quotes"
# hashes for comments


for many people, python is the clear choice, but i think 3 is less friendly than 2 (im no huge fan of oop either.) and as long as you can do a task in bash easily enough, thats the thing to use.

personally, i like bash until i have to write for compatibility with things like busybox-- most of the scripts i do are compatible with both, but when theyre not-- fig will tie commands together nicely.

i realize python is HUGE while bash is... well, theres no busybox version of python. but that would be cool.

i know i will likely get mostly flak for this, but i tried to explain it. i dont think bash is always the best thing-- but it often is. thats why the most important fig program ive written related to puppy is 32.8% shell code. but its shell code when shell code is easier than the alternative. for the purpose in question, thats 32.8% of the time.

mcewanw
Posts: 3169
Joined: Thu 16 Aug 2007, 10:48
Contact:

#7 Post by mcewanw »

Shortest answer: if you have no desire to program anything, don't.

Second shortish answer: Unless you can write a computer application, however simple or complex it may be, that is useful to someone (which most importantly would be yourself), don't waste your precious time.

Long answer: Unix/Linux as we know it was written in C (C being basically designed for that purpose) and then shell command language was written in C to mimic the underlying C system call interface to the OS Unix. Becoming more and more experienced at using the shell is thus a great way to get a good feel for how Linux really works (pipes and redirection, what Linux means by stdin, stdout, stderr, tty devices, and so on). Unix, C and the shell are thus VERY closely related.

Summary answer: Don't bother learning any kind of major computer language, and certainly not something like Python or C itself and certainly not C++ (unless you are really planning to spend a long time becoming an application developer). However, because Linux management tasks can often be so easily accomplished using simple shell commands, it is really worth while to play around with that (without putting too much effort into it...). You don't need to become an expert at it at all - just simple tricks (like 6502coder mentioned), is what is most useful about it. And over time, you may be surprised how much shell language you have actually taken in, especially if you string a few simple tricks/commands together in a text file and learn how to make that executable - i.e. a shell script. Many people on this forum have picked up a lot of bash shell scripting tricks over the years, many probably who had no knowledge of shell commands at all to begin with. It becomes easy to add very simple gui's to these wee scripts using yad or gtkdialog, IF you want to and IF you get that far and would LIKE to try.

Note: Simple commandline 'tricks' often involves running simple utilities (like cut and sort) rather than just the shell command language 'bash'. That's how Unix/Linux was originally designed to be used. AWK, by the way, is a whole computer language in its own right but most only bother to learn a few tricks with awk (one-line snippets of code piped into from some underlying command utility) - which is enough most of the time.

Final answer: If you really like Linux and wish you could get more out of it, don't be afraid to practice with some simple shell commands and scripts using some of these many available utilities like date, cut, sort, cat, echo and so on. It is a real waste of most people's time to bother trying to learn some major programming language like Python or Qt/C++ programming, or whatever, unless you really want that as a hobby or plan making a career out of it... Bash + Utilities is a different matter - they are there on your system all the time, to be used as a convenience and enjoyed, but only if you want to. It is a lot of rubbish to ever say that everyone needs to learn how to program, otherwise - pointless exercise for most I'd say.

You only need to know a few simple bash commands to find it useful - you need to know TONS of Python to be able to do anything useful with it, so why bother is what you should ask yourself...

William
github mcewanw

learnhow2code

#8 Post by learnhow2code »

mcewanw wrote:You only need to know a few simple bash commands to find it useful - you need to know TONS of Python to be able to do anything useful with it, so why bother is what you should ask yourself...
you dont need to know tons of python to be able to do anything useful with it. pythons worst enemy is its experts, who always know the most complicated way to do something. (sometimes bash experts are worse-- but a lot of bashs "best practices" are to narrowly avoid a serious error.)

the bash commands really arent simple. oh some are-- and so is a lot of python. those simple commands can end up with you spending half an hour tweaking a single line when it doesnt work the same across bash and busybox-- this is my main gripe against bash (note: i use full bash every day. im not exactly hating on it.)

as i said, some bash commands/shell utils are really, really fast. grep is simply "optimized." find is indispensable. but its little things like '{}' \; (no that wont tie up all your processes, its the syntax for running commands on files listed by find) that make using bash less friendly.

trying to use bash for everything is probably more painful than learning a second tool. but if its your preference, you should go with the thing that works for you. i love bash, but i really get tired of fiddling with its many little perl-like syntax kludges. some of them are welcome, of course.

but as to using bash to make a tool using yad over some of the nonsense python uses for guis? yeah, im with you on that. python guis absolutely suck-- especially for most things youd want to do in a simple way. theres more than one reason why a lot of my code is shell code, even when im using another language to tie it together.

the main reason to use anything else over bash is because it creates another option. its too bad there arent more places where people can help you get everyday tasks done (a little at a time) in languages other than bash-- that would help a lot.

string-handling in bash is a mix of powerful tools and tedious kludges, both helped and hurt with regexes. bash doesnt let you create scoped functions or even return a value with the function call. and the array handling is awful-- which most of the time you can get around using newlines. its feels especially tedious if you know a reasonable alternative.

Sailor Enceladus
Posts: 1543
Joined: Mon 22 Feb 2016, 19:43

#9 Post by Sailor Enceladus »

I don't understand the question. You can make both CLI or GUI with any language? Where's the "Invalid Poll" option? :lol:

learnhow2code

#10 Post by learnhow2code »

Sailor Enceladus wrote:I don't understand the question. You can make both CLI or GUI with any language? Where's the "Invalid Poll" option? :lol:
the question is very poorly worded and not very well conceptualized, but its a usable thread. you can figure out what they mean from the rest of the thread. (if not, you can probably guess with reasonable accuracy-- otherwise id be happy to explain my own interpretation.)

Post Reply