HERE is what i do hate the most about "coding"...

Status
Not open for further replies.
C

CrazedNerd

Guest
Just a "blowing off steam" post. Don't take it too seriously, I am just like everyone else in a lot of ways.



So, in order to create a list of instructions, you need to first create a list of instructions or find the right information for yourself to put your concept into action. Nobody actually talks in programming languages. There's no such thing as "coding": it's all "de-coding". In other words, creating complicated programs is totally in-efficient. It is fun to watch yourself make things happen (to me it's very exciting at times), but I still don't see how it benefits end users. Maybe im just not meant to do this.
 
Last edited by a moderator:


What are you trying to do. I know many programming languages; including ones I don't like.
 
I don't have any problems with coding because I don't do any.
m1203.gif
 
Oh, well the biggest issue: part of me believes that just doing one instruction at a time in life is really the way to go...rather than creating a list of them for a computer to do...

I personally wanted to make a hobby and profession out of this, the latter very slowly. But sometimes i doubt if its the ideal thing for me to do.

There's not much more to this thread than that, i could get to sleep the previous night, that was the issue.
 
What are you trying to do. I know many programming languages; including ones I don't like.
Here on Linux.org, @CrazedNerd made several posts about learning both bash shell scripting and the C programming language. He posted some of his scripts and code.

The programming language I disliked the most was an obscure scripting language that Microsoft created for network device driver installers on Windows NT 3.51 and later. To the best of my knowledge, it was the only use for it. I wish I could remember the name of that awful scripting language.

I could easily come up with a list of secondary candidates for "worst programming language." I liked some of them when they were in popular use, and could make them sing and dance as well as anyone. The state of the art evolved considerably during my career. Language features that I consider essential today were not yet invented or considered important back then, so those languages might go on my "worst" list. I know that BASIC has added all kinds of modern features, but the BASIC I learned and used could easily go on someone's "worst programming language" list. It was easy to learn bad habits back then, and much harder to unlearn them later.
 
Here on Linux.org, @CrazedNerd made several posts about learning both bash shell scripting and the C programming language. He posted some of his scripts and code
Just adding to this, i probably understand bash well enough to do server admin, even though i dont know much about that itself. I am pretty new to C, and i guess ive been impatient about wanting to take ideas and turn them into programs.

Ive also recently (as in, basically past two days) had issues with life in general, and this thread came out of that.
 
Last edited by a moderator:
Just adding to this, i probably understand bash well enough to do server admin, even though i dont know much about that itself. I am pretty new to C, and i guess ive been impatient about wanting to take ideas and turn them into programs.

Ive also recently (as in, basically past two days) with life in general, and this thread came out of that.
Sorry to hear about your personal challenges. We all have 'em.

Programming is like learning a musical instrument. Acquiring sufficient skill to play pieces that people actually want to listen to can take a lot of learning, practice, and time.
 
Right, but what are you trying to do with C? bash I can surmise.

@sphen yup, I was programming around that time but didn't do any driver coding. Did a fair bit of assembly language though. Loved it :)
 
Right, but what are you trying to do with C? bash I can surmise.
Fair question: to me the only thing that matters is something practical and fun. "Security" should always be built into the project beyond exploits, and the money isn't always a problem. WELL i guess the latter sounds callous when you factor in inflation, but why would i want to charge money when most of the software i use is "free".

I think you need to submit more information to the CrazedNerd loop before it can spit out an answer:D
 
Find something that you do over and over, then automate it.
That's definitly a great approach for any type of command line scripting.

Im thinking its probably better for me to base my whole approach on appealing books, because that definetly worked for bash. Ive found my weakness is to judge the quality the book, but doing that makes the whole process to frustrating and complicated. I personally don't think any of the binary oriented languages are great for beginners to try to master, even java absolutely requires objects.

So im fine with this topic being closed if no one wants to talk about learning approach that are fast and mostly devoid of distracting/unusable nonsense.
 
I would suggest picking a language and trying a Udemy course. They have beginner to expert on lots of topics. Cheap too if you wait for the sales.
 
I would suggest picking a language and trying a Udemy course. They have beginner to expert on lots of topics. Cheap too if you wait for the sales.
A lot of the problem mentioned in the post was just related to physical problems of deciding not to use my main computing chair (it's a recliner...), but now i back in the chair and it's all therapuetic and fun again.

Yeah, C and bash (bash obviously first of course) for linux only users who want to take on harder programming projects. As a programming, you do end up learning at least 5 languages over your life, if you count some of the bash commands as separate languages (like grep, sed, awk) then I already know too much ;). But you have to take one at a time, or else it just gets all messed up and confusing. You can't make a 3D video game on day one, sometimes my musings and fantasies get the best of me.

Python is a really good language too, and it works symbiotically with bash and machine languages, i already don't like java at my current knowledge level.

You can read the scripting thread in the command line forum for all the different scripts i made, this C program is kinda neat, i only added the part where it tells you which of the random numbers it chose the most frequently, i took the rest from a book:

Code:
include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define SIZE 10

//shows how to do a counter for random numbers
int main ()
{
    srand(time(NULL));

    int frequency[SIZE] = {0};

    for (int count = 1; count <= 1000000000; ++count)
    {
        //+1 to change the bottom value
        size_t number = rand() % 10;
        ++frequency[number];
    }

    
//frequency of numbess already stored in frequency[number]

    for (size_t number = 0; number < SIZE; ++number)
    {
        printf ("%zu%17d\n", number, frequency[number]);
    }

    for (size_t number = 0; number < SIZE; ++number)
    {
        if (frequency[number] >= frequency[0] && frequency[number] >= frequency[2] &&  frequency[number] >= frequency[3] &&
                 frequency[number] >= frequency[4] &&  frequency[number] >= frequency[5] && frequency[number] >= frequency[6] &&
                 frequency[number] >= frequency[7] &&  frequency[number] >= frequency[8] &&  frequency[number] >= frequency[9])
        {
            printf ("\n%zu was the highest occurring random number, at %i occurrences.\n", number, frequency[number]);
            return 0;
        }   
    }
}
 
For fun, try this out instead of your big compound && statement:

int high = 0; int element = 0; for (size_t number = 0; number < SIZE; ++number) { frequency[number] > high ? high = frequency[number], element = number : 666; // # of the beast } printf ("\n%zu was the highest occurring random number, at %i occurrences.\n", high, element); return 0;
 
For fun, try this out instead of your big compound && statement:

int high = 0; int element = 0; for (size_t number = 0; number < SIZE; ++number) { frequency[number] > high ? high = frequency[number], element = number : 666; // # of the beast } printf ("\n%zu was the highest occurring random number, at %i occurrences.\n", high, element); return 0;
Thanks for that, i knew that there was some alternative to my clunky looking code and ill try it later...
 
For fun, try this out instead of your big compound && statement:

int high = 0; int element = 0; for (size_t number = 0; number < SIZE; ++number) { frequency[number] > high ? high = frequency[number], element = number : 666; // # of the beast } printf ("\n%zu was the highest occurring random number, at %i occurrences.\n", high, element); return 0;
Lol, i just saw that # of the beast joke there, nice.

However, the compiler gives me a casting error, and after it's done running, the final output is reversed:
Code:
rand-stat.c: In function ‘main’:
rand-stat.c:48:22: warning: format ‘%zu’ expects argument of type ‘size_t’, but argument 2 has type ‘int’ [-Wformat=]
   48 |         printf ("\n%zu was the highest occurring random number, at %i occurrences.\n", high, element);
      |                    ~~^                                                                 ~~~~
      |                      |                                                                 |
      |                      long unsigned int                                                 int
      |                    %u
0        100000217
1         99991890
2         99968007
3        100005388
4        100002875
5        100007066
6         99994319
7        100006152
8        100024561
9         99999525

100024561 was the highest occurring random number, at 8 occurrences.

It's supposed to tell you which number was chosen most frequently by rand seeded with time. When i run it with my compound if statement, it does this:

Code:
0        100009617
1        100010714
2        100002862
3         99986132
4         99992494
5        100007862
6         99987226
7         99998849
8        100000229
9        100004015


0 was the highest occurring random number, at 100009617 occurrences.

The compound if statement is needed in order to compare each number with itself and the other ones. The program takes about 8 seconds to produce a billion random numbers, between 0 and 9, and put them into a table. And even though they're biased towards the lowest numbers of the range (between 0 and 4), the exact results are completely unpredictable and evenly distributed. I can't change the bias of srand, at least not yet.

However, this exchange was relaxing and therapeutic, and if you want to play with my source code earlier in the thread to something, then you can definitely PM me about it or post it here.
 
Yup I wouldn't write code like that but it made you think ;)

Some compiler setups won't use %zu so just use %d or %u or something. If you like doing this type of stuff maybe try learning some C sort methods (bubble, merge, quick, etc).
 
Yup I wouldn't write code like that but it made you think ;)

Some compiler setups won't use %zu so just use %d or %u or something. If you like doing this type of stuff maybe try learning some C sort methods (bubble, merge, quick, etc).
Yeah to me size_t is a wierd data type, however, it's good for manipulating things at the byte level in arrays.
 
Yeah to me size_t is a wierd data type, however, it's good for manipulating things at the byte level in arrays.
size_t isn’t anything weird at all, size_t is just a typedef for long unsigned int.
Defined like this in the C standard library:
C:
typedef long unsigned int size_t;
So size _t and long unsigned int are exactly the same thing. typedef is a keyword used to create an alias for another type.

Once you start using structures and unions, or arrays of structures/unions, you might find typedef useful to create aliases for your data structures, so you can refer to them as if they are a new type, rather than having to use "struct MyStruct foo;", you can simply use "MyStruct foo;"

size _t is used for indexing arrays (and is also used to index containers in the C++ std library).

The reason for the errors your were seeing is because you have a type mismatch.

In the call to printf, it’s expecting a long unsigned int (or size_t) as a parameter for the %zu placeholder, but you’re generating and passing printf a normal int (signed integer) value.

The fix is to change %zu to %d in your printf statement.
 
Status
Not open for further replies.

Members online


Latest posts

Top