Slashdot Mirror


What's To Love About C?

First time accepted submitter edA-qa writes "Antiquated, clunky, and unsafe. Though beloved to some, C is a language that many choose to hate. The mass opinion is indeed so negative it's hard to believe that anybody would program anything in C. Yet they do. In fact a lot of things, even new things, are programmed in C. The standard was recently updated and the tools continue to evolve. While many are quick to dismiss the language it is in no danger of disappearing."

17 of 793 comments (clear)

  1. Re:because by Anonymous Coward · · Score: 5, Insightful

    Using a string literal as not const is very bad form.

  2. One good reason... by Anonymous Coward · · Score: 5, Insightful

    It's not the bloated obscenity that is C++.

    1. Re:One good reason... by AuMatar · · Score: 5, Insightful

      Value templates- yes, templating on the value, rather than the type. It's an extremely niche use case that causes difficult to read code and provides little in the way of benefits. I doubt even 5% of the user base knows it exists. Kill it.

      Diamond inheritance- it isn't used much, but when it is it's a problem. Because you don't know when the common base class will be initialized, or which constructor will be called by what values. Make it illegal to solve those problems (or add it to the specification)

      STL algorithms- sorry, totally disagree. The entire thing is a horrible hack based on using constructors to make quasi-first order functions. They were never meant to work like that. At best it's confusing, at worst it's unreadable and hard to debug. I bounce any code review I see using them. Worse, it encourages people to make more code like that, which tends to be done worse and be even more unreadable and frequently just wrong (generic programming has a lot of gotchas). I'd rather see the whole thing killed.

      Structs vs class- it is pretty harmless, but we're talking bloat. It's bloat. There's no reason to have both. I wouldn't say this is something that has to be fixed, but it's silly to have the two of them.

      Yup, I stand by my original opinion- all of these could be cut with no real loss to the language. Then again, if I were writing my own language I'd take C, add constructors, destructors, and C++ style syntax for member functions, add container classes, and call it perfect.

      --
      I still have more fans than freaks. WTF is wrong with you people?
  3. Maybe because it compiles down to the metal... by skids · · Score: 5, Insightful

    ...and not some VM? Most of the popular languages these days are all dynamic. And they are very convenient and nice. But if you actually want to know what the machine is actually doing, and want to have a say in such things, C is the way to go.

    I mean, unless you want to, you know, use pascal or fortran or something.

  4. Good habits by Bucky24 · · Score: 5, Insightful

    Personally the thing I like most about C is that it's not "safe". It doesn't take care of a lot of memory management for you and you can easily eat up all the memory or introduce a buffer overload vulnerability if you're not paying attention. It forces programmers to actually look at what they're doing and consider what it will do in the long run, and causes good coding habits to form. I think the majority of people who dismiss C as "too hard" are coming from Java programming. C gives you a lot of power, but, as the well-cliched saying goes, "with great power comes great responsibility".

    --
    All the world's a CPU, and all the men and women merely AI agents
    1. Re:Good habits by jmsp · · Score: 5, Insightful

      > It forces programmers to actually look at what they're doing

      OMG! There. That's where all the hate comes from.

      --
      (Programming in C since 1984)

    2. Re:Good habits by ShanghaiBill · · Score: 5, Insightful

      the C guys write better Java code than the Java guys write C code.

      My experience is that the C guys (and gals) often write better Java than the Java guys write Java.
      Programmers who have never written in C (and/or assembly) often have a poor understanding of how computer actually work.

  5. Control by Dan+East · · Score: 5, Insightful

    C offers control. If you can't handle having that much control (over memory, how the CPU acts on that memory, etc) then your software will have many problems and you will hate C.

    --
    Better known as 318230.
    1. Re:Control by jythie · · Score: 5, Insightful

      Not just control, but predictability. C does exactly what you tell it to do and you can see what it is doing more easily then other languages. You can tell C++ to do 'X', but it might slip in a 'Y' and 'Z' without telling you.

  6. The portable assembler by heson · · Score: 5, Insightful

    Close to the metal but still not specific to any machine if you do not need to. Easy to understand exactly what machinecode the compiler will produce.

  7. Think of it as standardized assembly programming by localman57 · · Score: 5, Insightful

    C is going to stay around for a long time in embedded systems. In this environment many microcontrollers still have 4k or less of RAM, and cost less than a postage stamp. In these systems there is virtually no abstraction. You write directly to hardware registers, and typically don't use any dynamically allocated memory. You use C because, assuming you understand the instruciton set, you can pretty much predict what assembly instructions it's going to generate and create very efficient code, without the hassle of writing assembly. Aditionally, your code is portable for unit testing or, to a lesser degree, other microcontrollers. This allows you to write a program that will run in 3.2 k of ram, rather than 4k, which allows a manufacturer to save 4 cents on the microcontroller they pick. This saves you $40,000 when you're making a million of something.

  8. Simple. by Short+Circuit · · Score: 5, Insightful

    Tons of people love to have something to hate. It might be because they don't like something about it...but I think it's mostly because people like to set up communities held together by rhetoric against a tool or technology perceived and portrayed as an enemy.

    "C++ sucks. We are at war with C++. We have always been at war with C++.[1]"

    Swap out "C++" for whatever language you like.

    Certainly there are going to be cases and scenarios where C is preferable over C++, where C++ is preferable over C, or where Brainfuck is preferable over either. Use the right tool for the right job,[2] and the right tool is whichever allows you to most effectively achieve your goals.

    [1] Or, at least since its inception. Or since [insert arbitrary date here].[3]
    [2] For whoever asks "what's the right job for Brainfuck?" ... just wait. Someone will eventually come along and get modded +2 Funny when they reply to you.
    [3] I see what you'll do there, Mr. Connor.

  9. Re:Useless submission. by Anonymous Coward · · Score: 5, Insightful

    If you're not a developer then you don't care about the nuances of C.

    Of course. Curiosity is a bad thing. You should stick to what you already know, and never try to expand your knowledge beyond your field.

  10. Negative opinions, says who? by fahrbot-bot · · Score: 5, Insightful

    Though beloved to some, C is a language that many choose to hate. The mass opinion is indeed so negative it's hard to believe that anybody would program anything in C.

    The masses to which you refer are idiots. C is great. It lets you do what you want, how you want. True, you're afforded enough programming rope to easily hang yourself, but you learn not to, and while most things can be more easily done in higher languages (you'll have to pry Perl from my dead, cold hands), many things can only be done in languages like C or its derivatives. C is one of those languages that separates the adults from the kids, so put on your big-boy pants, stop whinging about it and step up.

    --
    It must have been something you assimilated. . . .
  11. right tool for the job by bcrowell · · Score: 5, Insightful

    The mass opinion is indeed so negative it's hard to believe that anybody would program anything in C.

    Huh? What mass opinion? Where's the evidence for this?

    Pick the right tool for the job. C is the right tool for some jobs, specifically jobs like writing drivers or operating systems.

    Historically, C won by having an innovative syntax for pointers, which a lot of people liked, and it also won by being a small language that was easy to implement. Because it was small and easy to implement, it ended up being widely available. Ca. 1980, the joke was that C was like masturbation: it might not be what you really want, but it's always available. A lot of people in 2012 may not realize that in the era when C was winning popularity, people didn't usually have access to free compilers, and for many types of hardware (e.g., 8-bit desktops like the TRS-80), there simply weren't any good development tools. Another big win for C was that because it was so widely available, it became easy to find programmers who could code in it; it fed on its own success in a positive feedback loop. This is why languages like java had C-like syntax -- they wanted to ride the coattails of C.

    IMO the biggest problems have been when people started to use C for tasks for which it wasn't the right tool. It started creeping up into higher-level applications, where it wasn't really appropriate. This became particularly problematic with the rise of the internet. Networks used to be small and run by people with whom you had personal contact, so nobody really cared about the kind of buffer-overflow vulnerabilities that C is prone to. The attitude was that if you gave a program crazy input that caused it to crash, well, what was the big deal? You crashed the program, and you were only hurting yourself.

  12. Litmus test. by HornWumpus · · Score: 5, Insightful

    If you can't code in C you can't code.

    That said, unless you are doing low level/embedded work if you can't find a better tool for the job, you also can't code.

    C should be _every_ programmers second language at the latest.

    The other thing to love about C? Pointers! Pointers to pointers! etc. Coding without pointers might be safe, so is fapping.

    --
    John McAfee 'It was like that time I hired that Bangkok prostitute; to do my taxes, while I fucked my accountant'
  13. Re:because - by TwineLogic · · Score: 5, Insightful

    Oh, no, it's not a mystery. The animosity comes from ignorance and lack of ability. Many newer programmers have never programmed in assembly language or C, and would not be able to build a computer out of logic chips. This same demographic has learned Java and believes that Hashmap is a magic O(1) thing you can just smear onto any algorithm. C was initially popular among people who were, in fact, able to build computers out of 7400-series logic, or even transistors, if need be. In other words, the animosity comes from those who aren't qualified to judge.