My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more
Why I am addicted to C

Why I am addicted to C

Todd's photo
Todd
·May 19, 2018

I was reading an amazing post by Sai Kishore Komanduri which was a response to a question about imperative vs. declarative programming styles when a question that I had been yearning to answer for a long time was finally answered.

Although I originally learned to program at ages 11 and 12, as an adult, when I returned to programming, all of these much higher-level languages like Python, JavaScript, Java, and C# were mainstream. Although I know all of those languages, something inside of me has always driven me to C programming and even x86 assembly.

But why? Why is it that when I say the phrase "C programming language" or "assembly language," most developers cringe, their eyes grow big, or they otherwise have a negative reaction when I am essentially obsessed with these languages... Obsessed to the point that I program in them every single night before bed and on my weekends as a form of... relaxation?

Why is it when I program in many higher level languages, I simply just don't enjoy it as much? Why is it that it was more difficult for me to learn and use SQL than it was to learn and use x86 assembly language? It is actually harder for my mind to reason about "objects" and "passing a function to a function" than it is for me to reason about "placing a struct on the heap and grabbing a pointer to it" and "passing a function pointer to another function" or "passing the address of the first instruction of a function as an argument to another function."

This is actually true by the way... I've learned to cope with it because when I see objects and high level constructions in another language such as decorators, first-class functions, and closures in Python or JavaScript, I would ordinarily be extremely confused. However, when I think of them in terms of C function pointers, I instantly understand and the problem resolves itself. Even still, I have never been keen on abstractions and what I end up doing is double-clicking that abstraction and trying to view the implementation details. If they aren't public, then I open it up in a decompiler or disassembler. I will not stop until I know how the implementation details many times.

Why is it that I open up an editor and I try to write a C program which defies standards and conventions on purpose, in order to learn more about the syntax, compiler, and try to break it or learn a new hack? Many times I've posted the most obscure questions in the world online and answerers will give me an answer, but not before they say "Why are you even doing this??? This is insane" and things like that.

I really began to feel "weird" or like an outcast... Well, the reality is, I AM weird, and I've grown to be ok with that.

But there's another reality that I discovered as well and it makes the entire thing clear. When I was a child, I was obsessed with how things work. I would come home from school and the other kids would watch TV, but I would get on my computer and go to howstuffworks.com and read... Read about airplane engines, locomotives, electricity, generators, nuclear bombs, nuclear reactors, etc... I then began to read books on electrical engineering, Tesla's work, etc...

Fast forward 20 years and today I'm doing Software Security Engineering and Malware Analysis which are largely revolved around reverse-engineering.... Learning how systems work! In order to discover bugs and exploit code, one must first have some degree of understanding of the system, or it at least helps greatly.

So, how does this relate to Sai Kishore Komanduri's post? Well, I realized that declarative programming disagrees with my brain because in it, you are simply telling the machine "I want XYZ and I don't care how I get it." This grinds my gears because my brain is obsessed with how we get it! I want to know how, I love to know how, and many times, I want to control exactly how something is done.

This is what separates C and even moreso, assembly language, from many other languages. You often hear of some specific functions being written in assembly directly due to "performance reasons." Well, the reality is, assembly just allows you to control fine-tuned details of an algorithm at the atomic level... I liken machine code and assembly to atomic physics of computer science because we are working at the fundamental level of what the computer is doing, similar to how atomic physicists are working with electrons, protons, neutrons, etc... It's a very tedious job but sometimes you get BIG THINGS out of it such as nuclear reactors, or in the case of stuxnet and many other malwares, a kernel driver exploit or an Advanced Persistant Threat.

house.jpg

However, to get a house built, you can't be concerned with the individual atoms of the wood and metal you are using to build the house, you must work at higher levels of abstraction, and this makes sense too. One of the things that I also discovered is that I initially loved experimenting with languages more than I even loved building production software using them... Well, what ended up happening is I realized that I could build production software which is used to experiment with languages, attack them, tear them apart, and break them... And thus I am driven more than ever not just to reverse-engineer, but to forward engineer tools used to reverse engineer other peoples' software... It's really a blissful situation!

Ultimately, I've learned the lesson that many other programmers learn which is that each language is simply a tool and has its strengths and weaknesses. There are certainly times when I would much rather use Python, JavaScript, or a bash script to get something done because it makes the most sense so this isn't about forcing a problem to be solved by a language...

But everyone is allowed to have their favorites ;)

I hope you enjoyed this article. Would be interesting to hear other people's experiences with this and other viewpoints.