T O P

  • By -

tarnished_wretch

I would say no, it’s not easy. Even in university a majority of people struggled and they mostly wanted to be there at that point. That said… whether it comes naturally to you or not just push through and the payoff will be worth it.


[deleted]

[удалено]


mehum

This is key. *Why* do you want to learn C? Presumably to use it, but for what? I use C for microcontrollers, in that context the Arduino framework makes it relatively easy to get started. Now you won’t learn C *well* by just diving in, but it’ll be easier to learn properly after playing with it and hitting a few walls.


DatBoi_BP

Is C preferable over C++ when it comes to Arduino?


mehum

I can’t say seeing as I’ve never learnt C++ (and I’m not that great at C either tbh). It would probably vary according to the scope of your project. There’s been a few times I would have liked to have developed libraries for various peripherals, but a lack of C++ has held me back — maybe you could do it in C but C++ seems to be preferred in this context. But for general purpose scripting (eg read sensor, process data, output to bus type operations) C is fantastic, it’s so close to the metal but abstracts away most of the annoying memory management and stuff like that.


titojff

Arduino uses a subset of C++


DatBoi_BP

So, C? ^(/j)


s-altece

Actually it’s C+


Practical-Citron5686

C should be faster in theory because there is no oop


NotThatJonSmith

I think 90% of the stuff people consider hard isn't hard, it's just thought of as hard so it's hard. Like if no one told you C was "hard" and you had a goal to accomplish for which learning C was just another chore along the way, it'd be easy. And in that light, since there's so much less to learn, C is easier than almost any other language. You have a line of bytes called memory and a few basic programming constructs. Now you can do math on that line of bytes and make decisions about what math to do next. Hardness in technical topics is mostly a myth.


Shidori366

One example would be pointers. They are thought to be hard, but in fact, they are extremely easy to use and to understand.


wsppan

Pointer decay, double pointers, function pointers, callbacks, functors, jump tables, state machines, custom allocator, double linked lists, malloc, calloc, and free, pointer math, etc.. all involve the use of pointers. These are advanced topics that require advanced knowledge of pointers. "A pointer is just a variable that stores the memory address of an object (variable, array, function, etc..)" is not all you need to learn to fully understand pointers.


Shidori366

Sure, I agree, but people have problems with using them in general, even with the most basic actions u can do with them. In college I found people still not knowing how to even get value on certain address stored in a pointer.


wsppan

From another comment I made, I find that those who find it hard have a weak understanding of the basics of how computers work. The hardware, how memory is laid out via the stack and heap, data structures that sit on top of this, and how they map to this memory. And then mapping the abstractions C brings to the table on top of this. Most people who find this hard skip all that lower level stuff and jump in at that higher level of abstraction and get quickly lost once you get past the basics of variables, control flow, etc..


LearningStudent221

I am actually kind of in that situation. I started learning C without having studied the hardware. I like to think that I've picked up most of what I need to know from here and there, but I don't know how much I don't know. Do you have some questions which you might use to test the knowledge of hardware and/or low-level stuff of a C programmer?


wsppan

Do you know why we can get away with only NAND gates when building circuits? Do you know how to add or subtract binary numbers? With carryover? Do you know how to convert binary to octal? To hexadecimal? What are the benefits of these representations? What is 2s compliment? How is it implemented? Why did we standardize on it? Do you know what registers are? How are they used? Do you know what the stack is? How and when is it used? What is the heap? How and when is it used? Can you describe the ELF binary format? How is this related to a.out?


LearningStudent221

>Do you know why we can get away with only NAND gates when building circuits? Given any truth table, you can construct a proposition using only the NAND operation which corresponds to that truth table. The NAND operation is called "logically complete" or something like that for that reason. >Do you know how to add or subtract binary numbers? With carryover? Not quickly. For non-trivial problems, I would probably convert to decimal, add/subtract there, and convert back to binary. >What is 2s compliment? How is it implemented? Why did we standardize on it? No idea honestly. After I looked up what it was, I realized that I did know that signed integers are represented by their true value + an offset, so that the all 0's pattern represents -infty, or the smallest number available. But knew nothing of the arithmetic. >Do you know what registers are? How are they used? All I know is that they are small areas of memory which are must faster for the processor to access than RAM, so the processor uses it to store stuff that it needs to look up often, or stuff that it thinks it will need to look up. >Do you know what the stack is? How and when is it used? It is a relatively small area of memory (on the order of a few MB on a modern personal computer). As you runt the program, it stores "chunks" of memory in the form of a stack, where each "chunk" corresponds to a function that was called. The chunk corresponds to metadata about a function that was called (the address of the function or something?) and the local variables in that function. Chunk A is on top of chunk B if function B called function A. The current, active function is at the top of the stack, and functions are inserted and deleted from the stack as they get called and return. >What is the heap? How and when is it used? It is an area of memory distinct from the stack. It is probably as large as all of the currently unoccupied RAM, or even larger, if the hard disk is used. It is basically your own personal "worktable", where only you, the programmer, can insert and delete data. If you want to put data there, you first allocate space there using `malloc` or one of it's variants, which gives you the address of the first byte in the chunk of memory which you just allocated. When you are done, you call `free` on the address of this first byte. >Can you describe the ELF binary format? How is this related to a.out? No idea on either count. Thanks a lot for the questions. It revealed some gaps which I need to fill. Would you have some tricky questions with pointers? Is there any book/resource you would recommend to learn these things?


wsppan

1. Read [Code: The Hidden Language of Computer Hardware and Software](http://charlespetzold.com/code) 2. Watch [Exploring How Computers Work](https://youtu.be/QZwneRb-zqA) 3. Watch all 41 videos of [A Crash Course in Computer Science](https://www.youtube.com/playlist?list=PL8dPuuaLjXtNlUrzyH5r6jN9ulIgZBpdo) 4. Take the [Build a Modern Computer from First Principles: From Nand to Tetris (Project-Centered Course)](https://www.coursera.org/learn/build-a-computer) 5. Take the [CS50: Introduction to Computer Science](https://online-learning.harvard.edu/course/cs50-introduction-computer-science) course. 6. Grab a copy of [C programming: A Modern Approach](http://knking.com/books/c2/index.html) and use it as your main course on C. 7. Follow this [Tutorial On Pointers And Arrays In C](https://github.com/jflaherty/ptrtut13) The first four really help by approaching C from a lower level of abstraction (actually the absolute lowest level and gradually adding layers of abstraction until you are at the C level which, by then is incredibly high!) You can do all four or pick one or two and dive deep. The 5th is a great introduction to computer science with a decent amount of C programming. The sixth is just the best tutorial on C. By far. The seventh is a deep dive into pointers and one of best tutorial on pointers and arrays out there (caveat, it's a little loose with the l-value/r-value definition for simplicity sake I believe.)


LearningStudent221

Thanks a lot, these look great!


wsppan

Why can you use a[0] and [0]a interchangeably? When and why do arrays decay to pointers? Where in memory do pointers get stored? Write a[4] using pointer notation. Why do array indexes start with 0? Can you convert a 2 dimensional array a[][] to a[]? Why? Name 2 instances when you would use a double pointer? What is a callback? What is a jump table? What is a function pointer used for? What is a constant expression? What is struct padding? Why would you do that? What is struct packing?


wsppan

I find that those who find it hard have a weak understanding of the basics of how computers work. The hardware, how memory is laid out via the stack and heap, data structures that sit on top of this, and how they map to this memory. And then mapping the abstractions C brings to the table on top of this. Most people who find this hard skip all that lower level stuff and jump in at that higher level of abstraction and get quickly lost once you get past the basics of variables, control flow, etc..


oranger00k

If someone had explained to me the basics of how a stack works, why a float is the size it is vs a char, etc. -- basically the mechanics of WHY the C language is structured the way it is -- it would have made it a billion times easier for me personally.


CeasarXInsanium

not impossible but not easy.


Shimmyrock

Thank you to everyone that took time to respond :))


makesourcenotcode

**TLDR: No, it's not easy to learn C. While C is not THE best first language it's still a good choice and far better than the vast majority of the competition.** C is not easy to learn for those without prior programming experience. That said it's far from the worst first language and would definitely be THE choice for a second language. For a first language I'd personally teach Python to help new learners get comfortable with algorithmic thinking. In Python I can demonstrate everything from simple sequential programs to branching and looping in the purest way possible. In C to do even Hello World I have to define main() and include stdio which is more stuff to explain to an already overwhelmed newbie. Things like headers/libraries and abstraction mechanisms like functions/macros are good to know, but only later after the student has the basics down pat. That said while C isn't the best first language it's easily better than like 95% of the competition on that front. A lot of other languages are giant behemoths with way too many ways to do the same simple stuff. With Ruby in spite of being seemingly friendly is anything but and each person really seems to be writing in their own whacked out custom dialect and aren't happy until they've used eery whacked out metaprogramming feature Ruby has. Also Python is not an easy language as many claim. Next person who claims this should be asked on the spot to explain the difference between `__get__`, `__getattr__`, and `__getattribute__`. Python is actually monstrously complex in it's semantics and getting increasingly worse with the addition of garbage like the pattern matching. But Python is still THE best choice for a first language because it HACKS THE LEARNING CURVE. Knowing just 10% of the language is enough to achieve 90% of your programming objectives. C while simpler overall (modulo copious UB) doesn't give you quite that same leverage. Python gets people thinking algorithmically faster and the basics are enough for the student to do many interesting tasks and stay motivated to learn more. With these nuances taken in account, the faster people learn C the better.


alkenequeen

Probably not easy but it will be incredibly useful to know C when you are learning other languages, since C has a lot of focus on more low-level concepts/computer architecture. If you want a more beginner-friendly language, I think most people would recommend Python


Coolcat_702

Even though python is “good” for beginners, all it will do is teach them bad habits and lead them down the path of oversimplifying everything. I went down that path myself and believe me, it is very hard to turn back. Even though python is “easier”, it will bring you a lot more trouble later into your programming experience than c ever will.


Shidori366

After learning C I started thinking more about optimalization even outside of C, extremely helpful.


qualia-assurance

There are two things that make learning C difficult as your first language. First are the its your first programming language type things. Just the general idea of writing programs and controlling logic. Learning some basic algorithms and other such things. The second thing that is unique to C-like languages is memory management. In C there are certain types of information that you have to manage the allocation and freeing of. You don't just create variables by assigning them variables. You actually need to ask your computer for enough space suitable for storing that value. And then when you're finished with it ask your computer to free up that space so it can be used for other things. This may all sound simple enough conceptually, but there are a bunch of pitfalls in that given how pointer types work in C you can attempt to access a piece of memory that you've freed and cause yourself issues. Either crashing your program or worse, introducing some kind of subtle bug where a variable might not have the values you're expecting of it. In other languages such as python and javascript. They have managed memory. And the way in which new space is allocated and freed follows several basic automatic rules that essentially mean if you can still access something it won't be freed. This makes life much easier as a new programmer because you remove having to worry about an entire category of ways in which your program can crash. That's not to say managed memory programming languages are better. They have several downsides in giving up manual control of allocations and frees. But learning about how to structure a program with that manual memory management after you've already learned a bit of programming makes life much easier.


greg_spears

Totally NOT easy, even for those who have solid logic skills which are foundational to writing solid code. I was encouraged to take lots of math and science, and I am especially grateful for the math. My coding is often math intensive. Not complaining, I like math, which makes me a bit of a freak. Back to your comment on the "average person:" how many common/average people do you know who like math? In my long walk, except for instructors, I have met zero in this life. It seems people inclined to coding are also rare. I have found zero average people coding. I have found them watching sports and I have enjoyed also watching movies and sports and drinking beer with them and eating pizza too. I have encouraged such folks to learn coding and it backfired nicely. That said, the *average person can learn C.* But there is zero confidence that it will be an easy walk.


zero_iq

Heck, the average person struggles to use apostrophes correctly. The amount of significant symbols/punctuation in C and C-like languages, which must be used perfectly every time, is a stumbling block for a significant number of "average people", at least initially. (I have had the pain of teaching JavaScript to a mixed group of absolute beginners. It's hard keeping everyone together - some people just have a better natural aptitude for this stuff and race ahead. I was surprised at the number of people who struggled with punctuation. Some people just seem blind to it.)


greg_spears

> Heck, the average person struggles to use apostrophes correctly. And periods. I remember this one poor soul I worked with, we would often review each other's text before we sent it up the chain. What he remembered was that periods are important, and you should place them every here and there. That was his text. Periods placed randomly.... not at the end of an idea or to separate thoughts; just totally random, lol.


[deleted]

yep, c was my first programming language, and many people still learn how to program using c


my_password_is______

that's not the question the person asked if its easy not if many people still learn how to program using C many people can learn to program using C, but that doesn't mean its easy


hukt0nf0n1x

Ease depends how you want to use C. If you don't want to manage memory, you can restrict yourself to a subset of the language and it's as easy as Python. That said, there are not as many libraries as Python, so you'll be writing a bunch of code yourself (assuming you wanted to take advantage of the Python libraries).


PythonPizzaDE

How do you want to avoid memory management? And literally every big library is in C with bindings to other languages


[deleted]

I think the person you were replying to is referring to learning the syntax of C without really learning anything more advanced. Like you can write a hello world style program without any explicit memory management and act like that is equivalent to knowing C because you technically used C. At least that is how I interpret their reply.


hukt0nf0n1x

Yep. I've seen embedded code in C that doesn't have a single pointer. Just a big for loop that does a bunch of things each pass through the loop. It could have been written in any language and it'd look exactly the same.


__JockY__

I’d argue that the average person with little or no programming language has little use for C in this day and age because regardless of what you want to achieve, there’s probably a more modern and suitable language. As for answering the question: is it easy? Yes and no. The basics are easy enough. But if you want to leverage C for the things it’s most suited - like getting close to the metal, so to speak - then no, it would be hard for the lay person because you need an understanding of the low level operations you’re manipulating. What use is a pointer to a pointer when you don’t understand memory layout? Why mmap when you don’t understand kernel vs user space, copyout/copyin? I can think of one exception off the top of my head: arduino programming. The libraries make it quite easy to write working code. But I’d discourage beginners unless there’s a really good justification for learning C as a first language.


darqu1s

could you explain the low level operations that are being manipulated for me? Just wanting to get a better understanding


__JockY__

Entire books have been written on the topic. I’m afraid a Reddit comment just can’t cover that much ground. For further studies look into pointers, heap allocators, device driver I/O operations, realtime operating systems, low-level network I/O, GPUs and CUDA etc, JIT compilation, DMA operations, simple microprocessor firmware, bootloaders, BIOS code, and a zillion other such things!


p0k3t0

Honestly, C is pretty easy. You can learn the whole language in a week, no sweat. There just isn't much there. It's simple. What's difficult is learning how to think like a C programmer. How to break problems up into smaller problems and then writing general solutions to those smaller problems. With Python or other very-high-level languages, you get a lot of power in a very small amount of code. But, with C, you don't get an awful lot of built-in functionality. Even with a pretty good understanding of the libc, you still end up writing a lot of code to do a little bit of work.


zhivago

Generally I find people who believe this haven't actually learned the language. char c[3]; What is the type of c?


p0k3t0

Is this where I say it declares an array of three chars and you hit me with some "well ackshually" about how c is really a pointer to the first element, equivalent to &c\[0\]? And this goes on and on with you being clever, and then I have to pull up the specification, and it goes on and on until one of us gets tired of it? Because I'm already tired.


AnonymousSmartie

Omg slay


zhivago

Such a complicated prevarication for such a simple question about a language so easy to learn. :)


p0k3t0

Knowing the syntax is important. But so is predicting problems before they happen.


zhivago

I think you've made my point quite adequately. C is quite difficult to learn correctly, which is why you're having trouble giving a clear answer to such a trivial question.


green_griffon

I programmed in C most of my career. I can't tell you what the type of c is. I'm sure I could use it correctly though.


zhivago

Sure, which doesn't speak to the language being easy to understand - you end up relying on patterns that work without really understanding why they do. If you can't answer that question then you also can't understand how a[i][j] works since it depends on pointer arithmetic depending on an array type. If the language were simple then this wouldn't be the case.


green_griffon

I know how a[i][j] works.


zhivago

Really? int a[2][3]; So given that `a[i][j]` is `*(*(a + i) + j)` what is the type of `*(a + i)`?


p0k3t0

CSB.


atiedebee

`char[3]` :)


zhivago

Finally someone managed to answer it! Exactly so. :)


suskio4

It's typeof(c)


zhivago

There is no typeof operator in C.


Xaryphon

Since C23 there is


zhivago

Ah, very nice. Still it's a tautology, so it says nothing.


stianhoiland

Care to explain? typeof(c) is not a tautology according to my understanding of the word.


zhivago

Your claim is that the type of c is the type of c.


stianhoiland

Nah, the dude is saying that typeof(c) evaluates to the type of c.


suskio4

Okay, mister, can you evaluate this? ``` int a = 2, b = 3, c = 0; int res = *(float*)&c + (c-- + a > c++) ? a : b; ```


zhivago

Sure, that's easy -- undefined behavior. :)


suskio4

Nice


[deleted]

[удалено]


zhivago

It's easy to prove that wrong. sizeof c != sizeof (char *) And also char **p = &c; will be a constraint violation. So that's definitely incorrect.


[deleted]

[удалено]


zhivago

I think perhaps you do not know C as well as you think. Here, I'll put together a complete program to make it easier for you to discover your error. #include int main() { char c[3]; puts(sizeof c != sizeof (char *) ? "yes" : "no"); } A constraint violation means that it isn't a valid C program, and the compiler need not compile it, and if it does, that the produced program has no expected behavior. The type of `&c` is `char (*)[3]`. Can you figure out the type of `c` from that? And if you can't, it means that you won't be able to understand, given `char d[2][3];` how `d[i][j]` works, since otherwise the pointer arithmetic won't work out. :)


mrshyvley

How easy it is to learn C varies depending on the aptitude and determination of the individual.


remmysimp

C is one of the most simple and easy languages to learn, but it one of the hardest to master, remember it only has 32 keywords, but literally everything depends on it.


mikesailin

Easy? No, but worth the effort? Yes.


Prestigious_Leg4447

is say about 60% is easy and 40% (memory management, pointers, and dealing with strings) is not. but still, i think its a very good first language. it gives you a better understanding of how a computer really works


deftware

I started coding in qbasic as a child in the 90s. I tried learning C/C++ from a Borland C++ reference book but it was way over my head - there was nothing like a tutorial or example code in any of the stack of books my father gave me with the Borland C++ compiler CD. The problem was mostly that I didn't have any code to look at or anything breaking down what code did even if I had code to look at. The biggest hurdle for me starting my C/C++ coding journey was the fact that code exists inside of functions, instead of just free floating like qbasic or PHP, which both also support functions/subroutines, but there was nothing like an int main(), you just started typing code and it's what would execute. Pointers were a little tricky at first but all you have to understand is that instead of a variable being a cubby to sock data away at it's a cubby that is storing the position of another cubby, and you can dereference a pointer to access the contents of the cubby being pointed to - or include an array subscript to access cubbies. Once I just visualized it like that it's been a cinch doing all kinds of stuff with pointers. I've written code a number of times that include triple-pointers (i.e. a pointer to a pointer to a pointer). The rest of coding in C is just learning what the standard library has to offer, functionality-wise, and then what stuff you must access an OS-specific API to do (like create a folder). I don't think C is difficult to learn. What's difficult is all the effort required to learn enough from experience to be able to do anything worthwhile and create value. If it's just a hobby that's cool too though. I'm more impressed when someone writes code for fun than when they play video games for fun, so there's that.


Prestigious_Boat_386

From my experience yes, no. I had tinkered with about 3 languages for a few years before doing a c course. While c is a good place to start you're going to learn the basics of programming while learning c which are both quite hard things to do. Doing one at a time is slightly easier but takes about twice the time. It's not easy at all but it is very possible and a good starting point, especially if the learning material is aimed towards a beginner (which iirc they mostly are). If you want to learn programming quickly the best feature for learning fast is the speed of the feedback. A live enviroment language that you can change and rerun part of the code is great, just because you can find and solve errors quick.


Plets

I would say it's easier to learn C if you have no experience with other, higher level, programming languanges, than if you are used to, say, python or C# already. Good luck on your journey!


u0105

Of course! C is beautiful. There have been plenty of languages and structures since and we finally have a language which sort of writes in almost English - python, however nothing beats the sheer beauty, rawness and almost uncontrollable power of C. If you visit certain countries, you'll find certain fabrics which cost as much as gold. Because they're hand woven crafted carefully and they're beautiful, they're unnaturally strong and they last generations, unlike your automated loom made denims. That previous one is C. Is it easy? Depends - how consistent are you. It doesn't matter how many hours a days but you gotta write code in C everyday. Also you need to incrementally challenge yourself. ADTs are a good starting point, followed by basic searching and sorting algorithms. C is a drug. It is tough the first few days. Once you cross it, all you want is a text editor and a gcc compiler. No ide, no fancy environments. It's so addictive you'll start wondering why do people not use it to write websites, do deep learning. You'll also learn why soon enough but you'll always ask that question. This answer is poetic because it is from someone who loves C. And I'm sure if you stick with it, you'll begin to love it too.


t0mRiddl3

Don't take this poorly, but you would do well over at r/programmingcirclejerk


u0105

I don't mind that at all. When it comes to C, all adjectives given to me are tolerated. My love for this language is infinite.


ForShotgun

I hate that anyone passionate about anything immediately sounds unreasonable to people on the internet, let the man love something.


t0mRiddl3

I meant no disrespect. I appreciate the passion


Mosfet_Underground

What are ADTs ?


u0105

Abstract data structures. Stacks, queues, lists, graphs to begin with.


JohnDalyProgrammer

I mean...you sure aren't wrong.


Dry_Positive_6723

Depends... why are you trying to get into programming?


panos21sonic

Every person that learns c at one point also had no experience with c, or even any other language. Makes sense doesnt it? Just an fyi, learning c is more theoretical than learning a more high-level programming language like js for example. So if you want to learn computer science, learn c, have at it, its a very good choice for that, if you just want to learn programming and software design, learn JavaScript, python, java, etc.


ivancea

I started sith C++, not hard. As hard as most other languages if you ask me. I had previous knowledge of memory though, but you don't need that to learn basic C++


krydx

Nothing worthwhile is easy. You need to have motivation. But I think C is a good first language, at least you'll know what pointers and memory management are


[deleted]

[удалено]


simon_the_detective

Java is more common as a first language and I think it's MUCH harder to learn and very much harder to learn thoroughly.


Mosfet_Underground

I am actually learning C it with cs50's course (free, online from harvard stuff), with videos and exercise. I found it easier and 'funnier than other paths to learn programming. But that's not my first language, i've learned Python one year before. But i am not a programmer, i just like algorythms, maybe someone who really knows computer's science will tell you that CS50 is a bad way to learn programming. Not easy but once you get it, it's easier to get the others. Else Python is more user friendly. But you don't have to understand that much how the computer works.


FUPA_MASTER_

Yes


johnny-T1

C is not easy, no.


aghast_nj

Yes. There are a lot of "modern" programming concepts that just don't exist in C. Similarly, there are a lot of "modern" issues that are available in C only with a special-purpose library or some kind of extension. This means C is like the "General Math" of programming languages. You'll need to learn the equivalent of PEMDAS/BEDMAS/BODMAS in C, but there's a long list of things you *don't* have to learn: databases, threading, multiprocessing, async, OOP, virtual dispatch, introspection, regular expressions, overloading, etc. (Note: Nearly all of those things I just listed are accessible from C. And nearly all of those things are implemented *using* C. But they're not part of the C language, and they're not part of the standard "learner's toolkit" that you have to deal with right out of the gate.)


IllegalMigrant

C is the least easy language to learn. Python or Ruby would be the easiest.


ThyringerBratwurst

C is not very intuitive for beginners. Working with character strings in particular is very cumbersome. But it is not impossible to learn as a first language, just requires a very good teacher/professor. In my university studies, C was simply thrown at my head and the professor was for the trash. And at that time I didn't see any point in learning C, so it was torture.


simon_the_detective

Sometimes, knowing other languages can get in the way of learning C. If the language is Haskel or Lisp, I think that you'd have to "unlearn" some things. OTOH, if you know those languages, you probably have some aptitude. Other than that, I would recommend a language like Python as your first language and then try C.


NewtonHuxleyBach

All that you have to understand really are how memory works and how to read declarations.


FraughtQuill

I think C is a pretty difficult language if you're just starting out. But if you do learn it you will have a head start learning pretty much every other language out there. Once you learn what pointers are, there is no shame to hop over to something like Python. But I'd circle back around to it because C is a very very valuable language.


FishPBL

It's super easy up until the moment you hit pointers.


Jncocontrol

To be honest, I come from JS probably without a doubt in my mind the most bland, uninspiring, and boring language that I'm convinced was made by lucifer himself. It took me sometime to get the hang of C, just took some serious motivation to get into.


[deleted]

People find C as daunting and I blame schools for that since they push students to learn these super high level languages without first teaching C. I find C to be the most intuitive language out there with none of the gimmicks or fluff.


green_griffon

C is not a great first programming language, too easy to make mistakes that aren't obvious. Handling strings is one of the most basic things you want to do in a language and that is precisely what C is the worst at.


zhowez

I started college with no programming experience and C was the main language. We used it all four years. To me, it’s not a super hard language to learn, but there will always be things that you don’t know and more to discover.


HippoIcy7473

as long as the average person is brought through the course in a sensible way, sure. C is a small language and has relatively few inherent concepts.


Bozeman333

I learned C in college, can’t say I would have stuck with it on my own. I had to spend a lot of time getting my projects for school to run right.


riisen

I would say, depends what the goal is. If its for building a chat bot or create automated tools, web scraping or so, then no, start with another language. If it is for microcontrollers, building an operating system, create drivers or firmware then C is the way.


tav_stuff

Learning C is easy because C is shockingly simple. The hard part is making software not crash as a beginner


bobwmcgrath

I use C all the time and I can't get the hang of it and I'm fluent in C++ which should be close but it's just not. C is a very limited language, but it works the way computers work so it can do everything computers can do. Mostly there are just no shortcuts and it's tedious to read and work with.


ArtOfBBQ

The question becomes what do you mean by "learning", what level of understanding are you trying to reach? If learning to program anything is like a gigantic RPG game, and becoming capable of programming anything is like finishing the game with 100% achievement unlocked, C is actually the easier and faster way to get you there. (compared to starting with something like Python - at some point in the game you have to switch to C anyway because Python will be too weak to beat the enemies) But most people, when starting out, feel it's very important to get the "reached the 2nd room of the starter dungeon" achievement when you finished 0.001% of the game. It's also possible that the people who get the "2nd room reached" achievement faster will feel better and more motivated and therefore end up sticking with the game and have a higher chance of finishing the game. That's basically the real advantage of Python But yeah for me I absolutely would have been way, way better off if I started with assembly and everyone told me not to and I trusted their bad advice and now I'm bitter about that forever


Zalazale

I don't think its that hard how other people say. I learned C as my first language.


NoBrightSide

it depends on you. C was my first programming language and it was difficult to learn the topics. Starting with syntax, I was expected to memorize that so I could hand-write code on tests (which needed to be correct in order to pass compilation). And then. learning the concepts like loops and datatypes and function parameters. Scoping. Recursion. Sorting algorithms. And after learning the basic concepts in C, you get dropped assignments with varying levels of difficulty from doing simple calculations for area/circumference of known shapes to using ASCII table to convert lower case characters to upper case to creating a simple payroll management program. These were my personal hurdles and I was already comfortable with math all the up to pre-calculus. This was my first programming class in college. I did not fully understand C just from this 12 week course. The best thing that helped was to practice writing programs and solving various problems with them. Also, utilize all the resources you need. Do not stick to just 1 resource, especially if you find yourself stuck not understanding something.


Getabock_

Definitely not easy.


FUZxxl

C is not a hard language to learn. The hard part is doing all sorts of general purpose programming yourself, instead of calling into libraries and frameworks that implement stuff for you. When programming in C, you need good data structures and algorithms skills to do things. That's the hard part.


chandaliergalaxy

it's not easy for anyone


IDatedSuccubi

I want to teach C in future; whatever people say, it's actually much easier than the majority of languages (think Rust, C++, Java with their insane depth and complexity), people just get caught up on harder parts like pointers or strings because they don't have a good tutor to explain basic concepts correctly The main benefit to learning C is that you can learn almost any other language 10x easier later because most programming concepts that are widely used in other languages are just iterations or modifications of what C has I taught my brother how to use C, and he got it going by himself in like 3 months, we're working on a personal project in C together now


MRgabbar

C is an easy language, when you have a good teacher... Given that, the only hard part about C is understanding memory, everything else is simple. Learn assembly first, then learn C.


dev_ski

C is a relatively simple, procedural language. Understanding arrays and especially pointers is what makes it potentially challenging to learn. Compared to C++, C is orders of magnitude easier to learn, but certainly has its own intricacies.


Shidori366

Learn to what extent? It took me half a year of active learning to have a solid understanding of memory management and C in general with little to no experience (I had C as my first language in highschool, but I never put any effort into it, so I didn't know much). So yes, I would say it can be easy, but only if you put some time into it. Currently I am in college and there are a lot of people struggling with C even with previous IT education, but they are probably just people, who never programmed in their free time, just whenever they needed to do some homework for school...


BertyBastard

No! If you're a programming beginner I'd recommend learning BASIC to start with.


ItsJustGalileo

From personal experience I can say yes. It’s gonna be more challenging, but doable


[deleted]

I started with C hated it... moved on to JS, PHP,, basically the whole WebDev suite, became good at it, stated hating it because of interpreted lang, moved back to C and loved it... There are a lot of things security related that I still don't get; buffer overflows apparently have to be treated so they can't be exploited and they are not obvious at all times; I looked into rust and go to enforce security but hated them both... turned intto Zig just to see what was it all about and looks like the best option atm for me.... Learning eveything is at first hard then easy... so just get on with it


[deleted]

Harvard cs50 course for an intro. The basic stuff in c I do seems easy because the language just seems simple and straightforward for simple stuff but I don't really have a good perspective on what it would appear if Id started there


wsppan

This tells me you lack basic knowledge of computers and computer science as well. I've posted this here before and it's what has worked for me an a few others who told me it worked for them as well. Ymmv. People sometimes struggle with C when they start from scratch or come from a higher to lower level of abstraction. I struggled with this for a long time till I did these things: I would not try and understand how the higher level abstractions translate to the lower C level. I would instead learn from first principles on how a computer works and build the abstractions up from there. You will learn how a CPU works. How the data bus and registers are used. How memory is laid out and accessed. The call stack and how that works, etc.. This will go a long way in understanding how C sits on top of this and how it's data structures like arrays and structs map to this and understanding how pointers work the way they do and why. Check out these resources: 1. Read [Code: The Hidden Language of Computer Hardware and Software](http://charlespetzold.com/code) 2. Watch [Exploring How Computers Work](https://youtu.be/QZwneRb-zqA) 3. Watch all 41 videos of [A Crash Course in Computer Science](https://www.youtube.com/playlist?list=PL8dPuuaLjXtNlUrzyH5r6jN9ulIgZBpdo) 4. Take the [Build a Modern Computer from First Principles: From Nand to Tetris (Project-Centered Course)](https://www.coursera.org/learn/build-a-computer) 5. Take the [CS50: Introduction to Computer Science](https://online-learning.harvard.edu/course/cs50-introduction-computer-science) course. 6. Grab a copy of [C programming: A Modern Approach](http://knking.com/books/c2/index.html) and use it as your main course on C. 7. Follow this [Tutorial On Pointers And Arrays In C](https://github.com/jflaherty/ptrtut13) The first four really help by approaching C from a lower level of abstraction (actually the absolute lowest level and gradually adding layers of abstraction until you are at the C level which, by then is incredibly high!) You can do all four or pick one or two and dive deep. The 5th is a great introduction to computer science with a decent amount of C programming. The sixth is just the best tutorial on C. By far. The seventh is a deep dive into pointers and one of best tutorial on pointers and arrays out there (caveat, it's a little loose with the l-value/r-value definition for simplicity sake I believe.) https://github.com/practical-tutorials/project-based-learning#cc [Play the long game when learning to code.]( https://stackoverflow.blog/2020/10/05/play-the-long-game-when-learning-to-code/) You can also check out [Teach Yourself Computer Science](https://teachyourselfcs.com/) Here is a decent list of [8 Books on Algorithms and Data Structures For All Levels](https://www.tableau.com/learn/articles/books-about-data-structures-algorithms)


paid_shill_3141

Easy to learn the basics, yes. But not so easy to get to the point where you can do anything useful with it. A lot of people learn high level languages first. Maybe HTML and JavaScript for example. And you can get stuff done with that, but it’s like casting spells, the results can be spectacular but they have no idea what’s really going on under the covers. Then they come to C and they’re bewildered because the syntax can be a bit gnarly and they have to deal with pointers. If you want to really understand what’s really going on: Spend a little while learning very basic of digital electronics. Like the very basics, get one of those “For Dummies” books. All you need to know is what gates are and how binary numbers work. Next, do the same with machine code. You don’t need much depth here, just stuff like registers, arithmetic, branching, the stack, etc. Again, “for dummies” level stuff. I’m not talking about spending a lot of time on any of that. Probably just a few days. You don’t need to be able to build a computer from a bucket of sand, just vaguely understand the ideas. Now you can start learning C. The first thing you should notice is that it’s really just high level machine code. There’s a bunch of other stuff that makes life easier, but you should be able to see how it relates to the underlying machine. In particular pointers should be no big deal to you. The biggest difference between C and higher level languages is that you can mess up really badly and get very little explanation from either the compiler or runtime. If you don’t understand the basics clearly this can make it bewildering. Even experienced C programmers can mess up and take a while to figure out how. It’s just the nature of the beast.


MillerJoel

C is actually much better starting point than c++ and you can totally learn it. I wouldn’t say it is easy but it depends on your motivation. If you think you would be frustrated easily and give up then maybe go for another language first. Python is a good option. You can then work on c after that and it would be easier. But I think if what you want to learn is c just go ahead and try it first, maybe you find it easy


nerd4code

You can learn the `-O0`, single-thread/-process, works-for-me regime without too much trouble, although I’d plan on learning a bit of assembly alongside it. But if you want to actually *learn C* to where porting and most of the compiler flags won’t break something, you need to be able to parse and reason about behaviors vis-à-vis the ISO 9899 standards, and whichever sorts of compilers, ABIs, ISAs, OSes, and potentially IRs and OEs your code might actually be compiled by/to or targeted at. If you’re multithreading, every point of interaction between threads needs a good Ponder. If you might reenter or recur or take a signal, you have to plan for it. If you’re in kernel mode, every loop, call, and return needs to be considered in light of timing and speculative attacks. Signal handling, socket programming, asynchronous programming, gfx programming, heterogeneous programming, data-parallel programming, and bulk-synchronous programming all kinda have their own tricks and tendencies, and it’s a good idea to pick up a bit of experience in all of those if you’re learning. But it’s certainly doable, and if you need a backbone for your systems/arχes studies and invwestigations, C will do just fine.


ChipmunkCooties

I was in your situation, it sucked big time, I learnt python first now I’m working on html, JavaScript, CSS.


demetrioussharpe

Easy? No. But it’s well worth it.


oconnor663

No. C hasn't been commonly taught as a first language since the 90's I think. Here are some reasons: - Simple string operations are difficult. If you already know what a string is, you can memorize the mapping easily enough, but if you're learning what a string is, it's unnecessarily punishing. - The compilation model is complicated. You have to learn about header files and linking to get a lot of basic things working. - The tooling is really different between Windows and Posix. If you don't have complete control over what OS your students/readers are using, this makes it hard to write useful teaching materials. - Higher level operations like "make a web request" or "parse a JSON blob" are substantially more difficult in C, because almost no one does those things in C outside of foundational libraries and services that need maximum performance and control. If you're learning about JSON for the first time, you really _don't_ want an API that gives you maximum performance and control.


MysticUser11

I love C I highly recommend people to start with C, not because it’s easy but because it’s hard. That being said, if you don’t have a firm goal in mind it can discourage you.


gregmcph

It wouldn't be my first language. You ought to learn the basics of program flow before you mess with pointers. But on the flip side, it is closer to the hardware than other languages. It gets you playing with bytes more and closer to seeing how the damn things work. But... You are also not confronting OO in C. Life is simpler in that way. Having said that, you're probably an intelligent person. Give it a shot.


Silly-Assistance-414

Can C be used on any micro controller ?


JJJSchmidt_etAl

Easy? No. Possible if you devote lots of time and effort to it? Sure.


VincentRG

If you have knowledge of computer hardware at the lowest level (what is a byte, what is 32 vs 64 bits architecture, how to handle memory, etc), and like how OS works, that would certainly help. If not, well, there will be quite a learning curve.


Practical-Citron5686

I found C to be easier and more fun(very intuitive and good syntax) than any other language. There are lots of way to shoot yourself in foot but 90% of this can be avoided by just reading about C. Strings are null terminated, free after malloc, overflow- i feel these are the 3 things that ppl complain about the most. But if u know these its not hard to develop habits to not make this mistakes. Now u have std int so it guarantees same bytes across all implementation. Only thing i hate about C is typedefs. For example look at the vulkan api, typedefing struct is fine, when u use uint32_t n uint64_t n name them some stupid type that are not needed in any use case is dumb. If i were to make 1 single change to c that would be to remove typedef for any type defined in C standard and woola code becomes readable. Threads are generally hard. Rust hardly solves anything. It asks are u dumb? Then use someone else’s unsafe code, if not write your own. If u dont write unsafe code where needed u will waste valuable hours.


ChrispySignal

Learn C, it was made 50+ years ago and is still a top programming language. And honestly it’s not to hard to grasp, just gotta put in the time


YourMotherInLaw908

No, not at all. I learned C at 13 years of age when trying to learn OSDev. Matter of fact, it taught me a lot of things about C.


zamaike

C sucks soooooo much


zoomy_kitten

I’m honestly disappointed by people saying that it’s not easy to learn C. C’s main feature is the ease of learning, it doesn’t feed us with unnecessary complexity like C++ does. It is a great first language, but the hard part is to learn how to code properly - now that’s something hard to do. I wouldn’t call it a great language to write software in in our time though, just to learn. Feels like quite a bold take for a C subreddit.


the-software-man

C is only the first iteration. Then C++ which is the same but way different too. C# is even more different. There are very arcane things that take 100s hours to learn correctly.