DEV Community

Cover image for Is C still worth learning?
Mustafif
Mustafif

Posted on

Is C still worth learning?

Let's clear this myth, Rust is not replacing C, and C is not going away anytime soon.

But you may ask, how come? It's because C is still crucial to this day. For example, the Linux kernel is almost entirely made in C; yes, there's talk of Rust as the second language but keep in mind that it's more towards device drivers and such, not core components.
No one will rewrite a million lines of code of the Linux Kernel is Rust or Go; that's unreasonable and unnecessary.

I'm not going to act like a C expert, but as I read up on this debate, I've come to understand that a C programmer thinks C; they don't see some of the faults as issues but as a regular task. For example, I love how Rust manages memory with ownership and automatically implements the Drop trait to free values when no longer used, but as I am using C to implement a byte-code compiler, freeing and allocating memory is an exciting topic.

C isn't for everyone, but that's true for every language. Many people enjoy programming in Python, but I can't seem to get into it because its syntax is too "simple" for me. I prefer a C-style syntax just because of its familiarity.

Another debate is jobs, and I do understand Python is a scorching topic in the market, but you have to understand this title is if C is worth learning, and it is considering many languages stem from it, and having a great understanding of C can make learning other languages easier.

I'm in no way trying to force anyone to learn C, it's ultimately your decision (I love it), but if you're considering it, I say go for it!

Top comments (14)

Collapse
 
thumbone profile image
Bernd Wechner

I'd go one further and suggest "learning" C is a bit of an overstatement IMHO. I mean it's not wrong, we learn anything new, but learning isn't learning ... just as oils ain't oils. C is so simple, that learning it is a doddle. It's just one small step above Assembly in that it's a processor independent abstraction.

You can read Kernighan and Ritchie in a casual afternoon and voila, you know C.

Now whether you put it to use or not is another matter. I haven't written C in over 3 decades now, it's simply not a go-to language for the kind of work I've done in the interim, but it will likely always have a niche a very significant one, as it remains the go-to processor independent low level language (and so fro Arduino's for firmware of all sorts where performance and memory footprint are serious issues) because Assembly remains a PITA to write and maintain and not very portable.

Collapse
 
mustafif profile image
Mustafif

I definitely respect your opinion and I still remember when I tried learning assembly (for a day) and I regret giving myself a headache that day.

Collapse
 
thumbone profile image
Bernd Wechner

Yeah, not sure ASM has much use anymore. The main issue being its lack of portability and being one step too low for comfort offering no pertinent benefits over compiled C.

Collapse
 
pauljlucas profile image
Paul J. Lucas

There's a difference between reading K&R and knowing C just like there's a difference between knowing how all chess pieces move and being a Grand Master.

Collapse
 
thumbone profile image
Bernd Wechner

You confuse knowing with mastery. If you read K%R you know C. If you read a chess book, you know chess. If you practice either extensively you gain skill and eventually with enough practice under your belt you become a grand master.

You take valid words but somehow produced a meaningless comment? Knowing and grand mastery are the same.

Thread Thread
 
pauljlucas profile image
Paul J. Lucas

Your original comment (especially with the inclusion of “viola”) comes off in the same sense as knowing how to ride a bicycle, so I submit that it was you who confused knowing with mastery.

Thread Thread
 
thumbone profile image
Bernd Wechner

You seem to got from bad to worse with your comparisons, Paul.

1) Nothing by reading of the original comment suggest mastery, simply knowledge. Voilà means nothing more than "see here" quite literally and is just an expression used to convey that in my language sphere. Perhaps in yours it means something else that I can't even begin to fathom, as I don't imagine how it might acquire some sense of "mastery" or notion of the superlative.

2) You cannot seriously be unaware of the completely inappropriate comparison between knowing of a simple consistent syntax and basic computing notions with the skill of riding a bicycle (which involved pretty much all the nervous system except the bit used learning C as well as the muscular, skeletal and balance systems (picked a bad example as I ride, and have taught people to ride, and it is learning C as dancing is to arithmetic, as walking is to sudoku, a completely unrelated thing not worthy of your or my or anyone's comparison).

I have never confused knowing with mastery my friend, and you seem hellbent on some mission to prove someone wrong (known as trollish behaviour on social media).

That said, the difference between knowing and mastering C is far, far less than the difference between being able to ice skate and mastering ice skating, for example. C is simply a very low level language with a rather constrained syntax and not a bad little introduction to basic computing as it covers most of the basic notions around storage, flow control and transformations.

It lost popularity in large commercial projects, in no small part because of its simplicity and it's freedoms. To clarify, when C was popular we all faced the endless problem of reinventing the same tedious wheels in standard problem solutions and over time libraries were shared, evolved and some became standard, the very trend that saw stuff like built into modern frameworks, so you can focus on writing the stuff that you need to write and not rewriting solutions to standard problems. And its freedoms, notably with memory management, became a burden of bug hiding magnitude. In a research centre I worked in once, I became the go to guy for C problems, people would walk into my office with a print in hand (on wide line tractor fed dot matrix) or ask me to look at their code in a line editor on a terminal because they could not work out that segmentation fault. That error itself was the keyword that permitted me to look them in the eye and say simply "pointers" and then we'd sit down and look at their pointers and eventually find the problem.

Knowing C is not hard. Coding it cleanly is an ongoing challenge for anyone, not least because of the extreme care needed around memory management which in most modern frameworks is silently managed in the background by a) hiding pointers as much as possible - heck in C# you have to literally declare a code block "unsafe" and b) running a garbage collector in the background (memory leaks being the bugbear of most complex C software).

C still has application, will likely always have it, for the self same reasons, because it is that one useful platform independent step above ASM and hence you can code something with complete control and within reason knowledge of the execution speed and efficiency of the result, while can it also compile (if you don't dip into too many libraries especially) very lean binaries and is most suited for firmware and areal time systems.

Anyhow, you will have to try a little harder if you wish to prove me wrong, not least because I don't mind one jot being wrong, relish it, it is the only way we learn and advance and I have been and am wrong often. But you will need to convince me of it first with a little more than specious comparisons to bicycle riding and chess and liberally different interpretations of words like "voilà".

You deserve better than that, I am sure. I know I do.

Not least, I wonder what the motivation is. I would much rather encourage so someone to read K&R and know the C story than discourage them, and would never confuse the knowing of C with mastery of good programming practices, not least with a language that indulges every coding vice known to man. The Obfuscated C contest continues to run, to this day. And it arose out of a sort of good humoured parody of the fact that you can write atrocious C code (the idea of the contest being to write functional code that looks atrocious).

Thread Thread
 
pauljlucas profile image
Paul J. Lucas

Voilà means nothing more than "see here" quite literally and is just an expression used to convey that in my language sphere.

My understanding of its definition is here, in particular the 3rd definition "... to suggest an appearance as if by magic." In the case at hand, the implication was that if one reads K&R, one magically knows C [because it's so trivial].

You cannot seriously be unaware of the completely inappropriate comparison between knowing of a simple consistent syntax and basic computing notions with the skill of riding a bicycle ...

My comparison with riding s bicycle was meant in the sense that either you know how to ride a bicycle or you don't. You can either balance and maintain upright or you can't. What one's body does unconsciously is irrelevant.

Thread Thread
 
thumbone profile image
Bernd Wechner

I think if you're hanging on notifications and racing to the defense citing 3rd run dictionary definitions, and defending poor comparisons then you're in a reflexive point making pose.

I suspect by now you have understood my intent with the expression. But to be clear:

Even with a magical view of "voila" the term holds water. There is something magical about how you can read a book and suddenly have knowledge at hand.

It is not entirely true that you can either ride a bicycle or not. While you can always draw a line to create a dichotomy, the vast majority if not all dichotomies are false by their nature, meaning reality knows nothing of the dichotomy, but has a blending transition. And so too with a skill like bicycle riding. Your line might be riding on flat clear pavement for a minute without falling over. And that would be a fair line to draw. And yet the subject (the rider) was managing it for 50 seconds just prior, 40 prior to the, 10 at some point, not for a roll of the wheel at some point earlier, and some point later they can ride over rougher ground, over a kerb and stay comfortable, up hills, downhills with control, do wheelies, and skid outs, and I can go on ... there is essentially a transition as the whole body acquires skill (the extended balance, nervous and muscular and skeletal systems) that goes from falling over shortly after mounting to doing aerial loop the loops. And again, having taught people to ride, and skate and chess and more I am very aware of these transitions and gradients and the arbitrary line you can draw at any point depending on the context to say they "can" do that or not. the same even applies to spoken languages, which unlike the terse vocab, syntax and grammar of C or ASM are replete with irregularities and idiom and rhetoric (I speak four and have taught one) and "Do you speak French?" means little to me ... why sure, I can hold a conversation, and yet I struggle to read a newspaper, and following a film is hard without subtitles etc. And at no point could I have read a thin book and felt "I now know French".

But of C, this is admirably possible. And yet, mastery is a different matter as it embraces a large context. For that you need now to know about compiling and linking for starters and then about many of the traps and mistakes programmers make in the field, of basic algorithms and approaches, and arguably even working in a team (as no sizeable project is ever coded entirely alone) etc. etc. At no point did I, would I confuse the two or claim you can master something so quickly and simply. But unlike riding a bicycle or chess or French with C there's a clear line where you know it.

Ironically, one of my languages is Esperanto, and it comes close to the same claim. Not quite, but close. Essentially you can learn the grammar and basic vocab of Esperanto in an afternoon and as long as you're content consulting a sheet of paper now and then and a small dictionary can hold a conversation that day ... and people regularly do, by simple virtue of a very terse syntax and grammar and (unlike French etc.) internal regularity guaranteed and agglutinative nature.

But I think we can let it rest and maybe agree, that reading K&R in an afternoon will give you a pretty good awareness of what C is and the ability to start writing code in C, but there's a fair bit more to learn to master programming let alone software engineering.

Collapse
 
oricohen profile image
OriCohen05

You are completely right, there's no any replacement, the language fundamentals will always be remembered and implemented.

 
pauljlucas profile image
Paul J. Lucas

You:

It is not worth learning today though.

Me:

That's highly dependent on what you want to work on. If you want to work on the Linux kernel and several other operating systems, the Python interpreter itself, the Apache web server, embedded systems, and lots of specialized stuff, you need to know C.

You:

Agreed. But a brand new developer is not going to work on the linux kernel anytime soon.

Due to saying "brand new developer," it sound like you mean "For a brand new developer, it's not worth learning C."

But for a long-time developer, especially one who wants to work on the aforementioned projects, you agreed with me. And now you emphatically say again:

There are better languages to learn today, and C isn't worth spending time on.

Which, again, implies ever, including for long-time developers who want to work on the aforementioned projects. I don't understand how you don't see that your statements are contradictory.

 
pauljlucas profile image
Paul J. Lucas • Edited

You wrote:

It is not worth learning today though.

Without further qualification, that means "It is not worth learning ever." If you meant "It is not worth learning initially" then I submit you should have said that.

Collapse
 
pauljlucas profile image
Paul J. Lucas

That's highly dependent on what you want to work on. If you want to work on the Linux kernel and several other operating systems, the Python interpreter itself, the Apache web server, embedded systems, and lots of specialized stuff, you need to know C. Plus you really don't understand how lots of stuff works on a fundamental level unless you know C.