Segmentation Fault ENGAGE!!
C is the mother of all languages, most programming languages nowadays are built around C, even the base of Linux, more specifically the Unix OS, is centered on C, this translated means that because I’m a computer science student, now focusing on Artificial Intelligence, I have to learn C right from the start. Without a choice, I saw myself learning this strange and complex language right on the first semester of my course, and now I’m going to share my journey and how I embraced the SEGMENTATION FAULT error.
“Unlike most computer languages, C allows the programmer to write directly to memory. Key constructs in C such as structs, pointers and arrays are designed to structure, and manipulate memory in an efficient, machine-independent fashion.”
― Wiki Books,
My First Steps
I started to learn from scratch, so I began by reading books and with some help of youtube videos I quickly saw myself displaying my “Hello World” message.This streak continued for I while, I was learning very quickly the basics of conditions and functions, which are equal to most programming languages. However, I soon after started learning how to use pointers and Memory story(which are the main concepts in C) and it was like getting hit by a truck, I couldn’t work it out, it seemed to be impossible to realize how it would all work. In addition, during this period I was assigned to build a PC game, called DOTS, the main principle is to unity DOTS to achieve certain objectives set by the PC, depending on the level of difficulty.
By this time, I could only work with not much more than simple functions, so it would really take a lot for me to build an actual game, so I felt a bit frustrated and nervous.
My first Game
I worked really hard and tried to imagine every time, how I would handle the storage in every line/function, although it took me a lot of time, it really let me understand the basic concepts of how C operates.
In about 2 weeks, I wrote my first game, and it looked something like this:
Even though it was not a lot, I was so proud of myself, I thought I finally completely learned C, until my teacher gave all of the students, when they were finished, the task of running Valgrind(a tool that shows the memory storage errors in a certain programs), and I had about 50 memory leaks, which in short terms means that my program might not work on my teacher’s PC if it has a different memory setup/layout.
After a lot of thinking, I decided to use an ancient tactic, which was to close my laptop and just hope it works out fine. To my surprise, it actually worked out, and I was just slightly discounted.
When SEGMENTATION FAULTS really entered my life!
However, I was shortly assigned with a Data Science work that involved organizing 1 to 2 million lines of various types of information hidden in less than 5 seconds. So I couldn’t waste any time, I learned all about sorting algorithms and how to optimize them and ended up just using a version of MergeSort, which in that time was really hard to do for me.
It was around this time where I got really in contact with C programmers best friends: Segmentation Fault Error, Stack Overflow, and Memory leaks. Every programmer gets frustrated with these errors, especially in this language because most functions are memory connected, making it really hard to discover the error, due to the fact that it simply displays an error in every single function.
However, when I finally got the hang of it, I started to get it right at first time, and it meant the world to me, because I could really understand the concept, in fact I had to understand what the computer did and how it processes information, and I could watch it work as I planned out.
In conclusion, now that I learned a lot of other languages I can seriously tell you that C helped me a lot in understanding and starting to use other languages, not only the fact that most of them are similar in some aspects to C , I could imagine how every function worked out in memory and storage aspects, which really helps in data Science. Moreover, even though it has a few years, it is still considered by many a future language and one that is never going to be unused. For example, HackerRank has ranked C very high up on the most used languages in 2018.
In addition, C really helped me learning C++ which is considered one of the hardest languages and one of the most In-Demand languages in today’s world as we see above.
My advice is that at some point you should learn C, maybe after you learn an easier language first like Python because C really helps you improve your programming capabilities and there will always be a marked for C/C++ programmers in the future.