Exploring the C Language
Here's a simple Python code for print bunch of stuff
print('Hello World')
print('Answer', 42)
print('Name', 'Sarah')
print('x',3.5,'i',100)
Here's the C code for the same thing
#include <stdio.h>
int main() {
printf("Hello world\n");
printf("Answer %d\n", 42);
printf("Name %s\n", "Sarah");
printf("x %.1f i %d\n", 3.5, 100);
}
Trying to learn some C
So, I have recently started to learn C programming language, and before you get impressed let me tell you its a passing interest that I am perusing because I am bored.
My stupid life
So, I was in this graduation course in college and there was this optional computers program that they pushed for with every student.
I had always been interested in computers, mostly for video games. But the programming that they taught us there was just so boring, we just copy and typed wherever was in the text book and forgot about it.
I feel like I should blame the teachers for not teaching us properly, but I know it wasn't the teachers fault this time and we (me and my friends) were idiots that didn't took interest in coding.
I don't even remember what language they tried to teach us, was it C or C++ or both, who knows? At least not me.
Now, here I am years later trying to learn C when AI can do all the coding in the world.
Why?
Why you may ask? I am not going to get any benefit from learning it, heck I might leave it incomplete or even if I do complete the course I might never be good at it other then some basic codes.
I did learn Python some time ago which is a much more easier language, I didn't complete that course either but I know some basics of the programming language and can do some small tasks for fun.
I am not using it in my job to make things easier simply because I can't, I don't have that level of expertise in Python.
I am a Noob.
But it is fun
Sometimes writing simple codes can be fun and it can break monotony of daily life so that's why I thing learning to code is not a professional endeavor for me but just an activity to distract myself.
Code above
Coming back to thee code codes in the top of the article:
It illustrates how much more easier Python is from C
Even though Python is made and written in C code, Python gives a lot of ease of usage.
Speed
Many people point out even if Python is easier it is slow and C is much faster, but modern machines are so fast does it really matter!
If you are doing so crazy renderings or scientific computations then yeah maybe, but for just enthusiast purpose it seems well suited even if it is slow then we can wait.
However...
Another advantage of C over Python is (and this might not be a advantage for real programmers) that since it is written with so much details you tend to make less mistakes.
For someone who might write code for fun (read nerd) finding cause of error in Python can be challenging as things are written too simple and what might be breaking the code is just hard to understand sometimes.
Now... I am not saying that you don't get errors in C but what I mean is that you have such tight control over every small bit of the task that it is much more easier to see what might be breaking the code.
Look at the two codes above
In the C code, you have to write what 42 is going to be when you print it, you have to write what "Sarah" is going to be and where, with greater level of control.
C code can still drive you mad, same as any code.
And every language has its advantages and disadvantages, that's why different languages are used for different purposes.
Coding and programing is completely an alien language to me. Good luck on your graduation course and I hope to see you succeed