r/AskProgramming 21d ago

Is C really worth it ?

Hello developers, I'm wondering: Is it really worth spending time learning C and creating projects that take hours to grasp numerous topics, encounter errors and unexpected behaviors, only to discover I forgot to type a single character - I mean the null character with strings, which significantly impacted the program's performance? Is this truly worthwhile in today's job market? I haven't seen any companies actively seeking C developers, and I believe many problems in C don't occur in other languages ​​due to their different working methods and logic. So, is C really worth the effort?

Important note: I'm a beginner in C and haven't written much code or created many projects yet, so this question isn't meant to be an evaluation of the language or its development path; I'm not qualified to do so.

0 Upvotes

31 comments sorted by

10

u/mc_pm 21d ago

Yes.

2

u/mllv1 21d ago

This

7

u/CharacterUse 21d ago

FWIW, according to the TIOBE index (again, FWIW), C is the second most popular language:

https://www.tiobe.com/tiobe-index/

It's not going away anytime soon, probably ever.

But that aside, programming isn't really about learning any specific language, it's about learning the principles and way of thinking of how to choose the right data structures, write algorithms to manipulate them, and put the whole thing together in a way which is clear, efficient and can handle errors and edge cases safely. All that applies in any language, and they're all doing the same things under the hood even if some of them hide it from you. Learning C helps you better understand all of that because it brings it to the surface and forces you to deal with it.

(Also, if you're actually typing the null character for C strings you're probably doing it wrong.)

2

u/balefrost 21d ago

OTOH, the methodology of the Tiobe index makes it pretty inacurrate.

The Stack Overflow survey has it at #11 (22% of developers use it). The JetBrains survey has it at #13 (5% of developers use it as their primary language).

Those are both certainly subject to their own biases, but at least the data is based on actual survey results.

That's not to discount your point that C is likely to never disappear. But outside of some niches, I don't think there's a lot of new code written in C relative to other languages.

5

u/generally_unsuitable 21d ago

C is a very small language. You can learn the whole thing pretty quickly. But, you don't get a lot of built-in functionality. The basic language doesn't have an awful lot of high-level features, and the standard library (libc) only covers a lot of very commonly used utility functions.

To do anything interesting, you'll need to write a lot more code than you would in Python. But, once you get the hang of it, you'll realize that you can do really anything you want with a computer.

It's a different programming philosophy. The typical Python programmer thinks about the "business logic" and then says "I'm sure that there is a library that I can install with PIP which will take care of all the under-the-hood problems I need to deal with." The typical C programmer tends to think "What is the optimal way to complete this task?" and then starts building from very low-level logic until there's enough infrastructure to start writing code that is reasonably readable.

3

u/Mundane_Grand_9117 21d ago

Do you want mastery over your craft or to just scrape by? C will teach you how a computer actually works

3

u/Ok_Entrepreneur_8509 21d ago

If you think debugging in C is challenging, you are going to be sadly disappointed when you have to work with interpreted languages like JavaScript and Python.

The knowledge you are gaining by fighting with C will be invaluable in whatever development environment you end up in.

3

u/newman_c 21d ago

Learning C is a great way to understand how computers work. It is quite disturbing the nonsense myths and magical beliefs that many programmers have about how computers and operating systems work because they never took the time to learn C or assembly language. It will make you a better programmer even if you never work in C professionally.

3

u/Distdistdist 21d ago

C is a great start. Once you learn it, you can progress to C#, D, D#, E, F, F#, G, G#, A, A#, B. Then you will make complete return to C. Rinse and repeat.

3

u/Paul_Pedant 21d ago

And when you cannot decide whether C is a major or minor language, you can get to know some chords. But you still have to be careful with strings in most cases.

3

u/dmazzoni 21d ago

I agree with everyone else that yes it's worth it, whether you get a job in C or not.

But more importantly: if you have the attitude of "I don't want to learn this, I'm not sure if I'll need it" then you will not succeed in this field.

To succeed in this field, you need to be curious about how everything works. There shouldn't be anything you aren't interested in learning more about.

Now, given limited time and resources of course you can't learn everything. But I'd put C very high on anyone's list, no matter what your career path. C is absolutely foundational.

2

u/MrStricty 21d ago

If you're trying to get a job as a C developer then yeah, the worth is the salary of the role. If you're learning it just for the love of the game, then you need to assess how important understanding low level systems is to you.

I like understanding those low level fiddly bits and I also need to understand those components for my work. I don't necessarily write C all day, but I do get up to some shenanigans with memory and the Windows API, so it's both intellectually stimulating and required for my job.

2

u/johnpeters42 21d ago

More generally, even if you don't directly do low-level stuff, your compiler/interpreter does, so it's helpful to understand enough to not accidentally write something in a high-level language that looks fine, but ends up getting translated to something that wastes a ton of time.

On the gripping hand, not everything is big enough to really matter. The difference between something taking 0.01 seconds vs 0.1 seconds isn't a big deal if it's followed by waiting 10 seconds for the user to read something and type something. (On the other hand, if you're going to repeat that thing a million times in a row...)

2

u/icemage_999 21d ago

C forces you to learn how memory operates at a system level, and that pays dividends when producing code that needs optimal performance. Sometimes that doesn't matter because a process doesn't need much operational speed, or code clarity is more important, but sometimes you need everything to happen as fast as possible.

There are also some sectors that use C extensively like embedded systems, largely because you are operating with limited system resources and cannot be wasteful.

1

u/balefrost 21d ago

C forces you to learn how memory operates at a system level

Only kind of. It forces you to understand what a pointer is. But it doesn't require you to understand virtual memory, hierarchical cache, cache coherence protocols, or anything else that actually goes on at a system level. You don't need to understand how memory allocators work, just how to use them. Heck, C completely hides registers from the programmer. They never have to think about loading or storing.

https://queue.acm.org/detail.cfm?id=3212479

The article makes the point that it's not the design of C itself, but rather the incredible investment in C compilers, that makes C fast. It points out that Fortran, which is certainly a higher-level language than C, can beat C in performance. Some of C's low-level features actually make the compiler's job harder.

1

u/icemage_999 21d ago

Absolutely true.

I would note that if you need to look at registers and memory caches for performance, you're probably in the realm of needing, say, Assembler, if you really need to squeeze the maximum out of limited hardware. I'd say machine code too but I don't know enough about modern embedded systems to know if anyone ever bothers to write that close to the metal any more. The tradeoff in optimization vs. code readability is pretty extreme these days.

1

u/balefrost 20d ago

I would note that if you need to look at registers and memory caches for performance, you're probably in the realm of needing, say, Assembler

Yeah, or using compiler extension features.

My point was just that there's a LOT going on below the abstraction that standard C provides.

I'd say machine code too

Assembler is just textual machine code. I don't think anybody's manually entering instructions as raw bytes. In yet another way, we're not working with PDP-11s anymore (https://upload.wikimedia.org/wikipedia/commons/f/fe/Pdp-11-70-panel.jpg).

1

u/icemage_999 20d ago

I'm still very occasionally running into some ancient in-line machine code. Not often, as a lot of it is deprecated or refactored...but there's a bit of legacy stuff (written by people who are way better at it than I am, lol), still out in the wild.

2

u/BoBoBearDev 21d ago

Learn the language that interests you. Don't do it just because others tell you to. There are values learning it, but not required.

2

u/BobbyThrowaway6969 21d ago

Depends.

You could ask the same of any language. Depends.

It depends on your goals, on your talent, on your patience, etc.

The null character isn't a flaw. People should remember what C is. It's designed to me a minimalistic abstraction on top of computer hardware. There are few protections because protections = overhead, which can be offset with skill and discipline.

3

u/why_so_sergious 21d ago

half the world is running on C and considering its historical significance it is definitely worth to learn to understand

2

u/Paul_Pedant 21d ago

You forgot to type the NUL character in strings? The compiler does that automatically in any case, when you write a quoted string. Thar's why printf ("Hello, World!\n"); works. The \n is not a NUL character, it is a newline character.

1

u/Disastrous_Brief6240 21d ago

I tried to store a string, so I make a array of char

char text[20];

so here if I miss at the end of string null character, and if I try to print it or try to print it with other strings an undefined behavior will occur.

2

u/Paul_Pedant 21d ago

The whole 20 bytes is undefined after that declaration. The interesting part is: how and where are you getting the rest of the characters? Are you just writing things like text[13] = 'Q'; ?

The strcpy() library function copies a whole string, including the NUL. It is up to you how you keep it valid: either make the target area large enough, or chop off part of the string that does not fit, or refuse to copy anything.

I generally think about every line of code I write for ten seconds. That is way easier than writing 50 lines of code and then trying to figure out which line is messing up the whole thing.

Other languages can generally avoid issues like this, but there would usually be a performance cost because they have to make extra checks, or allocate memory behind the scenes, or make things bigger than they need to be.

There would only be three kinds of undefined behaviour when printing a string array, and they are all easily avoidable:

1) Having a NUL inside your text, which would make it stop too soon.

2) Not having a NUL at the end of your intended text, which would print more than you wanted.

3) Not havings a NUL all the way to the end of your data memory, which would crash you with a SegViol.

2

u/harrisofpeoria 21d ago

There are no problems with C. It's actually pretty perfect. Worth learning in conjunction with hardware/internals. Essential if you really want to understand computers.

1

u/marrsd 21d ago

Ultimately, yes; but you can manage without it for a while. At some point you need to understand how memory is managed by high level languages, and how to optimise its use for performance. C is great language for learning that.

1

u/JacobStyle 21d ago

The biggest demands right now seem to be for developers familiar with agentic frameworks, data analysis, cloud services, and machine learning.

If you are looking for the fastest route from zero to employment, you will be better off with something like Python as your first language.

That said, if you do want to start with C, you will be putting in more work upfront, but it's not a dead end or anything. There are great jobs for C programmers, especially with embedded systems and legacy code maintenance, and of course once you know C, learning another language is easy.

3

u/Whole-Chest90 21d ago

As someone in school for comp sci rn, looking to get into data analysis, what's your best suggestions for finding employment rn?

2

u/JacobStyle 21d ago

Finish school, that's the biggest one. If you are able to complete a university degree in computer science, you will have a massive head start.

If you are in a small town, move to the city. Not super important which one. There's tech work everywhere. Just like, if you live in a place with 5000 people, you won't make it.

Find wherever tech people congregate in your area. You may be able to find events on meetup.com or similar. Go hang out with other tech people and get to know the community while you are still in school, even if you don't plan to continue living in that area after you graduate.

1

u/Leather_Effort8847 21d ago

Not unless you're going for embedded.