DEV Community

Cover image for Learning C as a first language
Swastik Baranwal
Swastik Baranwal

Posted on • Updated on

Learning C as a first language

Has anyone learned C as their language as people usually don't recommend learning it as your first language because it's hard because of pointers, address, DMA, no OOP, no abstractions etc.

But I do really recommend learning C as your first language. Most will think that it's traditional, no one goes door to door these days, C is really old etc.
It can be though of assembly of first century.

Learning C has it's own advantages like:

  • You will understand how a computer works
  • C is the lingua franca of programming.
  • You will write better programs.
  • You will find it much easier to learn other programming languages.

I learned C when I was making my own Pokemon game with disassembly and decomps and really it helped a lot in understanding everything. Somethings were hard for me but I didn't lose hope and understood all of them. Then I tried to see other languages like Python, C++ and all. I found them very easy to understand and got well-versed.

Finding learning resources for C are really hard to know in depth. I found many of them and learned from there.

Learn C
Tutorials Point

Programming-Language 2nd by Brian Kernighan
Understanding Using Pointers Techniques Management
C Programming Modern Approach 2nd Edition

Awesome Repos:

TODO: Add more links

Top comments (18)

kovacivo profile image
Ivo Kovac

I fully agree with your opinion on learning C language as first programming language. I started first with Pascal and then got to C language (well, my very first language was actually BASIC, but it was when I was 9 years old).

lucastrvsn profile image
Lucas Trevisan

I learned C as my first language at college and don't regret it. Everything you do in C is from scratch and this is really good for long term knowledge.

localhost4484 profile image

I think the same as you. The C was hard for me as well (especially pointer concepts), people around me always tell me why still learn a traditional language, why don't go javascript, even more, start learning program by tools or frameworks.

dayvster profile image
Dayvster 🌊

My first language was C++, however the way to learning C++ is by learning C firs. Especially back when i was young and all we had were dry boring manuals which guided you through variables, arrays, if statements etc and finally to structs and classes.

Would I recommend people take the same approach as I did? No.
Everyone learns differently and not everyone has the same end goal in mind.

Not everyone will respond to it the same either, some might like this path and others might hate it so much that they instead completely change careers.

ahferroin7 profile image
Austin S. Hemmelgarn

A couple of nit picks:

because it's hard because of pointers, address, DMA, no OOP, no abstractions etc

Pointers are only hard if you're not paying attention and didn't have them explained properly. If you properly explain the concept of indirection first (which most people will have no issue understanding, as the concept is baked into most natural languages), pointers will often come naturally as a logical extension when explained.

DMA is not a thing in most C coding unless you're doing OS-level code (like Linux kernel code) or tight embedded stuff that doesn't involve an OS. In fact, I've done a decent (not huge) amount of work in C and never touched DMA at all. It's more an assembly thing in many cases anyway.

OOP and abstractions are absolutely possible in C, that's part of what pointers (especially function pointers) and structs are for (your object is a struct, your methods are function pointers, and you use a constructor method just like you would in many languages). Check the Linux kernel source code if you don't believe me, they're more object-oriented in some places than a lot of C++ code I've seen.

delta456 profile image
Swastik Baranwal

I agree with you. I meant that the standard library does not provide with abstraction like modern languages give. You can even in OOP in ASM as well if you see it that way.

mxrcochxvez profile image
Marco Chavez • Edited

I mostly agree with this. OP does have some opinionated arguments. But I feel as though C is a programming fundamental language like Python. At some point no matter what kind of developer you are you will have to interact with some C/C++ level issues. Another thing that is good to learn from C is the top down approach, because in JavaScript there is hoisting so the top down approach isn't always enforced regardless of the fact that certain things don't hoist.

lilithkarapetyan profile image
Lilit Karapetyan

I strongly agree that at some point, it's necessary to understand how things work, and C is perfect for that. However, in my opinion, the introduction to Computer Science should start with basic coding and introduction to Programming. By basic coding, I mean learning the basic concepts such as loops, variables, functions, etc. Students first need to understand what they are doing before knowing how everything works under the hood. I think that languages with simpler syntax may be better as the first language. After understanding what programs are and how they work at higher levels, it's time to dive in deeper and explore how everything works using C.

thojest profile image
thojest • Edited

Hmm instead Rust? Learn a low-level language which is very modern and also offers many abstractions you would expect from a modern language. At the same time, performant, memorysafe and a great active community.

delta456 profile image
Swastik Baranwal

That is a nice idea for sure but what I have seen beginners doing while finding the length of array in Rust and C is you can just do arr.len() as it is a method but in C they will get confused on how to do it because they are used to in-built functions. You have to do sizeof(arr)/sizeof(arr[0]) in C. I think it is necessary to know how it's done in the inner workings.

juancarlospaco profile image
Juan Carlos

C is just the base for everything, almost everything has C API.
If you add Nim that allows to interoperate with JavaScript,
you have C, C++ and JavaScript at your finger tips with 1 code base.

murrayvarey profile image

The problem with C as a first language is that it's difficult to build something useful early on. You're left doing low-level exercises, rather than creating an application that can help your folks or impress your mates. I imagine this can be off-putting. Beginners might be left wondering: "Is this what programming is all about?"

Don't get me wrong, C is a fantastic language to learn. And for some people starting out, it might be exactly what they're after. For others, not so much.

One other thing: C can be a nightmare to google, purely because of its name. I remember pulling my hair out at that when I was learning.

lautarolobo profile image
Lautaro Lobo

In my University, at CS, they teach first functional with Haskell, one semester, then 3 semesters to understand fully C. I agree with you, but the only thing is that it makes it harder for you to learn functional programming, because you'll get used to imperative. Knowing that, C is a really good lang to start with CS.

connellpaxton profile image

It is a great language that pops up all over the place, it teaches good fundamentals, to be cautious and not to waste resources. Its a great first language and I would and have recommended it

amrable profile image
Amr Fahmy Hassan

I agree with you specially that if you learn a relatively low level language, it will make learning other languages easier.