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?

641 comments

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

    Si.

    1. Re:Si. by alex67500 · · Score: 1

      Why, very relevant! I use the C. word almost daily!

    2. 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.

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

      Said the Anonymous Coward...

    4. Re:Si. by Anonymous Coward · · Score: 0

      Were you attaked by a bat?

    5. 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.

    6. Re:Si. by Gr8Apes · · Score: 1

      Untrue, if you program in assembly.

      --
      The cesspool just got a check and balance.
    7. Re:Si. by motorhead · · Score: 0

      What a silly bunt.

      --
      Employee Of the Month - Cyberdyne Systems Corporation - September 1997
    8. Re:Si. by Anonymous Coward · · Score: 0

      Oh, say! can you C?

    9. Re:Si. by hermitdev · · Score: 2

      Or a library written in another language, in which case C, or more exactly, the ABI (usually dictated by your C runtime of choise), is the common dialect.

    10. Re: Si. by jimmetry · · Score: 0

      still needed C when I wanted math.h on the coprocessor of a Motorola HS12...

    11. 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.
    12. Re:Si. by Anonymous Coward · · Score: 0

      Exactly!

      You never see C++ libraries.

      What you see are X-language-of-choice wrapping a C library.

      For all intents, Javascript is the only useful scripting language (since it can be used client(web browser) and server side (Node.js)), everything else (eg perl, python, ruby, php, etc) tends to only be useful in a server context. C++ and OBJC are used when C just isn't flexible enough. That's why some people decry OOP as being sloppy and inefficient.

      If it takes 10 instructions to do the same thing as 1 instruction in C, the language is a failure. C++ makes sense at a higher level, but not low level things that it's often highly inappropriate to use for. For example. Linux Kernel should be C. It needs to be portable and compile on as many things as possible, and not be subject to OOP styles of thinking.

    13. Re:Si. by Anonymous Coward · · Score: 0

      "ch" is not a digraph. It is a diphthong.

    14. Re:Si. by jc42 · · Score: 2

      "ch" is not a digraph. It is a diphthong.

      Well, I'd disagree. It certainly is a digraph, since all that means is that it's two letters that together represent a sound or sounds different from the usual sounds represented by each letter. Since 'c' rarely represents /t/ in English, and 'h' rarely represents what we usually write as 'sh', the sequence 'ch' represents a sound different from "tsh", and thus satisfies the definition of "digraph".

      As for diphthong, I can see how one might stretch the term to cover it, but it's a real stretch. The term "diphthong" normally means a sequence of two sounds, typically a sequence that acts like a phoneme in the language. "ch" sorta does this, but the stretchiness comes from the fact that neither of those two sounds are usually represented by 'c' or 'h'. We accept "i" as a diphthong in words like "I" or "time", but it's partly because the phoneme /i/ is one of its two sounds; the initial /a/ is simply not written. Similarly, a "long O" in English typically means an /ou/ or /ow/ sequence, and again the main use of 'o' is included (but the second sound isn't written). The spelling "tsh" would qualify as a trigraph for the main "ch" sound in English, and with that spelling, it would represent a diphthong. But for "ch", it doesn't quite work. It's really an example of the other use of the letter 'h', meaning "a sound sorta like the previous letter's sound, but somewhat different. But this doesn't work, either, because what's the normal sound of 'c'? It's usual either /s/ or /k/, not /t/.

      But my main objection is that, in a sense, we're both wrong. English spelling is insane and perverse, and no attempts to apply precise meanings to any written sequence can really be correct. If English had had spelling reforms like all the other European languages have had over the past couple of centuries, we could make meaningful statements about spelling. But this never happened, and any attempt to tie spelling to pronunciation in English is bound to merely make one look foolish. We're not only OT in this thread, but we're arguing about something that can never be analyzed sensibly in English.

      My favorite suggestion re this situation (and I've forgotten who first suggested it) is that, since English has become much of the world's de facto international language, the roughly 95% who aren't native speakers should gang up on the English-speaking minority. An international conference for revising English spelling should be formed, or perhaps now it should be an organization built around a web site. That organization should work out a reasonable phonetic writing system for English. The supporting nations should declare that writing system to be their standard for English, with software to transliterate between it and the various "standard" English spellings used by native speakers in different countries. With time, they could overpower the insanity of current English spelling.

      But it's clear that this ain't gonna happen any time soon.

      (As a native speaker of English, I'd support such an effort. So if some victims of their English-as-a-second-language class want to organize it, I'd be willing to lend at least my moral support. But as a native speaker of English, I'm probably not qualified to organize it. ;-)

      --
      Those who do study history are doomed to stand helplessly by while everyone else repeats it.
    15. Re: Si. by Anonymous Coward · · Score: 0

      Esta es una de las mejores respuestas que he enkontrado en muxo tiempo... Todo lo que se de programasion lo hice en se... Me alegra saber que todavÃa està en el primer lugar

    16. Re:Si. by Anonymous Coward · · Score: 0

      You silly bunt.

    17. Re:Si. by K.+S.+Kyosuke · · Score: 1

      As for diphthong, I can see how one might stretch the term to cover it, but it's a real stretch.

      Wait, how could "ch" be in any remote way a diphthong if there's no vowel involved?

      --
      Ezekiel 23:20
    18. Re:Si. by K.+S.+Kyosuke · · Score: 1

      Well, technically, you only need to use a C interface, not C as a language.

      --
      Ezekiel 23:20
  2. Very much so! by Anonymous Coward · · Score: 1

    Because not too much in C++ makes a whole lot of sense if you don't know where it's coming from. Every programmer should know how C++ features are/were/and can be mapped to plain C and what implications this might have for run time behavior and errors.

    1. Re:Very much so! by Anonymous Coward · · Score: 0

      When I studied CS, we first learned C. Then we studied OOD&P. Then we implemented OOD&P in C. And after we've done that, we were given C++.

    2. 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."
    3. Re:Very much so! by jejones · · Score: 1

      The key word: "countless".

    4. Re:Very much so! by Rei · · Score: 1

      Nobody said you have to learn everything - its not like C++ is all-or-nothing. It's precisely the opposite, it's a grab-bag of tools and you can use whichever ones you want. But you should at least learn the ones that apply to what you're doing. Using strings? Learn std::string. Using a variable-length array? Learn std::vector or similar. Using smart pointers? Learn std::shared_ptr. Just learn the part that applies to whatever you're using, it's just RTFM. There's only a few basic concepts you'll need to understand.

      --
      "We consider that six courts and an asylum claim are a rather odd way of returning to Sweden within a month."
    5. 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...

    6. 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".

    7. Re:Very much so! by Rei · · Score: 1

      To a degree, but the vast majority of what you'll see only requires understanding a few concepts over basic C (objects, iterators, templates, etc), the rest is no more RTFM than what you'd see from any C library. C++11 introduces a few concepts (lambdas, for example), but again, the vast majority of the new stuff is no more RTFM than any old C library. You see someone use a... oh, let's say std::shared_ptr, and you don't have any experience with it? You just look up, the same as you'd do if you saw someone using a C package that you weren't familiar with - say, if you read code and someone was using a FcMatrix and you'd never programmed with Fontconfig.

      --
      "We consider that six courts and an asylum claim are a rather odd way of returning to Sweden within a month."
    8. Re:Very much so! by Gr8Apes · · Score: 2

      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.

      The STL.... the thing that drove me from C++ in the first place with its horrible non-portable implementations due to non-standardized name-munging amongst different compilers. (Note: I'm sure this situation improved from the date(s) I'm referencing, but even the thought of the STL brings back old nightmares)

      And my most recent forays with C/C++ were thankfully STL free, as it was mostly straight C code, or merely linking into C code.

      --
      The cesspool just got a check and balance.
    9. 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.

    10. Re:Very much so! by Anonymous Coward · · Score: 0

      You have to learn everything.

      There, I said it. Where is your god now?

    11. Re:Very much so! by FrankDrebin · · Score: 1

      I for one much prefer good-ole printf and friends to std::iostream with its overloaded operators and finicky formatting manipulators. But in order to make such choices, you do have to learn the newfangled stuff to a certain level, in order to properly assess it.

      --
      Anybody want a peanut?
    12. Re:Very much so! by Rei · · Score: 1

      You don't have to learn anything to keep using printf in C++. Why would you think that you did?

      --
      "We consider that six courts and an asylum claim are a rather odd way of returning to Sweden within a month."
    13. Re: Very much so! by Fwipp · · Score: 2

      And the solution to that isn't to ditch the language - you just reject code that does obtuse and sneaky things in your project. If multiplication of your objects doesn't make sense, then why on earth would you overload the * operator?

      Even though a[i] and i[a] are the same thing in C (well, except for making the compiler's job harder), you shouldn't use them interchangeably in your code.

      You shouldn't judge a language simply because it allows obfuscation. You should judge your coworkers for writing obtuse code.

    14. Re:Very much so! by hermitdev · · Score: 1

      I think it's more a function of what people "know" than "like". I also think this is true regardless of the language/tool set used. It is also usually an indicator of the developer's experience. A junior dev is far more likely than a senior to have a need for something and reinvent the wheel out of ignorance of available options rather than a justified reason to do so.

    15. Re:Very much so! by hermitdev · · Score: 1

      iostreams are a bit ugly, but at least they're type-safe. iostreams also have the added benefit of operator overloading, allowing types to format themselves. You can't do that with printf - you'd at a minimum have to have an extra string buffer to defer to a type to format itself to then pass to a printf for additional formatting.

    16. Re:Very much so! by hermitdev · · Score: 1

      Name mangling is not standardized, still, and it probably never will be unless there is a formalized ABI. It sounds like you were using STL from pre-standard days. Even post standardization, it took all of the compiler vendors to catch up. The landscape is a lot better now. In particular it's been great to see the effort MS has put into becoming standards compliant and treating C++ as a first-class citizen on Windows instead of the ugly step child locked in the attic because they can't kill it.

    17. Re: Very much so! by iMadeGhostzilla · · Score: 2

      No one says it was you who overloaded the operator. You may be looking at code someone else in your team wrote, or an ex co-worker, or an open source contributor -- and it could be even you and don't remember it. The point is, the reality is if you are given code to work with and you see i = j * 5, if it's C you know what it does; if it's C++, you don't, regardless of who wrote it.

      I think the danger of that happening for low level, frequent-running, system code outweighs the flexibility that C++ gives you, and vice versa for app code.

    18. Re: Very much so! by petermgreen · · Score: 2

      If multiplication of your objects doesn't make sense, then why on earth would you overload the * operator?

      If bit shifting your object doesn't make sense then why on earth would you overload the << operator

      I can't really make up my mind on operator overloading. On the one hand it can make custom types far more pleasant to use. On the other hand because operators are more concise than function calls and you can't add new ones it's very tempting to abuse operators to mean something other than their original meaning. Heck it's so tempting that even the authors of the standard library did it.

      --
      note: i'm known as plugwash most places but i screwd up registering that here somehow in the past and now can't register
    19. Re:Very much so! by Gr8Apes · · Score: 1

      That's truly disappointing to hear. Hopefully it's no longer link order dependent as well? The only thing I can say that was a positive out of the 3 months spent tracking down why something worked in all test cases but sporadically failed for the full models on SGI machines was I learned to read compiler output (subsequently mostly forgotten for C anyways) The fact that it took days to validate small models on PCs and IBM boxes which wound up giving alternate results, depending upon which compilers were used added to the problem. Turned out that different limit lengths per compiler of pointer descriptors truncated the name, and when the name mangling exceeded the compiler/linker output, you got some interesting results out of your pointers, like the next object in the array instead of the one you were expecting, or perhaps some random area in memory, since the apps were not restricted in those days.

      --
      The cesspool just got a check and balance.
    20. Re:Very much so! by Anonymous Coward · · Score: 0

      To be fair, I'm not sure my advice on someone using smart pointers would be to learn std::shared_ptr. I'd be more likely to tell them to use unique_ptr and pass references or the raw pointer around the rest of the time, and if ownership has to be transferred then to move it. It keeps ownership very clearly defined. I'd try and avoid telling them that shared_ptr exists. (I'd definitely avoid telling them that auto_ptr exists.)

    21. Re:Very much so! by Josef+Meixner · · Score: 1

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

      Oh, really?

      unsigned short i;
      double j;

      j = -1.0;

      So where does this code store the value of j multiplied by five? How do I not have to know, what types I use. Also what about stuff like: #define j call_expensive_function()

      Sorry, but the idea, that you can tell from a line of C what is happening is wrong. It is not as complex as C and often the likely result is correct, but there is nothing in the language which precludes very stupid code.

    22. Re: Very much so! by Anonymous Coward · · Score: 0

      You are so correct.

      I mean making * operator do something weird and unrelated would be as stupid as, I don't know, overloading left bit shift of a file object into writing into a file. That would be hilarious!

      output_stream 2;

      Look at that, it might left shift something or it might write into a file!

      Thank god there are no languages where the basic design is that and even encourages insane operator overloading.

    23. Re:Very much so! by BenSchuarmer · · Score: 1

      That's backwards. If you know the syntax, "C++" means increment C, but use the original C.

      If you're using C++ for anything other than writing procedural programs, you're violating the basic principles of C syntax.

    24. Re: Very much so! by Fwipp · · Score: 1

      Because it's, like, the first thing you learn when learning C++.

      Any time you see `std::cout "string";` you'll know exactly what's going on. This is a case where standardized operator overloading improves readability, because it's standardized and near-universal. The one-time cost of learning this convention is outweighed by the ongoing improvements in composibility & comprehensibility.

      Similarly, if you're working in a very large project, it may make sense to overload the operators for very common operations done with your common objects. Again, the standardization is what's important. If convention is to use `foo * bar` to mean "transmogrify the user foo with the list of magicians bar," and it's a pattern that appears over and over again in your project; every developer on your team is going to be aware of the convention, and after your first week working there, it will no longer be surprising.

      Again, the case to be made isn't "Language X has feature Y, which can be abused so let's not use X" - rather, you should say "We won't use feature Y" (with possible exceptions on a case-by-case basis).

      I don't love C++. When I have to use it, I write "C with objects," and I know I'm limiting myself quite a bit there. But rejecting a language because it allows you to aim the gun at your foot is silly. That's what code-review is for! If a pull-request is confusing, don't merge it! If a new coworker is doing confusing shit, just talk with them about why your team doesn't code that way.

    25. Re: Very much so! by Fwipp · · Score: 1

      UGH slashdot, eating my angle brackets.
      Should be `std::cout << "string";` of course.

    26. Re: Very much so! by serviscope_minor · · Score: 1

      So much bullshit.

      In C if you see code written as:

      assign(i, multiply(j, 5));

      you have equally fuck all idea what it does. In C++,

      i=j*5 means this:

      i.operator=(operator*(j, 5));

      If you don't read i=j*5 as the above then you're incompetent at C++ and just crying because it's not identical to C.

      I think the danger of that happening for low level, frequent-running, system code outweighs the flexibility that C++ gives you, and vice versa for app code.

      Premaure optimization is the root of all evil.

      --
      SJW n. One who posts facts.
    27. Re: Very much so! by KenHansen · · Score: 1

      But in order to make such choices

      He was talking about making a choice...

    28. Re:Very much so! by david_thornley · · Score: 1

      That's only a problem with crap software. Fortunately, C is always readable, and you always know what it's doing.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    29. Re:Very much so! by iMadeGhostzilla · · Score: 1

      The "i = j * 5" example is meant to cover reasonable cases, not to take it to the extreme. Of course you can do all kinds of obfuscations in both C and C++. The point is that in a well-meaning, reasonably competent team, C++ coders often out of best intentions overload operators and do other things that obscure your understanding of what is actually happening. You will have to either assume/hope that the code doesn't have side effects you're not aware of, or you'll have to go and check elsewhere, which interrupts your flow of reading and understanding the code. With C, in a team of the same quality, you don't need to do that -- what you see is what you get. What I'm saying is under normal conditions, your confidence in knowing what happens is higher when looking at C than at C++ code, and the more critical the code is, the more important your level of confidence in it is.

    30. Re: Very much so! by Rei · · Score: 1

      Premature optimization is the root of all evil

      Quite true. It's usually novice programmers who are obsessed with trying to optimize every line and produce code that's a damned mess, impossible to maintain, and usually not actually that fast. There's an old joke:

      First rule of optimization: Don't.
      Second rule of optimization (experts only!): Don't yet.

      That is, of course, tongue in cheek. Optimization is often important. But trying to optimize every line is an idiot's approach that leads to terrible programs. A person who knows anything writes nice clean code, then runs it through a profiler to see where it's actually wasting time. Then they optimize the heck out of it - but not with stupid stuff like hand-inling functions and unrolling loops, but first off, from a left-brain structural approach. How can the program be changed that reduces how often this loop gets run? Is there a different algorithm that makes better sense here? Then they learn in extreme detail what is actually going on in the compiler and what tools are at their disposal. Could I stick a "restrict" keyword here? If I reduce the size of this array will I get more cache hits? Should I thread this function? Etc. Then they progress down further. Are there math approximation functions I could use here? Could I use a call that calculates multiple values at a time if I group together these data elements? Etc. And then only in the most extreme case do you go all the way down to actual assembly. But by that point, you should already have a pretty good idea of what the assembly is going to look like.

      But whatever you do, you just don't just jump in and start doing this sort of stuff everywhere in your code. You profile, run, profile, run, profile, run, and focus your efforts where it'll make the most difference. 99% of your code remains clean and maintainable, and the only obfuscated parts are where there's no choice but to have it obfuscated in the name of performance.

      --
      "We consider that six courts and an asylum claim are a rather odd way of returning to Sweden within a month."
    31. Re: Very much so! by swillden · · Score: 1

      the reality is if you are given code to work with and you see i = j * 5, if it's C you know what it does; if it's C++, you don't, regardless of who wrote it.

      Nonsense. The only way you don't know what that means in C++ is if the code was written by a complete, drooling idiot.

      Seriously, this is the first thing C programmers pull out to criticize C++... but in 23 years of professional C++ programming, I have never seen bizarre arithmetic operator overloading used in practice, except for iostreams, and you get used to that pretty quickly, given that it's been part of the standard library since very early on.

      I have a few times seen libraries of mathematical operations, say on vectors or tensors, that made heavy use of arithmetic operator overloading, but it was so they could say "i = j * 5" where i and j are n-dimensional matrices. In those cases, operator overloading not only makes sense, it's a dramatic improvement over C.

      If you want to criticize C++, there are lots of valid criticisms, mostly around the huge variety of features and the complexity of their interactions, which can get really subtle. And you can criticize many of the insane template metaprogramming constructs (though those can be really useful sometimes, particularly in building up infrastructure that allow the compiler to diagnose all sorts of errors you might make). If you don't like "invisible" stuff, you can criticize the abuses that can be made of constructors and destructors. But operator overloading? Faugh.

      --
      Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
    32. Re: Very much so! by iMadeGhostzilla · · Score: 1

      Joel Spolsky's example touches on those too: "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" and so on.

      It's a caricature of real world's examples meant to illustrate this: when you read competently written C++ code, you don't know in your head what's going on on the machine level without going outside of the code block you're reading to check. With competently written C, you do. I don't think there is much dispute over that.

      The question is, does that matter? That's (more) up for debate. My conviction is yes, it matters for system code, and no not quite, it doesn't matter as much for app code. When I look at system code, I want to know what happens at the CPU level. When I look at app code, I want to know how these abstract elements combine to make something new.

      As for operator overloading, I agree there are C++ things that are more invisible. With operator overloading, I just don't like it because of precedence and all. The sole purpose of overloaded operators, I believe, is to make the code more readable, by one person's standard, but readability is in the eye of the beholder. I prefer chained function calls as I find it easier to map the code in my head to the process at runtime.

    33. Re: Very much so! by Anonymous Coward · · Score: 0

      There are far better languages than C++ when it comes to prepackaged data structures or even generics (slapping everything into header files is dumb. Half the time I'd be better off using M4, because typed code generation is sometimes more of a headache than simple textual substitution).

      What no language does better than C is provide so much power in such a simple language, and do it reasonably portably.

      Also, if need need another page and a half to implement a list, you have problems. Rolling your own list, or in Unix using sys/queue.h, can be simpler from a memory management perspective because you can get rid if a useless node allocation.

      And as some people argue, programming is the art of creating specialized data structures. Bundling a bunch of genetic data structures together often leads to bloated and difficult to maintain code. Again, if you think std::list is some kind of life saver, or lambdas make threading easier, there are much better languages out there.

      C++ just seems like a horrible middle ground. I prefer C + situation-appropriate-high-level-language.

    34. Re: Very much so! by Anonymous Coward · · Score: 0

      Except nobody would write it like that in C, they would do i=j*5; and you would know exactly what it did.

      If they wrote it as assign(i, multiply(j, 5)); you would need to go and check it, like you would in C++ in all cases.

      I have no idea what Premaure means, but my optimization is mature C where I know very much when I need to consider how it will perform. There are some optimizations which cannot be done after the fact (including many cache issues, which can easily change the time to complete by a couple of orders of magnitude.)

    35. Re:Very much so! by Rei · · Score: 1

      It really depends on what type of app you tend to write. I more often write apps where there's no obvious single owner for a pointer.

      --
      "We consider that six courts and an asylum claim are a rather odd way of returning to Sweden within a month."
    36. Re: Very much so! by The+Evil+Atheist · · Score: 1

      The operator overloading argument is nonsense. You can say the exact same thing about any kind of function overloading. In Java, ArrayList.add is a completely different method to HashSet.add. You would similarly have to look up the type of object you're calling the add method of to figure out what it does. And even then you're not guaranteed that name is an accurate description of what it does. This is nothing to do with C++ but name overloading in general. For example, you can rewrite your example using no operators: assign(i, multiply(j, 5)) and you will still not know what it does without looking at the types of the arguments and the specification of the functions.

      Name overloading of any sort is essential if you want a language to support generic code easily and cleanly. Otherwise you get the even worse C macro hacks that don't blow up on compile. Templates blow up on compile, and once you stop being afraid of it, it actually makes generic coding a lot easier to manage than macros.

      --
      Those who do not learn from commit history are doomed to regress it.
    37. Re:Very much so! by The+Evil+Atheist · · Score: 1

      The STL of today is different from what you started with. If you need to non-mangled names, there's still extern C to create an API boundary.

      --
      Those who do not learn from commit history are doomed to regress it.
    38. Re:Very much so! by The+Evil+Atheist · · Score: 1

      They're only countless if you're a compiler developer or a standard library author. You can definitely count the features if you're just an end user programmer. Here they are:

      Constructor/destructor pairs, containers/algorithms, lambda expressions.

      That's three things that you need to know. The most interesting of the three is the container/algorithm duality. Just look at Sean Parent here replace a page and a half of code C-like C++ code with 5 lines of proper C++ https://www.youtube.com/watch?... using nothing but algorithms.

      I'd argue you'd actually need to learn LESS in order to learn what algorithms such as rotate or stable_partition do than having to write it out all the time.

      --
      Those who do not learn from commit history are doomed to regress it.
    39. Re:Very much so! by The+Evil+Atheist · · Score: 1

      You'd prefer having to specify that you're printing a long long and not a short rather than letting the compiler figure that out for you (through operator overloading)? You'd prefer having to waste time looking up format specifiers or waste brain power remember them?

      --
      Those who do not learn from commit history are doomed to regress it.
    40. Re: Very much so! by The+Evil+Atheist · · Score: 1

      And what's stopping someone from naming a function that has nothing to do with the meaning of its name? It's the same problem.

      --
      Those who do not learn from commit history are doomed to regress it.
    41. Re: Very much so! by iMadeGhostzilla · · Score: 1

      We're talking about cognitive ease (and cognitive strain) of reading code, so that is not the same: when I see
      hs.add(elem) it is very obvious that the "add()" is some hs' thing. But when I see hs + elem it goes against years of practice that the operands are numbers or strings and for a tiny fraction of a second I may have to ask myself what are hs and elem again. That's cognitive strain.

      IMO though operator overloading is justified with template programming since the "+" operator is guaranteed to exist so it's like a standardized function name. So I guess what I dislike is that C++ encourages things that don't have purpose other than looking nice to some people. In C at least it's accepted practice that going wild with macros is bad but with C++ there are things that are done only because they appear "elegant."

    42. Re: Very much so! by The+Evil+Atheist · · Score: 1

      I don't know what libraries you are using, but something like the + operator in C++ is still used mostly for number and string like objects. I rarely see misuses of operator overloading these days. But that's beside the point. Yes, when you see hs.add(elem), it's obvious it belongs to hs. But you still don't know what hs or elem is unless you look it up. But in C, you do not have member functions. You have free functions add(hs, elem). And if the person decided that their library requires that add(...) work with a multitude of types, they would make the arguments tagged structs or void pointers, leaving you with even more cognitive strain to look at all the different conditional states in the add(...) function that handle all the different combinations of types explicitly. And that also doesn't guarantee that inside the add(...) function it treats all possible combinations of arguments with equivalent semantics.

      Not to mention that, actually, C has some implicit operator overloading as well. You can add pointers and integers together and it behaves differently to adding integers. You will have to look up the actual types of the operands to figure out what the semantics are and that has caught out many good programmers.

      For any complex software libraries, whether written in C++ or C, I have never encountered one where I never needed to keep referring to the types of the operands anyway, so the cognitive strain is mostly equivalent.

      --
      Those who do not learn from commit history are doomed to regress it.
    43. Re: Very much so! by serviscope_minor · · Score: 1

      That pretty much summarises it. An ol dprof of mine used to quote:

      Make it run,
      Make it right,
      Make it fast,
      Make it small.

      Compared to C, C++ makes the first two steps much easier. For low leel optimizaions there's not much in it, but C++ gives you more time for the third step (due to the first two being easier) and also the expressiveness helps for restructuring or choosing different algorithms.

      For the last step it's a wash again, but given the same amoun of time overall, C++ again wins due to makeng the earlier steps easier.

      --
      SJW n. One who posts facts.
    44. Re:Very much so! by Gr8Apes · · Score: 1

      It wasn't merely the mangled names, but the complete crap-fest and lack of organized rules on how that was to be handled, and what to do when limits were exceeded during compilation/linking. Yes, if compilation results in a name that can't effectively be linked, perhaps a warning might be in order? I've gone a different route and although you should never say never, I doubt I'll be facing that particular problem again. My current focus with anything C/C++ would either be to integrate to it, or convert it to something else, not write meaningful new code in it.

      I agree with Stroustrup that templates could have been better, IMHO a whole lot better.

      --
      The cesspool just got a check and balance.
    45. Re:Very much so! by Anonymous Coward · · Score: 0

      You are confusing library vs language.

      With a robust C library I can do a lot also. In C++11 the built in library is sufficient for many 'mundane' tasks. The std::* library is just that, a library. Do not confuse them with the base language. They do come hand in hand usually though. At this point in time the stdc guys have not deigned on how to build some nice list functions. So we reinvent it over and over. Just like we did with the old C++.

    46. Re: Very much so! by petermgreen · · Score: 1

      the difference is there is a virtually unlimited number of function names most of which do not have a pre-existing meaning. There is a very limited number of overloadable operators all of which do have a pre-existing meaning. So the temptation to abuse is much higher and ideas of what constitutes abuse much fuzzier..

      --
      note: i'm known as plugwash most places but i screwd up registering that here somehow in the past and now can't register
    47. Re: Very much so! by The+Evil+Atheist · · Score: 1

      All languages have features that can be abused. It's a trade off. And even when operator overloading is abused in C++, they are still typesafe. You can't override them for existing definitions for other types so you'll get compile errors.

      --
      Those who do not learn from commit history are doomed to regress it.
    48. Re:Very much so! by The+Evil+Atheist · · Score: 1

      Google's managed to have a massive C++ codebase with templates and everything. If such a large codebase can exist, then it's proof it's no longer a problem. C++11 has been around for three years, and C++0x + TR1 a lot longer.

      --
      Those who do not learn from commit history are doomed to regress it.
    49. Re:Very much so! by Anonymous Coward · · Score: 0

      Well yeah it sure does. Since C++ has been running forever now, C has probably incremented well past a thousand. We should overflow the ram any minute now...

    50. Re:Very much so! by Gr8Apes · · Score: 1

      That doesn't discount that templates, and C++ itself, cannot be a whole lot better. People built huge codebases with COBOL. Would you say there are no problems there?

      --
      The cesspool just got a check and balance.
    51. Re:Very much so! by The+Evil+Atheist · · Score: 1

      No one said it can't be better. Even Bjarne Stroustrup keeps saying it needs to be better (virtually hear no other language creator say that). But you're making it out to be a lot worse than it is based on decades(?) old experience.

      Listening to one of the CppCon talks, some Google engineers talked about how they refactored their entire C++ codebase to modern C++11. Have you noticed any significant downtime in Google services lately?

      --
      Those who do not learn from commit history are doomed to regress it.
    52. Re:Very much so! by Gr8Apes · · Score: 1

      Gosling did it, as did Ritchie. in a panel conversation along with Stroustrup. That covers all the majors. So how many other big language creators do you know that haven't said something similar?

      Not particularly, because I don't really use them much. And how hard is a lookup routine anyways? (Even mail is mostly lookup with a minor backend that I personally have written at least 4 times - ie, even I can do it:) The rest is adserving (blocked significantly, apparently) and tracking, and other things that don't really affect the general user's services.

      --
      The cesspool just got a check and balance.
    53. Re:Very much so! by The+Evil+Atheist · · Score: 1

      I don't know how to talk to a person who thinks Google search is just a lookup routine anyone can personally write 4 times.

      --
      Those who do not learn from commit history are doomed to regress it.
    54. Re:Very much so! by Gr8Apes · · Score: 1

      Even mail is mostly lookup with a minor backend that I personally have written at least 4 times - ie, even I can do it

      ie, the mail backend is minor, sending, receiving, as all you're doing is integrating with system provided services. No, I haven't written an SMTP type server in more than a decade, why would I? There are very suitable choices out there that are current with the latest RFCs and easy to integrate with. As far as inbound, that's not terribly hard either, but again, there's systems out there that handle that. What's needed is a client that can handle the UX. Simple mail isn't too bad, where gmail excelled (for 2005 anyways) was in allowing you to categorize and search (hence the lookup) your mail via a web front-end. Hopefully that clarified things a bit.

      and, as an FYI, recently I designed and wrote a flexible notification system in about 1 month. That included sending notifications via email and SMS and in-app messages on triggers as well as accepting inbound responses and acting on them, and included search capabilities. That system has been in use for years with 1M+ users and no faults. IOW, this stuff isn't all that damn hard. FYI - Google's search isn't even all that great, IMNSHO, they just initially had better interfaces and results (ie, they crawled more web) than all the competing services at the time. Hell, I'd bet I wasn't the only one that was writing their own crawler/search solution at that time and stopped when Google became available. Google's claim to fame was in monetizing search. Now that, I grant you, is more than a little challenging.

      --
      The cesspool just got a check and balance.
    55. Re:Very much so! by The+Evil+Atheist · · Score: 1

      I don't know what you think Google his, but I don't think their 100 million lines of majority C++ code is just for mail. The fact is they obviously have not encountered problems with templates that you think still exist. They refactored that monster and neither search nor mail has been reported to have been down for any significant amount of time.

      --
      Those who do not learn from commit history are doomed to regress it.
    56. Re:Very much so! by Gr8Apes · · Score: 1

      I merely corrected your misinterpretation of what I said 2 entries earlier. You seem to be stuck in a faulty logic loop. I don't care about Google's success on refactoring their code nor that mail and search have largely remained up. I would be surprised if either was fully down, actually, based on how they're running them.

      --
      The cesspool just got a check and balance.
    57. Re:Very much so! by The+Evil+Atheist · · Score: 1

      And I don't care that you had problems with templates decades ago. If tens of millions of lines of code can be refactored (programmatically may I add) without significant downtime, then the template name mangling etc problem simply isn't that big of a deal.

      --
      Those who do not learn from commit history are doomed to regress it.
    58. Re:Very much so! by Gr8Apes · · Score: 1

      All depends on what you're doing. And, as a side note - citation needed that the code was 10s of millions of lines, and that it was refactored programatically. Mail just isn't that much C/C++ code. If it is, Google is doomed. Same for search.

      --
      The cesspool just got a check and balance.
  3. 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 Z00L00K · · Score: 1

      C is always relevant. Other languages come and go in popularity but if you know C well you can always find a job.

      --
      If builders built buildings the way programmers wrote programs, then the first woodpecker would destroy civilization.
    2. 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. Re:Relevant C by Eunuchswear · · Score: 2

      0x2b | ~0x2b == -1

      --
      Watch this Heartland Institute video
    4. Re:Relevant C by smittyoneeach · · Score: 1

      Brilliant!

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

      Thanks. I was going to do the whole soliloquy, but I suspect that slashdot would have given a "too few words per line" error.

      --
      "Transparent" is a shit show that trades on every stereotype going. A man in drag is NOT a transsexual.
    6. Re:Relevant C by TemporalBeing · · Score: 1

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

      Fixed that for you.

      --
      Truth is like the sun. You can shut it out for a time, but it ain't goin' away. - Elvis Presley (source: imdb.com)
  4. C is primordial by Anonymous Coward · · Score: 1

    It is the equivalent of creation narratives for human cultures.

    It is a bridge between the bare metal of the system (biology, assembly language) and culture/high-order functioning (culture, modern languages).

    There is no better way to simultaneously understand (not to mention use) both system hardware and everything that has been erected atop system hardware than C.

    There are few (any?) other languages that occupy this middle, connective ground so well.

    With C you can be OO, but you can also be nearly ML. And you can do them at the same time.

    1. Re:C is primordial by Anonymous Coward · · Score: 1, Insightful

      With C you can be OO, but you can also be nearly ML. And you can do them at the same time.

      Nearly lost my coffee... it is hard to figure out your point of view. If you use ML to mean machine language, and not the language ML, you must be quite old or quite young... if you think C is close to machine language, you can't be that old, but if you classify C as OO as anything more than in a rudimentary way, you can't be that young....

    2. Re:C is primordial by Anonymous Coward · · Score: 0

      I used know a bit about the internals of an long gone program from the late 70's. It was object oriented and written in assembly. If you can load the program counter from a register, you can do objects. In some version of basic you had computed goto's....

    3. Re:C is primordial by geantvert · · Score: 2

      Then he must be in his mid-40s because I fully agree with him.

      C is almost ML because almost all features of the langage can be directly translated into a few assembly instructions. This is also one of the last languages that still provides full control over memory and pointers.

      C can be OO. It does not provide OO features such as inheritence or dynamic casts but they are easy to emulate with structs and macros. See forIf you want to create compiler for a new langage today, it is far easier to generate C instead of ASM. exemple the Gobject API. This is clearly not the most elegant way to do OO but it works and it can be as efficient a true OO langage.

    4. Re:C is primordial by geantvert · · Score: 1

      The malformed sentence in the middleshould of course be "See for exemple the Gobject API" and later "If you want to create compiler for a new langage today, it is far easier to generate C instead of ASM. "

    5. Re:C is primordial by Anonymous Coward · · Score: 0

      If you can load the program counter from a register, you can do objects. In some version of basic you had computed goto's....

      Inaccurate. You can do OO without that. Loading the program counter from a register simplifies polymorphism, but if you keep track of your object type in the data you can do conditional calling based on object type anyway.
      The benefit of being able to load the program counter from a register is that the calling time will be the same regardless of the number of classes involved.

    6. Re:C is primordial by Anonymous Coward · · Score: 0

      C is almost ML....

      C has no relation to the language called ML, which younger people know from it's distant relative, OCaml. If you programmed in the 60s, there is no problem not knowing this. If you programmed in the 80s, there is no problem as ML commonly meant machine language, as ML wasn't that popular... in 2014, when comparing programming languages, be more freaking specific, please.

    7. Re:C is primordial by Rockoon · · Score: 1

      C is almost ML because almost all features of the langage can be directly translated into a few assembly instructions.

      Behold the backward belief system of some of the "C is low level" crowd.

      A language is low level if almost all of the features of the hardware can be directly translated into the language. See, you've got it backwards. You want it to be the other way around, but when its the way you want then its trivial to get to the argument that BASIC is low level too.

      Another segment of the "C is low level" crowd focuses on pointers. You are all wrong. Was paying attention when the language was invented. Always understood to be a high level language until the snobs came.

      --
      "His name was James Damore."
    8. 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.

    9. Re:C is primordial by mooingyak · · Score: 2, Insightful

      OOP is a style, not a language feature. Sure many languages make this easier to do, but writing OOP in C is certainly possible, as many of us can attest.

      --
      William of Ockham had no beard. The most likely explanation is that it was chewed off by squirrels every morning.
    10. Re: C is primordial by TimMD909 · · Score: 1

      You're not comparing the languages properly. If jQuery was ported to C++, it would be the same as the no conflict style: jQuery("zoolander").addClass("ambiturner");

    11. Re:C is primordial by gtall · · Score: 1

      So, you think you are smart enough to figure out what your optimizing C compiler did to your code?

    12. Re:C is primordial by Guybrush_T · · Score: 1

      With enough experience, yes. And you can check the generated assembly afterward to see if it matches what you expect.

      Of course there are some cases where you know that you don't know what will get out of the compiler, but for the majority of if-then-else assignments, you don't get surprised by what comes out of the compiler.

      There are exceptions on some architecture (e.g. Itanium) where the CPU is so complex that is it very hard to predict anything, but on x86/ARM, it's pretty simple.

    13. Re:C is primordial by Spazmania · · Score: 1

      C is close to machine language because every basic operation except a function call results in simple, brief, and concise machine language code. "c=a+b;" results in only a few instructions. And except when you're calling functions whose internals you haven't investigated, everything else is like that.

      C is a high level language in that it masks the repetitive assembly language constructs to do those basic functions, but it still only provides basic constructs which are directly tied to what the hardware itself does.

      By comparison, perl has a basic construct: "$myhash{"stuff"}=5;" This complex operation under the hood is masked by the simple language construct. It is far away from assembly language.

      By comparison, C++ has a basic construct: "cout << "stuff";" While not as egregious as perl, this simple language construct masks function calls and loops under the hood.

      In C, simple constructs in the language always result in comparably simple machine level code with comparably short running times. That's what is meant when folks say that C is close to machine language.

      --
      Moderating "-1, Disagree" is simple censorship. Have the guts to post your opinion.
    14. Re:C is primordial by Anonymous Coward · · Score: 2, Informative

      Take for example the JS expression $("a").addClass("blue").

      That's not even Javascript.

    15. Re:C is primordial by Anonymous Coward · · Score: 0

      Yeah, like using printf, which translates directly to the x86 instruction prnt that does like 50 different things.
      Those hardware guys were really smart, making such complex instructions, uh?
      They were so smart that every modern cpu comes with a mlc instruction, that allows to allocate memory, wow, I'm really impressed, C really maps directly to low level, that malloc() we all love is so efficient because it is implemented directly in hardware.
      Ahaha, I laught at those youngsters, using those modern languages that don't even have pointers!

    16. Re:C is primordial by Wootery · · Score: 1

      If you mean machine-code, please just put machine-code. "ML" is taken.

      exemple the Gobject API. This is clearly not the most elegant way to do OO but it works and it can be as efficient a true OO langage.

      Indeed, and if you want elegant GObject, there's always Vala, a C#-like language which compiles to C.

    17. Re: C is primordial by rioki · · Score: 1

      Yes but you would not be able to actually empress this in C. Not possible! The best you could do would be something like:


      void set_class_to_blue(Element* ele)
      {
              set_class(ele, "blue");
      }

      foreach(dom, "a", set_class_to_blue);

      Any if you inline the code, you can see what it does line for line and translate it to ASM.

      Take the JQuery in contrast. That does the $("a") actually do? It creates an object that contains a classifier that may later evaluate to DOM nodes. On this object you then can call function; theses functions then operate on all instances. So the statement $("a").addClass("blue") is semantically equivalent to $('a').forEach(function (ele) {ele.setClass("blue");}). But it is not implemented in the same way. Even if you inline all the JS code, it will be hard to break it down to actual processor instructions (just the VM), because half of the time a semantic construction does nothing useful.

    18. Re:C is primordial by cheesybagel · · Score: 1

      C used to be close to machine language when people had PDPs and VAXes. Not now. Something like OpenCL is much closer.

    19. Re:C is primordial by zieroh · · Score: 1

      If you use ML to mean machine language, and not the language ML, you must be quite old or quite young..

      FWIW, I've never even heard of the language "ML", and took ML to mean Machine Language.

      (Late forties, if you must know).

      --
      People who say "sheeple" have about as much sophistication as an AOL user, and in fact are probably actually AOL users.
    20. Re:C is primordial by zieroh · · Score: 1

      A language is low level if almost all of the features of the hardware can be directly translated into the language. See, you've got it backwards. You want it to be the other way around, but when its the way you want then its trivial to get to the argument that BASIC is low level too.

      Another segment of the "C is low level" crowd focuses on pointers. You are all wrong. Was paying attention when the language was invented. Always understood to be a high level language until the snobs came.

      "Low level" is relative. Yes, C was understood to be a high level language when it was invented over 40 years ago. Times have changed. If you were paying attention to anything since then, you'd realize that C occupies a space pretty low down in the language landscape.

      (And yes, I am a C programmer, first and foremost).

      --
      People who say "sheeple" have about as much sophistication as an AOL user, and in fact are probably actually AOL users.
    21. Re:C is primordial by happy_place · · Score: 1

      Algorithms are now more efficient at keeping a processor occupied than hand tweaking, with the complexity of processors being what they are, w/ multiple instruction pipelines and vector processing, multiprocessors and such. C is the equivalent of what ASM used to be. It is the least complicated abstraction language that a processor manufacturer can provide low level developers. Many processors are built with the language in mind. As a result if you want to extract the most performance from your hardware, C is the solution. Many higher level languages are written in C, or the core components that HAVE TO BE fast are written in low-level C.

      C is also "almost" portable. Which generally speaking means it can be used across families of processors with greater efficiency, while maintaining performance.

      Also there's still a hellalotta stuff, core libraries, drivers, embedded software, and software frameworks written in it... so yeah, it's not going away... I use it daily.

      --
      http://www.beanleafpress.com
    22. Re:C is primordial by rl117 · · Score: 1

      It's easy to implement OO in C *badly*.

      GObject shows that it's possible, but being possible does not make it sensible. It comes at the expense of an almost complete absence of type safety and const correctness since you cast it all away. And then you lose performance due to having to then check every single passed object is of the correct type (g_type_check_instance...). And if you screw up (which you will do), your program will crash. The C++ compiler would have done all of this for you, and you'd have a safer, more robust program at the end. It handled all those checks at compile time.

      Creating classes with GObject is a maintenance nightmare. Consider ongoing refactoring as well as the initial writing; there's a lot of pieces to keep in sync to avoid disaster, and it's easy to slip up since you will often not be warned about inconsistencies. And when I was doing a conversion of GObject C to C++, I found a whole pile of latent bugs which the C++ compiler picked up but which the C compiler couldn't detect due to all the typecasting removing information. The conversion to C++ + STL improved the quality and robustness significantly, as well as making ongoing maintenance easy.

      I was once a C zealot who believed GObject was amazing. I even worked commercially doing GTK+ programming. Hindsight shows how wrong I was. Use the right tool for the right job. And for OO, this does not incude C!

    23. Re:C is primordial by Spazmania · · Score: 1

      What part of "every basic operation EXCEPT a function call" did you fail to understand?

      --
      Moderating "-1, Disagree" is simple censorship. Have the guts to post your opinion.
    24. Re:C is primordial by anybody_out_there · · Score: 1

      printf() and malloc() are not part of the C language. They FUNCTIONS that are part of the standard library (stdlib) which is OPTIONAL

      and yes, I've worked on projects were the standard library was not used...

    25. Re: C is primordial by Fwipp · · Score: 1

      Might wanna revisit your Boolean logic, bro.

      A -> B != ~A -> ~B

    26. Re: C is primordial by n7ytd · · Score: 1

      Yes but you would not be able to actually empress this in C. Not possible! The best you could do would be something like:


      void set_class_to_blue(Element* ele)
      {

              set_class(ele, "blue");
      }

      foreach(dom, "a", set_class_to_blue);

      Any if you inline the code, you can see what it does line for line and translate it to ASM.

      That's not C. What is this "foreach()" you speak of?

    27. Re:C is primordial by hermitdev · · Score: 1

      One of the simplest constructs in C++ that makes me cringe is when I see people do:

      std::string foo = "";

      instead of:

      std::string foo;

      The reason being, although functionally equivalent, the second version results in faster, smaller code. On every implementation I've looked at the first one results in calls to strlen, a possible memory allocation and a strcpy. The second is a mere memset of the internal pointers to null. Even though us humans that understand C++, the compiler knows only the language. It typically does not know anything about the standard library. Yes, there are exceptions, such as compile-time warnings/errors for mismatched arguments to printf style functions. But, those are exceptions, not the rule, and they are few and far between.

      When I see the first form, I immediately understand that I am looking at code from some whose primary language is not C++, but instead likely Java or C#.

    28. Re:C is primordial by Anonymous Coward · · Score: 0

      >JS expression $("a").addClass("blue").

      First, you cannot do that in plain Javascript either because that is from the jQuery library. Second, if you were actually using C for a web browser language it would be simple enough to write a library call to do it from C too.

    29. Re: C is primordial by dgatwood · · Score: 1

      That's not C. What is this "foreach()" you speak of?

      Presumably a function that calls another function using a function pointer.

      With that said, a more idiomatic C syntax would be:

      DOMDocument *document = ...;
      DOMNodeList *list = getElementsByTagName(document, "a");
      for (DOMNodeListItem *item = list->first; item; item = item->next) {
      DOMElement *elt = (DOMElement *)item->node;
      char *old = elt->className;
      asprintf(&elt->className, "%s blue", elt->className);
      free(old);
      }

      Or some such. And you'd probably wrap that in a function and call it addClassToElementsByTagName(char *tagName, char *newClass), at which point your calling code would be back to a one-liner again.

      --

      Check out my sci-fi/humor trilogy at PatriotsBooks.

    30. Re: C is primordial by dgatwood · · Score: 1

      BTW, how did you get Slashdot to let you indent content?

      --

      Check out my sci-fi/humor trilogy at PatriotsBooks.

    31. Re: C is primordial by Anonymous Coward · · Score: 0

      Psssst. OpenCL kernels are written in C.

    32. Re: C is primordial by Anonymous Coward · · Score: 1

      That's valid Javascript. This code calls the $ function of the jQuery library

    33. Re:C is primordial by fyngyrz · · Score: 1

      Yes, ML *is* taken: By Machine Language. Doesn't mean squat that some johnny-come-lately tried to usurp it. LIke Flex. Flex is a 6800/6809/68000 OS. Someone adopting a duplicate name later to mean something else is just muddying the water to no one's benefit. Until the namespace is full, duplication is a bad idea. And the namespace is NOT full, brothers and sisters.

      --
      I've fallen off your lawn, and I can't get up.
    34. Re:C is primordial by Anonymous Coward · · Score: 0

      To be pedantic, that example uses JQuery syntax, which is a whole library written on top of raw JS.

      Writing the equivalent in core JS, without expansions, would require several lines.

    35. Re: C is primordial by cheesybagel · · Score: 1

      Actually OpenCL is a C like language that is compiled into the assembly language of the target architecture. At least that is what happens with AMD, Intel and NVIDIAs implementations of it.

    36. Re:C is primordial by russotto · · Score: 1

      It's easy to implement OO in C *badly*.

      Sure, and the canonical example of this is C++. C++ is a bad implementation of objects in C, along with a bad template language, now along with some bad functional constructs, all of which fit together badly. And then there's the STL which uses all of that; it's the proverbial dancing bear of C++.

    37. Re: C is primordial by Anonymous Coward · · Score: 0

      Yea... Because compiling to assembly language is so un-like C. It's not like that's been an intermediate step in most C compilers or anything. Face it. You claimed C is superior to C at being C. Also, OpenCL isn't a language. Though it specifies one for use in writing kernels. And oddly, that language is often parsed with clang.

    38. Re: C is primordial by Anonymous Coward · · Score: 0

      So which intruction does a C compiler emit when multiplying two 64-bit numbers on a 32-bit processor? When adding two _Complex numbers? When instrumenting a pointer dereference to catch a buffet overflow at runtime (which GCC, clang, TCC, and other compilers can do).

      Anybody who thinks C is low-level doesn't understand C very well. You mistake C's relative simplicity and the elegance of pointers with being a dumb mapping to hardware.

    39. Re:C is primordial by Anonymous Coward · · Score: 0

      How do you think OO languages are done under the hood? It all goes back to machine language anyways, and C is nothing but human readable abstraction of it.... or, well, more readable than assembly. With some extra bits abstracted away. And some ruotine stuff made easy, such as loops. If compilers do some magic with C code it's because they can, not because they have to.

    40. Re:C is primordial by rl117 · · Score: 1

      This is all highly debatable!

      However, if you had to choose between GObject-C and C++, the rational choice is C++. It's the better choice on all counts: safety, speed, correctness, robustness, maintainability. I had to learn this lesson the hard way by spending years banging my head against the wall using GObject when I could have just used C++.

    41. Re: C is primordial by Spazmania · · Score: 1

      So which intruction does a C compiler emit when multiplying two 64-bit numbers on a 32-bit processor?

      Turns out to be a trivial add and shift loop.

      When adding two _Complex numbers?

      I had to look that one up. It actually is core starting in C99. Yikes. Fortunately not something more than a handful of folks use, what with C not being the language of choice for scientific computing.

      When instrumenting a pointer dereference to catch a buffet overflow at runtime

      Properly behaving C compilers don't automatically add code to detect buffer overflows.

      --
      Moderating "-1, Disagree" is simple censorship. Have the guts to post your opinion.
    42. Re: C is primordial by Spazmania · · Score: 1

      They say the exception proves the rule. That you had to dig all the way to -complex numbers- to find an exception to the C-is-close-to-the-hardware rule kinda proves my point.

      --
      Moderating "-1, Disagree" is simple censorship. Have the guts to post your opinion.
    43. Re: C is primordial by Anonymous Coward · · Score: 0

      I forgot to add floating point. For a long time floating point wasn't very common. It's still common for the compiler to emulate various FP semantics, if not all FP types and operations. And that's hardly an exception.

      You also fail to realize that hardware evolved to emulate C. There are still mainframes, for example, that have to _emulate_ C's unsigned modulo arithmetic. Floating point based DSPs have to emulate C's signed integer types.

      C isn't low-level, it's just _simple_, and hardware has evolved to ease the mapping of C types and operations.

      As for compilers instrumenting code to prevent overflows, that's about to rapidly change. And because C _is_ a high-level language, they can do so without breaking standards-conforming code.

    44. Re: C is primordial by Anonymous Coward · · Score: 0

      > C isn't low-level, it's just _simple_, and hardware has evolved to ease the mapping of C types and operations.

      If you can provide an example, that would help. I've never seen a ISA feature that looked like it was tailored to C which didn't already exist well before C became popular.

      For what it's worth, K&R themselves described C as "not a very high-level language."

    45. Re:C is primordial by Anonymous Coward · · Score: 0

      It all goes back to machine language anyways, and C is nothing but human readable abstraction of it.... or, well, more readable than assembly. With some extra bits abstracted away.

      (Pssst... all high-level languages are abstractions of machine language)

      Besides, assembly has one job: make the instruction set human-readable, and it does that very well. Macro assemblers go a step further, but if you abstract away things like registers, stacks, and interrupts, you're not really dealing with assembly language anymore, no matter how you candy coat it.

      C doesn't map processor instructions one-to-one, which is THE basic feature of assembly. C is nothing like assembly. I wish people would stop repeating this ridiculous bit of lore.

    46. Re: C is primordial by Spazmania · · Score: 1

      There are still mainframes, for example, that have to _emulate_ C's unsigned modulo arithmetic. Floating point based DSPs have to emulate C's signed integer types.

      Ancient mainframes using 1's complement arithmetic, floating point on systems without a FPU and integers on devices that don't do integer math in hardware? Got any more wacky exceptions that prove the rule?

      As for compilers instrumenting code to prevent overflows, that's about to rapidly change.

      Don't bank on it.

      --
      Moderating "-1, Disagree" is simple censorship. Have the guts to post your opinion.
    47. Re: C is primordial by Anonymous Coward · · Score: 0

      to catch a buffet overflow

      What's a "buffet overflow"? Is that like when food falls on the floor?

    48. Re:C is primordial by Rockoon · · Score: 0

      Times have changed.

      People have changed, too.

      When C was invented, their werent language snobs. Now there are, and they so desperately want C to be low level (so that they get "low level" cred) that they will invent insane arguments such as "times have changed" and "C occupies a space pretty low down the language landscape"

      Its really simple. The definition of "low level language" does not subscribe to a "place" on a "list", or what "time" it happens to be. The fact that you so desperately want to change the definition in a way that makes you a "low level programmer" proves that you are a fucking language snob. You dont magically become a low level programmer while banging C code out just because python was invented, you fucking moron.

      --
      "His name was James Damore."
  5. 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 amalcolm · · Score: 2

      And even more things, like your central heating programmer, and things of that ik won't nercessarily run Linux or even an rtos, but do their own co-operative multitasking, if required.

      --
      Time for bed, said Zebedee - boing
    2. 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.

    3. Re:Embedded Systems by Anonymous Coward · · Score: 0

      depends on Linux and C

      Not really. There are plenty of network-aware embedded devices/systems that don't run Linux, nor had their firmware written in C.

    4. 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
    5. Re:Embedded Systems by Anonymous Coward · · Score: 0

      C is as central to the OS as Intel is to the CPU... there are other ways to do it, most people make use of it anyway, and as much as other things come and go, no one sane envisions it going away completely in the foreseeable future (and yes this is a terrible analogy, but I stand by the central idea).

      Here, let me put it another way... comment here if you're doing all of your work from Haiku OS! Yea... and you guys went as far as C->C++. Raise your hand if you're typing on a Lisp machine! Yea, didn't think so.

    6. Re:Embedded Systems by Anonymous Coward · · Score: 0

      I will agree with the "don't run Linux", but I'd like the examples of "nor had their firmware written in C". Because I've done a lot of embedded devices, and though it's common I won't use Linux, I've never had one where I didn't use C. I guess there's Arduino, but I've never used that in an actual embedded device, and that's some weird stripped down C++ like programming language that it feels more Cish to me than C++. But it doesn't matter, since at least around here, they tend to go with PICs.

    7. Re:Embedded Systems by TheRaven64 · · Score: 1

      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.

      Rust is a reasonable replacement for a lot of the things that C is good at. Go is a good replacement for a lot of the things that C is bad at but is used for anyway.

      --
      I am TheRaven on Soylent News
    8. Re:Embedded Systems by TheRaven64 · · Score: 1

      The mbed development environment for the ARM Cortex M series uses C++, but you need to stick to a fairly limited subset of C++ to fit within the requirements, at which point you're basically using C with an annoying type system and some nice syntactic sugar for constructing vtables.

      --
      I am TheRaven on Soylent News
    9. Re:Embedded Systems by Guybrush_T · · Score: 1

      I have to disagree. It really depends what you are doing. I love C and I believe that C will not be replaced for certain pieces of low-level software (kernel, libraries, ...).

      However, when you need to write a script or a dynamic web page, using C is painful and actually not a good idea. Python and PHP are much better for that. I'm not a language fetishist, I'm just an average lazy programmer. When I need to do some work, I choose the most efficient tool to do it. I won't try use a new language because the grammar is kewl. Usually, I switch to other languages when I feel it is much more appropriate to my current task.

      If a language survives (after the initial hype), it is for a good reason. Shell script, Javascript, Python, PHP, ... will also be there for a long time.

    10. Re:Embedded Systems by Relfos · · Score: 1

      You can use other languages that are not C to do embedding work/hardware drivers/etc, eg: object pascal, which is also a low level language with direct memory access.
      I've written hardware drivers using it, for example.

    11. Re:Embedded Systems by jrumney · · Score: 1

      depends on Linux and C.

      Not really. Over at mbed.org, ARM has a rather nice C++ library for its Cortex M series, which are really too memory constrained to think about running any version of Linux on them.

    12. Re:Embedded Systems by zarthrag · · Score: 1

      I don't think any of the languages you've mentioned are ones people would consider one of those "vogue" kiddie languages. Scala, D, Swift, Everything on this list, is not something I would tell a child to start learning, and then bet a career on.

      That said, use the right tool for the job! PHP is absolutely a great idea for a webpage, which is, by it's very nature, a scripted entity. With much pain, C *can* do it, but there is a better tool, already. PHP - and just about every other scripted language is written in C/C++. So is the JVM. It's all just (another) layer of abstraction, in the end.

        But, when it comes to kernels, firmware, and just about anything embedded - C should be near the top of your list. It's not the most popular language, but it's steady. It sits nicely on top of only assembly language - and thus, is easily used on any (and almost every) hardware-architecture there is.

      --
      Why can't all fpga/microcontroller manufacturers just release free optimizing compilers???
    13. Re:Embedded Systems by thevirtualcat · · Score: 2

      Actually, Arduino's environment is C++. The frontend works out your #include lines and feeds the result into avr-g++.

      avr-gcc/avr-g++ lacks support for the STL, but you can use all the C++ language features you want. Classes, templates, casts... it all works.

    14. 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.

    15. Re:Embedded Systems by Austerity+Empowers · · Score: 1

      There will always be systems & embedded programming to provide the platform on which higher level languages will run, and thus there will always be C.

      I've heard of a few attempts to write system level things (kernels, device drivers, etc.) in C++, but none have gone anywhere.

    16. Re:Embedded Systems by Anonymous Coward · · Score: 0

      There is C and there is common lisp. Everything else is superfluous DSL fluff

    17. 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."
    18. Re:Embedded Systems by ChodeMonkey · · Score: 1

      Or Fortran....

      --
      All your attention are belong to my old internet meme.
    19. Re:Embedded Systems by Anonymous Coward · · Score: 0

      There is C and there is common lisp. Everything else is superfluous DSL fluff

      DSL?

      Where is Forth in your massive family tree of programming languages?

    20. Re:Embedded Systems by Jecel+Assumpcao+Jr · · Score: 1

      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;

      You might not be aware that in very early versions of C the syntax was actually a=+b; but they changed that when they noticed there were two ways to interpret a=-1; and they decided they didn't want to use white space to distinguish between them.

    21. Re:Embedded Systems by jythie · · Score: 1

      Yeah, one of the things I adore about C is how easy it tends to be to use it from other languages. It is so predictable that it is easy for linker (or equivalent) writers to map symbols and such.

    22. Re:Embedded Systems by jythie · · Score: 1

      For all its failure, you have to admire LMI for putting its money where its mouth was. While it did not catch on in the mainstream it really was an alternative that did things well.

    23. Re:Embedded Systems by Darinbob · · Score: 1

      Too many coders seem to not see the world outside of the web, PC apps, mobile apps, etc. I suspect many of them think their auto ignition code is in JavaScript or Python.

      I think some of the attitude comes from treating programming as the 9 to 5 job only, without an actual passion or interest in the subject.

    24. Re:Embedded Systems by Darinbob · · Score: 1

      There is the style of C++ with reduced feature set. Ie Embedded C++ and the like. Like C, but better type checking and code organization, some nice low-bloat features, and minimal retraining for C programmers. Just avoid the difficult stuff likely to bloat up the code, don't copy PC programming style.

    25. Re:Embedded Systems by AaronLS · · Score: 1

      "support and development just stops as all the ADD kids jump at the new toy"

      We'll assume you means support and development of the language specification/Compilers/IDEs/etc.

      Agreed that if there's not a solid backing either through a large community or major corporations, then yeh you'd be an idiot to invest production code in a a language that might not have longevity. This is not a risk unique to high level languages. This is a risk with any language that doesn't have a mature and committed community or corporation supporting it.

      ""five years down the road someone will fork the fork and you can throw all your code away"

      I would be interested in examples of major languages that went this way, and why code had to be wholesale thrown away?

      Let's assume by fork, you mean forking the language specification and/or compiler. Someone forking shouldn't cause you to need to throw away code. You would only have to throw your code away if the new fork became so popular that maintainers of the upstream decided to abandon their language and maintain the fork, AND you were of the opinion that the old upstream compiler/specification was not matured enough for you to stick with it.

      Even if you switched to the forked compiler, I can only imagine a childish tantrum resulting in someone throwing away their code over some compiler errors that required minor syntax changes. You sound just like that type of person. If anything usually some clever regex will solve this problem. Although I agree, it's a good sign you were an idiot for choosing a language supported by those who do not value backward compatibility, and/or you invested production code into a language that was still in early development when backwards compatibility is usually not a primary goal.

      These are attributes of niche languages. There are some low level languages that have been created as experiments, proof-of-concept, etc. that suffer from the same issues. C-- was a lowlevel languages created to try and implement common compiler algorithms for reuse, which is now dead. Ambitious little projects without enough of an audience to gain traction, and eventually the maintainer's time is directed elsewhere and it dies(the language, not the maintainer).

      Those are attributes of niche languages, not of high level languages.

      "That'll never happen with your C code."

      You've not been around very long OR you've never tried to leverage some really old C code and had to fix hundred of compiler errors to get it up to speed. Now usually that's more of an issue with the code not being written to be very portable, but there's nothing inherent about C that makes it any more immune to the portability issues that high level languages suffer from when bad programmers get their fingers in there. Code that compiled fine 10 years ago often won't compile anymore if it's not been maintained, because the more common compiler options are vastly different. You've not been around the block if you've had to maintain someone's really old code and had your compile seg fault the first attempt to compile it.

      In fact, I'd say writing portable code requires alot more skill in C because you're at such a low level and have to be much more knowledgeable of things that higher level languages hide from you. It probably makes you a better programmer for it, but that's about like saying beating yourself with a stick makes you tougher.

      Anyway, there's lots of reasons people invent new languages. Some of them are doing it just for fun, and never intended them for production use. Proof of concepts, etc. Writing a compiler is a great learning experience.

      There's nothing to be sickened by. It's not like there is some street peddler trying to get you to use some esoteric language. There might be a few misguided fools who are all excited about some language and pushing it for production use where it is inappropriate, but someone's misplaced zeal is usually no fault of the language or language designers.

    26. Re:Embedded Systems by Anonymous Coward · · Score: 0

      I may be wrong, but isn't Rust aiming to be a replacement to C, or at least C++?

    27. Re:Embedded Systems by Marillion · · Score: 1

      And don't forget to ask what language was that high level language written in?
      Ruby - written in C
      Erlang - written in C
      Node.js - written in C with a few x86 and ARM assembler bits
      Perl - written in C
      Python - written in C

      And the truly mind-numbing one: GNU C compiler - written in C.

      --
      This is a boring sig
    28. Re:Embedded Systems by Anonymous Coward · · Score: 0

      Oh, which ones? The ones written in assembly?

      I'm actually interested. Which languages are used for low level embedded programming besides C / asm? I know some compilers exist for C++, but I thought they were all even more crappy than C ones. Who actually uses something else, and why?

    29. Re:Embedded Systems by ClayDowling · · Score: 1

      You -can- use Object Pascal to do systems level programming, but the language wasn't designed for it and it won't be a lot of fun. I've done it, but after about a year of maintaining the code I rewrote it in C to get around some of the uncomfortable compromises that made the Pascal version hard to maintain.

    30. Re:Embedded Systems by Anonymous Coward · · Score: 0

      > The JVM is written in C.

      The JVM is written in C++ and is in process of having a Java based JIT, named Graal.

    31. Re:Embedded Systems by Anonymous Coward · · Score: 0

      He's a troll from 4chan.

    32. Re:Embedded Systems by the_arrow · · Score: 1

      Node.js - written in C with a few x86 and ARM assembler bits

      Uhm, it uses the Chrome v8 JS engine which is written in C++.

      --
      / The Arrow
      "How lovely you are. So lovely in my straightjacket..." - Nny
    33. Re:Embedded Systems by sjames · · Score: 2

      Of course, C++ started life as a pre-processor for C called cfront.

    34. Re:Embedded Systems by Anonymous Coward · · Score: 0

      by it's very nature

      "its".

    35. Re:Embedded Systems by jcarr · · Score: 1

      > too memory constrained to think about running any version of Linux

      Chips like that are dying out due to memory being larger & other chips that can at least run uboot (also written in C).

  6. Yes by Anonymous Coward · · Score: 0

    It's like asking if verbs are any use when we can just noun everything.

    1. Re:Yes by Anonymous Coward · · Score: 0

      Did you just verb "noun?" Did I just verb "verb?" That's perverse!

  7. C is very relevant in 2014, by Beck_Neard · · Score: 2, Insightful

    Because it's extremely dangerous and a lot of people are still using it. The 'standard' standard library is so full of security holes it's not even funny, and attempts to 'improve' it over the years have mostly been unsuccessful because the bad coding patterns still exist.

    C is a great language, it's just that most humans are incapable of using it safely and securely. It's like a .45 with a downward-pointing barrel. It's all too easy to shoot yourself in the foot.

    For full disclosure, I used to be an avid C programmer, until I realized the harm I was causing myself and others. It's like when you drunk drive and think you're just fine. It takes an external perspective to realize how reckless your behaviors are.

    --
    A fool and his hard drive are soon parted.
    1. 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.

    2. Re:C is very relevant in 2014, by Anonymous Coward · · Score: 0

      Just because you are unable to use the available technologies in 2014 doesn't mean the language is bad.

      There are safer alternatives to the "standard" functions, there are tools to perform static and dynamic analysis of your projects, there are standards like MISRA-C that provide guidelines and rules for safe usage of C, etc.

      I personally think C has the simplest rules of all popular languages.

    3. 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.

    4. Re:C is very relevant in 2014, by Tough+Love · · Score: 2

      OP was equating intentionally using C with intentionally driving drunk. As a long time C hack (still am) I concur.

      --
      When all you have is a hammer, every problem starts to look like a thumb.
    5. Re:C is very relevant in 2014, by Anonymous Coward · · Score: 0

      Most useful tools come with dangers and one has to be careful when using them. Mitigation of those dangers invariably means compromising the usefulness. Programming tools are not any different in that respect.

      I am not aware of any language that offers the benefits of C without any of the risks associated with careless programming. However, there are many languages that offer some protection against stupidity, but have lost most of the simplicity, flexibility and efficiency of C. It is a tradeoff. Ultimately, 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.

      (Captcha: python)

    6. 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
    7. Re:C is very relevant in 2014, by Anonymous Coward · · Score: 0

      Well, other languages do too.

      COBOL is extremely limited, as it was intended for "application developers", whatever they were.

      But give COBOL to a CS'er like me, and I got a wonky syntax to do the same as C, because I control the memory.

      Maybe the problem is that memory control is dangerous. Well almost. I still see people to this day looping from start till end of a list, and checking for space for an end. Full list? Stack overflow. Ugh, disgusting.

      At least z/OS has some pretty aggressive protection going on that x86 doesn't, otherwise I'd have no hope for the ol' systems (they should hardly ever have existed really then)

    8. 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
    9. Re:C is very relevant in 2014, by Tom · · Score: 2

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

      I consider this its greatest strength. If you want a training wheels language, there are probably 200 to choose from. If you want a language for adults, there aren't all that many choices.

      --
      Assorted stuff I do sometimes: Lemuria.org
    10. 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.

    11. Re:C is very relevant in 2014, by rioki · · Score: 1

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

      THIS is the only reason for C's existence. If solves one problem, remove all barriers between the programmer and the machine and still be a reasonable language. Assembly is the only way to program with less barriers, but that is not a reasonable language. C is useful in those cases where you simple can't trade speed for the programmer switching off his brain.

    12. Re:C is very relevant in 2014, by Rei · · Score: 1

      That's the reason why people should use C++. You have memory-managed iterable objects to keep you from shooting yourself in the foot that way, and they're quite high performance (usually higher performance than most of the "roll your own" implementations I've seen from C programmers reinventing the wheel). But if for some reason in a C++ program you think you need your own iterable structures for some particular performance reasons in some particular application, you can always change/replace them, in part or in whole. You can still do raw C in C++ - but you don't have to. C++ is "micromanage memory where you need to, don't where you don't need to".

      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.

      --
      "We consider that six courts and an asylum claim are a rather odd way of returning to Sweden within a month."
    13. Re:C is very relevant in 2014, by Anonymous Coward · · Score: 0

      You're still effectively using C.

    14. Re:C is very relevant in 2014, by Anonymous Coward · · Score: 0

      And there is nothing wrong with that.

    15. 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.
    16. Re:C is very relevant in 2014, by Anonymous Coward · · Score: 0

      Because it's extremely dangerous and a lot of people are still using it. The 'standard' standard library is so full of security holes it's not even funny, and attempts to 'improve' it over the years have mostly been unsuccessful because the bad coding patterns still exist.

      C is a great language, it's just that most humans are incapable of using it safely and securely. It's like a .45 with a downward-pointing barrel. It's all too easy to shoot yourself in the foot.

      And Java is implemented so securely these days?

      Or Flash?

      Give me a fucking break. Profit has been a priority above security for decades now, which has become practically a mantra in this day and age of profit windows being 15 minutes long. You WILL move quickly to net those profits, which translates into insecure, rushed designs.

    17. Re:C is very relevant in 2014, by Anonymous Coward · · Score: 0

      C is a great language, it's just that most humans are incapable of using it safely and securely. It's like a .45 with a downward-pointing barrel. It's all too easy to shoot yourself in the foot.

      It's widely used in embedded applications, including many safety-critical things. Going to your gun argument, C is like a gun that's dangerous for a untrained child but quite safe for a trained and rational adult. It depends on how you use it.

      Where I work, we use C for all embedded work, most of which is safety-critical, and some of which is certified to the highest safety level within our industry. The industry's software development methodology revolves around extensive specification and testing. It takes a lot of time, but it works: the software we ship works as intended and is safe.

      One thing that is disallowed in our shop because it's considered unsafe is use of malloc/free, because that can be non-deterministic - meaning that you never know when malloc will return, or if it will fail. Likewise, Java is disallowed because it relies on garbage collection - like many other "safe" languages. When we need heap-like memory allocation, we use memory pools that allocate fixed-size blocks, which makes them deterministic.

      For development and test tools, we use primarily Python, though I also use C++ for some things. In a past life, I worked on a large safety-critical system that was written in C++.

      I've done C++ for many years, and I generally prefer it to C, but it turns out that you can do a simple form of object-oriented programming in C that gets you most of the benefit of that style. I've also done "generic" programming via C macros as an alternative to C++ templates (which I never much liked). That requires a little creativity, but it turns out to be quite possible once you get the hang of it.

    18. 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.

    19. Re:C is very relevant in 2014, by Anonymous Coward · · Score: 1

      It's kinda depressing that for every language I may learn there's a whole group dedicated to making me feel like I just wasted my time.

    20. Re:C is very relevant in 2014, by linuxrocks123 · · Score: 1

      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.

      Umm ... LLVM is a fairly conventional, if well-designed, compiler, and its backends certainly do have to have a model of the processor, and know how to generate assembly from the IR, and all that. GP is right: you can't get away with no one knowing how the processor works.

      And provably correct code is still a pipe dream.

      --
      vi ~/.emacs # I'm probably going to Hell for this.
    21. Re:C is very relevant in 2014, by Anonymous Coward · · Score: 0

      We are not mere humans, now bow underling.

      - A compiler engineer

    22. 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

    23. Re:C is very relevant in 2014, by Rei · · Score: 1

      Right. Because bug-free automatic memory management is silly, who would want that? Who would want inline threading when you can write a page of pthread code every time you want a thread? Why would anyone want templates when they can copy-paste and modify/maintain the same code a 20 times? Who doesn't want to have to reimplement every type of data structure known to man, each time introducing the risk of bugs? I could go on, there's so many reasons why there's "no reason or excuse to use C++"!

      --
      "We consider that six courts and an asylum claim are a rather odd way of returning to Sweden within a month."
    24. Re:C is very relevant in 2014, by Anonymous Coward · · Score: 0

      Clear that cloud of depression with the knowledge that those people's opinions are irrelevant. Unless you're forced to code in a particular language due to your job, just pick whatever feels right to you and you can usually make almost anything work.

    25. Re:C is very relevant in 2014, by Anonymous Coward · · Score: 0

      I used to be an avid C programmer, until I realized the harm I was causing myself and others.

      Maybe you just suck. Enthusiasm only gets you so far. At some point you have to suck it up and learn.

    26. Re:C is very relevant in 2014, by Kinthelt · · Score: 1

      In Bjarne we trust. I should hope he knows what he's talking about.

      --

      "Evil will always triumph over good, because good is dumb." - Dark Helmet (Spaceballs)

    27. Re:C is very relevant in 2014, by jlar · · Score: 1

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

      Behold. A C program that has gained sentience.

      You’re in a desert walking along in the sand when all of the sudden you look down, and you see a tortoise, it’s crawling toward you. You reach down, you flip the tortoise over on it's back. The tortoise lays on it's back, it's belly baking in the hot sun, beating it's legs trying to turn it'self over, but it can’t, not without your help. But you’re not helping. Why is that?

    28. Re:C is very relevant in 2014, by Dasher42 · · Score: 1

      About those C++ templates, you said, "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)."

      I used to use the -fno-implicit-templates parameter on g++: https://gcc.gnu.org/onlinedocs... when I was doing C++ heavily. I also usually didn't have more than two templated types, mostly to keep the debugging simpler. Do you still have any quantification for the overhead with C++ code generation versus C's as you used it? Did you try options like this? And how heavily templated was the code?

    29. Re:C is very relevant in 2014, by guacamole · · Score: 2

      That's why most application developers will not touch C with a ten foot pole. C remains extremely fast and simple programming language, but it has little built in support for "safe programming".

      To be honest, some of that is not the failure of the language but the libraries. For example, string handling is a big source of programming mistakes in C. So why isn't there a _standard_ library for safe string handling? (I know there may be several third party libraries) A library could abstract away the management of pointers to chars, things like growing and shrinking storage of the strings, creating string objects, destroying them, etc. without programmer ever touching a raw pointer to memory containing the string data.

    30. Re:C is very relevant in 2014, by RoccamOccam · · Score: 2

      "C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off".
      Yes, I said something like that (in 1986 or so). What people tend to miss, is that what I said there about C++ is to a varying extent true for all powerful languages. As you protect people from simple dangers, they get themselves into new and less obvious problems. Someone who avoids the simple problems may simply be heading for a not-so-simple one. One problem with very supporting and protective environments is that the hard problems may be discovered too late or be too hard to remedy once discovered. Also, a rare problem is harder to find than a frequent one because you don't suspect it.

      -- Bjarne Stroustrup

    31. Re:C is very relevant in 2014, by Anonymous Coward · · Score: 0

      That's why most application developers will not touch C with a ten foot pole.

      Many if not most applications are written in C.

    32. Re:C is very relevant in 2014, by Anonymous Coward · · Score: 0

      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.

      Do you even know *how* ABI is defined? How do I call `def foo()` in superlib.py from my java? oh, need an interpreter and lots of crap in the middle. OK, how about (Something::*)(const FooStruct &) ? Oh, right, you need that thing mangled to get real symbol.... And how about myFunction() in C? Right, there it is. One simple, plain symbol in the .o file.

      1. it's easier to export C symbols
      2. it's easier to define stable C ABI
      3. it's easier to wrap C API, if you need it
      4. It's the Lowest Common Denominator of interop

    33. Re:C is very relevant in 2014, by Anonymous Coward · · Score: 0

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

      It's also C's greatest strength.

      Like many other great things, it doesn't cripple itself because of user incompetencies. I definitely am a believer in programming language diversity, and usually prefer other languages for what I do, but I also think the feature set of a good language is what it is because it is useful for its typical use scenarios--not to prevent mistakes by people who don't know how to use it. C's typical use scenarios involve basic elements of computing--linking higher level algorithmic issues to lower level hardware issues--so it finds a lot of utility. Languages that target a fundamental use case in computer science, and do that well, regardless of user assumptions, will flourish.

    34. Re:C is very relevant in 2014, by Anonymous Coward · · Score: 0

      > 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.

      Ever, I say ever seen the error messages produced by C++?

      C is sooo much cleaner, and less likely to blow my foot off.

    35. Re:C is very relevant in 2014, by Anonymous Coward · · Score: 0

      Thanks

    36. Re:C is very relevant in 2014, by Kielistic · · Score: 2

      This is why romanticizing C is not a good idea. It's a pain in the ass language that should only be used when it has to. Currently there a far too many C zealots that are trying to project to the world that they are experts but would be better described as Dunning-Kruger sufferers.

    37. Re:C is very relevant in 2014, by hazeii · · Score: 1

      And C++ doesn't? (cited as it was mentioned as something better).

      Any high-level language is an elaboration on the underlying reality. C is closer to whats really going on than its offspring (a simple consequence of it being built at the time we were learning to drive computers effectively).

      Really, the argument is about teaching people how to drive when they don't know what's going on under the hood. How many people these days care about that? Like your average programmer, they just want to get from A to B.

      --
      All your ghosts are just false positives.
    38. Re:C is very relevant in 2014, by Anonymous Coward · · Score: 0

      It's not a question of "getting your hands dirty". C has numerous unsafe practices because at that time no one cared about safety. GOTO statements were still peachy waaay back in those days.

      The two reasons it has not, and will never be, fixed are: fear of losing ubiquity by forking (my toaster can run c) and masochistic programmers who take pride in how difficult they can make things for themselves.

    39. Re:C is very relevant in 2014, by Rei · · Score: 1

      Right, because the computer world hasn't been facing an overabundance of bugs in code related to memory mismanagement, insufficient threading, improper code duplication, and buggy implementations of common data structures?

      --
      "We consider that six courts and an asylum claim are a rather odd way of returning to Sweden within a month."
    40. Re:C is very relevant in 2014, by Anonymous Coward · · Score: 0

      Agent Smith was Tough Love in version 1.0 of the matrix.

    41. Re:C is very relevant in 2014, by deesine · · Score: 1

      Describe in single words only the good things that come into your mind about your mother.

      --
      damaged by dogma
    42. Re:C is very relevant in 2014, by Sigma+7 · · Score: 1

      Because bug-free automatic memory management is silly, who would want that?

      Actually, it's still possible to have some bugs if you improperly use auto_ptr and shared_ptr, etc, but it's still much better than the classic method of allocation.

      To be bug free, it has to be on-par with something like Java, where you can't break memory management no matter how hard you tried. This won't happen as long as there's the need to deal with raw pointers or if you have to dodge misaccessing elements (e.g. bounds checks...)

      "It's harder to shoot yourself in the foot with C++, but if you do, you blow your whole leg off."

    43. Re:C is very relevant in 2014, by Anonymous Coward · · Score: 0

      That doesn't compile.

    44. Re:C is very relevant in 2014, by n7ytd · · Score: 1

      Because bug-free automatic memory management is silly, who would want that?

      Actually, it's still possible to have some bugs if you improperly use auto_ptr and shared_ptr, etc, but it's still much better than the classic method of allocation.

      To be bug free, it has to be on-par with something like Java, where you can't break memory management no matter how hard you tried. This won't happen as long as there's the need to deal with raw pointers or if you have to dodge misaccessing elements (e.g. bounds checks...)

      "It's harder to shoot yourself in the foot with C++, but if you do, you blow your whole leg off."

      Really? Are you saying it's not possible to have a Null Pointer Exception in Java? Hmm...

    45. Re:C is very relevant in 2014, by GiganticLyingMouth · · Score: 1

      Actually, it's still possible to have some bugs if you improperly use auto_ptr and shared_ptr, etc, but it's still much better than the classic method of allocation.

      Of course, you're not using auto_ptr anymore, right? It's been deprecated in C++11, and there's little to no reason to use it in favor of unique_ptr. auto_ptr was the attempt at implementing unique_ptr semantics prior to having rvalue references as part of the language. As for the possible pitfalls... shared_ptr can still fall prey to cyclical dependencies, but unique_ptr is very good for enforcing ownership semantics.

    46. Re:C is very relevant in 2014, by GiganticLyingMouth · · Score: 2

      So why isn't there a _standard_ library for safe string handling? (I know there may be several third party libraries) A library could abstract away the management of pointers to chars, things like growing and shrinking storage of the strings, creating string objects, destroying them, etc. without programmer ever touching a raw pointer to memory containing the string data.

      Sounds like you're looking for C++ and std::string

    47. Re:C is very relevant in 2014, by gweihir · · Score: 1

      I do not disagree. But there are still actual experts and they need tools like C and they can provide exceptional results with it and sometimes those exceptional results are critically needed. That for every true expert there are 10 wannabes, I do not dispute at all. The job of a good technical manager is to be able to separate them.

      Still, C is a hardcore tool, and anybody able to produce good (!) software with it has some serious skill. And even people that are only able to write mediocre software in C are not too bad. Most of the Java-crowd would not even get C software to compile, when they suddenly need to do things like write a make-file or call a compiler directly. That is not romanticizing C, that is just reality. An expert tool demands the user of it to be an expert or causes failure. Give 10 people a lumberjack chainsaw (a definite expert-only tool) and 9 will end up killing or seriously hurting themselves, but the 10th person can do much needed work with it.

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

      respect for C++ but, for me, the middle ground is Python for the high-level stuff, plus calling C from Python for low-level stuff. I'm in "analytics" so this is perfection to me. We don't need all that C++ stuff.

      --
      --- widget evolution: enhanced, plus, super, ultra, extreme, exxxtreme, ultra-extreme, ..etc.
    49. Re:C is very relevant in 2014, by Darinbob · · Score: 1

      Bzzt, next you'll be saying that no one should ever use assembler because humans are not prevented from making mistakes in it. It is dangerous because sometimes that is needed. Like a bulldozer, they're dangerous but they are needed therefore we have trained people who use them. But you don't let just anyone who works in the factory drive the forklift, some will hurt themselves.

    50. Re:C is very relevant in 2014, by Sigma+7 · · Score: 1

      In C/C++, the null pointer can do anything from crashing the application to crashing the system (e.g. MS-DOS), sometimes with a time delay you don't know about until it's too late. Once the problem occurs, there's nothing you can do about it (aside from system-specific functions) and your app crashes.

      In Java, null pointers throw an exception rather than attempting to fiddle with whatever is at that memory location. It's not a memory management bug, as it prevents issues before they start. And in the event the null pointer happens without warning, you can easily use a catch statement at a certain point, and try to get the application back to a normal state (if desired).

    51. Re:C is very relevant in 2014, by EuclideanSilence · · Score: 1

      * 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.

      Sometimes when trying to explain verified software I say "This is a correct program. It might not be the correct program you intended it to be, but your code is objectively not any correct program."

    52. Re:C is very relevant in 2014, by EuclideanSilence · · Score: 1

      And provably correct code is still a pipe dream.

      Bullshit. VLSI code is almost always verified by finite models, and many processors are verified down to the level of mathematical axiom. Provably correct software code exists in small amounts, and it's emergence is inevitable.

    53. Re:C is very relevant in 2014, by Forever+Wondering · · Score: 1

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

      Perhaps C's greatest asset is that it assumes that the coder is not an idiot, whereas other languages do.

      --
      Like a good neighbor, fsck is there ...
    54. Re:C is very relevant in 2014, by Beck_Neard · · Score: 1

      The problem isn't at all coder trust. There are plenty of languages that trust the coder a lot yet are far harder to make mistakes in. C doesn't just let you do bad stuff, it puts the bad stuff at the end of a sparkling, glittery, shiny road lined with flowers and filled with elves playing gentle flutes. Oh and there's also scantily clad mermaids in the distance, seductively beckoning you to join them.

      Even if you drill into people's heads that they shouldn't take the easy route, eventually a weary traveler is going to be enticed with the prospect.

      --
      A fool and his hard drive are soon parted.
    55. Re:C is very relevant in 2014, by Beck_Neard · · Score: 1

      A myth about C is that it's a "hardcore" language. C isn't really that complicated a language. There's nothing to be proud of about coding in C. There's a reason C is used in a lot of introductory programming courses. Learn haskell then get back to me. Learning to write good code in C is another matter entirely, but why use a language that makes this hard?

      Most important thing, though, is that I've never seen "exceptional results that no other tool can match." The only area where this is even remotely close to being true is speed. I'll concede that C code can be made fast. But speed comes at a huge cost. Sometimes the cost is worth it (like say, a numerical simulation engine). Most of the time it's not. And new technologies are closing the gap every day.

      --
      A fool and his hard drive are soon parted.
    56. Re:C is very relevant in 2014, by Beck_Neard · · Score: 1

      It's not necessary to write an OS in C. People have written operating systems in high-level languages, sometimes very high level languages. Hell, someone wrote an OS in haskell. The only time you need to use C to write systems code is when it's some weird hardware with a non-standard C implementation, like for microcontrollers. But even that is slowly disappearing as more and more embedded systems go towards ARM-based (and sometimes x86-based) stuff, which has a very healthy language ecosystem.

      --
      A fool and his hard drive are soon parted.
    57. Re:C is very relevant in 2014, by Beck_Neard · · Score: 1

      > And provably correct code is still a pipe dream.

      http://sel4.systems/

      --
      A fool and his hard drive are soon parted.
    58. Re:C is very relevant in 2014, by Darinbob · · Score: 1

      There are also the languages that give you a dose of ricin. Everything seems fine until a couple weeks after you ship the product when you get the sniffles.

    59. Re:C is very relevant in 2014, by Darinbob · · Score: 1

      Great, start a new high level language that only uses the high level language from start to finish. No cheating by using C to bootstrap, or using an OS written in C, etc.

    60. Re:C is very relevant in 2014, by Darinbob · · Score: 1

      Gah, my Cortext-M3 had 16K ram and 128K code. I think we could complete the project with double of each. It's a great ARM chip though, Thumb2 is a huge improvement over standard ARM vs Thumb and interwork, and the interrupt system is great, but the size is cramped.

    61. Re:C is very relevant in 2014, by linuxrocks123 · · Score: 1

      Impressive. But they verified about 9000 lines of C code, and, by their own admission, it's a brittle verification (meaning if they change anything substantial they have to do a lot of work to re-prove it). The specifically say, in one instance, that it took one man-year to verify a change to 5% of the code base. That's ~500 lines of code.

      A year. To change 500 lines of code. imo verifying software is still more a gimmick than anything. We've been writing reliable airline software without formally proving it for over 30 years. It takes a ton of effort, but so does formal verification.

      But thanks for the link, that's an interesting pig they made fly.

      --
      vi ~/.emacs # I'm probably going to Hell for this.
    62. Re: C is very relevant in 2014, by Anonymous Coward · · Score: 0

      Hit the nail on the head with this comment. Not only c extensions but the portability as well. C was designed for having only a text editor and compiler available so there are no prerequisites thus it is mucho portable. When I want to write code that works on ALL major platforms without requiring a runtime or libs I choose C to start with. It is an element on our periodic table of langs I would compare with carbon. Is carbon relevant in 2014? I think so.

    63. Re:C is very relevant in 2014, by linuxrocks123 · · Score: 1

      Bullshit. VLSI code is almost always verified by finite models, and many processors are verified down to the level of mathematical axiom.

      Bullshit on your bullshit, no it's not, and no they're not, not even close. Hardware companies have a fetish for formally verifying floating point stacks because, 20 years ago, the fickle and vacuous mainstream press people decided one particular piece of errata in one particular processor -- the Pentium FDIV bug from 1994 -- was important for some reason, even though every processor ever made and used has errata. AMD took advantage of Intel's bad publicity to formally verify their own FDIV instruction -- JUST the FDIV instruction, mind you -- and then doing formal verification with floating point stacks became something of a thing. There's nothing more going on than that.

      Take a look here, in the section "Errata": http://download.intel.com/desi...

      Doesn't look like the "proved" that VLSI very well to me, although they doubtless subjected it to a fuckton of simulation hours. Which is what they should be doing; theorem proving software or silicon is, usually, a ton of effort for little gain. Simulation hours cost much less than developer time. Our processors would likely be 486 level today if the designers had to prove everything correct. If that.

      Provably correct software code exists in small amounts, and it's emergence is inevitable.

      Said the formal verification researchers, for 30 years or so now.

      --
      vi ~/.emacs # I'm probably going to Hell for this.
    64. Re:C is very relevant in 2014, by hermitdev · · Score: 1

      At least z/OS has some pretty aggressive protection going on that x86 doesn't, otherwise I'd have no hope for the ol' systems (they should hardly ever have existed really then)

      That may be, but it didn't stop me from crashing an entire LPAR, knocking the entire development staff off the mainframe by running a simple select sql statement against DB2.

    65. Re:C is very relevant in 2014, by hermitdev · · Score: 1

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

      This is not true, at least not initially. And your example of LLVM (and clang) completely disregards its history. LLVM/clang are only relatively recently self-hosting (can be used to build themselves). LLVM & clang are written in C++ and for a long time relied upon an external C++ compiler (typically gcc) to be built.

    66. Re:C is very relevant in 2014, by Beck_Neard · · Score: 1

      The question isn't whether writing verifiable code is hard. It's obviously hard. The question is whether the alternative - the risk of a buggy OS bringing down your system and causing potentially huge losses - is worse. In many cases I'd argue that it is. Maybe not if you're writing an iOS game, but definitely for a lot of other stuff.

      --
      A fool and his hard drive are soon parted.
    67. Re:C is very relevant in 2014, by Bent+Spoke · · Score: 1

      For cripes sake, C is just a tool. If you don't know how to use the tool, of course your going to be prone to throwing it down and declaring it to be useless. It is useless, if you don't know how to use it properly!

      C takes a long time to master. And maybe that is the problem. Most other languages are much less unforgiving and quicker to pick up. But with C, we're talking about decades.

    68. Re:C is very relevant in 2014, by Anonymous Coward · · Score: 0

      Well yeah, but those higher level structures come with huge overhead costs that microcontrollers and small devices can't bear.

    69. Re:C is very relevant in 2014, by The+Evil+Atheist · · Score: 1

      There has to be a point when you encounter the n-th buffer overrun that could, I don't know, compromise the security of the internet, before you realize "hey, maybe it's not stupidity or carelessness that people still create and miss these bugs" and you don't want to spend anymore effort having to deal with it when it should no longer be a thing in the modern world.

      --
      Those who do not learn from commit history are doomed to regress it.
    70. Re:C is very relevant in 2014, by gsslay · · Score: 1

      To'o man'y intru'sive apo'strophe's.

    71. Re:C is very relevant in 2014, by Kielistic · · Score: 1

      Don't get me wrong- C is definitely the right tool for some jobs. I'm not about to give up my C compiler. I am merely lamenting this macho culture around it. "Real programmers use C" and the idea that if you don't use it it means you are a bad programmer.

      Perhaps I am just extra critical of this because it was the prevailing attitude with the faculty and student body at the university I attended. Coupled with a fairly anti-math culture it produced less than stellar results as you might imagine.

    72. Re:C is very relevant in 2014, by Anonymous Coward · · Score: 0

      I once gave a co-worker a copy of K&R with the title crossed out, and "C++ : The Good Parts" written in. :)

    73. Re:C is very relevant in 2014, by SkepticalEmpiricist · · Score: 1

      > To be bug free, it has to be on-par with something like Java,

      It would help to be more precise here. By "bug-free", you specifically mean avoiding memory-corruption errors where you `free` the same memory twice, or get buffer overflow errors and so on. The toughest part of that problem is the question of taking pointers to items on the stack - how do we prevent coders from trying to `free` such memory? There are a number of solutions to that problem.

      One solution is simply to have serious limits on what the stack can be used for and to force all pointers to point to heap-allocated objects. This is the Java solution. It does solve that problem well, but it's a very dramatic solution to take. But it's not the only solution - Rust takes a different approach. Rust is basically C++, but where the compiler insists that it must be able to prove to itself that all pointers are being used correctly. I'm not here to promote Rust specifically (disclaimer: I've actually written very little Rust!), my goal is to emphasize that Java is only one solution to that particular problem.

      Of course Java can give NullPointerExceptions. But that can be lived with. I guess the point is that dereferencing a pointer is well defined in Java - it eithers gives you a value, or it gives an exception. The same cannot be said of C. In C, dereferencing a dangling pointer to a (now invalid) part of the stack is undefined behaviour - if you're very lucky you'll get a SIGSEGV, but more likely the program will continue and just give strange results.

      Java isn't "bug-free" - that's obviously a ridiculous thing to say about any language! But it does get rid of a lot of undefined behaviour - and that is definitely a good thing, even though we can still discuss other solutions to the same problem.

      Finally, Java doesn't have destructors and therefore you must explictly write and call `close()` methods on objects that need non-trivial destruction. For example a `DatabaseConnection` object where writes must be `flushed` as part of closing the connection. As a result, Java developers need to remember to call `close()` explicitly - not too soon and not too late - basically they have to manually perform all resource management for such objects. Again, I don't want to just criticize Java for this. Sun had decisions to make in the 90s and they were limited by the compiler technology available then. They focused on one particular problem (`malloc` and `free` of RAM), they chose a simple solution (force almost everything onto the heap) and made certain follow-up decisions (garbage collection). If Sun were making the same decisions today, I think they would use something like Rust. I always found the "action at a distance" concept that is embedded in Java very hard to explain to beginners (some things have reference semantics, some don't. And the references *themselves* have value semantics [think String]).

    74. Re:C is very relevant in 2014, by strikethree · · Score: 1

      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.

      The metaphor does not stand. C with guides and guards has not been invented yet. All of the "safe" languages are more like a device that you put your wood into and choose the shape you want it from a list of predefined shapes.

      C is a very powerful tool. It is almost as powerful as Assembly language. The bar is very high indeed to competent with C.

      Hmm... upon reading my comment, I realize that C *IS* guides and guards... for Assembly language. There is no way to add more guides and guards without limiting free-form cutting with the saw.

      --
      "Someone needs to talk to the tree of liberty about its ghoulish drinking problem." by ohnocitizen
    75. Re:C is very relevant in 2014, by Ihlosi · · Score: 1
      Hmm... upon reading my comment, I realize that C *IS* guides

      C doesn't really guard anything. It does keep you from having to roll your own multiword arithmetics or integer division algorithms, and from dealing with architecture-related things that are mind-boggling for a human, but just another set of rules to a compilers (pipelines, delayed instructions, etc.), and takes over things like optimizing register usage.

      On a computer, all the guides come at the cost of performance. Sure, you can make a programming langugage where buffer overflows are alway caught, but that language will spend a lot of CPU cycles on checks.

    76. Re:C is very relevant in 2014, by TheRaven64 · · Score: 1

      These prototyping boards are fairly expensive (around $40), but the system is amazing - web-based IDE and the device appears as a USB mass storage device that you can just drop the code onto. They're easy to drop into a breadboard and connect other stuff to. ARM's pushing them for the kinds of people who wouldn't normally do embedded development, but I'd love to see them in schools. They have similar I/O capabilities to the BBC Micros that we used in the '80s and '90s, but are small enough that you can put the controller in the computer. I don't know how much the microcontroller itself is in bulk, but I'm really impressed with the prototyping system and I'd love to see them in schools.

      --
      I am TheRaven on Soylent News
    77. Re:C is very relevant in 2014, by Anonymous Coward · · Score: 0

      the tortoise over on it's back

      tortoise lays on it's back

      it's belly baking in the hot sun

      beating it's legs trying to turn

      "its".

      trying to turn it'self over

      "itself".

    78. Re:C is very relevant in 2014, by Anonymous Coward · · Score: 0

      and it's emergence

      "its".

    79. Re:C is very relevant in 2014, by Anonymous Coward · · Score: 0

      Jesus, get a life! Do something productive with your day instead of policing other people's grammar and punctuation.

      "My grammar? Let me tell you about my grammar..." ->BLAM<-

    80. Re:C is very relevant in 2014, by Gibgezr · · Score: 1

      You've got a little boy. He shows you his butterfly collection plus the killing jar. What do you do?

    81. Re:C is very relevant in 2014, by Anonymous Coward · · Score: 0

      In C++, you accidentally create a dozen instances of yourself and shoot them all in the foot.

      Not since C++11 ! We have move semantics now, dodging the bullet before it reaches your foot.

  8. 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 Anonymous Coward · · Score: 0

      Oh come off it, last time I coded assembly on an embedded platform was when I was bitbanging NTSC out of an Arduino. That's a signal with a 1MHz base frequency on a CPU that runs at 16MHz. Timing is critical. But if you're using the MCU's built-in timers, even the built-in ADC, you don't need that level of precision. And that's on an AVR, which is absolutely the bottom end of embedded development. Embedded development these days is mostly ARM SoCs which run at least Linux.

    2. Re:Very relevent for small target embedded stuff. by andyn · · Score: 2

      Depends mostly on compiler and toolchain availability on those platforms. You still have Python-capable processors for embedded systems if you can't afford to learn C.

      FWIW, I've been struggling with LPC4300 series processors. The open source toolchain is just so bad that your CPU hard faults on first attempted function call (most likely due to incorrect memory maps).

    3. Re:Very relevent for small target embedded stuff. by Anonymous Coward · · Score: 0

      This.

      But I feel that there is certain threshold. If you know a couple of languages and fell that you could pick up C in a week or two you might as well not bother.
      It's about the time when you have a pretty good idea of how to write your own compiler that C start to become useful.
      Until then you sort of need the hand holding that other languages provides or the obviousness of assembly to avoid "strange errors"

    4. Re:Very relevent for small target embedded stuff. by alex67500 · · Score: 2

      You still have Python-capable processors for embedded systems if you can't afford to learn C.

      There you go. This. C is for the clever people. We leave the rest of the mediocre languages to the masses.

    5. Re:Very relevent for small target embedded stuff. by Anonymous Coward · · Score: 0

      I just spent the last month working in assembly & C code doing a compiler migration for an embedded MPC5554 target. Yes, assembly code is still relevant, it's mandatory for any power pc board support package, many of the initialization registers aren't memory mapped and you have to use assembly code to access them.

      Back on topic, I've been seeing more and more C++ on embedded targets lately. It's always a subset of the language, but still makes for cleaner and better partitioned designs when used correctly. Though I would not say that C is on the decline for embedded, just that's it's being replaced with C++ on targets where OO is an advantage, like on some of the hc9s12 targets we use.

    6. 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.
    7. 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.

    8. Re:Very relevent for small target embedded stuff. by Anonymous Coward · · Score: 1

      Heh, when I did embedded development we were always forbidden from using bitfields. Load, operate, store is the correct way to access a hardware register. "Let the C compiler do something probably based on the assumption the target address is in RAM" is the wrong way to access a hardware register :p

    9. 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...

    10. Re:Very relevent for small target embedded stuff. by AmiMoJo · · Score: 1

      What's the alternative though? If your C compiler isn't able to optimize the code well enough and forces you to drop to assembler, well there isn't really any other language that is likely to do any better. At least with C it is usually easy and consistent when you want to mix some assembler in.

      --
      const int one = 65536; (Silvermoon, Texture.cs)
      SJW, n: "Someone I don't like, and by the way I'm a fuckwit" - AC
    11. Re:Very relevent for small target embedded stuff. by TheRaven64 · · Score: 1

      The thing is, if you use structures with bit fields, C will not optimize the manipulations with them correctly

      You're conflating the language and the implementation. LLVM does lots of optimisations for bitfield manipulation and has various patterns in the back ends for using them and intrinsics so that you can help the compiler out. If you're seeing some missed optimisation opportunities, then please file bug reports.

      --
      I am TheRaven on Soylent News
    12. 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
    13. Re: Very relevent for small target embedded stuff. by Anonymous Coward · · Score: 0

      An arduino running c is sheer luxury compared to a 6502 with 256 bytes of ram. You and your expensive hobbyist chips!

    14. Re:Very relevent for small target embedded stuff. by Dan+East · · Score: 1

      The thing is, if you use structures with bit fields, C will not optimize the manipulations with them correctly.

      C won't? Or a particular compiler won't? This has nothing to do with C whatsoever and is specific to a compiler / target CPU combination.

      --
      Better known as 318230.
    15. Re:Very relevent for small target embedded stuff. by DavidCBillen · · Score: 1

      I agree you can't completely avoid writing assembly for some embedded - especially DSP.

      But years ago I pretty much switched to C++ for embedded except tight inner-loops that require hand optimization. I had to convince my boss at the time that it was acceptable by showing lots of generated C++ assembly code compared to equiivelent C. In practice C++ often produced BETTER code, (those virtual functions are like using function pointers that you casually pepper the code with).

      It seems though that most people have blurred the line between C++, and the form of C++ that we're [aggressively] taught to write. The actual C++ language doesn't require using accessor functions for every coefficient in a transform matrix, that's just what people do.

      Off topic: But I really don't know why so many people use C++ for non-embedded. It's perfectly valid for many - maybe most - applications to trade efficiency for safety, so use a different language. Why pick one that accommodates all the power of C then constantly beat on the developers with a giant list of coding guidelines? When the greatest attribute you seek in a developer is pedantry then something's wrong.

    16. Re:Very relevent for small target embedded stuff. by Anonymous Coward · · Score: 0

      The thing is, if you use structures with bit fields, C will not optimize the manipulations with them correctly.

      Nonsense. If your output isn't optimizing them correctly the problem is your compiler, not the language. A bit field is just a short-hand way of referring to individual bits within an anonymous structure field; after that it's up to the compiler what to do with it.

    17. Re:Very relevent for small target embedded stuff. by emh203 · · Score: 1

      You must be doing something very wrong. I have 3 products now with the LPC4357. The GNU tools work just fine!

    18. Re:Very relevent for small target embedded stuff. by serviscope_minor · · Score: 1

      The actual C++ language doesn't require using accessor functions for every coefficient in a transform matrix, that's just what people do.

      Indeed, I often write with structs. POD is a very useful concept in C++ and I like it.

      Except for matrices where I do use accessor funcions, namely operator[], or did you mean a .get_11(), get_12(), etc...? I've certainly seen code like that before.

      --
      SJW n. One who posts facts.
    19. Re:Very relevent for small target embedded stuff. by DavidCBillen · · Score: 1

      I was just grabbing an arbitrary example. When people talk about C++ overhead I think they imagine coding [something like] a time-critical matrix transform using accessors and making a function call to read each coefficient. (Even though the optimizer would inline it anyway). Maybe even a std::vector. My point was that these are just practices. If you need tight code you can create it with C++ and still get benefits.

    20. Re:Very relevent for small target embedded stuff. by RabidReindeer · · Score: 1

      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.

      Depends on the compiler and the compile options/pragmas selected.

      If you need EXACTLY the certain machine instructions in EXACTLY a specific order, I don't recommend embedded ("inserted") assembler. The overhead of calling out to a separate assembler module isn't that high and you don't muddle the (allegedly) platform-independent C code with non-C code.

      If you want to set/check bitfields with attention to concurrency, that support has been in there for a long time. Even back in the 1980s C compilers were incorporating the "volatile" keyword for things like memory-mapped I/O devices and spin locks, optimising bit-set/reset/test operations and the like.

    21. Re:Very relevent for small target embedded stuff. by Anonymous Coward · · Score: 0

      volatile?

    22. Re:Very relevent for small target embedded stuff. by serviscope_minor · · Score: 1

      Oh certainly.

      My implementation has a matrix being a linear array of vectors.

      operator[] on a matrix returns a vector object which has a pointer to the data.

      operator[] on the vector indexes the pointer.

      It means I can use proper C/C++ style multidimensional array like syntax (yay one of the few correct uses of the C/C++ term!), i.e.

      some_matrix[row][col]

      The optimizer squashes away the intermediate Vector object and the resulting code is identical to raw access of a multidimensional array, or by-hand multidimensional access of a linear array.

      --
      SJW n. One who posts facts.
    23. Re:Very relevent for small target embedded stuff. by n7ytd · · Score: 1

      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.

      No, the C standard does not guarantee that bit fields are implemented in a portable way, but if a compiler is not optimizing correctly, that's the fault of a broken compiler, not C.

      If you are accessing hardware registers using bit-mapped structures, then yes, you need to understand the machine code being spit out by the compiler.

    24. Re:Very relevent for small target embedded stuff. by n7ytd · · Score: 1

      Heh, when I did embedded development we were always forbidden from using bitfields. Load, operate, store is the correct way to access a hardware register. "Let the C compiler do something probably based on the assumption the target address is in RAM" is the wrong way to access a hardware register :p

      Load, operate, store is the correct way to access a hardware register, except when it's not. Some hardware has side effects when reading from or writing to a hardware port. On some devices, using bit-manipulation instructions is the correct way to do things.

    25. Re:Very relevent for small target embedded stuff. by GiganticLyingMouth · · Score: 1

      Off topic: But I really don't know why so many people use C++ for non-embedded. It's perfectly valid for many - maybe most - applications to trade efficiency for safety, so use a different language. Why pick one that accommodates all the power of C then constantly beat on the developers with a giant list of coding guidelines? When the greatest attribute you seek in a developer is pedantry then something's wrong.

      C++ is great anywhere you need performance. Numerical computing, scientific computing, image processing, computer vision, machine learning, etc -- all of these benefit greatly from C++, as you can use it as a high-level language in the non-performance critical parts, but at the same time, be able to optimize effectively in the places where it matters.

    26. Re:Very relevent for small target embedded stuff. by tepples · · Score: 1

      You're conflating the language and the implementation.

      A language is only as good as its best free implementation.

      Several years ago I was complaining about the space inefficiency of GNU libstdc++ when linked statically (as is required on platforms that don't ship with a copy of GNU libstdc++). A Hello World program using <iostream> was 180K of Thumb (including terminal driver) when optimized for size (-Os -Wl,-gc-sections), compared to about 6K with the equivalent <cstdio> program, which isn't very comforting on a device with 256K of RAM. I investigated it further, and the constructor for cout was initializing all sorts of date, time, and currency formatting objects that the program never called. Some Slashdot user told me that C++ the language is not at fault and recommended that I switch to the $6000 per seat Green Hills Optimizing Compiler. Technically he's right, but a price tag like that is not very practical for hobbyists.

    27. Re:Very relevent for small target embedded stuff. by aralin · · Score: 1

      It's a third comment picking on the missing word "compiler" in my comment... "C compiler won't optimize"... geese. That seemed like a pretty clear thing... no comment edits on slashdot though :(

      --
      If programs would be read like poetry, most programmers would be Vogons.
    28. Re:Very relevent for small target embedded stuff. by Anonymous Coward · · Score: 0

      -1 FTMA (Far too many acronyms)

    29. Re:Very relevent for small target embedded stuff. by Anonymous Coward · · Score: 0

      But is many cases C is directly translatable to Assembly; this includes direct memory manipulation.

    30. Re:Very relevent for small target embedded stuff. by Darinbob · · Score: 1

      Don't forget about inline assembler!

    31. Re:Very relevent for small target embedded stuff. by Darinbob · · Score: 1

      I use C because it's both the right tool, and because the rest of the team freaks out when mentioning basic C++ and because the code would have to be rewritten.

      Basically you use the language that the project is written in, end of story. No one likes the new guy who shows up and tells everyone else that they're doing it wrong. I guarantee that the 50-somethings really don't like the 20-somethings with that attitude.

      I worked with a guy once who didn't get this. Freshly minted PhD, on an embedded system, and he spent most of his time convincing us that Java was a better language to use. In 1998 when state of the art JVM was slow as hell on a Sparc, and he wanted one on the sluggish CPU we had. Eventually he quit, and I heard through channels that he gave a Java One keynote talk where he mentioned the luddites he used to work with. Sure, Java is great for some things but it's not best for all possible things.

    32. Re:Very relevent for small target embedded stuff. by Darinbob · · Score: 1

      Bah, yer a poseur! Old farts used octal because it mapped better to the PDP opcodes. Hex was new fangled stuff for Apollo missions.

    33. Re:Very relevent for small target embedded stuff. by Darinbob · · Score: 1

      Generally the only time I use assembler is when very specific things are needed. Access to an instruction that the compiler doesn't use, like atomic memory operations, cache flushes, context switches, and so on. Basically highly system specific uses rather than optimization.

    34. Re:Very relevent for small target embedded stuff. by Ihlosi · · Score: 1

      I found that compared to having separate files for functions in assembly (that are then called from C), inline assembly is usually more hassle- and bug-prone.

    35. Re:Very relevent for small target embedded stuff. by Darinbob · · Score: 1

      It depends on use. Full standalone functions can go into files but then you have a hassle of trying to get your C constants or macros into the assembler. Unless you use the CPP with assembler option. Even then if you need to grab the third field in a struct you're going to have to stick some define in the assembler and make sure your header file and assembler don't get out of sync.

      For some smaller stuff you can get more efficient code by not having a function call, as the compiler can optimize what you have as part of a basic block (at least with gcc as you can better control this), your instruction pipeline doesn't burp, and you don't need juggling of registers. It also depends if you think that function calls are expensive on your processor not or if your goal is to save size. A good example here would be a function doing saturated addition which is available on some processors but most languages don't have this as a built-in, and people who want saturated addition almost always want performance.

    36. Re:Very relevent for small target embedded stuff. by Anonymous Coward · · Score: 0

      BS. Embedded development still happens on 8-bit controllers. Your ARM SoCs are for phones and higher end stuff, not the low level things that are all around you that you don't even notice. There is one in your mouse, in your keyboard, in your monitor, maybe in you lamp. If it has a blinking led there is a good chance it's made with tiny MC instead of analog circuit. There are tens of those inside your average car.

    37. Re:Very relevent for small target embedded stuff. by Ihlosi · · Score: 1
      BS. Embedded development still happens on 8-bit controllers

      And there's also plenty of ARM chips that don't run Linux (because they can't due to lack of a MMU), e.g. Cortex-M0...M4-based parts.

      That's one of the nice things about small target embedded work. It covers everything from 8-bit to 32-bit, from simple (no hardware multiplier, no division in hardware) to loaded (hardware floating point support, MAC units, HW dividers), from slow (temperature logging) to fast (control loop running at 30 kHz requiring 3us latency).

    38. Re:Very relevent for small target embedded stuff. by Anonymous Coward · · Score: 0

      Wimp - when I was a kid we programmed our boot loaders by throwing a sequence of toggle switches and dumping them with another switch. Tape is for trust babies.

    39. Re:Very relevent for small target embedded stuff. by Anonymous Coward · · Score: 0

      Very right. The control and flexibility that C gives your is uncomparable. The key is in deciding when you need it.

  9. Using C on a daily basis by Anonymous Coward · · Score: 0

    As an embedded software dev, I use C on a daily basis still, and it's unlikely to be replaced by anything else any time soon

  10. 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.

    1. Re:C had no real successor by jones_supa · · Score: 1

      I don't think there is any other. The latest specs of C++ has made some functionality much simpler, but it's still indeed rather complex language. C is the golden standard for embedded and other small footprint stuff, C++ provides high-performance OOP for GUI apps and video games.

    2. Re:C had no real successor by Anonymous Coward · · Score: 0

      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?

      Forth?

      Ducks and runs..

    3. Re:C had no real successor by Rei · · Score: 2, Insightful

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

      C++ is no more complicated to use than C. You can write C code in C++ and it'll work just fine, with only a few rare exceptions.

      What C++ does give you is many more capabilities. Now, if you don't want to take the time to learn these capabilities, that's not the language's fault. There's a few things that were implemented a bit awkwardly (mainly looking at you, streams), but the vast majority is quite simple and straightforward, and it just keeps getting better and better (check out the capabilities of C++11 if you haven't yet - auto declaration types, inline threading, for-each looping, smart pointers in STL, and on and on... really, really nice).

      If you don't like a particular part of C++? Don't use it. But that's no excuse to use "C-only". Want to use printf instead of cout? Go right ahead. But dammit don't do your own memory management when you don't absolutely have to, or your bugs are going to screw over the rest of us when we use your software.

      --
      "We consider that six courts and an asylum claim are a rather odd way of returning to Sweden within a month."
    4. Re:C had no real successor by gweihir · · Score: 1

      And too slow and a failure as an OO language. I mean, even the designers of C++ warn against complex class hierarchies. How stupid is that?

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    5. Re:C had no real successor by Rei · · Score: 1

      Your proof that C++ is in general slower than C is....?

      STL is generally quite optimized (more than most C programmers will do with their home-rolled reinventions of the wheel), and templates allow code to be built automatically then and optimized by the compiler, which is why for example std::sort is faster than qsort().

      Your "complex class heirarchies" suggests that you seem to just think of C++ as "C with objects". You can write excellent C++ code making use of all sorts of powerful C++ features without ever rolling an object of your own.

      --
      "We consider that six courts and an asylum claim are a rather odd way of returning to Sweden within a month."
    6. Re:C had no real successor by gweihir · · Score: 1

      And how did you manage to not understand my statement "...failure as an OO language"?

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    7. Re:C had no real successor by Anonymous Coward · · Score: 0

      Or you can write excellent C code that doesn't require the bloated STL and all the complexities (so-called "powerful features") that C++ offers you to shoot yourself in the foot. If you want to argue that C++ is somehow universally superior to C (as you seem to be in many comments thus far) you're going to have to provide more proof than "you C idiots reinvent all the wheels poorly and only criticize my pet C++ because you're a bunch of ignorant unenlightened plebs."

    8. Re:C had no real successor by Rei · · Score: 1

      "Complexities" vs. "Powerful features". Okay, I'll bite. Implement an equivalent to std::vector (one of the most basic and commonly used STL objects) in C for me. Make it 100% bug free and perform better than std::vector. Go.

      (Because if I want something like that, all I have to type is "std::vector<datatype>". Oooh, so damned complex, I'm trembling even thinking about it!)

      --
      "We consider that six courts and an asylum claim are a rather odd way of returning to Sweden within a month."
    9. Re:C had no real successor by justaguy516 · · Score: 1

      C++ is like a Swiss Army penknife gone mad. The one with three blades, corkscrew and screwdriver was a useful enhancement over a plain knife ; though a plain knife is sufficient for most of what you need. But now the penknife has 1000 blades ranging from fish gutting to bear fighting, a built in arc welder, all the tools needed to strip the engine of a Maserati PLUS a built in grill and oven. Its crazy.

    10. Re:C had no real successor by itzly · · Score: 1

      I don't like exceptions, but without exceptions, how do you indicate failure from a constructor ?

    11. Re:C had no real successor by jbolden · · Score: 1

      I always liked Forth. Concatenative programming tends to lead to some great "ground up" designs. As a successor to Forth, PostScript was actually a quite good programming language but almost no one knew it (they just had computers put out PostScript code). One of the things I like about Haskell is how it encourages Concatenative programming like Forth did while offering better control structures.

      No reason to duck.

    12. Re:C had no real successor by itzly · · Score: 1

      No C programmer is going to implement 100% of the std::vector class, and then only use 1% of the features, even though this is accepted practice for a C++ programmer. Instead, a C programmer would just write some code for the 1% he's going to use.

    13. Re:C had no real successor by Anonymous Coward · · Score: 1

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

      C++ is no more complicated to use than C.

      He said complex, not complicated.

    14. Re:C had no real successor by Rei · · Score: 1

      There's several ways. One is exceptions, which you already said you don't like. Another is to pass by reference (or pointer, if you prefer) a success flag into the constructor. Another is to use a factory method to build the object. Another is to have a queriable flag built into the object. You can even implement such a flag by having the object able to evaluate as boolean ("explicit operator bool() const { return success_flag; }"), so you can do "if (X x) { .... }". There's countless ways, all the way up to and including the standard approach in pure C, having a "create" or "initialize" function that does the work that can fail. It's all about your personal preferences.

      --
      "We consider that six courts and an asylum claim are a rather odd way of returning to Sweden within a month."
    15. Re:C had no real successor by Rei · · Score: 1

      No problem, we'll make it easy on you - just implement the basic subset - creation, initialization, push_back, indexing, and erasure.

      Surely since vector is one of the most basic, common types in C++, and you saw fit to put the words "powerful features" in quotes (meaning that you think that the features are trivial), this task must be a breeze for you, right? So go on, give me your quickly written bug-free implementation that performs better than std::vector. And remember, all I have to type is "std::vector<datatype>", so this must be a breeze, right?

      --
      "We consider that six courts and an asylum claim are a rather odd way of returning to Sweden within a month."
    16. Re:C had no real successor by suy · · Score: 1

      And too slow and a failure as an OO language. I mean, even the designers of C++ warn against complex class hierarchies. How stupid is that?

      And the designers of Ruby also suggest that you don't create complex class hierarchies. And the designers of Java created interfaces to avoid complex class hierarchies. Maybe the problem are complex class hierarchies, or trying to solve everything with OOP when you should not?

    17. Re:C had no real successor by Anonymous Coward · · Score: 0

      C++ is no more complicated to use than C. You can write C code in C++ and it'll work just fine, with only a few rare exceptions.

      What C++ does give you is many more capabilities. Now, if you don't want to take the time to learn these capabilities, that's not the language's fault.

      Template metaprogramming (or, "why on earth would I use a language that could be made to make the compiler emit an indefinite list of prime numbers?".) That's when I checked out of C++. (This was around 1996.)

      The problem with some of those capabilities is that - from a maintainability perspective - they should never be used. In the real world, developers have different levels of ability with the language. If your language has complex enough features, some expert will come along and use them, followed by some less effective developer that thinks they understand the feature but really doesn't, hacks the code into little bits and pieces, resulting in an convoluted mess.

    18. Re:C had no real successor by itzly · · Score: 1

      I don't think there's a way to make any of that look pretty. What if the constructor is implicitly called to initialize a base class, or in a copy constructor ? Also, if the constructor failed because of lack of memory, where is it going to store the flag that it failed ?

    19. Re:C had no real successor by itzly · · Score: 1

      Apparently you didn't understand a word I was saying. And no, I didn't put powerful features in quotes. You seem to think that reading is a breeze.

    20. Re:C had no real successor by Rei · · Score: 1

      One of the suggestions I made is the very thing that C does (an "initialize" or "create" function), so if you don't think that looks pretty, then you won't find the C versions pretty either. And I personally find "if (X)" using an explicit bool operator quite pretty, although I personally have no problem with exceptions.

      Also, if the constructor failed because of lack of memory, where is it going to store the flag that it failed ?

      Are you talking about stack or heap memory failure? If you're talking heap (say, a failure of a "new" call), then the answer is, "As a basic member variable in the class (struct), exactly the same as C data structures do". If you're talking about not having enough memory to create the class on the stack, then you wouldn't have enough memory to create the C equivalent on the stack either.

      --
      "We consider that six courts and an asylum claim are a rather odd way of returning to Sweden within a month."
    21. Re:C had no real successor by Rei · · Score: 1

      Sorry, didn't notice you'd taken up the AC's argument. So are you saying that you don't agree with their sarcasm about the capabilities of STL? Do you accept that STL provides great benefits at avoiding reinventing the wheel and thus introducing bugs? Do you agree that anyone randomly trying to reimplement even a basic subset of std::vector (one of the most basic of STL tasks) would in all likelyhood:

      1) ...find it's not some "trivial" task, relative to simply just calling "std::vector<datatype>"?
      2) ...find that they don't exceed its performance, and may well come in slower, esp. if they don't spend a long time tuning it?
      3) ...probably introduce bugs in certain edge cases that they don't catch right away?

      These are the reasons that we don't reinvent the wheel.

      --
      "We consider that six courts and an asylum claim are a rather odd way of returning to Sweden within a month."
    22. Re:C had no real successor by Rei · · Score: 1

      Template metaprogramming has a use, but generally only in libraries or certain edge cases. But unless you're in that particular use case that needs it, don't use it. And the thing is, people don't use it unless they need to. When was the last time you pulled up a random C++ program off the net and found it full of template metaprogramming? To me that's happened precisely zero times.

      If you want to talk about the ability to make programs convoluted messes, macro metaprogramming is by the way far, far worse. And unlike template metaprogramming, I've actually run into that far too often, people who think they're being clever and saving time by macroing the program into a disaster zone. And if you *want* to be evil, my god, can you ever...

      --
      "We consider that six courts and an asylum claim are a rather odd way of returning to Sweden within a month."
    23. Re:C had no real successor by Rei · · Score: 1

      Whoops, broken link: "my god, can you ever..."

      --
      "We consider that six courts and an asylum claim are a rather odd way of returning to Sweden within a month."
    24. Re:C had no real successor by TimboJones · · Score: 1

      There is very little possible to do in an OOM situation using language exceptions. Let the program segfault. If you need more, handle the OOM signal using SEH or the SIGTERM handler, or whatever other mechanism is provided by your memory handling library. If you absolutely need OOM recovery, use malloc instead of higher-level language constructs and keep your fingers crossed.

    25. Re:C had no real successor by gweihir · · Score: 1

      Complex class hierarchies are not the problem. But they need some understanding how to implement dynamic dispatch right or things will get very slow. Python does it right with using hash-tables. Eiffel does it right with binary search. My guess is SmallTalk already had an efficient mechanism. All those that use linear-search for dynamic dispatch have no clue what they are doing. Unfortunately, even today, many OO language designers do not know how to do it right. Java is a prime example. Interfaces are just a workaround for a compiler far to stupid to get even basic OO mechanisms working.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    26. Re:C had no real successor by david_thornley · · Score: 1

      A flag you can query isn't sufficient in the general case. A constructor called from non-placement "new" (presumably implicitly because you really shouldn't write it much in modern C++) can fail to get memory allocated, in which case having a flag in the object isn't going to work. For that, you either need to throw an exception or use "(nothrow)" to get the constructor to return nullptr instead.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    27. Re:C had no real successor by david_thornley · · Score: 1

      What's good about complex class hierarchies? Inheritance creates really close coupling, and close coupling is bad. When you can, it's better to incorporate an object than inherit from its class.

      That makes almost as much sense as calling C++ slow.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    28. Re:C had no real successor by twistedcubic · · Score: 1

      C'mon, now. C++ needed the relatively recent "move constructor" to solve a serious inefficiency when doing, say for example, complicated matrix arithmetic using classes (created in the most obvious way). Before this, there were hacks, like template metaprogramming. The reputation of C++ is well-deserved, even if all of that stuff is fixed now.

    29. Re:C had no real successor by Darinbob · · Score: 1

      C++ was a successor, but it kept growing, and growing, and...

      Ada could have been, and especially the more recent versions of it are very nice, but too many people just did not like the verbosity, even the department of defense that mandated its use refused to use it. Modula-II could be an alternative but it never really caught on outside of Europe, and Pascal was too limited and not standardized.

    30. Re:C had no real successor by Rei · · Score: 1

      Let's say it all togeher one more time: "C++ is not C with classes"

      If you don't find a particular C++ approach to doing something (such as custom rolling yourself classes for a matrix app) to be appropriate, then don't do that, but for $DEITY's sake, don't roll your own memory management, basic data structures, and on and on and on.

      And I'm sorry, but if you were making a matrix multiplying program with custom-made C++ objects, how on earth did you end up copying whole rows without realizing that's what you're doing? I have trouble picturing that's even possible. How could you be so daft as to write a copy constructor, then set one copy of an object equal to another, and think that your copy constructor wasn't being called?

      No, it didn't take template metaprogramming to avoid that before move constructors, template metaprogramming isn't even particularly applicable to such an app. It simply took a move() member function. Move constructors / operators are just a cleaner/prettier way to do that.

      There was nothing "broken" to be fixed, except for a programmer who apparently was writing a copy constructor and then copying objects over without realizing that the object was copying itself.

      P.s. - your example of "matrix arithmetic classes" makes it pretty obvious that you're talking about some assignment you were given in CS-101 that you probably got an D on. That's one of those sort of tasks that's assigned by professors to try to teach people to understand what objects are but in the real world people rarely write themselves if they ever even use one directly.

      --
      "We consider that six courts and an asylum claim are a rather odd way of returning to Sweden within a month."
    31. Re:C had no real successor by Anonymous Coward · · Score: 0

      I ban the STL in my C++ style guide. I had to junk someones code and rewrite it one too many times, as it was easier than trying to debug that mess.

      Too many people code a problem which they fail to debug, and when you do that with the STL you make it far harder for the person who needs to clean up your mess to do so. The STL is widely known for producing horribly cryptic error conditions which tell you very little about where the problem is.

      The C equivalent may be slightly more code, but it is far more easily debugged. If you add enough to your STL laden code to make it easy... it is no longer shorter than the equivalent C.

    32. Re:C had no real successor by Rei · · Score: 1

      I ban the STL in my C++ style guide.

      I have to say, it's an honour hearing from the author of "How To Program Terrible C++ A Nutshell"

      --
      "We consider that six courts and an asylum claim are a rather odd way of returning to Sweden within a month."
    33. Re:C had no real successor by rl117 · · Score: 1

      I used to be a "C" zealot who considered it unmanly to use other languages. I've got past that with age. C is simple, but it comes at the cost of having to do every last thing by hand. Even when it's unnecessary and the chance of making mistakes is high. After spending years on the nitty-gritty details, there comes a time when you have to ask: do I really need to implement the needed bits of a vector/list/set/map/hash or do I just use one that I know will work without any trouble. Chances are it's optimised better than my hand-rolled one would be. And it takes a few seconds to use, since I don't have to write all that wheel-reinventing code myself. I can focus on the problem I was trying to solve, rather than unnecessary groundwork.

      Stuff like std::vector is often criticised by those who don't appreciate what it does. After optimisation, element access is as efficient as a C array, and the automatic memory management is no worse than what you'd need to do in C anyway. And it's type-safe and exception-safe. Same with std::string. This is also often more efficient than using the C string functions (though obviously can be less so if used badly). But it's safe and easy to use, which is the big win. How often have you screwed up C string manipulation. That's right, we all have, and even when it appears safe and working, it's often a disaster waiting to happen.

      I'm replying to this because as I was reading through I was working on some code for work. We were using std::vector in a set of nested objects to keep track of their children using std::shared_ptr, and to allow cross-references with std::weak_ptr. Works just fine. But profiling showed that our usage patterns were suboptimal. We needed to keep track of objects by their insertion order (linear) but also needed to do fast lookups (set/rbtree). I could have hand-rolled a custom implementation, or made a custom container with embedded vector and set objects and logic to keep them synchronised. However, a little research and this was the solution:


      template<typename T, template <typename ElementType> class Ptr>
      struct indexed_container
      { /// container type.
      typedef boost::multi_index_container<
      Ptr<T>, // value type
      boost::multi_index::indexed_by<
      boost::multi_index::random_access<>, // insertion order
      boost::multi_index::ordered_unique<boost::multi_index::identity<Ptr<T> >, std::owner_less<Ptr<T> > > // sorted order
      >
      > type;
      };

      Total time from finding the problem to researching and creating this working solution (including converting the existing code to use it): 2 hours.
      So now I can do indexed_container<foo, std::shared_ptr>::type c and get a custom container containing std::shared_ptr<foo> indexed by both insertion order and by pointer value. With C++11 I could use a templated typedef and also avoid the struct wrapper. And multi_index_container template is usable for all sorts of esoteric multiple-indexing with indexing on individual/multiple fields or with custom f

    34. Re:C had no real successor by Smerta · · Score: 1

      C++ is no more complicated to use than C.

      This I have to take issue with. I will agree that C++ is a useful language, including embedded systems, but it's much, much more complicated than C. You can write in a subset of C++ which is largely the same as C (never quite the same though), but if you were to draw a Venn diagram of C++'s features vs. C, it's crazy (I went through this exercise, for a presentation). Again, don't get me wrong, I've been using C++ on real time systems for 20 years, but it is an entirely different animal. For an example (this is a quote from Peter van der Linden's outstanding book "Expert C Programming", in fact I think he was quoting Tom Cargill):

      "If you think C++ is not overly complicated, just what is a protected abstract virtual base pure virtual private destructor and when was the last time you needed one?"

      There are other examples, but hopefully that one serves as a good example.

      If you don't like a particular part of C++? Don't use it.

      Here I am 100% in agreement with you, at least when it comes to personal projects. The problem is that when you work in a larger organization with a disparate knowledge of the language, you've got some people writing "C with classes" (if even that) and some people using template metaprogramming, complicated overridden copy constructors, placement new, custom allocators in STL containers, etc. Now, sometimes you can either just "use" that wizard's code and hope for the best, or just read it and run away, but sometimes you have to maintain it.

      I am working with a group right now where I am the "C++ expert" in the group (I don't consider myself an expert), and there were a few individuals in the group, years back, that /clearly/ were language wonks. Their code is (mostly) correct, but it's almost inscrutable, and when it needs to be changed or fixed, everyone in the group except for me is terrified. So here is where the whole "Just use what you're comfortable with" breaks down. You can try to address this with a coding standard that restricts usage, subsets the language, etc. but still, it's very easy to introduce code that some in the group just can't understand. IMO this is possible in C too (hello, IOCCC!) but it's "harder" to do, because the language is simpler, there's just less you have to understand and keep in your head while you're reading someone else's code.

  11. Agreeing? by Anonymous Coward · · Score: 1

    Do you agree?

    I agree that with a summary like that, this is a trollish article designed to get a lot of posts and bring out people's emotions.

    C is used for embedded devices. No other languages are competing for it at that level.

    Most C developers are probably a bit older, and as such don't waste their time on social media.

    As C is a simpler language, there's less need for online help. C++ is a cluster fuck of a language, so it *requires* a huge online support community. Social media popularity is an extremely poor metric. That's more based on fads and marketing than usefulness.

    1. Re: Agreeing? by Anonymous Coward · · Score: 0

      Yip. Mmhmm.

    2. Re:Agreeing? by ameoba · · Score: 1

      Social media popularity is an extremely poor metric. That's more based on fads and marketing than usefulness.

      So you're saying that node.js isn't going to take over every aspect of computing by 2020?

      --
      my sig's at the bottom of the page.
  12. C the secret rulers of the the world. by Anonymous Coward · · Score: 1

    Languages don't just go away and vanish. Almost everything you use is built on top of it, even if you never have to see it yourself.

    You can have a good career without ever touching C, but you need to know it is there. The only way to make it irrelevant is to replace all the existing infrastructure code with something else, and it is far too late for that to be feasible.

    Like COBOL and FORTRAN, it will probably be with us forever.

    1. Re:C the secret rulers of the the world. by Anonymous Coward · · Score: 0

      On the contrary there are tons of old dead languages which are not used in any significant volume in the modern day (ever heard of EZtrieve?)

      C is not one of them, it will likely be the last standing of current popular languages. I would be unsurprised to find that C is still in common use 100 years from now. I could not say that about any other current language.

  13. C++ is C by melonman · · Score: 1

    Modern, best-practice C can be compiled with a C++ compiler. (There are a few gotchas moving in either direction - http://www.cprogramming.com/tu... - but it's not hard to avoid them.) For all its object-oriented impurity and spec-bloat, the one thing I love about C++ is that you can write relatively high-level code when that makes sense, but you always have the option to grapple with all the fine detail when that's useful.

    --
    Virtually serving coffee
    1. Re:C++ is C by paai · · Score: 1

      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

    2. Re:C++ is C by Tough+Love · · Score: 1

      It's not C until it has designated initializers.

      --
      When all you have is a hammer, every problem starts to look like a thumb.
    3. 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.)

    4. Re:C++ is C by Anonymous Coward · · Score: 0

      I agree, and I understand.
      I'm actually a C# developer primarily, with my roots in C/C++.
      Object Oriented thinking and solutions don't come easy with languages that let you "break the rules". (write over const values, for example).

      I found C# to be a big leap, and I nearly never made it. Glad I did. Now I think in completely different terms, and this makes really big problems easier to manage.
      However, the downside is that I often look over my shoulder and think how much quicker and easier it seemed to developer in a procedural way.
      but there does come a point with higher level projects where procedural development breaks down, and you lose control of your code.
      I see this a lot with javascript on the front-end. You just can't maintain lots of code in this state.

      But anyway, my central point is, it doesn't matter the language, bad programming can still be done! - and depending on what you're trying to do, a procedural approach might be just fine, and perhaps more efficient too.

    5. Re:C++ is C by Anonymous Coward · · Score: 0

      The problem with object oriented programming is that both the programmer and the computer think in procedural terms. Having the interface between them in a paradigm that is fundamentally different to both is a choice I have never understood, but the labour required to make it work does seem to provide a great number of people with jobs. The downside is that it takes most of the fun out of programming.

    6. Re:C++ is C by Anonymous Coward · · Score: 0

      Very true. If you write "modern, best-practice C", you'd be using designated initializers, and so a C++ compiler would fail. It's entirely possible to write code in polyglot C, but very often proper C code isn't valid C++, especially when it comes to C99.

    7. Re:C++ is C by Anonymous Coward · · Score: 0

      (There are a few gotchas moving in either direction - http://www.cprogramming.com/tu... - but it's not hard to avoid them.)

      Like having to create a cross-compiler for your target platform.

      The C standard is intentionally kept small and with certain functionality kept undefined to ensure that it is easy or at least possible to write compilers for everything.

      C++ is a great alternative to C in the field where Java, C# or Python are contenders.
      It's not a catch all replacement for C.

    8. Re:C++ is C by Tom · · Score: 1

      I thought the same and then I started to use OO a lot in PHP.

      If you come from C, don't go the "OO is my religion, deliver me from functions" path. Write functional code and use objects in it where it makes sense. I've written computer games as a hobby for most of my life, and in that context you have a lot of natural objects. The player, the weapon, the level, the building, the city, etc. etc. you also encounter inheritance very fast.

      I still write largely functional code and my objects are basically containers. It works great for me, even though some pure OO extremists would cringe at it.

      I don't see OO as a paradigm. It's a tool, a method, and it mixes nicely with others if you do it right. I'm very thankful to PHP for their approach which offers you a full OO model, but doesn't force it on you.

      --
      Assorted stuff I do sometimes: Lemuria.org
    9. Re:C++ is C by Dutch+Gun · · Score: 1

      Interestingly, I've found many C libraries actually use a very OOP-like interfaces - just without the "objects". For instance, you'll first call some sort of create() function to get a pointer to a struct that contains state data or perhaps a handle. You then pass this pointer or handle to "member" functions - essentially, a function that operates on or modifies the state of that data. Then you release the allocated context struct via some destroy() function. That's pretty close to what a class and it's member functions do - the only difference is that C++ member function pass the handle or context pointer implicitly as a hidden first parameter. The create() and destroy() functions are the constructor and destructor respectively.

      Granted, it gets a bit more complicated when you start dealing with inheritance and various access permissions, but that's really the heart of OOP - packages of data and groups of functions that operate on that data. C++ certainly wasn't my first language - I knew BASIC and Pascal before that, but the basic premise of OOP clicked with me. It definitely did take a while before I was *good* at designing classes though. For all of my career, we used C++ at work, so I was learning and improving all the time, and there were always colleagues who I could ask for advice. If you don't have anyone who is showing you the ropes, I can see how that would be tough.

      --
      Irony: Agile development has too much intertia to be abandoned now.
    10. Re:C++ is C by Rei · · Score: 1

      Neither does C++ force objects on you. Your approach is quite reasonable.

      I came to give up my antipathy toward objects and come to love them when coding in LPC for an LP mud. In LPC, each file you make is an object (written in LPC, which is very much like regular C), and it corresponds to a physical object in the game. So among the many functions you can call are those which set your name, your short and long descriptions, and add various callback functions for when people try to interact with you in various ways. All objects have inventory, and generally exist inside another object, all of which can be queried. Your object call any function on any other object. Your player object is, yet again, another object. "Wizards" (coders) manually call functions on other objects.The net result is this really intuitive "I'm just interacting with other physical things" style of coding and debugging.

      It also made for very good "code wars" with other wizards. Example: it was common for wizards to create "dest tools", objects that when called would destruct a player's object, forcing them out of the game and to have to reconnect, as a punishment. Usually these were done with artsy flourishes and leadups. One wizard I knew wrote a dest involving him picking a rose, playing "she loves me, she loves me not" with it, and when the last petal is plucked ("She loves me not"), the target would get dested.

      Tired of him using it on me, I wrote a counter dest, which when I saw his dest, I would call it on him. It would then destroy all objects in his inventory (including any dest tools, thus stopping his dest) and put an object in his inventory that would eat all of his commands so he couldn't counter me or or quit out. My parody dest would then commence, involving a giant ogre playing "She loves me, she loves me not" with the target's limbs while they cry out in pain, before discarding the torso and destructing their player object.

      So said wizard took to using an instant dest, so that I wouldn't have time to call my tool. So I took to creating a tool that would make itself invisible, leap into the wizard's inventory and wait for them to issue their dest command, block it, then trigger my dest. It became an arms race, leading to tools that would monitor one's inventory (and later, their room) for sneaky invisible objects and destroy them, to tools to try to sneak past these, and so forth. Once I accidentally nearly took out the MUD in the process - I was testing in the login room and a tool went awry, dested me, fell to the ground, and dested everyone that logged in. I could upload new code to the MUD via FTP to try to correct it, but without being able to log in, I had no way to execute it. The day was saved when I uploaded a file into another coder's home directory (the only one still logged in, in a different room) with a name like "PLEASE_DO_NOT_LOG_OUT_URGENT_READ_THIS.txt" explaining the situation and how to remedy it; he luckily noticed the file and fixed the problem.

      --
      "We consider that six courts and an asylum claim are a rather odd way of returning to Sweden within a month."
    11. Re:C++ is C by Anonymous Coward · · Score: 0

      Interestingly, I've found many C libraries actually use a very OOP-like interfaces - just without the "objects". For instance, you'll first call some sort of create() function to get a pointer to a struct that contains state data or perhaps a handle. You then pass this pointer or handle to "member" functions - essentially, a function that operates on or modifies the state of that data. Then you release the allocated context struct via some destroy() function.

      Exactly right. The difference between "f = fopen()" and "f.open()" is just a matter or syntax. Several years before C++ came along, I did object-oriented programming in C. Basically, you just pass a pointer to a structure into a function as the "this" pointer that is implicit in C++. C++ makes such things easier and look nicer, but you can do object-oriented programming in C at a basic level just fine. And as you point out, that sort of thing is illustrated in several of the C standard library functions which have an open/process/close semantic. That sounds a lot like construct/process/destruct, except for a slight shift in terminology.

    12. Re:C++ is C by Anonymous Coward · · Score: 0

      That is one of the most spoken dumbass posts I've seen. Just goes to show that an idiot communicating effectively will effectively communicate idiotic shit.

    13. Re:C++ is C by justaguy516 · · Score: 1

      Read the original X-windows code. Impressively baroque OO written in C, with structs and function pointers, just as God intended it to be done.

    14. Re:C++ is C by Anonymous Coward · · Score: 0

      Fucking BULLSHIT! Designated initializers weren't actually introduced until C99 (and thus not part of C89 AKA ANSI C, the most portable version of C even today), but you're obviously too retarded to know such a basic fact.

    15. Re:C++ is C by DanielOom · · Score: 1

      The Object-Oriented Paradigm is not that hard, but C++ is very complex and C contains just the functionality you need.

    16. Re:C++ is C by swillden · · Score: 1

      always implementing the big three (default constructor, copy constructor and = operator.)

      Or, in the case of the last two, intentionally declaring them private and NOT implementing them (or if you have a C++11 compiler, explicitly deleting them), so as to make the class non-copyable. Relatively few classes need to be copyable. Declaring the copy ctor and assignment operator private ensures that client code can't accidentally copy your non-copyable objects. Not implementing them ensures that if class code accidentally copies an instance, you get a link error.

      --
      Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
    17. Re:C++ is C by Anonymous Coward · · Score: 0

      No. The goalpost is "Modern, best-practice C", not "C from 1989". Don't try to move it.

    18. Re:C++ is C by Anonymous Coward · · Score: 0

      First, OO languages tend to encourage design that revolves around state changes. While it makes it more manageable than a random mishmash where you can poke at things randomly, it misses the bigger picture which is that the state is really an enemy, not a friend.

      Second, from maintenance programmer's pov there is no such thing as a unused feature. You can't control everything in a non-trivial project so anything can raise its ugly head. Go ahead and declare that you are not going to use templates or exceptions so you don't need to deal with them. See how far you can go before you end up debugging them anyway for some reason.

    19. Re:C++ is C by luis_a_espinal · · Score: 1

      First, OO languages tend to encourage design that revolves around state changes. While it makes it more manageable than a random mishmash where you can poke at things randomly, it misses the bigger picture which is that the state is really an enemy, not a friend.

      That is absolutely true. Hard to say what it has to do with everything since (well-written) modular and procedural programming also deals with state change via ADTs and associated manipulator APIs. Think Ada's private and limited private types, or opaque pointers whose examples abound in Ada and C/C++.

      Second, from maintenance programmer's pov there is no such thing as a unused feature.

      Code reviews, scanning tools, processes, guidelines, stuff that programmers worth a shit abide by, that helps with that.

      You can't control everything in a non-trivial project so anything can raise its ugly head.

      Non-trivial projects that are 1) run well, and 2) staffed with competent programmers will use any and all of the tools I mentioned above. For example, I can use plain ints to pass pointers in C or C++. It is a feature. But we can have coding guidelines that prevent that, and code reviews and other static analysis tools that act as gatekeepers.

      If you have #1 and #2, no problems. Lack either, then problem. I know, I've seen it when working in small and (very large) C/C++ and Java projects.

      Software process management + developers == culture.

      A good development culture will police itself against that with relative success IN ANY NON-TRIVIAL project.

      A crappy development culture will never be able to police itself like that EVEN WITH TRIVIAL projects.

      Go ahead and declare that you are not going to use templates or exceptions so you don't need to deal with them.

      Been there, done that. Apparently you haven't.

      See how far you can go before you end up debugging them anyway for some reason.

      See my responses above. What this tells me is that either you have never worked with an effective development culture and/or you have very limited experience with quality development, code reviews and automated static code analyzers.

    20. Re:C++ is C by luis_a_espinal · · Score: 1

      always implementing the big three (default constructor, copy constructor and = operator.)

      Or, in the case of the last two, intentionally declaring them private and NOT implementing them (or if you have a C++11 compiler, explicitly deleting them), so as to make the class non-copyable. Relatively few classes need to be copyable. Declaring the copy ctor and assignment operator private ensures that client code can't accidentally copy your non-copyable objects. Not implementing them ensures that if class code accidentally copies an instance, you get a link error.

      Bingo. That is an ever better solution from the point of view of stopping things absolutely. The only problem I have with not implementing them is that we only find this out till linkage time. For large projects, or for testing, this can be a drag.

      I much prefer to implement them private so that any code that accidentally attempts a copy gets stopped when the compiler hits the compilation unit (which could be right off the bat and closer to the code, as opposed to having it delayed all the way to the end during link time.)

    21. Re:C++ is C by swillden · · Score: 1

      Private and unimplemented is the key, on old compilers.

      On new compilers use:

      class MyClass {
      MyClass(const MyClass&) = delete;
      // ...

      Doesn't matter what access specifier you use, because any attempt, from any code, to copy a MyClass will be diagnosed as an error by the compiler.

      --
      Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
    22. Re:C++ is C by Anonymous Coward · · Score: 0

      So, assuming you've at some point written large'ish middleware for two dozen more or less independent entities whose processes and hr policy you don't own, I take it you have some advice on how to convince them to voluntarily embrace such a culture?

    23. Re:C++ is C by luis_a_espinal · · Score: 1

      So, assuming you've at some point written large'ish middleware for two dozen more or less independent entities whose processes and hr policy you don't own, I take it you have some advice on how to convince them to voluntarily embrace such a culture?

      I don't because I do not see a distinction between development and management/hr culture. It is one. You, the generic "you", either have the culture, or do not. You either keep it, or you let it devolve.

      Even within large organizations, different departments will have different cultures, some better than others. The question (the one I never made) is not whether such a good culture can be kept by every organization of any size.

      The question is, when a culture supports such a culture, can it handle self-imposed limits on code features. The answer is yes, and I've worked in very large organizations (10K+), on projects with product code bases spanning millions of lines and histories of many years.

      I've seen it work. I have no reason to lie or make bullshit.

      You either believe my personal anecdote, or you do not.

      It is as simple as that.

    24. Re:C++ is C by Anonymous Coward · · Score: 0

      a class and it's member functions

      "its".

  14. You don't know C++ properly until you know C by Viol8 · · Score: 1

    Too many C++ programmers who learnt C++ without learning C first jumped straight into the OO and/or generics including the STL. Which is fine up to a point. But they tend to get completely lost when someone asks them to do any low level coding such as writing a bespoke B+ tree from scratch or something similar. Also when presented with multi level pointers they tend to get confused and don't really seem to understand the difference between pointers and C arrays.

    1. Re:You don't know C++ properly until you know C by Anonymous Coward · · Score: 0

      The inverse of this is that C programmers who move to C++ often write C++ like it's "C with classes". They have little to no concept of the STL or generics.

    2. Re:You don't know C++ properly until you know C by janoc · · Score: 1

      " 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. This is a common myth that there is a difference.

      I suppose you mean the difference in the sense that an array means a continuously allocated block of memory of a certain size, whereas a pointer can point anywhere and you need to explicitly allocate that block if you want it. However, that has to do with memory (non-)management in C, not some intrinsic difference between pointers and arrays. You can get the same functionality e.g. using STL vectors - those guarantee that they are allocated as a continuous block.

      This entire mess is a consequence of people coming from higher level languages where a pointer (address) doesn't really exist as a type. For people who have learned assembler and understand how the machine works at the low level pointers are an obvious concept. And yes, jumping into C++ without learning C is a really bad idea - especially when that student is often still struggling with basic concepts like data structures or algorithms.

    3. Re:You don't know C++ properly until you know C by Dutch+Gun · · Score: 2

      I'm not sure I agree. I learned C++ first and then C a year or two later, and I can manage raw pointers just fine, thank you. I just think you're crazy if you do it willingly when there are much better alternatives available.

      I've seen plenty of C turned C++ programmers who essentially treat classes like a giant package for wrapping up loosely related functions into horrifying kitchen-sink classes. They don't know how to create proper interfaces, and pass all sorts of raw pointers around, managing memory manually, even though there's often no reason for doing so. In short, they've never dropped the habits they acquired from C. And frankly, bad C++ is arguably worse than bad C.

      One could argue that this is a result of learning C before C++, but honestly, it's really just a matter of programmer skill and/or competence. A C programmer should be able to learn the ins and outs of OOP and generics / templates, and a C++ programmer should be able to drop down to low-level pointer-intensive code if they need to. If not, it just means that they stopped trying to learn new things - nothing more than that. Or, maybe no one ever took the time to point out better methods of writing code.

      Anyhow, C is a dangerous, crusty language, but it's not going away anytime soon due to it's sheer pervasiveness, utility, and efficiency. It's essentially the common denominator of languages, which is why so many libraries are written in C. Just about any language can interop with C (or it generally doesn't get off the ground). Moreover, entire operating systems are written in C, meaning it's going to stay relevant as long as those OSes are around, and I don't see them fading away in the near future.

      --
      Irony: Agile development has too much intertia to be abandoned now.
    4. Re:You don't know C++ properly until you know C by Viol8 · · Score: 1

      "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"

      Seriously??

      char a[100];
      char *b = a;

      printf("%d, %d\n",sizeof(a),sizeof(b));

    5. 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
    6. Re:You don't know C++ properly until you know C by jrumney · · Score: 1
      Or a more complex example:

      aaa.c:

      char a[] ="TEST STRING";

      bbb.c:

      extern char *a;

      int main(int argc, char *argv[])
      {
      printf("%s\n", a);
      return 0;
      }

    7. Re:You don't know C++ properly until you know C by twistedcubic · · Score: 1

      Incorrect. The variable "a" is a pointer. The problem above is that "a" and "b" have different types-- "a" is a const pointer, while "b" is not.

    8. Re:You don't know C++ properly until you know C by david_thornley · · Score: 1

      Sure. Now pass a and b to a function and try that printf again. They're both pointers then. The fact that sizeof() is different when they're defined is not a tremendous difference.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    9. Re:You don't know C++ properly until you know C by user317 · · Score: 1

      it could be worse :)

      char *f = "foobar";
      f[0] = 'a';

      --
      me fail english? thats unpossible
    10. Re:You don't know C++ properly until you know C by Darinbob · · Score: 1

      Don't forget though, this expression is legal C: a[1] == 1[a]

    11. Re:You don't know C++ properly until you know C by Darinbob · · Score: 1

      I know too many learned-C++-first-and-stuck-with-it programmers who make every class of theirs a kitchen sink class. I know many programmers who started with C who can do OO much better than most C++ veterans.

      One problem though is that if you're used to writing efficient code then it takes a strong mental effort to get used to writing inefficient C++ code style. C is still used in contexts where code efficiency (time and/or space) is still important, whereas most C++ programmers are in an environment where efficiency is considered a distraction.

    12. Re:You don't know C++ properly until you know C by Dutch+Gun · · Score: 1

      I know too many learned-C++-first-and-stuck-with-it programmers who make every class of theirs a kitchen sink class. I know many programmers who started with C who can do OO much better than most C++ veterans.

      You say that like you're arguing with me, but I make almost this exact same point, just with different words. I was just providing a counter-anecdote, but I've seen plenty of bad C++ programmers too. Good programmers write good code, and bad programmers write crappy code. I personally think it doesn't matter which language you start with.

      One problem though is that if you're used to writing efficient code then it takes a strong mental effort to get used to writing inefficient C++ code style. C is still used in contexts where code efficiency (time and/or space) is still important, whereas most C++ programmers are in an environment where efficiency is considered a distraction.

      Oh? I can't speak for other industries, but that certainly doesn't describe my job of videogame programming, where C++ is used almost exclusively for large-scale games. C++ compilers do an excellent job at turning higher-level abstractions into very efficient code. Otherwise, the videogame industry would still be using C, as we're pretty fanatical about performance and highly optimized code.

      The C++ committee has generally adhered to C's original zero-cost (i.e. "you only pay for what you use") principles when designing new language features. Good C++ programmers understand which abstractions actually incur a runtime cost and which don't, and know how to use them appropriately. In many cases, the higher-level abstractions C++ provide are actually compiled away to zero or negligible runtime costs. Sorry, but characterizing C++ as some slow, inefficient, high-level language seems a bit of a stretch to me.

      --
      Irony: Agile development has too much intertia to be abandoned now.
    13. Re:You don't know C++ properly until you know C by Anonymous Coward · · Score: 0

      C is a dangerous, crusty language, but it's not going away anytime soon

      Sounds a lot like your mom. I don't want to throw her out so why do you want to throw my C out?

    14. Re:You don't know C++ properly until you know C by Anonymous Coward · · Score: 0

      due to it's sheer pervasiveness

      "its".

  15. macro assembler by Mirar · · Score: 1

    A lot of problems want to have a solution that is very close to the hardware. C is an excellent macro assembler, but you need to remember to treat it as such.

    It seems like very many programmers don't know, or don't want to think over the lower level implications of everything you do in C.

    C is relevant because as long as we use computers, we need to tell them what to do, and C (and fuzzy bloated C like C++) does that for us.

    Most people and most programmers don't need to touch computers on that level, and then other programming languages should be used. Those languages are often written at least partly in C.
    As usual, use the right programming language for the problem.

    I would even go as far as saying that you shouldn't do C++ if you can't do C, and you should probably not do C if you don't know how assembler (and machine code) works. Then you should stick to all the protective layers that you can, like in Python.

    (Any good programmer should be able to program on any level from assembler to C and C++ to Python and shell-scripts and up.)

    1. Re:macro assembler by N1AK · · Score: 1

      Any good programmer should be able to program on any level from assembler to C and C++ to Python and shell-scripts and up.

      And every good butcher should be a great farmer, every good soldier an expert weapon maker, every good driver a world class mechanic ;)...

      I learnt assembler, I think it was valuable to do so and I'd still suggest it to others, but it's nonsense to suggest that you need to know it to be a good programmer.

    2. Re:macro assembler by Anonymous Coward · · Score: 1

      A butcher does not need to be a farmer, but he does need to know how livestock is raised. Likewise, a good solder needs to know how a weapon works. Programming is no different. You cannot write good code in any language if you don't know how a CPU works (in broad terms).

    3. Re:macro assembler by smallfries · · Score: 1

      Where are you drawing the line for good?

      I can see that somebody could program without knowing anything at all about assembly language, but I find it difficult to believe that they would be any good at it. For many years CS curricula around the world contained the same sequence of courses: a "high" level language (be it C, C++ or Java depending on time and location), assembly language for a real architecture (SPARC, MIPS or x86) then a compiler course later in the degree that explicitly teachs the mapping from (parts of) the high level language into the low level language.

      It has been understood for a long time that know both of these languages and having some explicit knowledge about what a compiler does to convert between them makes a programmer better. The vast majority of programmers my age (mid 30s) went through this sequence of courses as a mandatory part of their undergraduate education. I'm really curious what your definition of a "good programmer" is that doesn't know assembly language. How do they differ from just a programmer?

      --
      Slashdot: where don knuth is an idiot because he cant grasp the awesome power of php
    4. Re:macro assembler by Tom · · Score: 2

      And every good butcher should be a great farmer, every good soldier an expert weapon maker, every good driver a world class mechanic ;)...

      Strawman argument.

      The OP doesn't argue that people whose profession is different from programming should be able to program. He argues that a good butcher should be able to kill with a mechanical tool, not just the fancy bolt gun the slaughterhouses have now. That a good driver should be able to drive stick-shift even if his car has automatic.

      And I agree. When I was in university, I tortured students with proper input handling in C until they got it, until they understood that unless they check their input conforms to whatever specification they make for it, instead of just checking the exceptions they can think of, I will always find a way to break their program by, say, keeping my finger on the "a" key for 3 seconds and overflowing their buffer. I'm pretty sure they're not the ones making web applications less secure today because lazy programmer doesn't do form validation.

      Learning the basics of programming on a not-holding-your-hands platform makes you understand what's going on and what can go wrong. If you learn programming on a training wheels framework, your programs will almost certainly be subject to all kinds of injections, overflows and other attacks whenever the framework doesn't protect you 100%, or requires you to make an explicit call to get those benefits.

      C is a great language to learn programming. Yes, you'll swear a lot and you'll hate the computer, your teacher and the world in general, but when you come out of that bootcamp, you're a marine and not some third-grade wannabe trooper with a 10 minute life expectancy once the shit hits the fan.

      --
      Assorted stuff I do sometimes: Lemuria.org
    5. Re:macro assembler by Anonymous Coward · · Score: 0

      Hold on, CS courses aren't training programmers, they're training computer scientists (hence the name). There's a ton of content which is of highly limited vocational use. You can't use the content of CS courses as some kind of proof that knowing such stuff makes better vocational programmers. Proper CS courses include LISP which is as far from the metal as you can get, and operates on completely different principles to assembly language and C. Rare will be the job which requires this. Proper CS courses also include sections on Turing Machines, complexity theory, etc. which is useless to the jobbing programmer (the rule there is, if you can't easily prove it's in O(n^2) don't even think of using it). Now we may think that knowing this stuff makes us better programmers in some vague and unspecified way, but it's just elitism to say you can't be a good programmer if you don't know this stuff. Plenty of excellent programmers have no idea about registers or malloc heaps. The whole point of programming is to build abstractions, and the whole point of building abstractions is so you don't have to worry about the situation N levels down.

    6. Re:macro assembler by dunkelfalke · · Score: 0

      That is one possibility. The other is that it helps you to a shitload of bad habits which are then very difficult to get rid of while a proper language strictly enforces good practises.

      Thus your example with the bootcamp is a wrong one. Learning C fist is like learning with the weekend militia wackos. You grab a gun and hope you won't shoot yourself in the foot. While higher level languages are more like a regular army. There are rules and rules and rules.

      --
      "It's such a fine line between stupid and clever" -- David St. Hubbins, Spinal Tap
    7. Re:macro assembler by jbolden · · Score: 1

      FWIW LISPs can be written which run very close to the metal. The Apply / Eval structure works with metal. Apply uses a memory frame (like you see in x86 assembler) and eval breaks down into CPU primitives. In the 1970s and early 1980s there were even LISP based CPUs.

      A world of LISP based hardware is a road not taken not a road that couldn't have been taken.

    8. Re:macro assembler by smallfries · · Score: 1

      Some good points; yup CS and vocational training are miles apart and one does not imply the other.

      But about elitism: how could it not be elitist to define what makes a good programmer?

      --
      Slashdot: where don knuth is an idiot because he cant grasp the awesome power of php
    9. Re:macro assembler by Tom · · Score: 1

      The rules exist in C as well, just the enforcement differs. In your average recently developed language, the IDE or the compiler will tell you that you're a bad boy and shouldn't be doing this shit. In C, the compiler will tell you to fuck off and come back when you understand what you did wrong or the system will just shoot your program and put it out of its misery.

      Having to figure out what went wrong instead of this tinkerer approach of "let's compile and see what the errors tell us to fix" is a good lesson in writing it right the first time.

      I've seen students who learn programming in Java very recently. Their approach has nothing of regular or army, it's amateurish "let's try this and see what happens". It's pathetic that they teach people programming like that, and it explains a lot about what's wrong with software.

      --
      Assorted stuff I do sometimes: Lemuria.org
    10. Re:macro assembler by LainTouko · · Score: 1

      You can be a good programmer without reference to assembly language by doing proper input validation, avoiding the impulse to be unnecessarily clever, commenting your code well, thinking about all the ways things can go wrong, checking for errors and handling them appropriately, designing sensible interfaces, writing tests, making sure you release resources you've finished with, avoiding clone and hack etc.

    11. Re:macro assembler by dunkelfalke · · Score: 1

      I wish C would do that. What happens in real life is that some miscalculated pointer just silently overwrites memory with random values causing irregular crashes that cease to happen when some printfs are added because the pointer suddenly overwrites memory elsewhere. Finding and squashing this kind of bugs in a huge project is a bitch. And all that because C programmers like to take shortcuts and otherwise cut corners because they think themselves real men. This is how it works, your description is more like wishful thinking. And this is also the reason for 90% of security holes out there. Macho programming languages are the wrong approach here, as are fully manual controls in a nuclear reactor or a modern airplane. The more monkey-proof, the better.

      --
      "It's such a fine line between stupid and clever" -- David St. Hubbins, Spinal Tap
    12. Re:macro assembler by david_thornley · · Score: 1

      C is a bad language to learn programming, since there's a whole lot of little frustrations and gotchas. It's an excellent second language to learn.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    13. Re:macro assembler by Tom · · Score: 1

      Finding and squashing this kind of bugs in a huge project is a bitch.

      Which is why you should learn to write code that compiles and works correctly on the first try. We know how to do it, computer science wasn't invented yesterday. But thanks to dot-com and startup craze and the desire to churn out pseudo-programmers fast, fast, fast, programming isn't taught correctly.

      If you want army style, I suggest this experiment: Teach students to code in a simple text editor and a special compiler that gives them one chance at compiling the program. If the compile fails, it deletes the code and they can start from scratch.

      The more monkey-proof, the better.

      Only if you hire monkeys to do your programming for you.

      This is a very famous article about how to do programming right. Note their error count. Compare it to pretty much everything else on the market.

      But programming this way isn't sexy, or macho or whatever else you want to call it. It's real work.

      --
      Assorted stuff I do sometimes: Lemuria.org
    14. Re:macro assembler by Anonymous Coward · · Score: 0

      There was also IBM's Future Systems project and Intel's iAPX 432 with hardware garbage collection. The idea of high-level CPUs wasn't only a LISP thing.

    15. Re:macro assembler by dunkelfalke · · Score: 1

      This is Lake Wobegon talking. You can't even comprehend written text correctly and you think yourself a mighty software developer? You are a monkey just like everyone else.

      It is not about compiling. The errors that can be caught at compile time are almost always uninteresting typos. If you try to eliminate these, you just sacrifice the code readability because people will name their variables i and j instead of making them speak for themselves. But all kinds of shitty code will still compile just fine but fail in a billion of different ways in runtime.

      It doesn't matter whether it is programming, flying an airplane or operating a nuclear power plant. Humans make errors. The less opportunities you give to a human to make errors, the better the results.

      --
      "It's such a fine line between stupid and clever" -- David St. Hubbins, Spinal Tap
    16. Re:macro assembler by Tom · · Score: 1

      The errors that can be caught at compile time are almost always uninteresting typos

      What an opportunity to give the unnecessary ad hominem back. The key-word was "experiment". The point is not that this is how software development be, but that teaching people to think first, then design correctly, then implement is the proper approach instead of the "tinkerer" one where you write down what comes to mind and then tinker with it until the compiler is happy.

      That, exactly, is how all these errors that the compiler doesn't catch happen.

      The experiment is not about avoiding compiler errors. If you thought it was, you didn't understand it one bit.

      --
      Assorted stuff I do sometimes: Lemuria.org
    17. Re:macro assembler by danaris · · Score: 1

      When I was in college, one of my CS professors had a weekly quiz that he called "Iron Code." It required you to write a (relatively simple) program, and submit it, using a custom utility (I forget the details; this was 15+ years ago now)...but you only got one shot. Your grade was based upon the degree to which your program's output in response to various inputs met the specifications. If it didn't even compile, you got a zero.

      I was so-so at this activity, but there were a fair number of students in the class who consistently got high marks.

      Humans can be taught not to make errors. It just requires more time and more careful attention to detail. It's not sexy, and it's usually not fun, but it's totally possible, and if it's your job, then you can damn well do it.

      I'm just glad it's not mine, because patience and attention to detail are not my strong suits. :-)

      Dan Aris

      --
      Fun. Free. Online. RPG. BattleMaster.
  16. 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

    1. Re:Libraries by stanjo74 · · Score: 1

      Any language platform needs to make system calls into the OS. For as long as all popular OS-es are written in C, all language platforms need to interoperate with C modules. C is the "lingua franca".

  17. Very by Anonymous Coward · · Score: 0

    Not only are a great number of software packages, including almost every operating system kernel and device driver written in C, also almost all of the other languages in current use are usually compiled or interpreted by code written in C. It is still easily the most important language.

  18. Several reasons by dargaud · · Score: 2
    One of the main reasons is that entire operating systems are written with it. When there are operating systems written from scratch in Erlang or Java or Go or whatever, then and only then we'll see C start to fade away. Until then it's here to stay. All the other reasons are secondary: ease of use (gcc test.c; ./a.out), widespread availability from tiny micro-controllers to behemoth supercomputers, low overhead, precise and full control of everything to the bit level, huge choice of well tested libraries, etc... That's why I regularly try and learn new languages but most of what I do is in C.

    As to why there are more threads related to C++ on the Internet, easy, it's because C++ is a lot more complicated and complex to grok. I need as much help as I can with some of its tortured constructs and seldom used idioms. C is more straightforward (even if there are plenty of tricky things in it, which the seasoned programmers will either know how to use or steer well clear of).

    --
    Non-Linux Penguins ?
    1. Re:Several reasons by AmiMoJo · · Score: 2

      I find C++ less and less relevant these days. I use C most of the time for embedded work or little desktop utilities, and C# when I want to do a more complex desktop app. C++ fits in somewhere between those two and most of the code written in it might as well be C, as it just uses C++ features to organize modules and do a bit of lazy memory allocation.

      There are areas where C++ shines, but I think these days it's becoming less and less relevant as there are better languages for embedded systems (C, assembler) and better languages for desktop/server apps (C#, Java, Python etc.)

      --
      const int one = 65536; (Silvermoon, Texture.cs)
      SJW, n: "Someone I don't like, and by the way I'm a fuckwit" - AC
    2. Re:Several reasons by Rei · · Score: 1

      The whole point of C++ is things like lazy, bug-free memory management.

      Nobody is forcing you to make custom objects. But for getenv("DEITY")'s sake, use STL instead of rolling your own data structures unless you absolutely have to.

      --
      "We consider that six courts and an asylum claim are a rather odd way of returning to Sweden within a month."
    3. Re:Several reasons by Anonymous Coward · · Score: 0

      Let us know when you get the STL working on a Cortex-M3 board, mmmkay? Thanks.

  19. Scientific work by Anonymous Coward · · Score: 0

    It's so ironic but in the modern day of high level languages designed for fast development of single use code I still go back to C several times a year to do the job properly. Code written in C is fast and, if you try just a little, is easily portable between platforms. Up to a certain point, what you tell the machine to do in C and what it actually does are the same thing. Beyond that point (memory vectorisation for example) it is still possible to work out what the difference is and change your code to deal with issues if need be. Not related to scientific work: but when I was learning C words that people used were orthogonal and small, meaning that there was a minimal number of things that you had to learn and for the most part there was one way to do any given thing. This made it easy to learn and practical to use. Also C exposes it's belly to the user so you can get in and hack at the elements that make the language up. C (to paraphrase Paul Graham) is a high point in the landscape of programming. There are very few such high points and vast expanses in between. I would still recommend to any who wants to learn computing today to learn C.

  20. Book on it... C of Peril... yarrrr! by inflex · · Score: 2

    Lots of old traps in there, I stopped about 5 years ago with this book, needs a lot more work, but covers the basic "ooops" events. Thankfully at least with things like Valgrind / CLANG|gcc a lot of the older dramatic mistakes can be picked out quickly.

    "C of Peril" - the book (pdf, free) at http://www.pldaniels.com/c-of-...

  21. C is dead by Jezral · · Score: 1

    I always tell people who want to learn to code to go for modern C++ (preferably C++11 or newer) first, and then if necessary learn some C afterwards.

    It is crazy how much more C code is needed to get the same level of performance and security that equivalent C++ has, and C coders know it. Just look at all the extensions that C compilers, and even the C11 Standard, borrow from C++ (generics, RAII) - but in a convoluted ugly way to preserve the precious ABI for 50 years.

    And for all those who will say that C++ can't fit in the tight spaces that C can...well, you're wrong. Just disable the parts of C++ that you don't want (usually exceptions), and you can still get most of the benefits of clean code and RAII, with the same or better performance.

    1. Re:C is dead by Anonymous Coward · · Score: 1

      This is interesting,

      Since C is a subset of C++.. how is it possible to learn C++ without C?

      This might explain why so much C++ code is so incredibly bad...

    2. Re:C is dead by Anonymous Coward · · Score: 0

      It is crazy how much more C code is needed to get the same level of performance and security that equivalent C++ has

      Could you give an example? My experience is the exact opposite. The C++ projects I came across that actually use the 'features' C++ added tended to be huge, bloated and inefficient. Sure, C++ added some useful things that ended up in the C standard, but many additions are simply their because their conceptual notion happened to be in fashion in computer science at the time. I cannot think of anything that truly improves performance or security.

    3. Re:C is dead by Anonymous Coward · · Score: 0

      C++ isn't exactly a good language to begin with. It has too many patterns too many ways to do the same thing (and fail at it badly in certain corner cases), the runtime is anything but stable or coherent across implementation.

      "Just disable the parts of C++ that you do not need" and you get C.

      C is quite good for all purposes, the preprocessor makes it less nice that it could be though.

      Barking at the ABI while C++ breaks it ever now and then sounds a bit weird. Btw regarding ABI: few 1k bytes per symbol speaks volumes about how far we are from a good way to manage symbols in C++.

      I have high hopes for rust.

    4. Re:C is dead by Anonymous Coward · · Score: 0

      Jesus Christ you tell people to start with C++

      Are you trying to put people off programming for life? C++ is far to complicated for beginners, experts and humans in general.

      The language is a mess of overlapping features and cruft. Recommended reading:
      http://yosefk.com/c++fqa/defective.html

      C is good at what it does. If you want a higher level language try python or java

    5. Re:C is dead by Anonymous Coward · · Score: 0

      C is no longer a subset of C++. Also, many things are done differently in C++, even if there is an equivalent C way with nearly the same number of lines.

    6. Re:C is dead by jones_supa · · Score: 1

      Since C is a subset of C++.. how is it possible to learn C++ without C?

      Because even when the C features are available inside C++, often some higher-level C++ counterpart is used instead. For example pointers are replaced with smart pointers or vectors.

    7. Re:C is dead by Anonymous Coward · · Score: 1

      Personally, I tend to write C in C++. Mostly because I think C is a better overall language, but I like being able to use vector, list and map classes from the STL. Though strings, yeah, C strings are way better than C++ strings.

    8. Re:C is dead by jcr · · Score: 0

      That's very bad advice. C++ causes brain damage.

      -jcr

      --
      The only title of honor that a tyrant can grant is "Enemy of the State."
    9. Re:C is dead by Anonymous Coward · · Score: 0

      Only those on the standards committee fully understand the C++ standard. And even they're still finding contradictions and ambiguities that require revisions.

    10. Re:C is dead by Jezral · · Score: 1

      Standard C++ has never been a strict superset of Standard C. You have never been able to take all C89 code and just compile it as C++98, primarily due to C++'s stricter type system (e.g. malloc() will need a cast added).

      Anyway, sure they share a lot of syntax and basic concepts, but when you compare modern C++ with C, it's like comparing a high level scripting language with, well, C. If you take code in Python, Perl, PHP, Java, C#, and C++, they'll all look mostly alike. If you code the same in C, it'll look foreign and require many more explicit sanity checks. But the C++ and C code will have the same performance, while the other languages will suffer lots of overhead.

    11. Re:C is dead by Jezral · · Score: 1

      The FQA? Really? Read it, laughed at it, moved on.

      Modern C++ is as easy to learn as Python or Java or C# or similar. The code will even look superficially the same.

      C++ is only hard to learn for those who insist on learning "C with Classes" and mix in all sorts of silly C'isms, like insisting on starting with raw memory management. If you start out with the high level stuff and containers, it's easy, safe, fast.

    12. Re:C is dead by Jezral · · Score: 1

      Well, the example I have laying around is one I made, just so my bias is clear: http://tinodidriksen.com/2010/...

      C: http://tinodidriksen.com/uploa... - 77 lines, 2.4k
      C++: http://tinodidriksen.com/uploa... - 33 lines, 1k

      The C code is a mess of extra code and checks, compared to the C++ version. The C++ version is as readable as the scripting languages. And C vs. C++ perform almost identically.

      Now, that is obviously a tiny example, but I find this to be true for larger codebases as well. If you use all that C++ offers you, you can make the code read like elegant functional or script (or a mix), and still have all the performance of C.

    13. Re:C is dead by jimbolauski · · Score: 1

      It is crazy how much more C code is needed to get the same level of performance and security that equivalent C++ has

      They both require the same amount of code that code is just hidden in C++, just because you don't see it doesn't mean it's not there.

      And for all those who will say that C++ can't fit in the tight spaces that C can...well, you're wrong. Just disable the parts of C++ that you don't want (usually exceptions), and you can still get most of the benefits of clean code and RAII, with the same or better performance.

      Creating drivers, firmware, kernels, and embedded applications using c++ will have external dependencies you will have to support those dependencies which will use up valuable space, C does not have this issue. Windows and Macs both have limited stdlib support of c++ at the kernel level, things like new and delete are not supported. There is a time and place for everything you just have to know what code is appropriate.

      Just look at all the extensions that C compilers, and even the C11 Standard, borrow from C++ (generics, RAII) - but in a convoluted ugly way to preserve the precious ABI for 50 years.

      There is no standard ABI in C, the ABI is platform dependent and always has been. It would make no sense to have a standard ABI as there are many different platforms and every platform but one would have to emulate the chosen platform. I suspect you have very little experience with C and this is why you think C++ is always the right answer

      Different codes work better for different applications but first you have to intimate understanding of those codes. A good programmer knows the strengths and weaknesses of each and can choose accordingly

      --
      Knowledge = Power
      P= W/t
      t=Money
      Money = Work/Knowledge so the less you know the more you make
    14. Re:C is dead by DavidCBillen · · Score: 1

      I always tell people who want to learn to code to go for modern C++ (preferably C++11 or newer) first, and then if necessary learn some C afterwards. ...And for all those who will say that C++ can't fit in the tight spaces that C can...well, you're wrong. Just disable the parts of C++ that you don't want (usually exceptions), and you can still get most of the benefits of clean code and RAII, with the same or better performance.

      You conflict me. I agree that C++ can generate optimal code - but only IF the programmer understands the underlying C (and even assembly) well enough to control it.

    15. Re:C is dead by Anonymous Coward · · Score: 0

      > They both require the same amount of code that code is just hidden in C++,

      s/hidden/written for you and tested

    16. Re:C is dead by Jezral · · Score: 1

      ...just because you don't see it doesn't mean it's not there.

      True, but so what? I can still write less C++ code but get the same performance as C. I don't care that it temporarily expands during compilation and then shrinks during optimization. I care about my code and the output - the IR is less interesting.

      There is no standard ABI in C, the ABI is platform dependent and always has been.

      I meant, the C Standard introduces new features in ways that won't break anyone's ABI. C11's _Generic is so bloody ugly compared to C++'s overloading, but it preserves the ABI. The fear of introducing ABI-breaking features is making C even more ugly to read.

      I suspect you have very little experience with C and this is why you think C++ is always the right answer

      Well, you suspected wrong. I have quite a lot of experience with C, C++, PHP, Perl, JavaScript, Java, Python, etc. I even started with C as my first real language. I just vastly prefer C++.

      I do not think C++ is always the right answer, except when asked whether to use C or C++. The only cases where I'd say use C is when there is no choice, such as cross-language APIs.

    17. Re:C is dead by Anonymous Coward · · Score: 0

      That's why drivers and OS kernels are written in C++ instead of C and asm.

      Oh wait...

    18. Re:C is dead by david_thornley · · Score: 1

      Most people don't need absolute optimal code, and even so it's easier to get optimal code in C++ than C.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
  22. Performance. performance, performances by Anonymous Coward · · Score: 0

    If you want performance, it's C or assembler. C is 1/3rd the speed, but 100's of times faster to write. Then you profile and do the expensive bits ONLY in asm ...

    I mean, know other languages, but C is still relevant.

  23. C can be the future by jcdr · · Score: 1

    I hope than C will evolve to add a clean simple and single inheritance object model without all the over-complex crap from C++.
    A even more advance would be that C get an optional standard library comparable to boost and the like that make consensus in the developer community.
    Finally a JIT would make it competitive to the increasing markets areas with high diversity of silicon processors architectures.

    1. Re:C can be the future by mwvdlee · · Score: 1

      I sure hope you were being sarcastic.
      It's hard to tell the difference sometimes.

      --
      Slashdot social media options: AIM, ICQ, Yahoo, Jabber and Mobile Text. Why no MySpace?
    2. Re:C can be the future by jcdr · · Score: 1

      Sincerely no sarcasm here, sorry.

      C have evolved quicker that C++ on certain fun features like dynamic table stack allocation, dynamic struct initialization, etc... I don't think that C should be an experimental language, but I hope that it will continue to integrate fun features that have proved to be useful, clean, and efficient. A simple object programming model could be very useful if done in a cleaver way than do not introduce drawback like undefined name mangling for example.

    3. Re:C can be the future by gweihir · · Score: 1

      That is a pity. It means you are exceptionally clueless. All these things you describe would ruin the advantages of C.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    4. Re:C can be the future by jcdr · · Score: 1

      A lot of big projects already organize there code in a way that look like objects. Often this is a just a struct and associated functions. Some projects have something close to single inheritance, using there own function table or using library like for example GObject. All those C projects already take advantage of some object programming features. Integrating a common subset of those features into C will certainly bring an advantage to everyone.

    5. Re:C can be the future by gweihir · · Score: 1

      No. It will not. It will remove flexibility, because suddenly there is a "right way" to do it and doing it another way will be perceived as "wrong". Just like any other OO language, it will restrict what can be done. Sure, you could still ignore these additions, but it will be a lot harder to get that approved and to teach alternate methods to yourself than it is now. In the end, it would ruin the language.

      Well, fortunately, nobody in the C standardization process will be this stupid. It would remove the exceptional position that C is in and make it mostly irrelevant. The other really big advantage of C is that it is very, very easy to write a compiler for it. That would also go away with your proposals.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    6. Re:C can be the future by jcdr · · Score: 1

      I agree to your concerns: C must only integrate features that have proved to be widely approved, simple, clean, useful, and efficient.

      Take for example the dynamic table allocation on stack or the dynamic initialization of a struct. Those features don't break existing code, but make new code more simpler to write and bring to the compiler a more direct indication of the goal of the code. I am certain that some useful features of a simple object programming model would be useful if introduced the same way in C. Don't get me wrong, I am not talking about a complex crap like C++ !

      I disagree that this will remove flexibility. For example dynamic table allocation on stack or the dynamic initialization of a struct have not removed flexibility. There have standardized features highly desirable without forcing anyone to use them. After many decades of object programming evolution, I am certain that some basic OO features could now be safely integrated into C.

    7. Re:C can be the future by jbolden · · Score: 1

      The C++ object model was basically that a simple inheritance model. Classes were union structures that had a self pointer. Methods were just offsets against that pointer in assembly. Inheritance was effectively a code copy. How can you be more simple that that?

      In terms of a JIT... https://gcc.gnu.org/wiki/JIT

    8. Re:C can be the future by jcdr · · Score: 1

      C++ since 1989 is not as simple as you describe. But even before C++ 2.0 some dramatic choice make it a over complex language. The most obvious problem from my point of view is the lack of a standard and direct naming schema between class and his elements and methods that started the name mangling fiasco. If you look to numbers of big C projects, you will find far simpler implementation of something that look like objects.

      Thanks for the JIT link, it very interesting.

    9. Re:C can be the future by jbolden · · Score: 1

      Well first off name mangling is a complier feature not a language issue. Developers don't see mangling. Also mangling comes from polymorphism not inheritance mainly though. It is a mess with respect to libraries, but once you start building in the ability to handle chains of libraries separately compiled you ain't talking about C with a few extra features anymore that's a huge step up in complexity. But you really aren't answering the question of how C++ with just ignoring lots of stuff doesn't do what you want.

      I've seen objects in C. Certainly GTK is a classic example and yeah. I think once you want objects it should just be C++.

    10. Re:C can be the future by HeckRuler · · Score: 1

      You want objects in C? DONE.
      You want simple inheritance? Here you go:

      struct father
      {
          struct father* next;
      };

      struct son
      {
          struct father inheritance;
          char* yobro;
      };

      But if you want a thing that contains data structures, code, and interfaces like an object in C++... that's just a .c and .h file.

      Inheriting and expanding that code base in a real object oriented way is going to involve some crazy shenanigans with a lot of function pointers like you see in the GTK. It's just not simple and clean in C.

      No, C is not going to get objects. If you gave it objects, that would be a fork, and many many other people have tried that. Some of them did a decent job.

      C is going to be in the future. But it's not going to compete with Java, C#, or C++. And certainly not with whatever crazy web-dev language of the week they have.

      comparable to boost

      OMG NO.

    11. Re:C can be the future by jcdr · · Score: 1

      Developers see mangling fiasco as soon as there try to mix libraries from different compilers or languages and you seem to agree on that. The fact that a lot of C projects use basically the same idea to organize there code to look like object could be standardized in C. No need to use C++ to do that.

      Using C++ just to get a few objects is fun only until you get stuck at one of the overlong cryptic unintelligible error messages from the compiler.

    12. Re:C can be the future by jcdr · · Score: 1

      I completely agree with the first half of your message.

      Yes inheritance imply function pointer, a very used feature in C so I don't understand why you find it so crazy.

      Yes new C features will be developed in a fork like in every project. Maybe one of the fork will be interesting enough to get accepted by a large part of the community and be merged into the standard. Actually a lot of projects have some basic construction that look like objects, but each is different. There is GObject, but it's still confined to a small subset of projects.

      I think that highly optimized standard libraries is the key for high level programming for any language. In a ideal world all languages would use the same libraries and only the syntax would change, but actually, using a language that have libraries that support most of the needs for your application make a lot of sense. PHP for example was one of the early web server language that provided a library complete enough to make web server programming easy and this proved to be a hit, despite the fact that the language was still in a early stage and evolved a lot over the first decade.

    13. Re:C can be the future by jbolden · · Score: 1

      Developers see mangling fiasco as soon as there try to mix libraries from different compilers or languages and you seem to agree on that.

      I do take your point though that C++ didn't offer any solution to this uou shouldn't have to recompile potentially hundreds of programs to replace one library with an updated version. I'm going to think a bit more about this. Lots of languages I know have the same mangling approach as C++. So I'm still not willing to call it a "fiasco" rather than an approach.

      Where I was differing from you is that linking IMHO is fundamentally a platform issue. IMHO the OS not the language should be responsible for linking. I don't think language designers should be responsible for the issues related to linking. C++'s original design simply doesn't support independence of libraries. That's a big problem on Linux (where packages are updated constantly) a medium sized problem on Windows (where the OS has an excellent linker) and not a problem at all on OSX (where each application is supposed to maintain its own libraries).

      But certainly if a language could avoid mangling by offering inheritance without polymorphism or mangling in a predictable way...

    14. Re:C can be the future by jcdr · · Score: 1

      Having application maintaining there own libraries is more like an loosely workaround than a solution. Some libraries of one application could share information with others applications that maintain an other version of the libraries, resulting in a inflating code and complexity to support old formats or resulting on unsupported situations. The Linux way of packaging libraries require constant support from the application providers, but the advantage is a fast evolving ecosystem, small footprint, and stable operations.

      I have to see an OS that can link any libraries for any language to any application. I known that the GObject introspection project dream to bring something close to that: http://helgo.net/simon/introsp... . AFAIK, Vala (a kind of C + GObject) is the most advanced experiment in that direction with automatic binding in a number of languages already functional: https://github.com/antono/vala... . But here the OS have very little to do as the hard part of the linking process is done by the GObject introspection library of each language. Please note that GObject is able to work so well precisely because the naming schema is well defined.

      It's actually popular to introduce a few new languages each year and to write a lot of libraries for each languages that do almost the same job. At some point in the future, so many choices will make more problems than it solve, mainly because of the dilution of the efforts and lack of support where the community is too small. C has a big community for good reason, but C in not used for some projects for others good reasons. Some basic object programming features is probably the most obvious one, especially when observing that many C projects organize there code like objects if not directly using GObject or similar libraries. Given the today situation, I think that C could evolve in a cleaver way without making any harm.

    15. Re:C can be the future by david_thornley · · Score: 1

      C++ allows multiple inheritance (which I'd recommend you approach carefully). Classes are more like structs than unions. Member functions are more than just offsets, because they're type-safe. Inheritance does not copy code, but rather introduces new code, and polymorphism is awkward to do in C.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    16. Re:C can be the future by Anonymous Coward · · Score: 0

      already organize there code

      using there own function table

      "their".

  24. GCC is now compiled with G++ by ciaran2014 · · Score: 1

    Case in point, GCC recently switched from being compiled with GCC to being compiled with G++.

    (Although I think it's a tad too absolute to say that "best-practice C can be compiled with a C++ compiler", but nearly.)

    --
    Help build the anti-software-patent wiki
    1. Re:GCC is now compiled with G++ by Anonymous Coward · · Score: 0

      sizeof('a') == 4 , sizeof('a') == 1 , C and C++ have some subtle differences. Also new and class are not valid C++ identifiers, some C libraries are nice enough to include a ifdef __cplusplus in their headers. There are more differences, including some language features added in recent versions of C and not included in C++, so best-practice C has many reasons not to compile as C++.

  25. C relevance and what C and C++ really are today by jfz · · Score: 0

    As long as C continues to serve as the foundation for a number of operating systems, it will remain relevant. To understand its merits as a language alone however, it along with C++ should be used only _after_ learning a high level language that doesn't clearly model allocation or memory within in its syntax, e.g. Haskell, Python, Java, Lisp. Then one can return to C, along with C++ and say "hey, this is an incredibly useful syntax for reasoning about efficient allocation and memory use". It does have competitors in that arena, however it continues to dominate due to tooling, inertia/entrenchment in education, industry and cargo cultism.

  26. Stable ABI by csasso · · Score: 2

    The C language has a stable ABI, and it is the only mainstream language that can make such a claim.

    1. Re:Stable ABI by csasso · · Score: 1

      Also, the C language is the De Facto Lingua Franca of the software world, i.e. all other languages have means to call a C function, or be callable from a C function.

  27. Very relevant, programming is not only desktop/web by janoc · · Score: 2

    C is very much still relevant - most of the deeply embedded computer firmware is written in either assembler or C, where the bit twiddling capabilities, compactness of the language and efficient generated code are of high importance. All those ATMegas, PICs, 80x51, Z80, Renesas, small ARM Cortex cores - chips that are too small in terms of available memory to use higher level languages and OSes effectively. Essentially, if you are writing "to the metal", you are most likely going to use C, assembler and (rarely) C++. Those chips costs peanuts and are pretty much everywhere, controlling everything from your toaster to brakes in your car ...

    Programming is not only about the desktop and web, you know.

    Even on more "grown up" platforms you will find C in the network code, most of system programming is done in C, C with its standardized ABI is an interface language (e.g. you can load a C-interfaced DLL into Python or Java, for example) and many many other applications. I would say that knowing at least the basics of C is as much a must for any programmer as knowing basics of English - unless all that you do are web apps in Javascript.

  28. 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.

  29. Small target! by Ihlosi · · Score: 2, Interesting
    Depends mostly on compiler and toolchain availability on those platforms.

    To clarify: "Small target" means memory (RAM/Flash) is measured in kB, sometimes even in bytes.

    You still have Python-capable processors for embedded systems if you can't afford to learn C.

    As far as target size goes, that thing does not qualify as "small target".

    FWIW, I've been struggling with LPC4300 series processors.

    Those chips look like they're on the large end of "small target". Cortex-M4s are already pretty beefy CPUs.

    The open source toolchain is just so bad that your CPU hard faults on first attempted function call (most likely due to incorrect memory maps).

    You can usually get pretty detailed reasons for a hard fault if you dig into the appropriate CPU registers (HFSR, etc).

    I'd check the linker command file. Setting up a basic memory map isn't that hard - it's the not-so-basic stuff where things get interesting (copying functions to RAM for execution, etc).

  30. C is relevant because it is low level. by Required+Snark · · Score: 2
    C is important because it directly presents the actual machine memory model. If you want to have an understanding of how software works, you need to understand this. People who never learn how memory is really organized lack fundamental knowledge.

    It's as if engineers could skip calculus because there are automated systems that will do it for them. Even if they never work directly with calculus, the experience is critical to being a competent engineer.

    Yes, C has features/bugs that can be really ugly. But as a professional you can make a system like C and it's runtime libraries work then you are much better equipped to do other complex tasks. The experience can result in careful habits that will help your entire career.

    --
    Why is Snark Required?
    1. Re:C is relevant because it is low level. by Ihlosi · · Score: 1
      C is important because it directly presents the actual machine memory model.

      Well, not really. There are some architectures that were basically designed to be used with C (68k, ARM), but there are others (8051) where a C compiler need to jump through some major hoops.

      And the C compiler still shields the programmers from things like stack frames or worrying about CPU register allocation.

    2. Re:C is relevant because it is low level. by jones_supa · · Score: 1

      I believe virtual memory and ASLR would also shuffle things around?

    3. Re:C is relevant because it is low level. by loonycyborg · · Score: 1

      C is relevant because it's lowest level language that isn't architecture specific. Nuff said. All new CPU architectures get C support ASAP because it offers enormous amount of software already written in C and supporting countless other architectures. And compiler for other languages tend to be written in C too. So C is kinda defacto mother language at the moment.

    4. Re:C is relevant because it is low level. by Anonymous Coward · · Score: 0

      Good point, but to be fair, pretty much all CPU's designed since the 1980's have been designed for c-compilers.

    5. Re:C is relevant because it is low level. by gweihir · · Score: 1

      Indeed. People that knmow C have a reasonable grasp how memory is organized and how code gets executed. That is invaluable even for work in other languages.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    6. Re:C is relevant because it is low level. by Anonymous Coward · · Score: 0

      Posting anon because of mod points used up above, and not because I have any NDAs in place after more than 20 years...

      The 68K was not designed around C, period, end of story. It was as close to being a single chip PDP-11 as Motorola could get without being (successfully) sued by DEC, and grew out of the MACCS project that began in 1976, way before C was on anyone's radar at Motorola. Every RISC architecture that hit it big, however, yeah, true.

      Oh, and get off my lawn.

    7. Re:C is relevant because it is low level. by Anonymous Coward · · Score: 0

      > Good point, but to be fair, pretty much all CPU's designed since the 1980's have been designed for c-compilers.

      No, you've got it exactly backward. C was designed around the CPU architecture, not vice-versa.

      The 68k architecture was mostly based on the PDP-11, which was tailored to high-level languages, but C wasn't even a blip on the radar when the chip was designed. UNIX wasn't even available outside AT&T until 1975, and almost nobody programming micros was using C in 1979.

      Likewise, the 8086 was designed well before C was commonplace. UNIX mostly ran on mainframes in those days, and the architectures were designed to facilitate HLL programming, but not C in particular.

    8. Re:C is relevant because it is low level. by Anonymous Coward · · Score: 0

      Yeah yeah, and you probably also thought those humanities and art history classes we had to take for our engineering degree were completely necessary too.

    9. Re:C is relevant because it is low level. by Anonymous Coward · · Score: 0

      And, that userspace memory address usually doesn't have anything to do with the machines memory space. Incrementing the memory pointer by one could take you to swap space or to an entirely different computer on a cluster!

  31. APIs & Lua by Kensai7 · · Score: 1

    The most important reason-feature to learn and use C is that it's the LOWEST COMMON DENOMINATOR in many other languages' attempts for interoperability. These APIs are many times written in C in order for the libraries to operate seamlessly between them. Another good reason is to improve what you can do with Lua. With C and Lua you can literally tact almost any problem, from drivers to databases. It might not be the most efficient way, but definitely you will get more bang for your time and money.

    --
    "Sum Ergo Cogito"
  32. Relevant to what? by aglider · · Score: 1, Insightful

    To mobile application market? Irrelevant.
    To online web services? Not so relevant.
    To online web server? Very relevant!
    To high efficiency applications? It's almost the standard.
    To operating systems? There's almost nothing other than C (in terms of market share).

    Please, elaborate more on your stupid question, you insensitive mobile clod!

    --
    Sent as ripples into the electromagnetic field. No single photon has been harmed in the process.
    1. Re:Relevant to what? by Anonymous Coward · · Score: 0

      You're first point, I disagree with. Look at pretty much every Android game and you'll find a JNI component. And the Android NDK used to make those JNI components? C.

    2. Re:Relevant to what? by AmiMoJo · · Score: 2

      Android apps can use C for native code, and many do for performance reasons (e.g. games) or to access lower level OS functions (e.g. interfacing with USB devices).

      --
      const int one = 65536; (Silvermoon, Texture.cs)
      SJW, n: "Someone I don't like, and by the way I'm a fuckwit" - AC
    3. Re:Relevant to what? by gweihir · · Score: 1

      Not even irrelevant for mobile applications. Once you get serious about security, you have to do some things in C, for example to be sure that crypto-keys do not get moved around and copied and for reliable overwriting when you delete them.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    4. Re:Relevant to what? by GuB-42 · · Score: 1

      To mobile application market? Irrelevant.

      Not totally irrelevant. Mobile has its share of high efficiency code written in C. Furthermore, Objective-C, the standard language for iOS apps, is a superset of C.

    5. Re:Relevant to what? by aglider · · Score: 1

      OK! OK! You are just confirming that the original question still has the original trivial answer. Which is "A whole lot!" in my mind.

      --
      Sent as ripples into the electromagnetic field. No single photon has been harmed in the process.
  33. I agree. by Anonymous Coward · · Score: 0

    I agree. C is a powerfull language.

  34. Devices / Appliances using Linux - C by aralin · · Score: 1

    A lot of HW related companies use mostly just C. Any sort of small device development or most appliances (switches, storage, etc.) have software written in C. Any driver development, etc. It is still the language anyone can pretty much agree on.

    --
    If programs would be read like poetry, most programmers would be Vogons.
  35. Low Level System Software by nateman1352 · · Score: 1

    C is great for low level stuff since it is capable of generating machine code that has zero dependencies. K&R even explicitly mentions "non hosted mode" with no libc and implementation defined entrypoint semantics. In fact, it is the only language in mainstream use today that has this feature (aside from assembly.)

    For kernel, drivers, firmware, embedded, and RTOS its pretty much the only choice unless you want to code everything in straight assembly. Since my current job is firmware programming, I've actually like the C language now that I've been forced to do a lot of heavy coding in it instead of Python.

    1. Re:Low Level System Software by Ketorin · · Score: 1

      Also, in C it is the norm that the operating system's own call and linking conventions are used. Of course it does help that all the major operating systems have been written in C itself, but still. For example, Delphi in contraction comes with pretty much with its own library ecosystems and linker, while native libraries need a wrapper around them, whereas in C the compiler is the only thing that is needed, and it can also be a cross compiler to bootstrap the minimalistic C ecosystem. Very few languages even have cross compilers. I'm trying to say, C's flexible build system is also a huge and often overlooked asset in low level system stuff.

    2. Re:Low Level System Software by gweihir · · Score: 1

      Very true.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    3. Re:Low Level System Software by Thiez · · Score: 1

      C is great for low level stuff since it is capable of generating machine code that has zero dependencies. K&R even explicitly mentions "non hosted mode" with no libc and implementation defined entrypoint semantics. In fact, it is the only language in mainstream use today that has this feature (aside from assembly.)

      I very much doubt that is true. For instance, I think Rust can also make that claim.

    4. Re:Low Level System Software by Anonymous Coward · · Score: 0

      GP said "in mainstream use today"

      Rust isn't even at 1.0, let alone mainstream.

    5. Re:Low Level System Software by Anonymous Coward · · Score: 0

      It's worth noting that C++ has the same things and is a fine choice too for freestanding code.

  36. Work dried up for this C programmer by Anonymous Coward · · Score: 1

    The only real place C is used any more is embedded systems. I never had any experience with that. I used to be a C expert. Understood pointers and C quirks. But the work dried up. Everything went to Java and C# as far as applications programming goes, and I went with it.

    1. Re:Work dried up for this C programmer by jones_supa · · Score: 2

      Yep, this is true. There is still work for the odd embedded or Linux kernel hacker guy, but from a sole business perspective, mastering C is not terribly useful.

  37. It was and is the ultimate macro assembler by msobkow · · Score: 2

    C started out with high level "constructs" that were basically the operators of the PDP-11 and VAX processors from DEC. While those constructs have mapped well to other processors, virtually every statement in C originally compiled to one instruction on those processors.

    To this day, C still gives you the power and flexibility of any low-level language worth it's salt, and ample opportunity to hang yourself and your code. Don't forget -- C++ originally targetted C as it's output, not machine code. C has similarly provided the "back end" for no small number of special-purpose compilers.

    Then there are the operating systems and device drivers that have been written with it, and all the embedded systems logic for devices all and sundry.

    C will never die any more than assembly or COBOL and FORTRAN will. There will always be those special-purpose high-performance tasks where it is worthwhile to use C instead of a higher level language. Just as there are times where it still makes sense to drop even lower and into assembly.

    You go ahead and try to bootstrap an entire C++ implementation so you can write a kernel in it. Good luck with that. Getting a C library framework running on a bootstrapped kernel is hard enough. C++ would be orders of magnitude harder.

    --
    I do not fail; I succeed at finding out what does not work.
    1. Re:It was and is the ultimate macro assembler by jbolden · · Score: 1

      BTW just to add another example Haskell's original design did that as well. GHC originally compiled to C/GCC.

  38. Linux Kernel is in C. All you need to know. by Anonymous Coward · · Score: 0

    All those web servers. All those Android devices. They run a Linux kernel. It's written in C.

    1. Re:Linux Kernel is in C. All you need to know. by jones_supa · · Score: 1

      You are correct about that, Linux is actually a huge driver for the need of C experts these days.

    2. Re:Linux Kernel is in C. All you need to know. by gweihir · · Score: 1

      Apache as well, and if you want a fast apache module, you better code it in C.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    3. Re:Linux Kernel is in C. All you need to know. by Anonymous Coward · · Score: 0

      who uses apache still?

  39. one of a kind by Tom · · Score: 1

    If you need to be efficient, you write in C, end of story. That's why.

    C++ and all the other languages there simply have too much overhead and give you not enough control over what's actually happening.

    Assembler isn't worth the major hassle for the tiny improvement you get over C.

    C, however, is at this unique point between the bare metal and the high-level abstractions where the trade-offs are perfect. You get just enough abstraction to be a) hardware-independent and b) can use a high-level programming language while remaining close enough to the machine that you can be really, really efficient, fast, short, the whole nine yards.

    --
    Assorted stuff I do sometimes: Lemuria.org
    1. Re:one of a kind by gweihir · · Score: 1

      For some tasks you still need assembler, as C does not expose the full CPU interface. (Example: overflow flag.) But in C it is easy to add some small pieces of assembler and that makes it far, far less of a pain that writing complete programs in assembler.

      After using C for about 30 years and having experience both in several assembler versions and numerous high-level languages, I agree that C is nearly perfect for its target problem set and that it is unlikely to be replaced in the foreseeable future.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    2. Re:one of a kind by Stele · · Score: 1

      C++ doesn't "simply have too much overhead". Most C++ features compile down to the equivalent, or faster (sometimes much faster), C code. C++ being "slow" or having "overhead" is a common misconception, and quite possibly the worst argument against using C++.

      Honestly, pretty much all of the "real" arguments I've seen against using C++ boil down to either "I don't understand it" or "I don't like it" or "why would anyone need anything other than JavaScript?". These are hardly faults of C++.

    3. Re:one of a kind by DavidCBillen · · Score: 1

      Assembler can be worth the hassle if you require very tight inner-loops or to exploit special processor instructions (like SIMD for example). Not to nit-pick your post but I deal with these things every day in DSP development. There are still very real needs for cycle shaving in lots of contemporary embedded applications and will be for a long long time.

    4. Re:one of a kind by Tom · · Score: 1

      If you write in the subset of C++ that has these cute features, you're effectively writing C with objects.

      I doubt any C++ code compiles to "much faster" machine code than well-written C, but you're welcome to prove me wrong with an actual example.

      --
      Assorted stuff I do sometimes: Lemuria.org
    5. Re:one of a kind by GiganticLyingMouth · · Score: 1

      C++ might not end up being faster, but it certainly has no reason to be slower*. Well-written C++ and C should run at about the same speed. However, C++ has the advantage of allowing you to use high-level constructs when performance isn't as much of an issue.

      * this is contingent on your compiler -- if you're using some compiler from a decade ago, some constructs (e.g. templates) may emit shockingly poor code

    6. Re:one of a kind by Stele · · Score: 1

      One area where the C++ compiler optimizer excels is in the template compiler. When using templates, the compiler is free to inline pretty much anything, and if you have a deep enough template call tree, it can boil the code down into extremely tight instructions.

    7. Re:one of a kind by Anonymous Coward · · Score: 0

      >If you write in the subset of C++ that has these cute features, you're effectively writing C with objects.
      No, you're writing C++. See Bjarne's recent post on isocpp.org

      >I doubt any C++ code compiles to "much faster" machine code than well-written C, but you're welcome to prove me wrong with an actual example.
      Not parent, but there are plenty of exemples. The usual one being qsort VS std::sort

  40. Control by perbu · · Score: 1

    If you want to write something highly performant C is still the preferred option. Not because C produces faster code, languages with advanced run time environments like Java are in a better position to optimize your code, but because you know exactly what is going on. In my experience, the two things you should avoid in a highly performance application are system calls and locks.
    In a high level language you can never be sure when a lock is taken or when a system call is fired off. In C, well, you'll have to be pretty explicit about both.

    1. Re:Control by gweihir · · Score: 1

      Code-optimizers can do only so much. As soon as the programmer needs to optimize, languages like Java are a lost cause. And then there are not-so-obvious optimizations: For example, the smaller your code is and the better its memory-access locality, the more performance you get from caches. There, C allows you to get into regions that Java does not even know exist. Not for all problems of course, and there are many tasks where performance is not that critical, but I have seen a few critical business applications in Java that were dog-slow because of Java.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
  41. The third worst thing to happen computer history by Anonymous Coward · · Score: 0

    C sucks - it is the third worst thing to happen computer history. Pascal was rising and C took over with it's appeal to anarchy. It is so easy to write nasty, trashy code in C. I would how much "C++" is actually C.

    What the first and second worst thing to happen computer history? The introduction of the IBM PC and the rise of Microsoft. The original IBM hardware (with 68000 computers with hard drive available dropping price) and MS-DOS set the industry back YEARS.

  42. C is still relevant by Anonymous Coward · · Score: 0

    I think it is a shame C isn't used more for business software. In my company we have a large number of C# projects and every one I've looked at is over engineered. We're a bit 90's in that most of our software is shunting bits of XML around the place. Most of the teams are huge (30+ people) and I think most could be done with maybe 5-6 good C programmers producing simpler, faster and better software.

    1. Re:C is still relevant by gweihir · · Score: 1

      That is something I have often observed with customers. Another problem is non-understanding of what UNIX already gives you. For example, some people wrote a huge document-transformation and transportation engine in Java, when all they needed was a cron-job using ssh to move files, transfig and ghostscript. Unix-expert: 2-3 days for the implementation (plus 4 Weeks test, deployment, etc.). Java people: more than 1 person-year and they are still fixing things in there.

      I have long since believed that making complex things easy in a language is a mistake (except for special-purpose languages, such as R), as many programmers do not have the expertise and experience that is required to write software as simple as possible. If you make complex things easy to use, they will just throw everything and the kitchen sink at the problem and end up with a complex monster that nobody understands anymore. Complexity can be hidden to a degree, but it is still there and there will always be instances when it surfaces and the only way to debug problems then is to understand the complexity. Languages that try to hide complexity make it far too easy to violate KISS.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
  43. Re:First post by NoNonAlphaCharsHere · · Score: 5, Funny

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

  44. Re:First post by jones_supa · · Score: 1

    At least he made the first post.

  45. Oh God no! by Anonymous Coward · · Score: 0

    If C starts having OOP features like inheritance, I will start wearing black suits with my shirt collar buttoned up all the way, hold a copy of K&R, and throw objects at you blasphemers and heatens. If you want those features, defile yourself with the 98 standard of C++.

    1. Re:Oh God no! by jcdr · · Score: 2

      C++ is not the only way to do object programming. If fact this is probably the most complex and crappy way to do it. A lot of others language have proven that object programming can be more simple. C is late in the object programming game and can take this as an opportunity to do it the right way.

    2. Re: Oh God no! by Anonymous Coward · · Score: 0

      "C is late in the object programming game and can take this as an opportunity to do it the right way." If you want C syntax and OO, wouldn't that be Java or C#?

    3. Re: Oh God no! by jcdr · · Score: 1

      I agree that Java and C# have a cleaner and simpler object programming model than C++, but there are not popular (if even suitable) to write low level code. C is very successful because it usability span from the smallest microcontroller to very big projects. Support for almost all silicon is almost exclusively done in C and it's very unlikely to change quickly. I think that adding a pragmatic simple object model to C will make a lot of sense.

  46. 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.

  47. I actually DID program a device in hex once. by wiredog · · Score: 2

    Once. Gave me a real appreciation for high level languages like C.

    And, yes, it was an embedded application. No user interface, the controller talked to the device, the device ran some very precise valves. It was actually a fun month getting all that working.

    1. Re:I actually DID program a device in hex once. by Anonymous Coward · · Score: 0

      How big did this program end up being?

  48. Yes and no. by Mister+Mudge · · Score: 1

    Yes - C is still useful, and very relevant as a touchpoint for its descendants.

    But no, those other languages do not "have block syntax that's derived from C." They all, including C, have a block syntax that's derived from Algol-68.

    --
    Mudge

    In theory, theory and practice are the same.
    In practice, they're not.

    1. Re:Yes and no. by Anonymous Coward · · Score: 0

      Algol 60, you mean. Algol 60 has blocks and compound statements, both of which are syntactically statements.
      Any language whose block syntax was derived from Algol 68 would have no syntactic distinction between statements and expressions, like Lisp and the ML family, because everything in Algol 68 has a type and returns a value.
      In Algol 68, even loops are expressions that return the trivial value, EMPTY, of type VOID. You'll find something similar in OCaml's loops, which return () of type unit.

  49. Embedded - Embedded - Embedded by Anonymous Coward · · Score: 0

    Though "embedded" systems are getting more sophisticated and complex, and some migrate to Linux (Car infotainment/navigation, etc), the age of IoT will require smaller (i.e. micro controller) sized systems, that will be heavily resource (i.e. memory, both RAM and FLASH) constrained. For the "real time" stuff, Assembly will still be used. C provides the capabilities that cross the lines between those "low-level" needs and yet, you can still create "object oriented like" higher level constructs if need be.

    1. Re:Embedded - Embedded - Embedded by Anonymous Coward · · Score: 0

      Funny, I have been doing real time embedded code since the mid-80's, and since about the mid-90's I haven't had much need for Assembly as long as I was allowed to use C (Suck on it, Ada). Critical code that I would have proudly demonstrated my prowess on hacking out in Assembly for the previous 10 years was suddenly being matched in speed (within 5%, and not too uncommonly within 1%, and we were measuring to the CPU clock) by C compilers derived off of gcc (every other C compiler not derived from gcc was pretty much crap), and by coders finishing the job in days to weeks before I could have gotten the job done. Since then, my opportunities to NEED to in-line some assembly for performance reasons on embedded projects come maybe once a year. And the stuff I worked on is still rolling around on Mars, keeping nuke subs silent running while even the head lights work (ask a submariner where the head lights are on the sub... when you get a funny look, tell them "in the head, bubblehead". Then thank them for their service.), and probably keep your (American or German-made) car from skidding.

  50. C# by Anonymous Coward · · Score: 0

    Java and its copy C# were written from the ground up to be OO. C++ is really an OO hack on top of C. I was a pretty damn good C++ dev back in the 90s (did other things after that) but god, today's C++ code is pretty much unreadable to me. WTF happened to it?

    1. Re:C# by Rei · · Score: 1

      Here's one of countless reasons why you should learn C++.

      std::thread([&](){ do_something(local_arg1, local_arg2); }).detach();

      Write me the equivalent in C.

      --
      "We consider that six courts and an asylum claim are a rather odd way of returning to Sweden within a month."
    2. Re:C# by Anonymous Coward · · Score: 0

      Here's one of countless reasons why you should learn C++.

      std::thread([&](){ do_something(local_arg1, local_arg2); }).detach();

      Write me the equivalent in C.

      First off, the space bar is your friend. Here's a C example with most of the boilerplate stuff stripped.

      void func(void *arg){ thread_1_stuff; } int main(void){ pthread_create(&pthread_t_var, NULL, func, &arg); thread_2_stuff; pthread_join(pthread_t_var, NULL); }

      So using threads consists of slightly more program text...so what? But guess what the C version doesn't require? The big fat C++ STL.

      Source: http://timmurphy.org/2010/05/0...

    3. Re:C# by itzly · · Score: 1

      It looks like your cat fell on the keyboard. What does the code do ?

    4. Re:C# by Rei · · Score: 1

      First off, in what freaking style guide is it acceptable to declare a function and a three-command main function all on one line? Inline lambdas are perfectly fine style, that's pretty much what they're there for, but what you did isn't even close to acceptable style.

      Secondly, that's not what I asked of you. I did not say "create the simplest pthread example you possibly could". I'll repeat what I asked of you:

      std::thread([&](){ do_something(local_arg1, local_arg2); }).detach();

      That is, I asked you to create:

      1) a thread, that
      2) runs a function called do_something, that
      3) takes two arguments, that
      4) are varialbes local to the function that spawns the thread, with
      5) no restrictions that the thread may only have one instance at a time, and
      6) runs detached

      Go.

      --
      "We consider that six courts and an asylum claim are a rather odd way of returning to Sweden within a month."
    5. Re:C# by Rei · · Score: 1

      Oh, and just to let you know, even your minimal example that doesn't come close to meeting the specs cheats on not declaring the pthread_t (you can't declare it inline) and has a bug in the declaration of func (should return void*). (we'll just take it for granted that that thread_1_stuff, thread_2_stuff, arg, and #include <pthread.h> exist, since the equivalents are assumed in my example)

      I'll go ahead and help you out on meeting the specs provided by giving you a realistic sample program (I'll skip file error checking for simplicity; all of the other code is plain C). Replace the C++11 code with the C equivalent.

      #include <thread>
      #include <stdio.h>
      #include <unistd.h>

      void do_something(float a, float b)
      { // Let's waste some time to simulate a time-intensive task.
          float c = 0;
          int i;
          for (i = 0; i < 10000000; i++)
              c = c * b + a;
          printf("%f, %f: %f\n", a, b, c);
      }

      int main(int argc, char** argv)
      {
          FILE* fp = fopen(argv[1], "r");
          while (!feof(fp))
          {
              float a, b;
              fscanf(fp, "%f, %f\n", &a, &b);
              std::thread([a,b](){ do_something(a, b); }).detach(); // REPLACE ME
          }
          while (1)
              sleep(1);
      }

      Surely that's a trivial task, right? You just need to replace one line, after all. Go for it.

      --
      "We consider that six courts and an asylum claim are a rather odd way of returning to Sweden within a month."
    6. Re:C# by itzly · · Score: 1

      I would write it something like this: start_do_something( arg1, arg2 ) ; But with a better name, of course.

    7. Re:C# by Rei · · Score: 1

      There's some descriptions and sample code above, but I'll break it down.

      std::thread(): This declares a std::thread object, which is a c++11 thread-launching object. Its constructor here takes an argument of a function.

      [&](){ ... code here ... }: This declares a lambda, which is basically an inline function. We could of course declare a function further up, then pass that to the std::thread, but that'd take more code, and more importantly, the declaration would be far from where it's actually being used, which is bad coding style. So we use a lambda to declare it right where we use it. The first part between the brackets declares what variables will be "captured", aka, made usable inside the lambda. So you could say [a,b,c] for variables [a,b,c]. & means "everything". The () is just like for any function - there's no arguments, so it's just (). The brackets are, again, just like with any other function - they enclose code. .detach(): We're telling our newly created thread to detach.

      gcc actually just wraps the c++11 code into pthreads, so it works exactly the same way - you even still have to link in -lpthread. But it's far easier in C++11, especially once you get away from trivial cases. And this is actually just the beginning of what you can do - there's also futures, for example, that let you do stuff like:

      auto a = std::async(std::launch::async, [](){ return waste_time(1.0); });
      auto b = std::async(std::launch::async, [](){ return waste_time(2.0); });
      printf("Result: %f\n", a.get() + b.get());

      The printf won't evaluate until both the first and second waste_time functions are done evaluating and have returned a value, but it doesn't make them evaluate in a particular order. If you wanted you could take std:async a step further and wrap it into an object that overloads common operators with an automatic call to get(), and thus you could have something like:

      auto a = my_async([](){ return waste_time(1.0); });
      auto b = my_async([](){ return waste_time(2.0); });
      printf("Result: %f\n", a + b);

      Usually, though (IMHO) futures are overkill.

      --
      "We consider that six courts and an asylum claim are a rather odd way of returning to Sweden within a month."
    8. Re:C# by Rei · · Score: 1

      And you would call it how? If you would simply call it "start_do_something(local_arg1, local_arg2)", then it's not threaded and doesn't even come close to meeting the spec.

      This is a really basic use case here. You've got a single line of code with a couple arguments and want to run it in the background. How much more basic can you get than that? In C++11 it's a single simple line of code. In C it's anything but.

      I'm still waiting for someone to *actually* implement the spec in C. We're talking about implementing a single line of C++11, a line involving a commonly desirable task, in C. How hard could this be if C is any sort of half-decent language at all? I even gave you a sample program to put it in (see below).

      The problem is that threading isn't trivial in C like it is in C++11, and thus most programmers avoid it unless they absolutely have to deal with it. Which leads to underperforming and hang-prone programs, a problem that's only going to get worse with time.

      --
      "We consider that six courts and an asylum claim are a rather odd way of returning to Sweden within a month."
    9. Re:C# by Rei · · Score: 1

      Note: 8 hours later, and not a single person has replaced the single line of C++11 doing a commonly desirable task (running a line of code with a couple arguments in the background any number of times) with C code. How pathetic is your language of choice that such a challenge isn't just a gimme?

      --
      "We consider that six courts and an asylum claim are a rather odd way of returning to Sweden within a month."
    10. Re:C# by Anonymous Coward · · Score: 0

      Your not-clever code really does look like your cat flopped on the keyboard. You also didn't type all the C++ boilerplate junk.

      While you're being a condescending prick, let's read what you really said: "[Compressed C++ gibbberish for my ego to stand upon here] Write me the equivalent in C." Never mind the fact that things are done differently in C than in C++ and that a real-world program in either would be written in fundamentally different ways.

      Perhaps you'll learn how to communicate effectively one day, but this obviously isn't it. Feel free to keep swinging your e-peen around if it makes you feel good, but at the end of the day every single comment you've posted on this thread screams "I'm an asshole who knows more than everyone here! Watch me smash bricks with my ego!"

      Here's a challenge that's about as correct as yours: write some C++ that does all that junk you're blathering on about without requiring the bloated STL or Boost libraries and doesn't use C pthreads. Protip: you can't.

    11. Re:C# by Anonymous Coward · · Score: 0

      They saw how much of a total asshole you are. You're never wrong even when you are, buddy.

    12. Re:C# by twistedcubic · · Score: 1


      Here's one of countless reasons why you should learn C++.
      std::thread([&](){ do_something(local_arg1, local_arg2); }).detach();
      Write me the equivalent in C.


      Wow! You should mention this on the Linux Kernel Mailing List. The Linux kernel is LOADED with threads, all written in C. You will certainly save the kernel developers lots of time when they switch. Please write back and tell me how it goes.

    13. Re:C# by twistedcubic · · Score: 1

      I totally agree with you. Please report the same on the Linux Kernel Mailing List. It's a shame the Linux kernel is written in C and does not benefit from this.

    14. Re:C# by Anonymous Coward · · Score: 0

      _beginthread(do_something,0, param);

      Why do you think this is hard in C? I am not even going to go into how easy this is to do with something like openmp.

      I will go with the other guy replying here: You are unwilling to be wrong even when presented with an example, this is no more difficult in C than C++.

      The correct answer as to how most C programmers would do it though was already given: start_do_something( arg1, arg2 ); simply because it is clear, and you will not have a ton of entry points to threads in most programs.

    15. Re:C# by Rei · · Score: 1

      _beginthread(do_something,0, param);

      That, of course, does not even remotely meet the spec I presented above. And it's not even standard.

      This isn't a challenge to write a replacement to Xorg or anything. It's one damned line of code, people, with your test case given to you, representing a common scenario. How freaking hard can that be? The fact that nobody on a slashdot thread full of pure-C fanboys can't manage this simple task just speaks volumes as to how terrible threading is in C.

      how most C programmers would do it though was already given: start_do_something( arg1, arg2 ); simply because it is clear, and you will not have a ton of entry points to threads in most programs.

      Well said, Programmer From 1983. Single core processors are the future! GUI hangings are just part of the business! Trivial background tasks should be spawned with exec* and communicated with via IPC!

      --
      "We consider that six courts and an asylum claim are a rather odd way of returning to Sweden within a month."
    16. Re:C# by Rei · · Score: 1

      So your argument is "because there exists a piece of software, the language of which it was developed in being chosen 23 years ago, then all pieces of software should choose its language too"? Impeccable logic. Who can argue with that?

      Let's take a look at how a typical part of the Linux kernel deals with threading, shall we? Here's the first random example I came across in a quick grep of a source tree - drivers/mtd/ubi/build.c

      First, we have to declare a struct (in a different file, ubi.h) to hold the data we want accessible in the thread:

      struct ubi_device { // ... Sniped - miscellaneous needed data fields ...

      struct task_struct *bgt_thread;
      int thread_enabled;
      char bgt_name[sizeof(UBI_BGT_NAME_PATTERN)+2]; // ... Sniped - more miscellaneous needed data fields ...
      };

      Now we need a struct to manage all of our threads' arguments:

      /* All UBI devices in system */
      static struct ubi_device *ubi_devices[UBI_MAX_DEVICES];

      UBI_MAX_DEVICES having already been defined in the .h. Now, of course, to be able to access the device, we need lots of helper functions. Among the half dozen or so:

      struct ubi_device *ubi_get_device(int ubi_num)
      {
      struct ubi_device *ubi;

      spin_lock(&ubi_devices_lock);
      ubi = ubi_devices[ubi_num];
      if (ubi) {
      ubi_assert(ubi->ref_count >= 0);
      ubi->ref_count += 1;
      get_device(&ubi->dev);
      }
      spin_unlock(&ubi_devices_lock);

      return ubi;
      }

      When they want to insert, they have to do stuff like:

      for (ubi_num = 0; ubi_num ... to merely even find a place to insert.

      So, let's look at the specific thread creation function:

      int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset)
      {
      struct ubi_device *ubi;
      int i, err, ref = 0; /*
      * Check if we already have the same MTD device attached.
      *
      * Note, this function assumes that UBI devices creations and deletions
      * are serialized, so it does not take the &ubi_devices_lock.
      */
      for (i = 0; i < UBI_MAX_DEVICES; i++) {
      ubi = ubi_devices[i];
      if (ubi && mtd->in

      --
      "We consider that six courts and an asylum claim are a rather odd way of returning to Sweden within a month."
    17. Re:C# by nctritech · · Score: 1

      It's a kernel, not a userland program. It's never going to be as simple as a userland program, so it's a bad example. Kernels can't have the C standard library or pthreads or the STL. Well, technically they could, but that'd make the kernel code massive for marginal benefit and any kind of library bug would become a kernel crash waiting to happen.

    18. Re:C# by nctritech · · Score: 1

      It seems that threading isn't nearly so simple in C++ either; at least, not if you want to get it right. From https://akrzemi1.wordpress.com... and http://www.open-std.org/jtc1/s... it would seem that while initiating a thread as you've discussed within a C++ program is easy, the nuances of C++ threading are uglier than C pthreads threading. Quotes like these make C++11 threading seem a lot less trivial than your initially impressive example suggests:

      "If a thread is cancelled no destructors of automatic objects are called; or at least, it is up to the implementation if they are called or not. This would cause too much resource leaks. Therefore, it is not possible to cancel a thread in C++. There is a similar mechanism though: thread interruption. Interruption is coöperative: to-be-cancelled thread must acknowledge the interruption. If interrupted, a special exception is thrown that unwinds child thread’s stack until it reaches the outermost scope. However, interruption mechanism is not available in C++11 either."

      "But all those threads computing fib1 are still running! And as they finish, they will write to all those instances of fib1. Which are no longer there, since the stack has been unwound. In its place will be the stack corresponding to the continuing computation that was initiated when the exception was caught. Thus we now have a large number of threads writing to various locations on the user's stack. By the time the user tries to debug the resulting mess, there is a good chance they will all be gone, leaving him/her with nothing but a stack with mysteriously smashed values. Or those might no longer be visible either because a return address may have been overwritten, causing the main program to take a wild branch."

      As I am not well-versed in C++, I'm interested in knowing about these things. Perhaps it will give me a reason to seriously look at the language.

    19. Re:C# by Rei · · Score: 1

      And if you mean for start_do_something(arg1, arg2) to be a function that creates a thread, then you're just passing the buck. What's the code for that function?

      --
      "We consider that six courts and an asylum claim are a rather odd way of returning to Sweden within a month."
    20. Re:C# by Rei · · Score: 1

      Your not-clever code really does look like your cat flopped on the keyboard

      Your boasting about your ignorance is well taken.

      You also didn't type all the C++ boilerplate junk.

      Yes, I did. All I left out was the #include and the defining of local_var1, local_var2, and do_something() (because the whole point is that they're whatever the programmer wants them to be). Everything else is included. I even included "std::" rather than assuming "using namespace std;".

      [Compressed C++ gibbberish for my ego to stand upon here] Write me the equivalent in C. Never mind the fact that things are done differently in C than in C++

      First off, there's nothing "compressed" about that, if by compressed you mean obfuscated. Any person who knows even rudimentary C++11 will understand that code right away. Secondly, all it means is "Run do_something with two local arguments in a thread and detach it". What fundamentally different approach are you envisioning for C++ that makes it no longer desirable to run functions in threads?

      every single comment you've posted on this thread screams "I'm an asshole who knows more than everyone here!

      Says the person who doesn't even understand simple C++11 code yet feels compelled to rant about how horrible C++11 is compared to C.

      Here's a challenge that's about as correct as yours: write some C++ that does all that junk you're blathering on about without requiring the bloated STL

      Saying "Use C++ without STL" is like saying "use C without the standard C libraries". It's an idiotic request. Secondly, "bloated"? Go benchmark qsort vs. std::sort and then come back here and tell me about how "slow" C++ is (hint: as is true in most cases, the STL version is faster; templates allow the compiler to do optimizations impossible on C generics)

      --
      "We consider that six courts and an asylum claim are a rather odd way of returning to Sweden within a month."
    21. Re:C# by Rei · · Score: 1

      It's a kernel, not a userland program. It's never going to be as simple as a userland program, so it's a bad example

      It's *their* example. And you can build a kernel with whatever language, compiler and libraries you want - all that matters is what assembled machine code comes out of it. And the whole point of standardized libraries is to prevent bugs. Having everyone reinvent the wheel is asking for bugs. When a few tens of millions of people use, say, std::vector for a couple decades, you kind of expect the bugs to be worked out.

      --
      "We consider that six courts and an asylum claim are a rather odd way of returning to Sweden within a month."
  51. Alternatives by Anonymous Coward · · Score: 0

    Interesting alternatives to C seems to be D, Vala and Rust.

    Perhaps C# with the .NET Micro Framework?
    Or C# with .NET Native?

  52. Add some non-experts to the committee. by taylorius · · Score: 1

    I think there's a disadvantage with having languages designed solely by language design experts, and that is a tendency to over complicate things. They all understand it, and appreciate it's elegance, so it must be the best way.

    To draw an analogy, consider the musical excesses of prog rock / jazz fusion. The musicians themselves may appreciate a Locrian scale played against an AbSus13th arpeggio , but the audience can easily end up excluded. Then a musically simple but catchy band like the Sex Pistols comes along and steals their audience.

    I reckon languages need to be really really simple to understand, in order to become popular. For most people they're a tool, not an end in themselves.

    1. Re:Add some non-experts to the committee. by Anonymous Coward · · Score: 0

      appreciate it's elegance

      "its".

  53. Yes by kjhambrick · · Score: 1

    > Do you agree?

    Yes

  54. Re:The third worst thing to happen computer histor by Anonymous Coward · · Score: 0

    Umm... the original IBM hardware did not use 68000. It used the 8086 - with its horribly inefficient instruction set.

    And even the latest incarnation, it is still a horribly inefficient instruction set.

  55. Like they say about that other language: by Ketorin · · Score: 1

    "C is worth learning for the profound enlightenment experience you will have when you finally get it; that experience will make you a better programmer for the rest of your days, even if you never actually use C itself a lot."

  56. Knowing C gives you additional insights... by gweihir · · Score: 1

    Now, nobody in their right mind would call C a "good" language with regard to syntax. It is however unsurpassed if you want a portable language that gives you almost as much control and speed as assembler. While simpler things can often optimized by compilers for other languages to be reasonably efficient, some things cannot or there are huge other costs, for example inflated memory footprint or crippled system interfaces. So when you do understand the machine model and need fine-grained control, C is the way to go. That is one reason why C is relevant today and will stay relevant for the foreseeable future.

    Another thing is that anybody that can program C well does understand how CPUs execute code. That provides a number of advantages when writing things in other languages and it allows the implementation of performance-critical sub-modules in C. For example, I have made excellent experiences with algorithm cores in C and glue- and control-code in Python. My personal take is that those that call C outdated or even demand its retirement do not understand how code is actually executed and just want to remove the advantage those that do have. In other words, a programmer that cannot (also) program well in C is limited in understanding and capabilities and hence I expect that many jobs requiring C do not actually entail work that is mostly or completely done in C, but people that do understand how computers actually work in the lower levels.

    --
    Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
  57. I think of it all as the "C" family of languages. by Qbertino · · Score: 1

    We know that problem in and out: People mixing up C, C++ and Objective-C. Especially non-experts. That's no surprise. Then saying, despite requireing "C/C++" in the confidential: "Oh, you only have 20 years of C - I thought you knew at least a little C++ - OK then, sorry, you're the wrong guy."
    Me: *pictures Vincent and Jules pulling out their 9mm parabellums and pumping the HR guy full of bullets" ...

    Non-trivial JavaScript only caught on on a large scale when the term Ajax was coined and with it we finally had a better word for JavaScript - until then most decision makers would mix up Java and JavaScript. Sometimes without anybody noticing that. ... In hindsight, I really can't blame them all that much.

    I think of all the C stuff as the "C" family of languages.
    As far as I can tell, coaxing C into some OOP thing is a little tricky, but doable. C++ is different, yea, but if you turn on your brain and are willing to ditch the habit of writing your own stacks, any C dev worth his money should be up to pro-level C++ development in a few weeks. Same for Objective-C. It's not that C people write everything from scratch these days. Where to you think those bazillion libs in Linux come from?

    As for the C-Family of languages: Of course there still relevant. What kind of stupid question is that? What's Linux built with? C. What's Windows built with? C++. What's Mac OS X built with? Objective-C. What is any non-trivial system critical component built with? C, C++ or Objective-C (in the case of OS X / iOS).

    And that's not changing any time soon, trust me on that one.

    --
    We suffer more in our imagination than in reality. - Seneca
  58. one of a kind by Anonymous Coward · · Score: 0

    I would suggest that you in need to be efficient, then write the core 20% that has to be fast in C, and then write the rest of the system in a nice language.

  59. Re:The third worst thing to happen computer histor by gweihir · · Score: 2

    C is not intended to be a beautiful language. C is intended to give you as much control over the raw machine as possible, without going to assembler level and with (these days) reasonable portability. If you compare C and Pascal, then you have failed to understand the purpose of C.

    --
    Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
  60. Derived from Algol. by Anonymous Coward · · Score: 0

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

  61. C++ is the better C by Anonymous Coward · · Score: 0

    Minimally c++ is c with better type checking. Templates are superior to macros. Mangled names enforce correct bindings. There is no issues writing os kernels in c++. Get with the nineties man.

  62. C++ getting better and better... by SpinyNorman · · Score: 1

    It seems C++11 was just finalized yesterday, but already we now have C++14 finalized and C++17 in the works....

    This is hardly the same language from a few years ago - the power and ease of use that has been added, both for library and application developers is amazing.

    Anyone programming in C++ who isn't thoroughly familiar with all the new stuff in C++11 is missing out tremendously...

    1. Re:C++ getting better and better... by Anonymous Coward · · Score: 0

      Agreed. I'm a "former" C programmer. I used to dislike C++ because I thought that while it brought in the OOP paradigm it didn't bring much else good. So I tended to prefer Java to C++ by a wide margin. But C++11 really turned the language around for me and C++14 continues this.

  63. Very relevant for producing more slashdot page loa by drinkypoo · · Score: 1

    It's very relevant for producing more slashdot page loads. But since the summary includes the answer to the question ("But aside from this incredible legacy, what keeps C atop the Tiobe Index?") this is a non-story.

    --
    "You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
  64. Re:Silly Thiez by Anonymous Coward · · Score: 0

    They never used the letter ...someone else did ;-)

  65. Re:I think of it all as the "C" family of language by Anonymous Coward · · Score: 0

    Actually Windows is built with a mix of C and C++. OSX, a mix of C and Objective-C.

  66. 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.

  67. Shaking my head by OzPeter · · Score: 1

    If people think that C is not relevant in 2014, I'd hate to think what they thought about the ladder logic type languages in PLCs that pretty well run every manufacturing plant in the world.

    --
    I am Slashdot. Are you Slashdot as well?
  68. C is effectively portable assembly code by fwc · · Score: 1
    My opinion about why 'C' is still highly relevant is that there are still many needs for small, tight, code which runs very close to to the metal, and C is ideal for this.

    When you look at the output code from a C compiler, it tends to be small and fast, and relatively light on resources. In many cases, with modern compiler optimizations, the resulting code can actually be smaller and faster than all but assembly code written by someone who really knows how to optimize for a specific machine. Almost all embedded development work is done in either C or assembly, and C tends to be faster to write, and portable - so you can move the code to the next project if necessary.

    Using any 'modern' object oriented language immediately adds a level of bloat which is generally not acceptable in places where C still shines. These modern programming languages are written for environments where a few extra bytes or a few extra cycles isn't going to cause a problem. When working on a resource-limited platform (aka where you'd kill for a few hundred KB of code space, and more than a few thousand bytes of ram) you're just not going to be able to use a modern language because of the overhead of an object oriented language.

    I'd actually predict C is going to grow in the near term, just because of the growth of internet-connected low-resource devices. I actually develop products on a platform which has a complete TCP/IP stack (including web server and SNMP) running in less than 128KB (yes K not M) of memory. These and other similar small platforms are going to be the basis of the 'things' half of the internet of things, all of which are going to have C code at their base.

    1. Re:C is effectively portable assembly code by Anonymous Coward · · Score: 0

      Which platform are you developing for? Sounds interesting.

  69. Right too for the right job kids by Anonymous Coward · · Score: 0

    C is still the right tool for a lot of jobs. It's also the wrong tool for a lot of jobs.

    Proceed accordingly.

  70. C != C++ by Anonymous Coward · · Score: 0

    C and C++ are not the same.
    One of C staying power is it runs on everything down to the smallest 8 bit CPU.
    With out the larger overhead of C++
    It can be faster in low level and driver code.
    Windows PE does not support dot net so there is another potential use.
    In short it is still useful.

  71. 90+% of C++ deva are really writing lazy man's C by gonar · · Score: 1

    90+% of programmers claiming to be working in C++ are really writing straight up C code with the occasional object. because they occasionally use an object and want to be lazy and declare their local variables at any random moment, they end up having to use the C++ compiler and so claim to be writing C++.

    what they are really doing is writing bad C.

    so, saying C++ is twice as popular as C is incredibly misleading.

    --
    The difference between Theory and Practice is greater in Practice than in Theory.
  72. C =~ C++ by jgowen · · Score: 1

    Tue 12/09/2014 8:48 am. I assume a lot of people write supposedly C++ programs that are actually mostly C; I know I do....

  73. Re:90+% of C++ deva are really writing lazy man's by halivar · · Score: 1

    It may also be that 90% of C++ projects are ones that should have just been C to begin with. The code will naturally try to fit the problem domain.

  74. 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...

    1. Re:It all goes back to ALGOL by phantomfive · · Score: 1

      though I had already been "mentally mutilated beyond hope of regeneration" by BASIC before that...

      Could be worse, you could have started with Python.

      --
      "First they came for the slanderers and i said nothing."
  75. Re:The third worst thing to happen computer histor by Anonymous Coward · · Score: 0

    You should try embedded FORTRAN then...

  76. There's A Lot of C Out There by Greyfox · · Score: 1
    I'm currently maintaining some that was written back in the 90's. Some of the files are so old they're still using K&R-style declarations. Personally I'd rather use a recent C++, but I still have more luck finding jobs for C than C++. Even though C++ is a direct descendant of C, the idioms for using it effectively are significantly different.

    I started digging around in the Gnu flex source code for fun recently. Even though it's pretty moldy and old and uses global variables all over the place while it's generating your scanner, I'd still rather use flex than anything else if I'm going to be parsing a complex file format. I'm looking at sprucing up its C++ classes a little bit. I know there are projects out there to do that already, but this is really more of an excuse to go digging around in its guts than anything else.

    --

    I'm trying to teach myself to set people on fire with my mind... Is it hot in here?

  77. Re:First post by Anonymous Coward · · Score: 0

    I always begin my indexes at 512 just to mess up with whoever has to work on my code.

  78. Re:90+% of C++ deva are really writing lazy man's by mariox19 · · Score: 1

    What you're saying then is that there is nothing more popular than code written in a bad, mongrel version of C.

    --

    quiquid id est, timeo puellas et oscula dantes.

  79. Get over it by Lawrence_Bird · · Score: 2

    How many times more this year (only 22 days left!) are we going to see these types of "articles"? Give it a rest. C, COBOL and Fortran will be around long after all of you are dead.

    1. Re:Get over it by AttillaTheNun · · Score: 1

      Indeed, one day archeologists will dig up a pile of line printer output from some long lost CS lab as the only remains of The Second Age of Light. The secrets contained will fuel the legendary Search For The Rosetta.h file where all those confounded macros are defined.

  80. Re:First post by NatasRevol · · Score: 1

    That's a great sig...

    --
    There are two types of people in the world: Those who crave closure
  81. Great but unusable? by sjbe · · Score: 1

    C is a great language, it's just that most humans are incapable of using it safely and securely

    That sentence is self-contradicting. To my mind C cannot simultaneously be a "great language" and be impossible for most people to use safely. I would posit that to be considered a great language, the ability to use the language safely and securely by someone of ordinary skill in programming is a necessary condition.

    Since we are so fond of automotive analogies here... While the power and utility of C is undeniable, it's kind of like a car with too much horsepower and not enough traction. Really talented people can handle it but most should drive something else. It might be amazing in the right hands but that doesn't make it great.

    1. Re:Great but unusable? by jbolden · · Score: 2

      Safe and secure are two factors that are important. Here are some others:

      a) Code can be written quickly
      b) Code is portable
      c) Debugging times are low
      d) Code is reliable, i.e. factors of the execution environment don't effect computed results
      e) Problem domain is large
      f) Has a huge range of specialized libraries
      g) Has a following so that it is easy to hire in the problem domain
      h) Can be learned quickly
      i) Has a set of primitives that pair well with the problem domain
      j) Code executes quickly
      k) Code makes efficient use of system resources
      etc...

      Any decent language is going to excel at some aspects in exchange for being dreadful at others. Popular languages are popular because they excel at particular problem domains. C excels in 2014 where safety isn't a major concern because most C programs don't have a complex API, or where execution speed is paramount.

    2. Re:Great but unusable? by Anonymous Coward · · Score: 0

      To my mind C cannot simultaneously be a "great language" and be impossible for most people to use safely.

      C4 is a great explosive, it's just that most humans are incapable of using it safely. The fact that something has restricted utility (in terms of application, requirements for training, etc.) does not mean that it has *no* utility.

    3. Re:Great but unusable? by Hognoxious · · Score: 1

      A car where, if you want, you can disable traction control, ABS, the rev limiter and all that. Perl has something like this, IIRC.

      Of course, if you decide to disable them and wrap yourself round a tree it's nobody else's fault.

      --
      Confucius say, "Find worm in apple - bad. Find half a worm - worse."
    4. Re:Great but unusable? by Hognoxious · · Score: 1

      To my mind C cannot simultaneously be a "great language" and be impossible for most people to use safely.

      So the only great piece of music is 'chopsticks'?

      --
      Confucius say, "Find worm in apple - bad. Find half a worm - worse."
    5. Re:Great but unusable? by Beck_Neard · · Score: 1

      Well I was attempting to be humorous. It's true - it's NOT a great language.

      --
      A fool and his hard drive are soon parted.
    6. Re:Great but unusable? by Anonymous Coward · · Score: 0

      don't effect computed results

      "affect".

  82. The C family is more than C/C++/Objective-C/C# by Delwin · · Score: 2

    There's also OpenCL which is far closer to C than the rest of them, and that is a language that is still up and coming.

    1. Re:The C family is more than C/C++/Objective-C/C# by Anonymous Coward · · Score: 0

      And it's largely due to the hardware environment. It's easier to think of a GPU as a bag full of beefy microcontrollers or DSPs with a window into the big system or GPU memory that must rarely be used for performance reasons. Rather, the core operations need to happen within the limited local memory that looks a lot more similar to a small system, and that's how it ends up getting programmed.

    2. Re:The C family is more than C/C++/Objective-C/C# by GiganticLyingMouth · · Score: 1

      I expect OpenCL will move more and more towards C++ -- CUDA (the NVidia proprietary counterpart) also started off as C, but is now much closer to C++. (e.g. uses C++ compiler for host-side code, templated kernels, etc).

  83. ML is the grandfather of Haskell by Anonymous Coward · · Score: 0

    The acronym ML is a Meta Language for functional programming. Variants of ML are quit popular, for example OCaml and Haskell.

  84. As relevant as Cobol in 90s by iamacat · · Score: 1

    That is, very much so because of huge established code base, but watch out for your future career. C would not be the best choice for any new code base. For low level programming, it can not achieve the best performance because it enshrines how CPUs and compilers worked in the 60s instead of being amenable to extensive optimization, non-trivial vectorization, running on GPUs or automatic use of multiple cores. On high level, it's not suitable for large teams, as one developer's bug can affect others' code in unpredictable ways.

    So anyone with long term career plans should at least be familiar with Java, .Net, Swift, Go and so on to be prepared when progress happens.

  85. whoever wrote this don't know hard core programmin by jerryjnormandin · · Score: 1

    wow... someone does not know anything about coding. Go ahead and try to write a kernel extension in python... wow. there are different languages for different tasks. C will be around for a very long time.

  86. Stud factor. by MikeFM · · Score: 1

    So long as programmers feel the need to write C to show off what studly coders they are we'll be stuck with C. We'd all be better off if we could spend less time fixing C-related bugs and concentrate on making sure safer languages were just as fast and functional. I'd suggest C# as a better alternative but recently I've been discovering how stupid its handling of byte order is. It's not a bad language except the amount of idiot Microsoftisms it has. C++ is just as bad as C. Objective-C is a mix of genius and insanity. Java is its own set of kludges. Python is nice but slow. Go isn't enough of an improvement. ... Not sure we're ready to replace C yet but we should get ready.

    --
    At what price learning? At what cost wisdom? The price is a man's peace of mind, and the cost is his life.
    1. Re:Stud factor. by david_thornley · · Score: 1

      C++ is just as bad as C.

      C++, properly used, is a much safer language than C. In a fairly well-written C++ program, you will not get buffer overflows and you will avoid a large class of memory issues C is prone to.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
  87. Systems programming by jbolden · · Score: 2

    First off I'd consider C++ and Objective-C to both be variants of C. And you can make a fairly good case that Java is also a variant of C.

    That being said there is a good use case for C by itself. Lots of algorithms execution times are of forms like R*n^2 + S*n + T. For N large, A is all that matters. For N small T can often be the dominant factor. The C language, like assembly excels at getting the execution times for T down. However for most business processing execution time isn't really all that important since n isn't large nor is T particularly big. In which case programmer efficiency matters a great deal.

    1. Re:Systems programming by phantomfive · · Score: 1

      Lots of algorithms execution times are of forms like R*n^2 + S*n + T. For N large, A is all that matters.

      Man, there's no A in your equation.

      --
      "First they came for the slanderers and i said nothing."
    2. Re:Systems programming by jbolden · · Score: 1

      Sorry I meant R. A was a legacy from the previous version but I was using C (now T) to mean two different things. Sorry for the confusion.

  88. Re:First post by Anonymous Coward · · Score: 0

    C's [] operator works with an offset, not an index. Incidentally, this permits some really odd, but valid, code:

    int sum = 0;
    int a[1000];
    initialize( a, 1000 );
    for( int i=0 ; i1000 ; ++i ) sum += i[a];

    The first element of an array is located at offset 0, so it is indeed the first post. In your defense, it would be posts[0]...

  89. Rust by jbolden · · Score: 1

    Well to go off topic for a second. What is the news with Rust? I know Samsung was backing it, but I haven't heard anything in well over a year. Anything happening exciting on the Rust from?

    1. Re:Rust by Thiez · · Score: 1

      The Rust language is intended to reach version 1.0 soon (either before the end of the year or early 2015), which comes with the promise of being backwards compatible. However the Rust standard library is still undergoing stabilization and parts of it may still change for a while. Right now a lot of work is being done in that area, to stabilize the most important bits.

      Mozilla is also working on Servo, a research-project to develop a browser engine in Rust. The goal is to experiment with more parallelization in the browser, and Rust is supposed to help by making it easier to write correct multithreaded code. To do this Rust has a strong focus on ownership of data.

      Rust can run without a runtime and the standard library is split up into several parts (which is not invisible to users of the standard library) that can be used separately when you choose to compile without the standard library. The advantage is that when you target, say, a platform that does not support dynamic memory allocation, you can still use the parts of the standard library that do not require allocation (liballoc). Or you can go without libc bindings. So it is relatively easy to run Rust on bare metal. You could write an operating system in Rust if you wanted to (and I think some people are trying to do just that, but I haven't heard from them for a while).

    2. Re:Rust by jbolden · · Score: 1

      I knew about Servo, that was the project that Samsung was paying for. Trying to get an Android browser that was far better than Safari especially since Android processors can go with a much larger number of cores.

      The non-standard standard library is interesting. Thanks for the info!

  90. Because it can be used in Safety Critical Systems by emh203 · · Score: 1

    Yes. There is an entire world beyond the sphere of web programmers. Go into the automotive sector and ask about using python, java or any other higher level language in a engine controller.... LInux? I don't want my car to take 2 minutes to boot and go into a kernel panic because a guy in his basement wrote a driver for something. Python? We can put 1 GB of ram so a lazy programmer can have his pristine language environment. In the world where things have to work reliably and there is no room for esoteric languages, C rules the roost

  91. Legacy Code by Casualposter · · Score: 1

    Who cares about how popular code is now? How popular was it? How much stuff is coded in C that is vital to people willing to pay people to fix it and maintain it and perhaps even improve it. Fer craps sake, Cobol is still alive and kicking. Just because some computer science wiz farts out some new language every three years doesn't mean that all the previously built code goes up in flames. The old code has more lives than a zombie apocalypse and some poor sap gets to make a living off of it. This is supposed to be a serious profession not a gaggle of high school sophomores giggling over who got asked to the senior prom.

    --
    Creative Spelling Copyright (2002). May use without Persimmons
  92. C book recommendations? by Anonymous Coward · · Score: 0

    I recently purchased "The C Programming Language" second edition to learn C. Can anyone recommend other must read books to become a competent C programmer? Books on good procedural design, modularity, writing code that can be easily ported to other platforms, coding conventions, testing, etc. I'm interested in OS development.

    1. Re:C book recommendations? by Anonymous Coward · · Score: 0

      Read the C spec!

      Aside from that the most useful thing you could read in terms of books are the intel manuals for x86 (which they used to ship for free, and probably still do.)

  93. more than it should be. by quarkalone · · Score: 1

    ... the relevance of C is more than it should be.

  94. Relevant by Anonymous Coward · · Score: 0

    As the base layer for cPython, the world cannot do without it.

  95. Leave it to the pros by AttillaTheNun · · Score: 1

    C was obviously invented to fill a niche - SkyNet will need a language to develop their self-aware minions.

    Otherwise, don't try this at home, kids.

  96. LLVM assembly by Dasher42 · · Score: 1

    Since we actually have a widely accepted portable assembly language now, I have been pondering this very question. LLVM assembly holds a lot of potential, similar to how the TAOS operating system promised back in the early 90's with its virtual processor assembly: https://sites.google.com/site/...

    The guy who inspired me to want to program used to write assembly on a 386 with a slightly hacked copy of the 8086-oriented freeware assembler CHASM. He read compiled binaries in hex like code. I asked him, "Doesn't it take a lot more time to write in assembler?" "Not that much", he replied, "You break things down into functions and build libraries of code you don't have to reinvent, just like in C." The guy was freaking brilliant.

    We've so frequently created new languages around new ideas in programming, and that's great, but eventually the number of abstractions becomes quite an issue. People are willing to write operating systems like MenuetOS in assembly in x86_64 asm. That's great. I'd love to see a compiler there to do validation of code, uphold Ada-like programming by contract, that sort of thing, but I'd love to see assembly programming make a comeback.

    1. Re:LLVM assembly by Anonymous Coward · · Score: 0

      http://ellcc.org
      And Growing!

  97. More stupid /. click-bait by Anonymous Coward · · Score: 0

    Just because you doesn't use it doesn't mean it's not relevant.

    I don't code in D-Flat or Python; but that doesn't mean they're not relevant.

    And yes, this is more stupid click-bait courtesy of Nerval's Lobster and dice.com.

  98. Imperative by Anonymous Coward · · Score: 0

    The Internet of Things does and will run on C.
    Your watch, your router, your oven, your car - all C.

  99. is this a trick question? by lkcl · · Score: 1

    i feel that the answer lies in the sentence "the internet is driven by c". if you want direct performance, executable compactness as well as operational efficiency (that is also massive step up from assembly language), you have *one* option available to you: c. that means that apache, wine, postgresql, openldap, cups, samba, libc6, the python interpreter itself, the linux kernel, the windows NT kernel and many more OSes: they're written in c.

    only when some of those constraints - performance, compactness and operational efficiency - may be relaxed in favour of, for example, a higher bang-per-buck ratio in the expressive power behind the lines of code written (python dict), or where code-resuse is critical without too much inconvenience (templates and objects of c++), *then* you begin to choose alternative programming languages.

    but as a general rule, if ever you see the word "system" or "service" in a sentence (operating "system", web "service"), automatically that implies "high performance" which automatically implies "high efficiency needed" and that means "c".

    so i feel it is therefore much more interesting to note the situations in businesses where c is *not* used despite there being circumstances where performance is critical. when people choose java for web services, for example.

  100. And guess what Fortran is making a comeback by JHL · · Score: 1

    I have worked in process control and high energy physics for the last 30 years. When the PAW (physics analysis workstations) were converted from Fortran to C++ it was a total disaster, a bloated piece of crapware emerged that took more resources, ran at half speed if it didnt crash with a memory leak first. I have stood on the bank of the river and watched the corpses floating by, the latest fads in languages back then, remember Pascal, Modula, Algol68 .... During that time Linux hackers were perfectly happy to write their C code with vi and make, perhaps with cscope and get reliable binaries that are maintanable. The point about C is its a SIL (Systems Implementation Language), no one in their right mind would think about writing a kernel in C++, its an abomination. For those of us who need OO then C# and Java are great, look at Android. The old languages that have survived the test of time have done so because they work for the niche they were intended for. C is brilliant at describing and using hardware interfaces and writing beautiful fast kernel code, and yes macros are great "ContainerOf" and "WaitEvent" are two that come to mind. So cheers to C, Fortran (making a strong comeback), Lisp and Python. May C++ rot in hell as soon as possible with the rest of the crap, if I want OO I will use Java.

  101. Embedded Development by Anonymous Coward · · Score: 0

    For embedded systems, there is just no replacement. I have been developing in embedded systems for eight years now. We use compilers like IAR, operating systems like ThreadX, and develop for microprocessors like Atmel and ARM.

    First and foremost, higher level languages are just too top-heavy for these systems. They have low code space and must be fast and efficient. Higher level languages, including C++, just do not offer that. Secondly, the language is very entrenched. It is the de-facto standard for almost all embedded development.

    The way I see it, the industry will eventually move to a point where something like Java or Objective-C is more standard, but the cost-benefit ratio isn't there yet. Android and iOS can do that because smart-phones cost a lot of money. But most embedded systems are cheap. The micro has to cost as little as possible.

    Yes, this means we live in a world plagued by all kinds of pitfalls. Buffer overruns, bad pointers, memory leaks, improper use of semaphores. I've seen all of it. I'm no purist. I would like this industry to move away from C. It needs to. The software we support is getting far too complex. RTOSes with several threads. Full stacks for TCP/IP, SSL, USB, Bluetooth, ANT. Complex memory and power management schemes. As it is though, C will probably be the standard for this industry for at least the next few years.

  102. Simple: portability by chaoskitty · · Score: 1

    It's simple. C is self hosting and extremely portable, and the amount of extra stuff needed to run C can be none (in the case of kernels, everything can come with the binary), little (shared libraries) or lots (a whole OS). There aren't many other languages which can self-host and can create binaries which can run on bare metal.

    Other supposedly portable languages like Java, Perl and PHP require an OS and environment to do anything, which makes them unsuitable for running on small embedded systems, for high performance applications, or for talking intimately to hardware.

    The languages also change too much over time. You can't just take old code and run it in a new interpreter. If Java wasn't in the hands of a megacompany, it MIGHT be more portable and less bug-ridden, but right now it's write once, run only in certain places, deal with a zillion security issues. Many companies I support have to keep around a VM or an older machine to run an older JVM because new Java is not compatible with old Java.

    C has changed, but not so much that K&R C is unrecognizable to someone learning C now. A program written in the 1970s can be compiled by a CS student today without much more than, perhaps, changing a few #includes. This is what makes it lasting and worth learning.

  103. Re:The third worst thing to happen computer histor by phantomfive · · Score: 1

    C is not intended to be a beautiful language.

    And yet, it is.

    --
    "First they came for the slanderers and i said nothing."
  104. Re:First post by LynnwoodRooster · · Score: 1

    Line 4 of your code fails to compile... Sigh...

    --
    Browsing at +1 - no ACs, I ignore their posts. So refreshing!
  105. I like C by Anonymous Coward · · Score: 0

    I think programming in C as a hobby is fun. Its just verbose, kinda like COBOL. I haven't seen too many job descriptions that mention C; the companies want .NET experience. Just saying.

    1. Re:I like C by Anonymous Coward · · Score: 0

      I like C too, but when I want cheap developers I go for something else like PHP (or if I want slightly better Java, or C#). When I want competence I hire some expensive C consultants, and choose one to make an offer to on the long term. I do not go to dice, that would be stupid.

  106. How relevant is the Linux kernel in 2014? by CaptainPhoton · · Score: 1

    The largest program I build each day is the Linux kernel.

    When I ask the question "How relevant is the Linux kernel in 2014?", the relevance of C becomes hard to question considering its 15 million lines or so. ;)

  107. C is like the Humble Brick by Martin+Spamer · · Score: 1

    It doesn't matter if you are building a house, a supermarket, a factory or a major civil engineering project you will needs some bricks.

    Building Software is the same

  108. C is for core software. by jellomizer · · Score: 1

    I am not implying that is what the C stands for.
    But C programs are best for what I consider to be Core Level software.

    Operating Systems, Compilers, Database engines, Web Servers...
    In general C is good for programs that needs to take the most out of your computer.

    However higher level langues should be used for those application where faster development time is more important then the products overall speed.

    Being that most business apps are just a form where people fill out and query a db. Those can be done in the PHP/Python/C++/Javas of the world. While the stuff handling the IO Calls should be done in C.

    Now back in the Mid 90's C was to be the the main programming language for any program. Due to the decline of Business Languages (Cobol, FoxPro, Delphi...) and the move to the PC which needed the extra speed to run on the slower Desktops.

    However now with most stuff being server based. It is cheaper to use a quicker to code, language with the cost of performance due to cheaper hardware prices vs expensive labor costs.

    --
    If something is so important that you feel the need to post it on the internet... It probably isn't that important.
  109. ObXKCD by sconeu · · Score: 1

    C-x M-c M-butterfly

    http://xkcd.com/378/

    --
    General Relativity: Space-time tells matter where to go; Matter tells space-time what shape to be.
  110. AC by Anonymous Coward · · Score: 0

    Are you still ignoring us?

  111. Re: First post by Anonymous Coward · · Score: 0

    Slashdot ate their less-than operator between i and 1000. Let's see if mobile can do this... <

  112. Test-Driven Development for Embedded C by Anonymous Coward · · Score: 0

    Test-Driven Development for Embedded C by James W. Grenning an absolutely essential read for anyone new to embedded c development. Or I guess you could call it IoT development if your are feeling like a cool kid.

  113. Still my second-favorite language. by DdJ · · Score: 1

    C is still my second-favorite language.

    It was my favorite from... around 1983 to 1989, at which time Objective-C became my favorite.

    (Apple is working towards destroying Objective-C, so my favorite may very well go back to C in a couple of years.)

  114. Unix is dead by DanielOom · · Score: 1

    Unix was proclaimed dead in 1990 by Byte Magazine. Windows is broken, Apple is rotten, Solaris has set, IBM AIX with age, HP-UX was fed to ducks, Excel has left Word that it is out of the Office, the Oracle is learning Delphi, but still there's quite a byte of C code running for president every day.

  115. Very, but not to everyone by Anonymous Coward · · Score: 0

    C is a COMPILED language that produces assembly code for the specific CPU being used when compiled. It is used in low level development. It is used in places where maximum performance in required such as other languages and operating systems. All other languages, except assembly language are at least initially implemented in C (++ or obj or Pascsal). Interpreted languages (PHP, PYTHON, Javascript) are not used for real OS'es. They are good to make demo Os'es. Unless a replacement low level language is developed, C (and family) will be used whenever there is a new OS or a new CPU or scarce resources are available or maximum performance is needed.

    Interpreted and other higher level languages are good for APPLICATION development.

  116. python by Anonymous Coward · · Score: 0

    >Python
    >block syntax
    Kill the blasphemer.
    It is relevant since there is no other low-level lango available and stable enough.
    Except C++, but it`s not that loved as C. And it shoots off your feet when you`re about to hurt a toe in C.

  117. Embedded by Anonymous Coward · · Score: 0

    It is the only language that I use for embedding programming when you only have 1k of ram.

  118. About c by fyngyrz · · Score: 2

    Here's the thing about c. If you're good enough to use it well (rare, I admit), the results can be made to be faster, more efficient, and more *clear*, meaning, you can actually see what's happening, while still remaining reasonably portable, than any other language. Even in the largest applications. Perhaps especially in the largest applications.

    Until someone comes with something faster, c is *the* goto language for high performance coding.

    As soon as you start sticking generalized objects in generalized boxes, as soon as you decide you can't manage your own memory, as soon as you decide you must have generalized abstraction (as opposed to specific, high-efficiency custom abstraction, boxes and objects), you're sacrificing performance, and you're probably sacrificing size and efficiency at the same time.

    If what you're writing is a word processor, well, so what. But if you're writing real time goodness, or something truly CPU bound (like almost any AI undertaking, or SDR, or speech recognition, or object recognition, etc.), not using c is a mistake. Not to mention a waste of the eventual end user's resources. Just because there are CPU cycles available doesn't mean that it's OK to chew them all up, likewise available RAM. Operating systems can do more than one thing -- if they're not choked to death by some lumbering, clumsily implemented hunk of crap.

    c is awesome. c is simple. But c is difficult, because you really have to know what you are doing. All that power at your fingertips means its 1000x easier to drive straight into a tree. You have to truly understand, on an intuitive level: stacks, memory management, objects, abstraction, how c statements likely map to CPU activity and instructions, and how to write clear code and documentation and a bunch of other stuff -- because it's up to you to manage all that stuff, and a failure in any of those areas is very likely to negate all the other advantages, or worse.

    The only thing better is assembler, where you can *really* be efficient and produce ultra-fast code. But assembler isn't portable, and that, sadly, is usually the end of that.

    --
    I've fallen off your lawn, and I can't get up.
  119. 1000x something, all right. by fyngyrz · · Score: 1

    Yep. c++ = larger executables; slower executables; less comprehensible code; less clear code (what is the CPU likely to be doing here? No bloody idea.)

    c is the bomb. c++ is just a bomb. A crutch. Anything you want to do in c++, you could have done in c, the primary difference being that as a c programmer, you would have -- had to have, in fact -- actually understood what it was you were doing.

    c++ is building kits from nasty little pre-molded pieces. c is carving your own pieces, where, if you like, every one can be a work of art and YOU control how they all fit together. You even get to make your own glue. :)

    Of course, if you can't carve, have an irrational phobia re glue, and can't design the pieces you need... well, time to drag the crutches out.

    --
    I've fallen off your lawn, and I can't get up.
    1. Re:1000x something, all right. by serviscope_minor · · Score: 1

      slower executables;

      Nope. std:sort is frequently faster than qsort.

      less comprehensible code

      Nope.

      std:vector a;
      a.push_back(1);

      so much more comprehensible than a cluserfuck of manual memory management.

      Anything you want to do in c++, you could have done in c, the primary difference being that as a c programmer, you would have -- had to have, in fact -- actually understood what it was you were doing.

      Now change C++ to C and C to ASM. Now change C to ASM and ASM to machine code. All it is is a lolz newbZ suck argument and it's crap.

      c++ is building kits from nasty little pre-molded pieces. c is carving your own pieces, where, if you like, every one can be a work of art and YOU control how they all fit together. You even get to make your own glue. :)

      You truly do not understand C++. You can do all that with C++, but there's no need to manage a variable length array AGAIN.

      Basically, C is a compiler. C++ is a programmable C compiler. I have never understood why C programmers have a phobia about programming the compiler. It's like you guys just love typing out the same stuff over and over again.

      Me? I like automation.

      --
      SJW n. One who posts facts.
    2. Re: 1000x something, all right. by Anonymous Coward · · Score: 0

      You only repeat stuff in C if you have an obsession with writing frameworks-- whete every thing that could be abstracted is abstracted. Good programmers know that worrying an application is the art of devising concise, specific data structures.

      If what you love about C++ are things like std::list, the STL, lambdas, unique_ptr, etc, then there are far better languages than C++. E.g. Java or Lua or Haskell or OCaml or Rust or....

      Ultimately, the only thing that C++ truly has going for it is popularity. But C is just as popular, yet it has several unmatched features: simplicity, portability, and interoperability.

  120. c++ roots by Anonymous Coward · · Score: 0

    through the years, I have heard the old c vs c++ arguments many times. c++ advocates all forget one inconvenient truth; c++ is not only a c derivative, but stroustrup's original implementations of c++ were PRE-PROCESSORS that read c++ code and generated c code.

    as with anything else, c is just a tool. when used appropriately, it is a great tool. in the hands of the wrong person, it becomes a danger.

    back in the days of PC-DOS I wrote quite a few TSR programs in c; i can't imagine writing a TSR in c++. given all the overhead involved, i am not sure it would have been possible to fit the resulting code in 64K!

  121. C will always be relevant by Codeyman · · Score: 1

    C is an abstraction of hardware concepts, and newer languages (even C++) tend to be abstraction of concepts from Comp Sci (object, function curries, comprehensions, templates etc etc). Someone has to bridge the two concepts. C++ succeeds as a language that supports both, but never been that big because most people either use it as C (and not use any features), use it poorly (because they don't understand how the various constructs work) on the hardware end. C has lesser concepts to worry about, but gives more rope to shoot you on the foot.
    E.g. simple statement like "if (string == "hello")" in C++ could mean that == is overloaded and if it accepts an object string, "hello" invokes the copy constructor for string object and passes it to the string object's == operator, which might do a char by char comparison, and then the unnamed object "hello" is destructed.
    You generally don't care about this for business logic or if your website is getting one hit every few seconds, but if you are getting a million hits per second, you need to start optimizing the way you do things, you'd need to know which of L1/L2/L3 caches you'll miss, what'll be the real impact of your code. C, without the fluff, gives you lesser things to worry about.
    C will be relevant because no other new language is trying to replace it.

  122. Agree by Lodragandraoidh · · Score: 1

    I agree.

    --

    Lodragan Draoidh
    The more you explain it, the more I don't understand it. - Mark Twain
  123. Very... by kefalonia · · Score: 1

    ...relevant... as in:
    "nearly each pixel of your screen while reading this is rendered via either C, C++ or something that is written or compiled in C and derivatives".

    That makes it sufficiently relevant, doesn't it?

  124. One reason so few jobs... by YVRGeek · · Score: 1

    are advertised seeking specifically 'C' is that a large portion of people who routinely program in C are not employed as programmers per se. It is the language (as many others here have pointed out) used to code for embedded systems and real-time control devices but these are generally programmed by Electrical Engineers or techs who are not listed on the company rolls as "programmer". In the math, physics and chemistry academic environments, guess how simulations and models are coded? Yep, in C (and yes, physicists and mathematicians programming on the CUDA platform largely use C too). FORTRAN is hardly ever used these days. Aside from my own experience, I have numerous friends who work as engineers, physicists, mathematicians - and even biologists - who regularly code in C. However, that's not their job function and most of them are, frankly, not great coders if you're looking at clarity and standardization of code. The EE's working on embedded sys stuff are probably the best of this lot because they realize that other people WILL have to read and work with their code.

  125. C is close to optimal by deepseabird · · Score: 1

    I'm not trolling here, I've spent way too many years using C++ to earn a crust and am an unpreposessing Scheme junkie too. The purpose of a language is to provide an automatic mapping from our "headspace" into something the computer understands. Complex semantics make this process more prone to overt errors and much more vulnerable to subtle errors that seem to work. Simple languages lay everything on the table, there is very little buried deeply in libraries. Really good code is usually "bespoke" code which someone has thought carefully about, not the result of putting a bunch of popular object classes into a code-supercollider. Good programmers can use C as safely as they can use C++, Java, Python or any of the other rising/risen stars; arguing that C provides little protection (using whatever metaphor you like) is just trolling: C isn't a language that you *expect* to protect you -- you take extra care with it. Pick the tools for the jobs -- there are a lot of jobs that need to be explicit, clear and easily checked: C beats the other popular imperative languages hands down here. Bet Ron Swanson codes in C (or assembler if he wants that "hand-tooled" feel).

  126. Performance. performance, performances by Anonymous Coward · · Score: 0

    Most often for high performance you don't even write the expensive bits in assembly.
    You take a look at the output of the C compiler, then modify your code so that the C compiler writes the assembly you want.

  127. Re: First post by jhoger · · Score: 1

    No it's an index not an offset. Unless you're talking about byte arrays.

  128. It's a Different World Down There by coverclock · · Score: 1

    I've been paid well to write tens or even hundreds of thousands of lines of code in C++ and Java. I've had reason to mess with Python and JavaScript and I enjoyed it. I keep wanting to get into languages like Haskell and Scala because they remind me of the research I did in graduate school thirty years ago on languages and operating systems for Fifth Generation architectures (yes, I _am_ that old). But you know what language has been the most profitable for me by far over my forty year career? C. Most of the work I do is either down close to bare metal (device drivers, kernel hacking, embedded systems), or else deep in software stacks in multimillion line code bases, and it's all in C, for better or worse. C is the structured assembly language we all wanted back when the microprocessor was first invented. There's this huge world of embedded systems, digital control, real-time, that is growing by leaps and bounds as everything we manufacturer has some kind of microcontroller or microprocessor in it, and the vast vast bulk of software built for those products is in C. I really, strongly, loudly encourage people to work as high on the abstraction ladder as they can, for two reasons: [1] it's a cost issue for the product development organization, and [2] the less other developers understand the low level stuff, the more money I'll make. I appreciate that the Eloi working on big servers, laptops, and even mobile devices, need to use as high a level language as possible. But down here among the Morlocks, it's a different world.

  129. as fuck by Anonymous Coward · · Score: 0

    C is relevant as fuck in 2014. /thread

  130. Re:First post by leslie.satenstein · · Score: 1

    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.

    I programmed in APL, a most wonderful language. For each function, you could specify the index origin to be used. ([]IO was set to 1 or 0, as you wished). You could be in the same function with index origin 0 and later with it set to one.

  131. Just thank god by romons · · Score: 1

    it isn't PL1

    --
    Go to Heaven for the climate, Hell for the company -- Mark Twain
  132. Re:I think of it all as the "C" family of language by Anonymous Coward · · Score: 0

    > OSX, a mix of C and Objective-C.

    Don't forget the I/O Kit which is written in Embedded C++

  133. C still commands a premium by Anonymous Coward · · Score: 0

    Posting as an anonymous coward to protect the guilty:

    I was meeting with the owner of a hedge fund a few weeks ago, and while reviewing a performance-sensitive part of their stack, I asked why it was in Java not C.

    The *owner of the hedge fund* said "C Programmers are Too Expensive for Me".

    Y'all go ahead and keep learning Ruby.

  134. And Perl is also still relevant for similar reason by Shivantrill · · Score: 1

    Teach your kids to drive manual transmissions, this will give them a better understanding of what is going on in their engine. Then they can drive nearly any car on the market and they will have more respect for their machines. Teach a programmer a compiled language like C, a scripting language like Perl and something with objects, C++ or Java come to mind. Then they can handle most languages except the really low ones, Assembly language. All they need to do is learn the syntax and apply what they have learned. C is still relevant and so is Perl even though I have been hearing for years that Perl is dying. The programmers graduating now lack much of the fundamental knowledge. They rely on their environment to do most of the syntax for them. They are not as good at debugging unless it is obvious and their tools spoon feed it to them. Many have never used a command line.

    --
    Karma, We don't need no stinkin' karma!
  135. C++ is just as light as C by Anonymous Coward · · Score: 0

    Creating drivers, firmware, kernels, and embedded applications using c++ will have external dependencies you will have to support those dependencies which will use up valuable space, C does not have this issue. Windows and Macs both have limited stdlib support of c++ at the kernel level, things like new and delete are not supported. There is a time and place for everything you just have to know what code is appropriate.

    That is not true. I wrote my own kernel in C++, it runs in x86_64 long mode, has a fairly powerful ATA 6 driver, mounts an EXT 2 partition, parses ELF32 headers, and starts a homemade shell in Ring 3 with proper protections and nice syscalls wrapped by a 200 LoC C89 userland library.

    The raw kernel.elf fits in 300kB, the Live CD with grub weight a bit under 7 MB, the running OS uses a total of 568kB of RAM.

    Things like new, new[], placement new and the equivalent deletes are not a problem at all, they are one line wrappers around malloc and free. Defining those takes a grand total of 16 lines of code, and it translates to a whopping ~24 bytes of machine code... Still too much for you ? You don't even have to use those if you don't want to. I know I want them.
    There are obviously no external dependencies, C++ can be freestanding without problem. I use no exceptions, no RTTI, no global static constructors (since there are no startfiles (but you can cheat anyway)), and no STL in Ring0 without rewriting it yourself, everything else's fair game.

    Please, do a bit of research. C is not always the right answer just because you work on low level problems or constrained platforms.

  136. Re:90+% of C++ deva are really writing lazy man's by Anonymous Coward · · Score: 0

    >they occasionally use an object and want to be lazy and declare their local variables at any random moment Looks like you haven't got that memo a couples degades ago about keeping things in the innermost possible scope.
    Function globals and file globals are so much better, amirite ?