5 ms·
C language is as simple as it gets. The only concept people struggle with is pointers, but even that is a very simple concept. Teaching something that is simple
by thecompilr 9y ago
C language is as simple as it gets. The only concept people struggle with is pointers, but even that is a very simple concept. Teaching something that is simpler than C to computer scientists will breed very poor engineers.
- CodesInChaos 9y agoC is a very tricky language, because a lot of constructs that work when naively translated to assembly (on common CPUs like x86 or ARM) are actually undefined behaviour.
- fpig 9y agoThis is always brought up when "difficulty" of C for teaching is discussed but it will basically never be an issue in a programming college course. It is a problem that doesn't exist.
- flafla2 9y agoI am currently a TA for 15-122 at Carnegie Mellon, the class that C0 was originally made for. I would argue that C0 does an excellent job at breeding good programmers because of the following features: 1. Contracts in C0 bake preconditions, post conditions, and loop invariants right into the language. Contracts are only checked when in "dynamic recompilation" mode (basically debug mode). This allows you to check the correctness of your code more easily (and, importantly, in an easily gradable way). 2. The language is designed in such a way to introduce C to programmers that are used to other higher level languages. In the C0 phase of the course we introduce students to fundamental concepts like memory allocation, code reasoning and contracts, binary representations of numbers, and unit testing. Next we transition to C1 (included in the C0 install) which introduces typedefs and other features of C. At this point we focus on introducing data structures. Finally we make the final transition to C, where we talk about undefined behavior, gcc, stack vs heap, etc. I've taken this course myself, and I would argue that this measured approach to learning C is far superior to throwing students (most of whom have no low-level programming experience) straight into C.
- grayhatter 9y agoI've replied here https://news.ycombinator.com/item?id=15500321 https://news.ycombinator.com/item?id=15500321 I think I mean to reply to you.
- networthless 9y agoSay hi to Isabella for me
- dasimon 9y agoWhile well-constructed C programs are as minimal and straightforward as programs come, the language is certainly full of pitfalls (just look at the underhanded C contest). Keep in mind that most computer science students in their first intro course have not yet developed the mental models that experienced programmers take for granted. Students will try doing all sorts of things which don't make much sense, and C is overly permissive of these things unless you introduce additional tooling, e.g. valgrind, which can become very overwhelming for intro-to-CS students who are still feeling lost. I agree that C0 on its own is overly simplistic, but the way it is used at CMU is as 'C with training wheels' - strict type checking, no potentially-unsafe pointers to the stack, dynamic array bounds checking, etc. Then, two thirds into the semester, students transition to real C, and learn how to correctly manage those potential pitfalls. This is how students at CMU have been learning C since 2010, and graduates don't seem to be any worse off for it.
- grayhatter 9y ago>... have been learning C since 2010, and graduates don't seem to be any worse off for it. [Citation needed] > C is overly permissive of these things unless you introduce additional tooling, e.g. valgrind, which can become very overwhelming for intro-to-CS students who are still feeling lost. Sure, but isn't the the POINT of college? To push you into unfamiliar territory? To force you out of your comfort zone, and then hand you the tools to learn something new? It may just be my arrogence speaking, having already taught myself C. But I taught myself C, when I had to fix a bug, I taught myself asan, and valgrind. None of that was very overwhelming. Complicated, very. Confusing, occasionally. But Once I learned them, they became easy, and intuitive, and helpful. I think the problem I have with your argument, is; when you apply it to math, the argument becomes painful. You don't want to learn algebra, it' too complicated; lets learn this subset of algebra, without irrational or imaginary numbers.
- ufo 9y agoI don't get the analogy. Every algebra course goes over the material in order of complexity. You don't go over real analysis until the students have mastered the basics. The problem with c is that the advanced things get in the way of the basics. You get students asking why their if statements didn't work and to answer you need to teach them GDB and valgrind and different compiler flags and how the stack works. This is a recipe for students that don't end up learning either thing. And it slows everything down so in the end of the year you can't cover everything properly and end up with mediocre C programmers you would never trust near a real C codebase --- Another thing to remember is that we should be very careful about that drill sergeant mentality that intro to CS should be hard and painful. This advantages students that had the opportunity to program before university and often ends up turning away women and other minorities from the field
- lou1306 9y agoI believe it is "simpler" in terms of formal semantics. Formalizing standard C is way harder (see https://github.com/kframework/c-semantics https://github.com/kframework/c-semantics). In fact, C0 is explicitly targeted at computer scientists rather than engineers.
- fenwick67 9y ago> C language is as simple as it gets Two types of files, compiler directives, pointers, malloc and friends, are you really sure about that? Any non-trivial C program will use these, on TOP of the basic syntax that first timers have to learn. There is a reason it is usually not taught as a first language, and Java, Python, C# or even Assembly are.
- grayhatter 9y agoYes, if you look at it from a C coders point of view. You know exactly what your program is doing (excluding compiler optimizations). Java is taught a lot, not because it's better. But because once you learn Java, all you know how to do, is teach Java. Python is taught early because it's fun/easy, not because it's the best. No one teaches ASM first anymore, what did you mean by saying asm is one of the first taught languages. (Maybe in some embedded systems, but generally that's not first, not by any reasonable definition.)
- ufo 9y ago> You know exactly what your program is doing I think thd more accurate sentence would be "know exactly what the computer is doing". Lots of languages have clear and simple semantics that let you understand what your program will do. This is not the case for C though. The only way to understand what a C program does is to have a very complete mental model of the low level computer architecture, memory layouts, call stack organization and so on (aka knowing what the computer does). That is actually lot to go through for a first introductory course (hence why they are making a restricted language to teach before jumping to full C)
- verall 9y agoThe Computer Engineering program at UT Austin teaches assembly (and architecture basics) for an academic RISC machine, then ARM assembly, and then C, in that order. So it's not no one, even if it's not as common anymore. It definitely makes C make more sense as an abstraction of asm. I believe the CS school starts on Java.
- 9y ago
- ci5er 9y ago> The only concept people struggle with is pointers Why is that? I've tried to explain pointers to people who struggle with the very small number of pointer-related concepts, and I ... fail. But I don't know why I am failing. These are not stupid people - and I speak the English language well enough - so those aren't the reasons...
- SeanDav 9y ago> "The only concept people struggle with is pointers, but even that is a very simple concept. " The concept of pointers is simple, but their implementation has all sorts of subtle layers: - interactions and apparent fungibility between pointers, arrays and strings - how about: ( * (void( * )())0)(); - what about: * (p++) vs ( * p)++ or "++ * p", "* p++" and "* ++p" (Quotes for display reasons only) - & vs * and various combinations of these - pointers to pointers - pointers to arrays of strings - pointers to allocated memory that is/are not in scope anymore. - Null pointer - Many others!
- eru 9y agoC only has a few parts, but their interaction is tricky. That relates also to C's lack of (non-leaking) abstractions. At the very least, you want something with friendlier behavior in the face of errors than what C gives you.
- eru 9y ago> The only concept people struggle with is pointers, but even that is a very simple concept. Recursion?
- maxxxxx 9y agoMaybe my brain is weird but I read Kernighan/Ritchie and had no problem grasping pointers. It's actually one of the simpler concepts compared to concurrency and others. But I know a lot of smart people who don't get pointers. I wonder if it's the teaching.
- camus2 9y agoC is not simple, C is language with a limited syntax and constructs which is not quite the same. Being proeficient in C means learning correct manual memory management, macros, an obtuse std lib, a compilation tool chain and management tools like Make, autotools and co. This is absolutely not simple. And don't get me started on string management with C.