Interesting tutorial

Programming languages, Coding, executables, and scripting.
Message
Author
cuckooflew
Posts: 681
Joined: 2018-05-10 19:34
Location: Some where out west

Interesting tutorial

#1 Post by cuckooflew »

Was digging around in some of my grandfathers old files, and I found a link to this tutorial, and am enjoying it , so decided to share it Probably others may have seen it before, but for those that have not:
https://www.cs.miami.edu/home/schulz/CSC322.pdf
Please Read What we expect you have already Done
Search Engines know a lot, and
"If God had wanted computers to work all the time, He wouldn't have invented RESET buttons"
and
Just say NO to help vampires!

No_windows
Posts: 505
Joined: 2015-08-05 03:03

Re: Interesting tutorial

#2 Post by No_windows »

This is a first for me..... a person showing off a grandparents computer artifact as opposed to something found in the physical world (shelf, tool box, or desk). This further illustrates something I've been thinking about lately... that time marches on.

cuckooflew
Posts: 681
Joined: 2018-05-10 19:34
Location: Some where out west

Re: Interesting tutorial

#3 Post by cuckooflew »

Yea, and things change, I suppose it is a form of evolution in some ways, maybe this should go into "offtopic", seems that the topic took a quick left turn now, and is not really programming. My grand father also used to often talk about the days when they did not even have Television yet,and how fast things started changing when computers and other technology started becoming a reality, rather then just science fiction.... But think a little more on this one:
computer artefact (my spell checker said artifact was wrong, but says both spellings are correctas opposed to something found in the physical world (shelf, tool box, or desk).
Is a computer not physical,? And is it not as much part of the physical world, including the desk that his computer is on, the shelf above the computer, and the tool box that is outside in the storage shed,...something to think about.
Please Read What we expect you have already Done
Search Engines know a lot, and
"If God had wanted computers to work all the time, He wouldn't have invented RESET buttons"
and
Just say NO to help vampires!

User avatar
None1975
Posts: 1019
Joined: 2015-11-29 18:23
Location: Lithuania, Vilnius

Re: Interesting tutorial

#4 Post by None1975 »

Thank you for the link. Very valuable. I read it with pleasure.
OS: Debian 10.3 Buster / WM: xmonad
Debian Wiki | DontBreakDebian, My config files on github

LE_746F6D617A7A69
Posts: 517
Joined: 2020-05-03 14:16

Re: Interesting tutorial

#5 Post by LE_746F6D617A7A69 »

I must admit that this tutorial is just great :)
–Recent LINUX kernel: 2.4 million LOC (1.4 million for driver, 0.4 millionarchitecture-dependent stuff (16 ports)
–Windows 2000: Estimates range from 29 million to 65 million LOC, supportsjust 1.5 architecures
...so many years have passed, and nothing have changed in this aspect... :lol:
You don’t have to grow a beard
to become a world-class UNIX hacker. . .
. . . but it does seem to help!
Linus is not a nice guy... - probably because he didn't grow a beard... (EDIT: You have to see that pdf page to understand :) )

This should be printed with big gold letters:
In assignments (and in live) use comments wisely
–Do explain important ideas, like i.e. what a function or program does
–Do explain clever tricks (if needed)
–Do not repeat things obvious from the program code anyways
...and this is no longer true:
By intention, int is the fastest datatype available on any given C implementation
Not only because now we have amd64, MMX, SSE, AVX, but also because new CPUs have efficient instruction pipelines and clever caching algorithms, so in most cases there's no difference in performance between char (int8_t), int16_t and int32_t. On Intel CPUs (starting from Haswell?) in some cases operations performed on the int8_t are almost 2x faster than on int32_t.

Anyway, I would buy a beer for Mr Schulz If I would met him ;)
Bill Gates: "(...) In my case, I went to the garbage cans at the Computer Science Center and I fished out listings of their operating system."
The_full_story and Nothing_have_changed

No_windows
Posts: 505
Joined: 2015-08-05 03:03

Re: Interesting tutorial

#6 Post by No_windows »

cuckooflew wrote: Is a computer not physical,? And is it not as much part of the physical world, including the desk that his computer is on, the shelf above the computer, and the tool box that is outside in the storage shed,...something to think about.
You didn't share the physical computer, desk, or shelf. You shared the 1's and 0's on the hard drive, which are not part of the physical world. Surely you recognize the difference between the physical and the digital? I pointed that out since I took it to be a bit of a milestone, or change in the way of the world.

arzgi
Posts: 800
Joined: 2008-02-21 17:03
Location: Finland
Been thanked: 4 times

Re: Interesting tutorial

#7 Post by arzgi »

LE_746F6D617A7A69 wrote: Linus is not a nice guy... -
Linus started at anger management course, I think it was last year.

Have not heard, if he completed it, but at least it has not been in the news that he would have been kicked out. :mrgreen:

cuckooflew
Posts: 681
Joined: 2018-05-10 19:34
Location: Some where out west

Re: Interesting tutorial

#8 Post by cuckooflew »

Ahh, Ok, well I see I all ready started this topic, but then dropped it,...back to the tutorial, I love it, it is simple, and a great start , so here is the first lesson:
ffrom: https://www.cs.miami.edu/home/schulz/CSC322.pdf
A First C ProgramConsider the following C program

Code: Select all

#include <stdio.h>
#include <stdlib.h>
int main(void)
{
printf("Hello World!\n");
return EXITSUCCESS;
}
Assume that it is stored in a file calledhello.cin the current working directory.
Then:
$gcc -o hello hello.c(Note: Compiles without warning or error)
$./hello
Hello World 
You should have some tools installed, before trying it :
https://packages.debian.org/buster/build-essential
Actually I think that will have all you need, if more are needed, maybe some one can tell us.

Code: Select all

parrot$ ./hello
HELLO WORLD
parrot$   
Please Read What we expect you have already Done
Search Engines know a lot, and
"If God had wanted computers to work all the time, He wouldn't have invented RESET buttons"
and
Just say NO to help vampires!

trinidad
Posts: 190
Joined: 2016-08-04 14:58
Been thanked: 2 times

Re: Interesting tutorial

#9 Post by trinidad »

You didn't share the physical computer, desk, or shelf. You shared the 1's and 0's on the hard drive, which are not part of the physical world. Surely you recognize the difference between the physical and the digital? I pointed that out since I took it to be a bit of a milestone, or change in the way of the world.
Your idea is representative of the kind of categorical dualism that permeates the human meta-narrative. Everything in the cosmos (universe) is cosmic (physical). Arguing for differentiation like the one you are making is one of the reasons people have difficulty thinking clearly. The cosmos is a monism and thinking about that deeply will help clear your head. Suggested reading: Donald Davidson.

TC
You can't believe your eyes if your imagination is out of focus.

LE_746F6D617A7A69
Posts: 517
Joined: 2020-05-03 14:16

Re: Interesting tutorial

#10 Post by LE_746F6D617A7A69 »

Isn't that monism just a higher abstraction layer for dualism? I mean something like HAL (Hardware Abstraction Layer)? :mrgreen:
Bill Gates: "(...) In my case, I went to the garbage cans at the Computer Science Center and I fished out listings of their operating system."
The_full_story and Nothing_have_changed

User avatar
Head_on_a_Stick
Posts: 13450
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: Interesting tutorial

#11 Post by Head_on_a_Stick »

trinidad wrote:Everything in the cosmos (universe) is cosmic (physical).
What about dark energy? That accounts for ~70% of the observable universe and it's not physical at all. And don't get me started on dreams :mrgreen:
Black Lives Matter

Debian buster-backports ISO image: for new hardware support

trinidad
Posts: 190
Joined: 2016-08-04 14:58
Been thanked: 2 times

Re: Interesting tutorial

#12 Post by trinidad »

What about dark energy? That accounts for ~70% of the observable universe and it's not physical at all. And don't get me started on dreams
Mental differentiation and distinction is physical as well, just yet to have a completely defined nature, and human mentality may never be adequately defined, but that doesn't mean it is unlikely to be something physical. The opposite is true. What humans most often define as not physical is more than likely to be physical. It can be argued that humans cannot be aware of anything that is not physical given that they are a physical something that is a situation of thinking intrinsic to what seems to be an ordered physical universe.

TC
You can't believe your eyes if your imagination is out of focus.

cuckooflew
Posts: 681
Joined: 2018-05-10 19:34
Location: Some where out west

Re: Interesting tutorial

#13 Post by cuckooflew »

I can see this is going to really be a interesting tutorial indeed.
... Here is the first home work assignment, actually for the "teachers" , and yes I am serious, but it is for fun, as well. Any way, can anyone give a simple example that requires input, and then gives out put, to add to the "hello world", EG:
We now, know how to get output, using: the printf command,

Code: Select all

printf("Hello World!\n"); 
And we want to add, a request for input, "please enter your name",
then a response, more output, "hello <name> welcome ", please hit enter to exit,
the enter key then closes it with a "thank you ".
Please Read What we expect you have already Done
Search Engines know a lot, and
"If God had wanted computers to work all the time, He wouldn't have invented RESET buttons"
and
Just say NO to help vampires!

User avatar
Head_on_a_Stick
Posts: 13450
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: Interesting tutorial

#14 Post by Head_on_a_Stick »

trinidad wrote:It can be argued that humans cannot be aware of anything that is not physical given that they are a physical something that is a situation of thinking intrinsic to what seems to be an ordered physical universe
Well the evidence for the existence of dark energy is derived from the observed expansion rates of the universe (as measured from type Ia supernovae) so non-physical entities can be detected indirectly.

Anyway this is all rather off-topic so we should probably stop :)

EDIT: s/matter/energy/
Black Lives Matter

Debian buster-backports ISO image: for new hardware support

User avatar
Head_on_a_Stick
Posts: 13450
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: Interesting tutorial

#15 Post by Head_on_a_Stick »

cuckooflew wrote:We now, know how to get output, using: the printf command,

Code: Select all

printf("Hello World!\n"); 
And we want to add, a request for input, "please enter your name",
then a response, more output, "hello <name> welcome ", please hit enter to exit,
the enter key then closes it with a "thank you ".
How about

Code: Select all

#!/bin/sh
echo 'Please enter your name'
IFS= read -r reply
echo "Hello $reply, welcome. Please hit enter to exit."
while true; do
   IFS= read -r key
   case "$key" in
      "") echo 'Thank you'
         exit 0
         ;;
      *) echo 'Please hit enter to exit...'
         ;;
   esac
done
Black Lives Matter

Debian buster-backports ISO image: for new hardware support

cuckooflew
Posts: 681
Joined: 2018-05-10 19:34
Location: Some where out west

Re: Interesting tutorial

#16 Post by cuckooflew »

That is a good one, for bash script, I was hoping for C (edited, I meant to say C) , but I did not specify that, so yes that is one way to do it,... I still have not tried search anything yet, I am sure there something in some tutorial,... but I need to take a nap just now..my medicine makes me sleepy.
Last edited by cuckooflew on 2020-08-16 18:57, edited 1 time in total.
Please Read What we expect you have already Done
Search Engines know a lot, and
"If God had wanted computers to work all the time, He wouldn't have invented RESET buttons"
and
Just say NO to help vampires!

User avatar
Head_on_a_Stick
Posts: 13450
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: Interesting tutorial

#17 Post by Head_on_a_Stick »

cuckooflew wrote:That is a good one, for bash script
Thanks but I don't like bash. POSIX sh ftw!
cuckooflew wrote:I was hoping for C++
Don't bother with C++, it's rubbish: http://harmful.cat-v.org/software/c++/

Plain C is better. Perhaps also look at Go or Rust. I can't use either though, unfortunately :(
Black Lives Matter

Debian buster-backports ISO image: for new hardware support

cuckooflew
Posts: 681
Joined: 2018-05-10 19:34
Location: Some where out west

Re: Interesting tutorial

#18 Post by cuckooflew »

Thanks
Found one, and it is C , not C++: (I meant C, don't know why I said c++ )

Code: Select all

#include <stdio.h>

int main(void) 
{
    char name[20];
    printf("Hello. What's your name?\n");
    //scanf("%s", &name);  - deprecated
    fgets(name,20,stdin);
    printf("Hi there, %s", name);
    return 0;
} 

Code: Select all

parrot$ ./name             
Hello. What's your name?
cuckoo
Hi there, cuckoo
parrot$  
Please Read What we expect you have already Done
Search Engines know a lot, and
"If God had wanted computers to work all the time, He wouldn't have invented RESET buttons"
and
Just say NO to help vampires!

LE_746F6D617A7A69
Posts: 517
Joined: 2020-05-03 14:16

Re: Interesting tutorial

#19 Post by LE_746F6D617A7A69 »

Head_on_a_Stick wrote:
cuckooflew wrote:That is a good one, for bash script
Thanks but I don't like bash. POSIX sh ftw!
Bash has a POSIX mode too - but I don't like it - it's better to live on the edge :mrgreen:
Head_on_a_Stick wrote:Don't bother with C++, it's rubbish: http://harmful.cat-v.org/software/c++/
Oh no! C++XX is just as modern as Java - it allows the programmer to focus on the problem, instead on the code...

...but hmm, aren't the programmers expected to write a code?
Bill Gates: "(...) In my case, I went to the garbage cans at the Computer Science Center and I fished out listings of their operating system."
The_full_story and Nothing_have_changed

cuckooflew
Posts: 681
Joined: 2018-05-10 19:34
Location: Some where out west

Re: Interesting tutorial

#20 Post by cuckooflew »

Head_on_a_Stick wrote:
cuckooflew wrote:That is a good one, for bash script
Thanks but I don't like bash. POSIX sh ftw!
cuckooflew wrote:I was hoping for C++
Don't bother with C++, it's rubbish: http://harmful.cat-v.org/software/c++/

Plain C is better. Perhaps also look at Go or Rust. I can't use either though, unfortunately :(
Your right, I just did not notice:

Code: Select all

#!/bin/sh 
With shell scripts I don't use the

Code: Select all

#!/bin/sh 
Is that bad, ? I just use this part EG:

Code: Select all

echo 'Please enter your name'
IFS= read -r reply
echo "Hello $reply, welcome. Please hit enter to exit."
while true; do
   IFS= read -r key
   case "$key" in
      "") echo 'Thank you'
         exit 0
         ;;
      *) echo 'Please hit enter to exit...'
         ;;
   esac
done 
Please Read What we expect you have already Done
Search Engines know a lot, and
"If God had wanted computers to work all the time, He wouldn't have invented RESET buttons"
and
Just say NO to help vampires!

Post Reply