@programming@programming.dev Why is C hidden gold?

Let’s say you decide to learn programming. You have two options. Either use the education system (college or courses) or become self-taught. In the first case, you will learn the programming languages that are imposed on you. The education system (universities, colleges, courses) uses the “modern” development stack. Because what matters to them is what can later bring income to companies and you in life, and taxes to the state. They are part of the system and that’s how it works. Or because they want to get certificates from industry giants and use everything in their implementation - from development tools to ideology. Only a very few colleges and courses specializing in a very narrow field, such as embedded devices, can teach you the C language.

If you choose to learn programming on your own, the first thing you will do is go to the Internet to determine where to start and what you need to learn today. Naturally, you will find there a lot of articles and posts on the topic of “what programming language to learn in X year”. And they will contain a detailed or not very detailed comparison of “modern” languages. But you are unlikely to find the C language among them. Moreover, almost all of these languages will have the intention of being “C replacements”. Naturally, you will choose a new, powerful, and promising language that will replace the “dying C”, while you “look to the future”. You will never find phrases like “Rust is a replacement for Zig” or vice versa, they will all be “replacements for C”. And by doing this they are trying to hide the C language.
We have seen why the C programming language is hidden.

But suddenly one wonderful day you came across a post with the words “give C language a try”, or, if you are over 40, you remembered where you started learning programming as a child before you started writing all this “SaaS garbage”. And you thought “well, okay, what if there is something, here is nothing to lose anyway”. And you started learning C, simultaneously integrating into the C community. And then you discover, to your surprise, that the C language is simple and effective, applicable everywhere, and continues to develop. And the community is kind, not pompous, without hype, and buzzing with interesting projects. You realized that the C language is not dying and is not going to die, as the “gurus” on youtube taught you and representatives of the “modern” language communities argued with foam at the mouth. And that it is unlikely that C will be able to replace anything in the near future. It’s as if you have found “your home” again, something you have been looking for a long time, but could not express in words. You have returned to the roots.
And this is why the C language is gold.

Look for your “gold”, never give up. When you find it, you will know for sure that this is it. Thanks for reading!

  • lemmy_in@lemm.ee
    link
    fedilink
    arrow-up
    40
    arrow-down
    1
    ·
    1 month ago

    And then, because you were never in a classroom and never took a class on security, you probably have no idea what a buffer overflow attack is or how to use tools like valgrind to check for them.

    Then you put your C code on the internet and get your server pwned inside of an hour.

    Slightly hyperbolic? Yes definitely. But there is a reason we don’t teach C to beginners anymore. Generally you want them to understand the mindset of coding before throwing them in the deep end. And I would bet nothing has caused more people to quit programming then Segmentation fault: core dumped

    • Sauerkraut@discuss.tchncs.de
      link
      fedilink
      arrow-up
      7
      ·
      1 month ago

      I hate to admit this… But, I am a CS grad from a good US university and my CS program never taught us how to use tools like valgrind either. Our projects were graded entirely based on if they worked and how neat the code looked at a glance.

      • BatmanAoD@programming.dev
        link
        fedilink
        arrow-up
        1
        ·
        1 month ago

        That’s not a confession, it’s a condemnation. It’s not your fault that universities generally don’t teach this stuff. (I think I had one lab session wherein we used valgrind.)

    • pycorax@lemmy.world
      link
      fedilink
      arrow-up
      4
      ·
      edit-2
      1 month ago

      I do believe there is value in understanding the fundamentals of how the computer executes code by learning C as it is a nice balance without going to the level of Assembly. I don’t think I would be as good of a programmer as I am today without having learnt C as my first language but the way the school teaches it is important.

      That said, that’s in the context of a role of a software engineer with a CS degree, if you’re just a regular developer writing web apps or plan on only ever using frameworks then yea, you probably don’t need that kind of knowledge. Even then, I’d argue knowing these details would help you resolve issues with the framework if you ever encounter them.

      It doesn’t necessarily mean you have to use C to make products but it certainly is useful to get a feel of how it works.

    • @modev@snac.bsd.cafeOP
      link
      fedilink
      arrow-up
      3
      arrow-down
      1
      ·
      1 month ago

      You are right I have never took a class on security and I am not security development specialist, so from your point it is reasonable.

  • Eager Eagle@lemmy.world
    link
    fedilink
    English
    arrow-up
    34
    arrow-down
    1
    ·
    1 month ago

    C was my first language some 18y ago, and I wouldn’t recommend it to anyone starting today. If anything, learning C is a great way to teach why, maybe, we shouldn’t be using it to build customer applications, web servers, and whatnot.

    Keep your gold, I’ll stick to sane error messages, memory management, a packaging system, and a dozen other things that actually make working on multiple projects somewhat doable and not a constant fight against seg faults.

  • shnizmuffin@lemmy.inbutts.lol
    link
    fedilink
    English
    arrow-up
    29
    ·
    1 month ago

    In my experience, and in the experience of my coworkers/contemporaries, our formal education taught us how to program which is distinct from which language we program in. For instance, my Java dev friend learned to program in C++ because that’s what was being instructed. I was forced to learn ActionScript 2 and then was forced to migrate to ActionScript 3, because that’s what was being taught. The experience of programming something and iterating on it was far more valuable than knowing a language like C++ or ActionScript.

    Languages come and go, some faster than others, and you’ll eventually get to a point where your personal preferences stop mattering as much as which language is best for the task at hand.

    PHP is dead. Long live PHP.

    • xmunk@sh.itjust.works
      link
      fedilink
      arrow-up
      5
      ·
      1 month ago

      As someone who writes high throughput PHP code I can confirm that it’s much more about technique than language capabilities (though in an embedded setting things with dynamic GCs are simply unusable unless static memory management can be enabled with a compiler switch).

      For most projects you’d be much more rewarded for focusing on tools/framework/libraries available for the different languages (since that’s where most initial effort will go) and then build up any missing functionality as needed ontop of that base.

      Most languages can do pretty much anything these days. The technical advantages are much smaller than the impact the right approach will have… it’s one reason that I hold “maintainability” as the most important attribute of a project.

      • shnizmuffin@lemmy.inbutts.lol
        link
        fedilink
        English
        arrow-up
        3
        ·
        1 month ago

        I made sure answering, “Has someone figured this out already?” is a formal step in defining project scope at my company.

        • xmunk@sh.itjust.works
          link
          fedilink
          arrow-up
          4
          ·
          1 month ago

          NIH (Not Invented Here) is absolutely the downfall of many tech companies. Code costs constant money to maintain - it may sound illogical since it’s unchanged from the day it was written but it absolutely is the case.

          • shnizmuffin@lemmy.inbutts.lol
            link
            fedilink
            English
            arrow-up
            3
            ·
            1 month ago

            The answer has been “No” a few times and boy does that suck.

            “No one has ever attempted something so convoluted/silly/impossible before. Guess we get to see if we’re actually programmers or not.”

  • calcopiritus@lemmy.world
    link
    fedilink
    arrow-up
    18
    ·
    1 month ago

    What’s up with all these posts lately talking as if C was the chain breaker that will let you achieve a higher spiritual level for your soul or some shit. This is at least the second I’ve seen this week.

    It’s a programming language. If you want to use it, use it. There is no illuminati pulling in the strings to prevent you from learning this holy language.

    That being said, like all programming languages, it’s a tool, with its upsides and downsides. Depending on the project it might be the best choice or the worst. But with the advancement in language design, there’s very little upsides compared to more modern languages, taking into account its big downsides.

  • xigoi@lemmy.sdf.org
    link
    fedilink
    English
    arrow-up
    17
    ·
    1 month ago

    C is the first language I learned and I think it’s a terrible language full of inconsistencies, footguns and unnecessary complexity.

  • 5714@lemmy.dbzer0.com
    link
    fedilink
    arrow-up
    15
    ·
    1 month ago

    Computer Science in Germany often includes C and Haskell, ie Imperative and Functional Languages, at the beginning.

  • csolisr@hub.azkware.net
    link
    fedilink
    arrow-up
    7
    ·
    1 month ago

    @modev I’m genuinely surprised to see so few C courses integrating standard C safety tools, such as linters. It’s extremely easy to write unsafe C on the beginning, heck I passed years avoiding loops like the plague because I didn’t manage to write them correctly without going on an off-by-one error. Something that a linter would have caught and fixed for me.

  • PushButton@lemmy.world
    link
    fedilink
    arrow-up
    6
    arrow-down
    1
    ·
    1 month ago

    C wasn’t my first language, but I learnt the most whilst learning C…

    People are talking about footguns and what not security related issues. I agree it’s easy to write bad C code, but if you want to learn what’s going on, learn C.

    Today I know a dozen of programming languages and C has always been in a special place in my heart. I am using Zig for my personal projects at the moment. It’s similar to C, without the pitfalls, and my C knowledge still helped me to learn that language.

    Learning C is a service you are doing to yourself for the rest of your life.

      • BatmanAoD@programming.dev
        link
        fedilink
        arrow-up
        3
        ·
        edit-2
        1 month ago

        On the one hand, you’re right, C is waaaay higher-level than many people realize, and the compiler and processor do wild things to make code go faster. On the other hand, the C abstract machine is close enough to how computers “really work” to give you a fairly useful mental model, in a way that no other mainstream high-level language can.

        Even so, if you want to know how low-level code works, you should probably just learn one or more actual assembly languages and write a few small programs that way.

        C has another advantage, though: firmware, OS kernels, and virtual machines (other than browser JS engines) are still almost entirely written in C. So while it doesn’t teach you accurately how processors work, it is relevant if you want to know about the system software that meditates between the hardware and high-level software.

  • BatmanAoD@programming.dev
    link
    fedilink
    arrow-up
    7
    arrow-down
    2
    ·
    1 month ago

    The education system (universities, colleges, courses) uses the “modern” development stack.

    Hahahahahaha!

    Only a very few colleges and courses specializing in a very narrow field, such as embedded devices, can teach you the C language.

    snort BWAHAHAHAHA!

    the “dying C”

    [wheezing]

    And by doing this they are trying to hide the C language.

    [incredulous snort]

    And the community is kind

    [wistful sigh] I truly wonder what it would be like not to know anything about Linus Torvalds. I sometimes wish I didn’t know about Richard Stallman!

    And that it is unlikely that C will be able to replace anything in the near future.

    I’m sure you wrote this backwards.

    • TehPers@beehaw.org
      link
      fedilink
      English
      arrow-up
      3
      ·
      1 month ago

      The “‘modern’ development stack” we used at my school when I was in a CS program was C++98 or something, compiled using gcc directly. This was in the last decade. It technically wasn’t C!

      But we did use C in my computer engineering classes so I guess they technically did teach it. I feel very fortunate that I haven’t needed to use it since then.

  • FizzyOrange@programming.dev
    link
    fedilink
    arrow-up
    5
    arrow-down
    2
    ·
    1 month ago

    I seriously wonder what kind of circumstances lead someone to be this irrationally devoted to such a flawed and outclassed language. Probably best if I just block you though…