what is the best way to learn C ? I know basic python but would like to learn C, I tried searching online but couldn’t find a good resource that’s good for a beginner like me. any suggestions ?

  • raccoona_nongrata@beehaw.org
    link
    fedilink
    English
    arrow-up
    1
    ·
    edit-2
    1 year ago

    While I’d take the advice of experienced C programmers over mine, in regard to general skill learning I’ve found ChatGPT is a good resource for organizing a lesson plan and figuring out where to begin.

    It obviously probably isn’t the best to actual teach you itself, but it can help with the following on a lot of topics and skills:

    • Pareto Principle: this is an idea that 80% of the results or outcome for something stem from 20% of the cause. You can apply this to learning complex subjects by identifying what that critical 20% is that yields the most amount of practical utility. I’ve found that if you simply ask ChatGPT to use the Pareto Principle to identify the most critical 20% of subject matter relevant to a skill it does a pretty good job.

    • Let it create a study schedule for you. Tell it how much time per day or week you have available for study, and then ask it to create a basic study plan of topics distributed over that period.

    • Use it to create visual exercises. If you come across a concept while studying that just isn’t making sense, you can often ask ChatGPT to create a visual exercise to illustrate the concept, which can help more efficiently unlock the “ah-ha” moments that are sometimes difficult to get to.

    • let it suggest project ideas for your skill level

  • Estinos@lemm.ee
    link
    fedilink
    English
    arrow-up
    1
    ·
    edit-2
    1 year ago

    I’ve started learning C four years ago, after a career spent coding ruby/javascript/Go, so I guess I was in the same position than you. I started by reading the GNU C manual, then the Glibc documentation, and the man pages for headers and functions I was using (all glibc functions have a man page ; depending on your distros, it may already be installed or you may need to install a specific package to install them all at once). And of course, reading header files in /usr/include/ is always useful for using this or that library. Later, I discovered the book Modern C and it completed my education to feel at home with C. I can’t say if it’s the best path, but it worked for me.

  • Dunstabzugshaubitze@feddit.de
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    https://jsommers.github.io/cbook/cbook.pdf

    Might be a good way for someone who is familiar with a higher level language.

    Than there is of course “The C Programming Language” by Ritchie and Kernighan and “advanced programming in the unix enviroment” by stevens and rago.

    So, i’d guess just get your feet wet with small stuff. Find out how to take arguments from the command line, or read a file, maybe programm a simple guess the number game. After you are more familiar with the syntax and so on you could look into using your c code in a higher level language. For python you’d have to look into ctypes for that.

  • thingsiplay@beehaw.org
    link
    fedilink
    English
    arrow-up
    0
    ·
    1 year ago

    There is no single best way for every beginner. When I web search for “how to learn c programming”, then a lot of tutorials will appear. It would be good to know what does make them “bad resource” in your opinion, so one can give a better suggestion. Also it would be good to know what your end goal with C is; systems programming? cli programming? why is Python not enough? do you want work as a C programmer somewhere?

    Read a book about C, follow the examples and try to solve stuff alongside, play with the code. Take your time. And look out that its not too old, as the language and tools changed over time. Here is a suggestion: A complete and up to date open source book as downloadable PDF

    • ShadowCat@lemmy.dbzer0.comOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      1 year ago

      I just want to learn the low level stuff about how programs are written in C, and things like how system starts processes, how programs interact with the OS etc, (I guess that’s basically systems programming ?).

      It would be good to know what does make them “bad resource” in your opinion

      some that I’ve looked up seem rather shallow and don’t explain things well, what I’m struggling with is the memory allocation stuff, like what is malloc ? realloc ? calloc ?

      why is Python not enough?

      Python is enough, I’m happy with it; I just want to learn more.

  • TheTrueLinuxDev@beehaw.org
    link
    fedilink
    English
    arrow-up
    0
    ·
    edit-2
    1 year ago

    One of the thing I recommends is to start small. Going from Python to C is quite a leap, because C language requires some fundamental computer science understanding when you write codes that offers no railing or safety net when you make mistakes. I would actually suggests that you start with C#, it is very forgiving when you make a mistake and have various tools to help you identify the bug in your program.

    Big part of C# is that there is available video tutorial on an introduction to C# provided by Microsoft and it have subtitles. The biggest reason why I would recommend C# to beginner is simply that they offers a lot of resources to help beginners understand the fundamental of programming in general. They have tons of books, video tutorials, vibrant community, and so forth. Also C# can run on wide range of platforms, Windows, Linux, Mac OSX, Raspberry Pi, and so forth. Once you master C#, you’ll find that a lot of the knowledge you gained from it is transferable to C, C++, Rust, DLang, and so forth.

    • reinar@distress.digital
      link
      fedilink
      English
      arrow-up
      2
      ·
      1 year ago

      C#

      eh… those are fundamentally different, C is not object-oriented so OOD part goes straight out of the window. The only thing similar about them is syntax to some degree (which is really irrelevant), approach is completely different.

      • TheTrueLinuxDev@beehaw.org
        link
        fedilink
        English
        arrow-up
        1
        ·
        1 year ago

        Yeah, but when someone is completely new to programming, it’s best to start somewhere easy where there are quite a lot of tools to help them fix bugs in code. In C# IDE, it have a lot of visual indicators to help them identify bugs, debugger is pretty comprehensive and integrated, and there are quite a lot of resources to introduce them to programming in forms of videos and documentations and community. The goal of learning C# is not to only program C#, but to get them acquaintances with general programming such as for loop, memory management like using disposal in C#, recursion functions and so go on. They can use C# as a starting point to just basic programming and then once they are comfortable, they can move on to other language that they are curious about.

    • ericjmorey@programming.dev
      link
      fedilink
      arrow-up
      0
      ·
      edit-2
      1 year ago

      Ever since edX had their IPO, I hesitate to call it free. Each edX course is free for a limited time now and their prices are way too high if you aren’t interested in a certificate and the certificates aren’t worth much of anything in the employment market. They need a $50 option for no certificate and “unlimited” course access. But with shareholders, would they ever consider such a thing?

        • ericjmorey@programming.dev
          link
          fedilink
          arrow-up
          1
          ·
          1 year ago

          That puts a bit of organizational overhead on the learner. The material is all there and organized, but it’s not as conveniently presented nor does it mark your progress automatically. I like that they switched to GitHub code spaces and away from cloud9 which complicated things further.

  • Square Singer@feddit.de
    link
    fedilink
    English
    arrow-up
    0
    ·
    1 year ago

    Why do you want to learn C?

    This here might be an A B problem, so I’d like to check what is your goal, before recommending how to get into C. For most use cases there are much better options around nowadays.

    Many of the use cases you needed C for in past decades now have better alternatives.

      • Square Singer@feddit.de
        link
        fedilink
        English
        arrow-up
        2
        ·
        edit-2
        1 year ago

        Tbh, A-B-problems are something super common in IT. So much time is wasted by going down the wrong road because someone comes to you with the apparent solution that they thought of, instead of just posing the problem they want a solution to.

        In case of this post, there are quite a few reasons why the OP wants to learn C after learning a bit of Python, and some of them have C as the correct solution, some don’t.

        For example:

        • OP wants to make C-modules for Python -> C is the correct language, though Google might already have a fitting module
        • OP heard that Python is slow and C is fast -> Improve your Python skills, learn algorithmics
        • OP has a legitimate problem to solve where Python is not fast enough -> Check out Java/C#/Rust or, if it really has to be, C++
        • OP wants to program microcontrollers -> C is good, but might want to check out MicroPython
        • OP wants to program games -> Unity + C#
        • OP wants to go real low level -> C
        • OP is a masochist -> C or Assembly

        Especially the “C is faster” argument is often a trap for new programmers, since C is only faster if you really know what you are doing. C can also be much slower if e.g. you mess up memory management. Or, more common, C is not at all, because the rookie programmer gets stuck at arcane error messages that they can’t fix.

        In most cases the pure execution speed is not what is limiting the performance, but instead the algorithms and data structures used. For example, if you loop through a large array to find an entry it doesn’t matter that the looping is 4x the speed, when you could also just use a hashmap/hashset, which will be orders of magnitude faster.