Slashdot Mirror


How Relevant is C in 2014?

Nerval's Lobster writes: Many programming languages have come and gone since Dennis Ritchie devised C in 1972, and yet C has not only survived three major revisions, but continues to thrive. But aside from this incredible legacy, what keeps C atop the Tiobe Index? The number of jobs available for C programmers is not huge, and many of those also include C++ and Objective-C. On Reddit, the C community, while one of the ten most popular programming communities, is half the size of the C++ group. In a new column, David Bolton argues that C remains extremely relevant due to a number of factors including newer C compiler support, the Internet ("basically driven by C applications"), an immense amount of active software written in C that's still used, and its ease in learning. "Knowing C provides a handy insight into higher-level languages — C++, Objective-C, Perl, Python, Java, PHP, C#, D and Go all have block syntax that's derived from C." Do you agree?

39 of 641 comments (clear)

  1. Si. by Anonymous Coward · · Score: 5, Funny

    Si.

    1. Re:Si. by Anonymous Coward · · Score: 3, Funny

      I have gone out of my way to never use that letter. Notise that at first it kan be a bit diffikult but you get used to it.

    2. Re:Si. by Thiez · · Score: 3, Funny

      Said the Anonymous Coward...

    3. Re:Si. by cheesybagel · · Score: 3, Insightful

      Even if you mostly program in other languages eventually you need to interface with some system function or legacy library and you *will* need to use C.

    4. Re:Si. by jc42 · · Score: 3, Funny

      I have gone out of my way to never use that letter. Notise that at first it kan be a bit diffikult but you get used to it.

      In English, pretty much the only "real" use of 'c' rather than 's' or 'k' is in the digraph "ch", which represents a phoneme that has no other standard spelling. However, you kan replase it with "tsh", which produses the same phoneme bekause phonetikally "ch" really is just 't' + 'sh'. So with this tshoise of letters, you kan further approatsh the kommendable goal of replasing an utterly unnesessary English letter with a more phonetikally-korrekt ekwivalent. At the same time, we kan make kwik work of replasing that idiotik 'q' with a sensible replasement.

      (Kyue the Mark Twain kwotes on the topik. ;-)

      --
      Those who do study history are doomed to stand helplessly by while everyone else repeats it.
  2. Relevant C by smittyoneeach · · Score: 5, Funny

    Relevant C
    2B || !2B
    Either learn what you're doing
    Or stick to the Wii
    Burma Shave

    --
    Get thee glass eyes, and, like a scurvy politician, seem to see things thou dost not.--King Lear
    1. Re:Relevant C by BarbaraHudson · · Score: 4, Funny

      To "C" or not to "C", that is the question.
      Whether ’tis nobler in the mind to suffer
      The slings and arrows of java coders,
      Or to take arms against a sea of perl,
      And by opposing end them? To die(): To sleep()
      No more; and by die() to say we exit(),
      The heart-ache of the thousand malloc()s
      That c code is heir to, ’tis a consummation (of ram)
      Devoutly to be wish’d to die() when we forget to free(),
      To sleep(): perchance to dream(): ay, there’s the rub;
      For in that sleep() of die() what random() instructions may come
      When we have shuffled off other's poor performance,
      Must give us pause: there’s the respect That makes durability of so long C;
      Burma Shave
      For who would bear the whips and scorns of n00bs,
      The oppressor’s wrong, the proud man’s memory managed tools,

      --
      "Transparent" is a shit show that trades on every stereotype going. A man in drag is NOT a transsexual.
  3. Embedded Systems by Anonymous Coward · · Score: 4, Insightful

    Those widgets the clueless newspaper reporters and marketers call 'the internet of things', otherwise known as embedded systems, depends on Linux and C. So therefore C is 'the next big thing'.

    1. Re:Embedded Systems by jythie · · Score: 4, Interesting

      One of the big reasons C will probably not be going away any time soon is there is no replacement and not much work being done on one. The higher level languages, language designers are constantly trying to redo or replace, but there is not much interest in replacing such a low level language... and the people who do use C are not interested either since they tend not to be language fetishists.

    2. Re:Embedded Systems by Tom · · Score: 5, Insightful

      and the people who do use C are not interested either since they tend not to be language fetishists.

      This. Half of the newer high-level languages today are just the mental masturbations of someone who either thinks he can make the wheel more round or the result of a "not invented here" mindset. There's so much crap out there forking a perfectly good language because someone thinks it should be a =+ b; instead of a += b;

      It's sickening, and a good reason to stay away from all this shit, because five years down the road someone will fork the fork and you can throw all your code away because support and development just stops as all the ADD kids jump at the new toy. That'll never happen with your C code.

      --
      Assorted stuff I do sometimes: Lemuria.org
    3. Re:Embedded Systems by chuckinator · · Score: 4, Insightful

      I agree with PP and GP, but there's more to it than just that. Software is like an organ of your computer; your computer typically won't do much worthwhile if there's not a whole bunch of the things working together to make complete systems. Almost every one of the higher level languages are implemented in C at some point in the software stack. Some might argue that certain JVM languages like Scala and Groovy and Clojure are written in pure java, but guess what? The JVM is written in C. Almost every piece of software out in the wild is either written in C or depends on critical components written in C all the way down to the operating system. If you're running embedded, you might not have an OS, but you probably should be using C on microcontrollers and embedded systems unless there's a real good reason not to.

    4. Re:Embedded Systems by phantomfive · · Score: 3, Insightful

      It's sickening, and a good reason to stay away from all this shit, because five years down the road someone will fork the fork and you can throw all your code away because support and development just stops as all the ADD kids jump at the new toy. That'll never happen with your C code.

      This is one good reason I program in C.
      The other reason is portability. You can write something in C and it will run on every major platform and almost every embedded platform. Furthermore, it is portable between languages. If you write a library in C, people can call it from C#, Java, Python, TCL, Ruby, or nearly any other language. It is the lingua franca of programming.

      --
      "First they came for the slanderers and i said nothing."
  4. Very relevent for small target embedded stuff. by Ihlosi · · Score: 5, Informative

    C is the high-level language there. If you want actual control over your target, you'll need to use assembly.

    1. Re:Very relevent for small target embedded stuff. by aralin · · Score: 4, Informative

      The thing is, if you use structures with bit fields, C will not optimize the manipulations with them correctly. So you end up doing a lot of hand-holding in driver development in C. You have to be very much aware of the code being produced. It is not uncommon that you check specific inner loop sections to see exactly how they are being compiled and then based on the result and number of instructions might need to rewrite the C part or even just insert the assembly code directly.

      --
      If programs would be read like poetry, most programmers would be Vogons.
    2. Re:Very relevent for small target embedded stuff. by mean+pun · · Score: 4, Insightful

      .. or at least people who think they are clever. Occasionally they are right.

    3. Re:Very relevent for small target embedded stuff. by jareth-0205 · · Score: 3, Funny

      C is the high-level language there. If you want actual control over your target, you'll need to use assembly.

      Luxury! You trust a compiler? When I were a lad we inputted the hex codes directly.
      /
      Well of course we had it tough... tape and a magnetised pin was all we needed.
      /
      You kids don't know you were born... we used to program using a cigarette end to burn holes in the punch cards.
      /
      etc...

    4. Re:Very relevent for small target embedded stuff. by TheRaven64 · · Score: 4, Insightful

      The clever people use C when C is the right tool for the job and use something else when it isn't. The rest use C, Python, or whatever else their favourite language is, irrespective of whether it's the right tool.

      --
      I am TheRaven on Soylent News
  5. C had no real successor by Anonymous Coward · · Score: 3, Informative

    Is there another OS/system programming language that is universally accepted as a reference, rather simple to learn, available on virtually any OS, real fast? I mean, go is nice and multi platform and powerful, but it is not even close to C popularity.

    C++ should have been C successor, but it is too complex to be.

  6. Re:C is very relevant in 2014, by gsslay · · Score: 5, Interesting

    It's like when you drunk drive and think you're just fine.

    Well the problem there is you're drunk, not that you can drive. C is a great language, and it gives its programmers a great deal of power and flexibility. But with that comes responsibility not to code like an idiot. If you're going to wield its power carelessly, of course you're a danger.

    Perhaps C's greatest weakness is that it places too much trust in the coder, where other languages don't.

  7. Re:C is very relevant in 2014, by Viol8 · · Score: 4, Interesting

    If its too dangerous for humans, who do you think is going to write all the compiler/interpreter and low level OS interfaces of whatever alternative language of your choice is? At some point someone has to get their hands dirty down at the metal whether its in C or assembler. If you're not up to that then fine, but please spare us the poor workman blaming his tools excuse.

  8. Libraries by heikkile · · Score: 5, Informative

    If you write a good useful library in C, it can be used from almost any other language, with little effort. If you write your library in any other language, you limit its use to a handful of related languages. Also, properly written C can be very portable to a wide variety of systems.

    --

    In Murphy We Turst

  9. Re:C is very relevant in 2014, by TheRaven64 · · Score: 5, Interesting
    There are good reasons and bad reasons why C is still popular.

    The main good reasons is the small footprint. I was recently given an ARM Cortex M3 prototyping board to play with. This is a pretty high-end part by IoT standards, but has 128KB of RAM and 512KB of flash for code and data storage. It's programmed using C++, but unless you stick to a very restrictive subset of C++ that's almost C, then you'll end up generating too much code (C++ templates are not just a good way of blowing away your i-cache on high-end systems, they're also a good way of blowing away your total code storage on embedded chips).

    The other good reason is that it makes it relatively easy to have fine control. Not quite as easy as you'd want. To give one example, the JavaScriptCore interpreter and baseline JIT were rewritten from C++ into macro assembler a couple of years back because C and C++ don't give you fine-grained control over stack layout. To give another example, some game devs were recently complaining on the LLVM list that their hand-optimised memcpy implementations were being turned into memcpy library calls, because they assume that they're using a macro assembler when they write C, and not a language with a complex optimising compiler behind it. It does, however, give you flow control primitives that make it easy to reason about performance and fine-grained control over memory layout. These are particularly valuable in certain contexts, for example when implementing higher-level languages.

    The biggest bad reason for C being popular is that we've standardised on C as the way of defining library APIs in UNIX-land. There's no IDL that describes higher-level concepts, there are just C headers, and the language that makes it easiest to use C libraries wins. There has been some improvement in C-calling FFIs recently, and a big part of the popularity of Python is the ease with which you can use C/C++ libraries from it. Even simple things are hard when interoperating with C. It's hard for an FFI generator to know whether that char * parameter is a null-terminated string or a pointer to an arbitrary block of memory that's going to be read by the callee, a pointer to a single char that's going to be written back, or whether the callee returns a pointer to within the block and needs the original memory to persist. Lots of libraries take function pointers that have a void* context pointer, so can be mapped to closures in the caller's language, but they all put the context object in different places so you need a custom trampoline for each one.

    With over 8 billion lines of open source C code (source: OpenHub.net), there's a good chance that the library that you want to use is written in C.

    --
    I am TheRaven on Soylent News
  10. Re:C++ is C by luis_a_espinal · · Score: 4, Informative

    I was and still am a pretty accomplished C prorammer, and can find my way in assembly. Then C++ came along and everybody seemed to jump on that bandwagon. I couldn't and many of my collegues either. When you have progressed to far along the procedural path, it seems to be impossible to wrap your head around the object oriented paradigma. That is why I also never got into Java.

    Paai

    You need to progress through modular programming and abstract data types. Then OO makes a lot of sense. Well written, highly modular C code with good abstractions tends to resemble well-written C++ without operator overloading in my experience.

    Hell, well-written modular programming resembles well-written OO programming (since the later can be seen as a natural extension... or conclusion of the former.) Well-written procedural code must exhibit characteristics of modular programming.

    What happens with C++ (specially at the beginning of its development) is that everybody tended to use every single goddamend feature, abusing operator overloading (and later templates). So C++ became "equivalent" to "overloading gotcha and magic-behind-the-curtains" soup smeared over a tangle of classes in an inheritance tree from hell (in many ways, not dissimilar from Java at the beginning with its own gotchas.).

    One can program clean C++ with very simple semantics, using operators to the bare minimum, using templates judiciously, knowing when to use virtual and always implementing the big three (default constructor, copy constructor and = operator.)

    If you can modularize your procedural code and how to layer your abstractions, then you know how to split your code into modules and classes. You know how to encapsulate and delegate responsibilities. That is key for developing cleanly in C++ (or Java or C#... or in any language for that matter.)

  11. Here be monsters by luis_a_espinal · · Score: 3, Insightful

    C++ is C

    I used to believe in this until I had to work on both. Although one can compile best-practice C with a C++ compiler (sans the gotchas), that glosses over the idiosyncrasies of each language. C does not have initializers as in C++.

    More importantly, it does not have references, type-safe casting operators and its template language is not turing complete as in C++. These differences will never go away, and these differences alter completely the type of design and implementation of your code and your abstractions.

    Not to mention the C++ rules of PODs versus everything else which affect how we link C code with C++ code (and viceversa.) And modern C++ heavily uses templates in manner that makes the language resemble something else entirely. Whether that is a good thing is highly subjective, but whatever.

    So from a practical point of view, it is sane to treat both languages as fundamentally different.

    When we program in a language (be it Ruby, Java, C or C++ or whatever), we ought to do so in the idiomatic way that naturally exploits the best capabilities of the language. So with that in mind, we cannot treat C and C++ as the same language (and it is not quite accurate to compare modern C++ as a superset of the former, regardless of historical evolution.)

    I do believe, however, that is very important, if not fundamental, to understand C semantics to use C++ effectively. The fundamental semantics behind the primitive types and control structures remain more or less the same. And I've always found that C++ programmers without a good background in C tend to make certain mistakes when they need to operate with pointers (since they are so used to work with references.)

    Furthermore, integration of C with C++ is not an uncommon task, and development of C++ code with that in mind is paramount. It is very hard to do that without a good understanding of C.

  12. Re:First post by NoNonAlphaCharsHere · · Score: 5, Funny

    We're talking about C. You want the zeroeth post.

  13. Re:C is very relevant in 2014, by petermgreen · · Score: 3, Informative

    I would argue that it is better to learn to write decent code than to let the language protect you from the effects of bad code.

    I would argue that there is a middle ground. C++ still lets you do the low level stuff when you need to but also provides higher level structures that when used responsiblly make code clearer and less error prone.

    --
    note: i'm known as plugwash most places but i screwd up registering that here somehow in the past and now can't register
  14. Re:The third worst thing to happen computer histor by whimdot · · Score: 3, Insightful

    I have written embedded Pascal. Never ask me to do it again.

  15. Re:C is very relevant in 2014, by juanfgs · · Score: 5, Funny

    . As a long time C hack (still am) I concur.

    Behold. A C program that has gained sentience.

  16. Re:You don't know C++ properly until you know C by jeremyp · · Score: 3, Informative

    " don't really seem to understand the difference between pointers and C arrays"

    Well, because there isn't one at the language level. The array syntax using square brackets is only a syntactic sugar for pointer arithmetic, nothing more.

    There is a difference between an array and a pointer.

    char a[100];
    char* b;

    b = a; // Fine
    a = b; // Not fine.

    If you read the standard, the language used is that, in an expression, an array "decays" to a pointer with the rule being that you get a pointer to the array's first element. The "array is not a pointer" rule is further demonstrated by passing an array to sizeof (as viol8 points out).

    --
    All I want is a secure system where it's easy to do anything I want. Is that too much to ask ~~ Randall Munroe
  17. Re:C is primordial by rioki · · Score: 4, Insightful

    Ok I will bite. Now I don't claim that C is on the same level than ASM, but you need to compare it to current languages. Languages like Python or JavaScript, they abstract out almost everything about the machine you are running them on. With C you program against a reasonably close abstraction of the real machine. In many cases you can hand compile the C code to ASM.

    Take for example the JS expression $("a").addClass("blue"). This expression written in C would take up something around 100 lines of code, simply because the machine you program against does not understand high level concepts. Even simple concepts like a string are not understood by C.

    I love programming in C, but in whole ecosystem of languages it is on the low end.

  18. Re:Very much so! by Rei · · Score: 3, Insightful

    I have issues with that notion, though. There's this popular perception among hardcore C programmers that C++ is "C with objects", and since they don't like or don't feel the need to do object-oriented programming, it's pointless for them. But C++ is a thousand times more than "C with objects". And even when it comes to objects, the most important ones aren't the ones you make yourself, but STL. Especially with the latest versions of C++. I just recently had to downgrade a simple app from C++11 to C++03 to support old compilers, and my god, I had forgotten what a royal pain pthreads are versus std::thread with a lambda argument. And if I had been forced to go all the way down to C, and thus would lose the std::list that simplified holding the threads' arguments. It would have been a page or two of code for what's a single line in C++11. And with far greater proclivity for bugs.

    I once was one of those "hardcore C programmers" who just saw C++ as "C with objects", and deliberately avoided using it and learning any more than I had to. But the more I learned, the more I came to appreciate it. I do of course make and use my own objects... but that's not really the most important aspect of the language. It's all of the countless features to automatically manage memory, data structures, ensure program correctness, and vastly reduce pointless verbosity that make C++ so important.

    --
    "We consider that six courts and an asylum claim are a rather odd way of returning to Sweden within a month."
  19. Re:First post by Letophoro · · Score: 5, Funny

    We're talking about C. You want the zeroeth post.

    You have to remember, there are two kinds of people in the world:
    1) Those who begin their indexes at 1.
    -and-
    1) Those who begin their indexes at 0.

  20. Re:C is very relevant in 2014, by gweihir · · Score: 4, Insightful

    C is not a tool for the incompetent (whether temporary due to alcohol or permanently). It is an expert-only tool. There are a few of those around and they will stay around, because in the hands of somebody skilled, these tools deliver exceptional results that no more generally usable tool can match.

    --
    Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
  21. Re:C is very relevant in 2014, by codewarren · · Score: 3, Interesting

    Actually this is false. It is possible to write a language that is both safe* and compiles itself.

    If you're not up to that then fine, but please spare us the poor workman blaming his tools excuse

    I can cut a straight line with a circular saw without using a guide or a guard, but I can do it a hell of a lot quicker with a guide to rest against and a guard to keep me from having to constantly check my fingers and chords etc. These things weren't invented because of bad workman, but because they make good workman better. Not everyone who notices that there may be better tools out there than C for the very things that C is used for is a workman blaming his tools.

    Someone eventually needs to write the rules for translating the higher level language down to lower levels, but this isn't the same as "getting their hands dirty down to the metal" in the same way that you've implied because it can be done in tiny self-contained, small chunks following yet more rules and rigorously like a mathematical proof and therefore not be subject to the same pitfalls as languages like C. It also only has to be done once (per processor) but then the safety is ongoing.

    This layering is just modular design and separation of concern. Look at IR in the LLVM project which has allowed an explosion of languages that can enjoy most of the same compiler optimizations that the C family enjoy using this principle.

    (btw, the Rust project is very interesting in this subject)

    * Of course, the term "safe" has a limited meaning. A compiler can't read your mind but, to the extent that a language is well designed, it can prevent you from doing things that you could not have intended to do and force you to follow rules that will never allow certain common errors that result from people having limited memory.

  22. Re:Very much so! by jlar · · Score: 4, Insightful

    But C++ is a thousand times more than "C with objects".

    I believe the above quote speaks for itself...

  23. It all goes back to ALGOL by Ottibus · · Score: 3, Informative

    "C++, Objective-C, Perl, Python, Java, PHP, C#, D and Go all have block syntax that's derived from C"

    And C got the block syntax from B which got it from BCPL which was a simplified version of CPL which was influnced by the first block structured language, ALGOL.

    I was taugh ALGOL at University, though I had already been "mentally mutilated beyond hope of regeneration" by BASIC before that...

  24. Re:Very much so! by Bent+Spoke · · Score: 3, Insightful

    This may be true for new code, but when maintaining C++ code written by others, not so much. Everyone has a different set of "features they like".

  25. Re:C is very relevant in 2014, by mrchaotica · · Score: 3, Funny

    C gives you a gun with which you can shoot yourself in the foot. C++ gives you the gun too, but at least it's got a safety on it that you have to disable.

    No, no, no, you got the saying all wrong! Here's how it goes:

    In C, you shoot yourself in the foot.

    In C++, you accidentally create a dozen instances of yourself and shoot them all in the foot. Providing emergency medical care is impossible since you can't tell which are bitwise copies and which are just pointing at others and saying, "That's me over there."

    Or alternatively,

    C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off. -- Bjarne Stroustrup

    --

    "[Regarding the 'cloud,'] ownership was what made America different than Russia." -- Woz

  26. Re:Very much so! by iMadeGhostzilla · · Score: 4, Interesting

    The downside of C++, is you can't look at the code and know what happens at the machine level. Joel Spolsky describes it below: (in an article on variable naming)

    "In general, I have to admit that I’m a little bit scared of language features that hide things. When you see the code

            i = j * 5;

      in C you know, at least, that j is being multiplied by five and the results stored in i.

    But if you see that same snippet of code in C++, you don’t know anything. Nothing. The only way to know what’s really happening in C++ is to find out what types i and j are, something which might be declared somewhere altogether else. That’s because j might be of a type that has operator* overloaded and it does something terribly witty when you try to multiply it. And i might be of a type that has operator= overloaded, and the types might not be compatible so an automatic type coercion function might end up being called. And the only way to find out is not only to check the type of the variables, but to find the code that implements that type, and God help you if there’s inheritance somewhere, because now you have to traipse all the way up the class hierarchy all by yourself trying to find where that code really is, and if there’s polymorphism somewhere, you’re really in trouble because it’s not enough to know what type i and j are declared, you have to know what type they are right now, which might involve inspecting an arbitrary amount of code and you can never really be sure if you’ve looked everywhere thanks to the halting problem (phew!).

    When you see i=j*5 in C++ you are really on your own, bubby, and that, in my mind, reduces the ability to detect possible problems just by looking at code."

    My opinion is, for code that lives closer to the OS (or the OS itself), where there are fewer lines of code but which run more frequently, C is king. For code that needs to multiply/grow/combine/evolve faster and still run fast, C++ is often a better choice.