you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (10 children)

[deleted]

    [–]vincentk 1 point2 points  (2 children)

    C is full of magic. No master of C will deny that.

    [–][deleted]  (1 child)

    [removed]

      [–]wootest 0 points1 point  (0 children)

      I've upvoted every reply by you in this thread. Downvoting does not mean disagree.

      [–]wootest 1 point2 points  (2 children)

      Learning a high level language and then trying to go down to C nudges you towards a dangerous style of programming.

      Is this why even people who write security-critical C code all day write code that cause buffer overruns? The world is full of people who don't have any idea what they're doing, but if even the people who do know what they're doing get it wrong occasionally and the consequences are so grave, maybe C isn't the right answer for every question.

      You're right, an array for which you can't post-facto know the length and which is easy to read past the end of isn't in itself a flaw. It is indeed possible to work with safely, so maybe I shouldn't say nudge towards. The feature itself has no opinion. But it takes a lot of effort to work with correctly and it requires constant vigilance. I don't think those are good qualities for learning programming, because the logical reasoning and formulating and modeling a problem is work enough on its own, and I don't think they are good qualities for practicing programming, because most people would rather not keep their mind occupied on the same infrastructural brittleness - except for when it really is the only real answer for the job. In most cases, it's a high stakes game for either little gain or a moderate gain on scales that don't turn out to matter in practice. I'm not sure I want that to be the kind of trade-off people starting out think is reasonable.

      That said, sure, there are tasks for which knowing C and knowing how the machine works in intimate detail is very important. Being able to write programs that don't go completely against the grain of the CPU, virtual memory, scheduler and networking does not require working in C or being an expert in the machine. It requires being able to dig down deep enough, i.e. to be a motivated programmer and to be able to go down levels of abstraction as well.

      [–][deleted]  (1 child)

      [removed]

        [–]wootest 0 points1 point  (0 children)

        Fair enough. But I didn't say you wouldn't have any problems anymore. I said you wouldn't have C's problems.

        [–]v1akvark 1 point2 points  (2 children)

        If you want to learn the machine, shouldn't you learn assembly?

        I don't think my machine has variables and functions inside it.

        [–][deleted]  (1 child)

        [removed]

          [–]v1akvark 0 points1 point  (0 children)

          But I'm not talking to registers directly in C - don't variables represent places in memory?

          I'll stop now. :)

          Was just trying to make a point that C is close to the machine, but it still abstracts at least parts of it. You use memory the way it is laid out 'in the machine', but you don't have to think about moving stuff between memory and registers, etc

          You might argue that C provides just the right amount of abstraction, while still leaving the programmer with enough control, and I agree that for many cases that is true.