Slashdot Mirror


A New C Standard Is On the Way

Esther Schindler writes "Last year, Danny Kalev — a former member of the C++ standards committed — explained the new features in C++. Now, in C11: A New C Standard Aiming at Safer Programming, he shares an overview of the changes in C — 13 years after the ratification of the C99 standard. Kalev describes the goodies in C11, including multi-threading support, safer standard libraries, and better compliance with other industry standards."

82 of 305 comments (clear)

  1. Hmm by mholve · · Score: 2, Funny

    No wonder they're not popular. C99? C11? It should be "C... X!" :p

    1. Re:Hmm by K.+S.+Kyosuke · · Score: 2

      The only thing we know for sure is that the ultimate version will be C42. Also, C14 will be rather popular but all implementations will generate binaries that will randomly fail, and will trip off airport security systems if you have them in you mobile devices with you.

      --
      Ezekiel 23:20
    2. Re:Hmm by cpghost · · Score: 2

      The only thing we know for sure is that the ultimate version will be C42.

      But by then, we'd have lost the hardware to that software answer (unless someone still has a C64 in the attic)

      --
      cpghost at Cordula's Web.
  2. On the way? by TheRaven64 · · Score: 5, Informative

    It's not on the way, it was released last year. Both gcc and clang are already a good way along implementing it, and we've added a big chunk of the library support to FreeBSD libc already.

    --
    I am TheRaven on Soylent News
    1. Re:On the way? by Anonymous Coward · · Score: 2, Funny

      It's not on the way, it was released last year.

      C'mon, this is /. -- it's either a dupe or it's old news.

    2. Re:On the way? by Tough+Love · · Score: 5, Funny

      The "11" actually refers to how far you can turn up the volume.[1]

      [1] Quoted from Tough Love's Album of Unreliable Facts (c)

      --
      When all you have is a hammer, every problem starts to look like a thumb.
    3. Re:On the way? by shutdown+-p+now · · Score: 5, Insightful

      This being C, 11 would mean that you can turn the volume from 0 all the way up to 10.

    4. Re:On the way? by Bacon+Bits · · Score: 5, Funny

      No, you can turn the volume up as high as you want, but it's only defined for 0 to 10.

      --
      The road to tyranny has always been paved with claims of necessity.
    5. Re:On the way? by bug1 · · Score: 2

      Y3k bug strikes again, he meant C3011

  3. C11???? by highphilosopher · · Score: 5, Funny

    That's great! I'm still using C4, and every time I compile my code blows up!

    1. Re:C11???? by jd · · Score: 2

      I hear C5 was dog-slow and users suffered humiliation.

      --
      It's a small world and it smells funny; I'd buy another if it wasn't for the money; Take back what I paid (SoM)
    2. Re:C11???? by Anonymous Coward · · Score: 5, Funny

      Plus, as using C-14, I am able to determine the compiling date of any given code.

    3. Re:C11???? by GoodNewsJimDotCom · · Score: 4, Funny

      I am still using the programming language made a long time ago C3PO. You'd be surprised how similar it is to Jawa.

    4. Re:C11???? by idontgno · · Score: 3, Funny

      It's really only useful for controlling 'vaporators and binary loadlifters.

      --
      Welcome to the Panopticon. Used to be a prison, now it's your home.
    5. Re:C11???? by Anonymous Coward · · Score: 2, Funny

      I've been using CB. All functions are called by the new "breaker.breaker" operator--and don't even get me started on the crazyvariable names you have to use...

    6. Re:C11???? by Imagix · · Score: 3, Informative

      Uh, why C02 when is was standardized in 2011? The headline is simply wrong. C11 isn't "On the way". It's already here, and has been here for > 5 months. You _might_ have an argument for C0B. (Long-running joke. C++0x was the next C++ standard, and there was a joke that they hoped that the x wasn't going to be a hex digit....)

    7. Re:C11???? by Sduic · · Score: 5, Funny

      The worst part was the C4 standard was prepared with SemTeX.

      --
      *this space intentionally left blank
      "One of the four pointers saying 'come and see', and I saw, and beheld a white
    8. Re:C11???? by Alex+Belits · · Score: 2

      --insert ~ath comments here--

      not thii2 2hiit...

      --
      Contrary to the popular belief, there indeed is no God.
    9. Re:C11???? by dintech · · Score: 5, Funny

      Since I'm using C64, I find I have to be careful with my memory usage.

    10. Re:C11???? by 228e2 · · Score: 2

      You. Get out.

      --
      Since when does being a Socialist mean 'someone who has a different opinion than me'?
  4. Drops the most important feature of C99 by Anonymous Coward · · Score: 5, Interesting

    C11 will make var arrays, one of the most widely used C99 features, optional due to pressure from Microsoft, who refuses to implement C99.

    1. Re:Drops the most important feature of C99 by Tough+Love · · Score: 3, Funny

      Last I checked, VC++ team has plainly stated that they are simply not interested in working on vanilla C, so why would they care about what is and isn't in C11?

      Given that Microsoft's implementation of C++11 also sucks, exactly what is the VC++ team interested in working on?

      --
      When all you have is a hammer, every problem starts to look like a thumb.
    2. Re:Drops the most important feature of C99 by Anonymous Coward · · Score: 3, Interesting

      Which is ironic, because Microsoft's Visual Studio team has stated they have no intention of supporting anything newer than C95. I don't understand why Microsoft is even allowed representation on the ISO committee.

      And the bounds-checking API which Microsoft "contributed" is useless. It's clunky, and requires more boilerplate coding than just using the standard interfaces with proper bounds checking. Plus they added a completely new errno_t typedef, which will probably breaks tons of existing code. Not to mention that not even Microsoft supports the API. The Win32 precursor to Annex K is incomplete and inconsistent. In other words, Annex K is dead in the water. Microsoft won't support it, and the BSD and GNU libc take completely different approaches.

    3. Re:Drops the most important feature of C99 by shutdown+-p+now · · Score: 3, Informative

      For VS 2010, C++11 (then 0x) implementation was actually better than g++. It looks dated today because g++ has more frequent releases and it didn't take it long to catch up and overtake. Ditto for Clang.

      For VS 2012, yeah, it's lagging behind, mostly because a lot of time was spent on C++/CX language extensions for Metro. They did update existing features to be spec conforming - e.g. lambdas were previously implementing draft semantics which have changed in the FCD, so those were updated to match the latter. It also adds a bunch of minor stuff like range-for and strongly typed enums, and a good chunk of new libraries (most notably atomics, threads and futures). Here are the details.

      There is talk about doing a separate release later on specifically for VC++ to catch up with C++11 support. If you care about that, rather than just seeing it as an opportunity for some MS bashing, please add your vote here (I did).

    4. Re:Drops the most important feature of C99 by Anonymous Coward · · Score: 2, Interesting

      Clang only ever looked dated compared to VC++ because the damn thing wasn't even finished yet. I doubt VC++ will ever catch up again with it, though. Clang in a relatively short time managed to go from barely able to compile C++03 to possibly the most complete implementation of C++11.

    5. Re:Drops the most important feature of C99 by Anonymous Coward · · Score: 2, Informative

      If by "short time" you mean 5 to 6 years, okay. It was open sourced in 2007, but had been in development at Apple for longer than that.

    6. Re:Drops the most important feature of C99 by jonwil · · Score: 2

      Having followed C++11 support in compilers, I can tell you that the C++11 support in even the latest version of Visual C++ (Visual C++ 2012 RC) is lagging behind both GCC and clang. To be fair, a lot of the lag is caused because Microsoft spent a lot of their resources in the VS2012 development cycle attempting to implement Variadic Templates (and not getting it done in time for the VS2012 release)

  5. Re:D? by chinton · · Score: 2

    No, it's finally P.

  6. Integer overflow! by Montreal · · Score: 5, Funny

    C99 -> C11, come on guys ...

    1. Re:Integer overflow! by Tanktalus · · Score: 2

      It should at least have been C111

  7. Re:Slow Adoption of Current Standards by JustNiz · · Score: 4, Informative

    Blame Microsoft, not the standards committee.
    GCC had it ahead of time.

  8. Re: by bleedingsamurai · · Score: 2

    The multi-threaded stuff sounds nice. But bounds checking, really? How difficult is it to check buffer size before copying?

  9. Jeezus christ by JustNiz · · Score: 5, Funny

    If I wanted plastic scissors I'd use Java. Give me my scalpel back.

    1. Re:Jeezus christ by arkane1234 · · Score: 4, Funny

      Too many people have been randomly slicing people.

      --
      -- This space for lease, low setup fee, inquire within!
  10. I don't get it... by xor.pt · · Score: 2, Insightful

    Why didn't they include some simple OOP features aswell? I understand this is a language for low level programming, and needs to be close to the metal, but many OOP features don't carry any significant overhead, and could just be avoided anyway.

    1. Re:I don't get it... by bleedingsamurai · · Score: 2

      If you want OOP and C go with C++ instead.
      C is supposed to be a high level assembly language, so simplicity and brevity are key.

      I find that Objective-C is pretty nice to. It is a very strict super-set of C that adds some OOP functionality and is no where near as complex as C++, in fact it is just a library or two sitting on top of a C compiler to interpret the OOP syntax. It is a shame that it is so tightly bound to Apple products.

    2. Re:I don't get it... by jd · · Score: 4, Insightful

      Because C is an ultra-clean procedural language. The entire purpose of using it is the purity. C with OOP can be found in ObjectiveC, C++, C# and D.

      --
      It's a small world and it smells funny; I'd buy another if it wasn't for the money; Take back what I paid (SoM)
    3. Re:I don't get it... by bleedingsamurai · · Score: 2

      I see.
      Well, as far as a little OOP in C goes, what I have done is to create structures with whatever member data I need, and within those structures I place function pointers to emulate methods.
      If you see yourself doing a lot of that you can create functions that return pointers to your makeshift structure-class.
      Obviously you don't really get any advanced OOP stuff, but you can get simple inheritance using this method and a whole lot of encapsulation. If I'm not mistaken I think that C-family languages that support OOP actually do something like this behind the scenes.

      I guess I wouldn't mind a smidgen of OOP in C as long as they implement it through a library and not directly into the core language.

    4. Re:I don't get it... by shutdown+-p+now · · Score: 2

      You don't have to use all the features the language offers to you, you know. It is absolutely possible to use C++ as "C with some objects".

    5. Re:I don't get it... by PCM2 · · Score: 2

      No, I don't think "the usefulness of potential features" should be considered, if you're talking about something like bolting object orientation onto C. As other people have said, that has already been done, several times. If you want object-oriented C, use C++ or Objective-C. If you want to go even further that direction, use C# or even Java. The difference between an object oriented language and a structured procedural language like C is significant. Or maybe you could explain a little more what you mean by "some OOP." You seem to be arguing that C gives you nothing but C++ gives you too much -- but complaining that a language gives you too much of exactly what you're asking for is a pretty confusing way to make your case.

      --
      Breakfast served all day!
    6. Re:I don't get it... by Tough+Love · · Score: 2

      Because C is an ultra-clean procedural language.

      Haha, ultra-clean is not a term I would apply to either C or its demon child C++. Speaking as someone who has written hundreds of thousands of lines of both.

      --
      When all you have is a hammer, every problem starts to look like a thumb.
    7. Re:I don't get it... by bleedingsamurai · · Score: 2

      It actually predates NeXT as well. XD It was developed by the founders of a company called Stepstone who originally licenced it to the NeXT company, then NeXT bought the rights to Objective-C and then Apple bought NeXT.

    8. Re:I don't get it... by fnj · · Score: 2

      So why don't you just use C++ then in the first place? No, I'm absolutely serious. You can basically take your existing C code and compile it with a C++ compiler in C++ mode, and with a very few exceptions it will compile and work just fine. Then you can start adding just those C++ features you want; no back-porting to C necessary.

      I mean, that was the WHOLE IDEA of C++ right from the beginning. There's nothing that says you need to use a single class in C++.

    9. Re:I don't get it... by cheesybagel · · Score: 2

      One issue is that the world is not a VAX anymore. Assembly language constructs can be way more complex than a lot of C statements. e.g. standard C has no concept of vector instructions.

    10. Re:I don't get it... by jd · · Score: 3, Interesting

      I used Ada some time back. It's a nice object-based language (not OO, object-based) but its strictness could sometimes be infuriating. Good, but infuriating.

      I wouldn't want C to go in the direction of Ada - yes, the safety of C needs improving, but I regard C as being increasingly a universal starting point, a theoretical third-generation language rather than an actual one. There are now many dialects of C and many spin-off languages, some using that starting point better than others. It's a bit like the Cambrian Explosion, only the offshoots can still borrow from the central stem.

      Ada, however, is highly architectured, like Occam. Architectured languages are intended for very specific purposes and fulfill those purposes extremely well. Well, when they've been architectured correctly, that is. They've traded in the theoretical base point and the benefits of evolution for the benefits of being highly predictable and highly dependable within their niches. A well-written Ada program has levels of assurance on reliability that no C program could have -- or ever should have, because to have that level of assurance would kill off the very thing that makes C so powerful, which is the rate at which it evolves and de-standardizes. (Destandardization means you can exploit and assimilate new ideas faster. C is The Borg.)

      --
      It's a small world and it smells funny; I'd buy another if it wasn't for the money; Take back what I paid (SoM)
    11. Re:I don't get it... by Ungrounded+Lightning · · Score: 2

      Objective C, like Smalltalk, has an issue with construction and destruction: Overridden methods use the sub/derived version if called during the execution of the super/base class constructor. This means writing a sub/derived class has the potential to break the already-debugged super/base class constructruction, which must be rechecked for every sub/derived class.

      C++ gets this ALMOST exactly right: Base class constructors get the base class version, derived class constructors get the derived class version. Iterate down the entire hierarchy. Equivalently with DEstructors as the successive levels are torn down.

      I say ALMOST because the spec, and most compilers have what IMHO is a bug: During construction and destruction of member objects, if the member object constructor or destructor (or something it uses) gets hold of a pointer to the containing object and calls an overridden method it SHOULD get the base class version. (On construction the support for the derived class version is not initialized. On destruction it's already torn down.) But whether it actually gets the base or derived version is problematic.

      If you take the binary combination of what the constructor and destructor get there are three "wrong" and one "right" combinations. In the early days cfront and cfront-derived compilers got it "wrong" one way, three compilers for PCs got it "wrong" another way, and gcc got it "wrong" the third way. So if (as I asked them on each of the first two standards efforts) they had specified using the "right" behavior, everybody would have had to make a minor change and nobody would have had an advantage.

      The first ANSI standard explicitly left this undefined and the second said essentially "don't write code that lets this happen". B-b (I haven't really looked at the recent update to see what it says.)

      This was important to the project I was working on back then: We had rolled our own garbage-collection and exception-handling systems, using preprocessor-defined overridden virtual function bodies to track the level of construction. (Catch and throw were still just reserved words and the politically correct way to handle heap management was with user-written explicit allocation and deallocation.) With this "bug" we couldn't count on correctly handling an exception thrown or garbage-collection triggered by a member object constructor or destructor. So we couldn't use them. Instead of building compact composite heap-allocated objects we had to use smartpointers, separately heap-allocate the "contained" objects, and knit together a cluster of separate objects, Smalltalk-style. B-b

      --
      Bantam Dominique roosters crow a four-note song. Once you've heard it as "Happy BIRTHday" you can't NOT hear it that way
    12. Re:I don't get it... by Raenex · · Score: 3, Informative

      It is a third-generation language with no features taken from the first, second, fourth or fifth generations.

      You're way overstating the case for C as some theoretically pure language. It's been tagged as a "high level assembler" for a reason, in that the underlying machine bleeds through (the second generation) much more than in other "third generation" languages.

      C is just a language that happened to take off. It isn't pure in any sense of the word. It's got half-assed "modules" based on crude file inclusion. Its mix of pointers, arrays, and integer types is baroque. It's got the beginnings of inheritance with its unions. It's structural but supports goto and setjmp/longjmp. This list is by no means exhaustive.

      It's also extremely dubious to say that object-oriented doesn't belong in the third generation of languages. Simula 67 was the first -- that's 1967, predating C. Also, Cobol, Lisp, and Fortran were third generation languages, all with distinct forms.

  11. Re:Missing features by AuMatar · · Score: 5, Informative

    C runs on way too many devices without floating point support to add those as standard libraries. It wouldn't be useful on many platforms.

    And C isn't about adding every feature in the world. The language itself is pretty much done. They're just changing libraries. They'll never add a major feature like closures, nor should they. If you want them, use another language when they're designed in well, not hacked on.

    --
    I still have more fans than freaks. WTF is wrong with you people?
  12. Re:Slow Adoption of Current Standards by Anonymous Coward · · Score: 5, Informative

    Visual Studio added stdint.h not to comply with C, but to comply with the pending new C++ standard. Microsoft has publicly declared that they have no intention of supporting anything past C95 (basically ANSI C circa 1989 with a few tweaks).

    So some of the coolest things in C99 and C11, like named initializers, compound literals, etc, will never be in Visual Studio, because C++ has refused to adopt those features from C.

  13. Re: by hawguy · · Score: 4, Insightful

    The multi-threaded stuff sounds nice. But bounds checking, really? How difficult is it to check buffer size before copying?

    Given the number of buffer overflow bugs that are found in C programs, apparently it's fairly difficult to do it consistently and correctly.

  14. Who needs threads? by spaceyhackerlady · · Score: 3, Insightful

    I've never been a fan of putting multi-threading/multi-tasking in a programming language. You get one abstraction of threads/tasks, and that's it. If you want to do it differently, you have to do it yourself with library calls. So why not leave it that way and keep the language simple?

    Unless there is an awfully good reason not to (and I haven't encountered one yet), I use pthreads.

    ...laura

    1. Re:Who needs threads? by moogla · · Score: 2

      They standardized the naming convention of thread primitives for C11-compliant compilers and C-libraries. The system can still use posix threads under the hood, but now there is a intended to be forward compatible that you can leverage.

      You will still be able to use one or the other. In some implementations you may be able to leverage both facilities (like using _Thread_local storage qualifiers in code that otherwise uses posix threads).

      --
      Black holes are where the Matrix raised SIGFPE
    2. Re:Who needs threads? by Jerslan · · Score: 2

      Yeah, but you really should try to code for a single standard... Mixing them because one or even most implementations support it is bad juju IMHO.

      GCC and Clang/LLVM may support using _Thread_local with a pthread, but some other compiler you may need to use (for some strange reason) might not and then you would need to do a lot of work to get things going with that compiler.

      It's a pet peeve of mine when I see a lot of mixed standards... If you're going to use pthread, use pthread. Don't try to mix it with something else just because you think you can (or your compiler lets you). Even if the new threads.h is just an abstraction layer on top of pthreads, it's best to stick to the threads.h method calls if you go that route. Mixing calls can sometimes lead to unexpected results.

    3. Re:Who needs threads? by Mr+Thinly+Sliced · · Score: 5, Informative

      IIRC it's because without putting explicit constraints on the memory model (needed for threading), you end up with holes of varying sizes when talking to memory from threads.

      It's mostly to do with CPU caching / memory barriers and having a consistent temporal view of data in and out.

      If it's not in the language, you end up with each platform/compiler having their own approach to barriers / atomics which makes glueing different bits of code together with different approaches a crap shoot when it comes to consistency.

      Here's a good place to start

  15. Re:Slow Adoption of Current Standards by shutdown+-p+now · · Score: 5, Informative

    Visual Studio is explicitly a C++ implementation, and does not focus on C support. It has what effectively amounts to C89 support, but that's a legacy thing. Any support for C99 and C11 features is purely accidental, and usually happens when some header is required by both C99/C11 and C++11 (hence why it's just headers and never language features).

    In the meantime, other implementations, which actually care about C as well and C++ - like gcc or clang - add C11 support fairly quick.

  16. Adds Rock music support by PaddyM · · Score: 2

    cause this language goes to 11
    *puts on sunglasses*

  17. Re:Slow Adoption of Current Standards by Anonymous Coward · · Score: 2, Informative

    I feel your pain on this, but MS has said time and again that they don't bother with the C standard because they make a C++ compiler, not a C compiler. So they only bother complying with C++98/03 and C++11. Any C99 compliance we get is essentially just due to the shared standards that C99 has with C++11. This isn't to say I excuse this decision, just a little insight as to why it took so long to get stdint.h.

  18. Re:Missing features by shutdown+-p+now · · Score: 2

    C runs on way too many devices without floating point support to add those as standard libraries. It wouldn't be useful on many platforms.

    Well, it already has all common math operations on floating point numbers as part of the standard language/library. Quite obviously, any vector operation can be implemented as a simple loop over the elements invoking the corresponding (already standard) scalar operation. Making them better optimized would then be a quality of implementation issue. Making this standard would mean that people could write portable code that works faster on compilers with special support for it, but still works correctly (and no slower than corresponding code with explicit loops) everywhere else.

    It doesn't even require any new language features, just libraries. Just add float4 etc as structs, and define standard library functions for all operations including arithmetic. Let compilers implement them as intrinsics where that makes sense.

    Maybe it doesn't make sense as part of the core standard, but it would make for a good TR.

  19. Re: by bleedingsamurai · · Score: 2, Insightful

    Are you suggesting it is possible to create a program that doesn't involve buffers?
    Even the simplest Hello World program uses buffers. Even fancy languages that have run-times and virtual machines use buffers. Buffers are an integral part of designing software because they are an integral part of how the machine works at the hardware level.

  20. Re: by turbidostato · · Score: 4, Insightful

    "I blame the programmers not the language."

    Good! Now you have to change the language once or blame the programmers forever (since you shouldn't expect to change them anytime soon).

  21. Bullshit by Tough+Love · · Score: 3, Insightful

    Where did C99 go awry? Some of its mandatory features proved difficult to implement in some platforms. Other C99 features were considered questionable or experimental, to such an extent that certain vendors even advised C programmers to replace C with C++.

    Speak for yourself Microsoft. It is not our fault that you can't implement C99 features properly or on time. For the rest of us C99 is alive, well and popular. Just avoid Microsoft's shoddy compiler and you will be fine. Both GCC and LLVM do the job properly.

    By the way, similar comments apply to Microsoft's tardy and dodgy implementation of C++11.

    --
    When all you have is a hammer, every problem starts to look like a thumb.
  22. Re:Missing features by tepples · · Score: 2

    Quite obviously, any vector operation can be implemented as a simple loop over the elements invoking the corresponding (already standard) scalar operation. Making them better optimized would then be a quality of implementation issue. Making this standard would mean that people could write portable code that works faster on compilers with special support for it, but still works correctly (and no slower than corresponding code with explicit loops) everywhere else.

    I believe the idea was that restrict pointers would help the compiler discover where it can transform existing code to use vectors.

  23. Re:Missing features by shutdown+-p+now · · Score: 3, Informative

    Restrict is to help the compiler discover when it can assume the lack of aliasing, and therefore aggressively prefetch and cache values. This is especially so when combined with static size array arguments (as in int[static 4]), which by definition cannot be null, permitting compiler to fetch without any checks. I guess it can also be used to improve parallelization by letting the compiler assume lack of dependencies between reads and writes where otherwise it would have to assume they exist, but that's not quite the same as vectorization.

    I know some compilers can do auto-vectorization on loops over arrays - notably Intel - but this is still too limited to be portable. Most implementations require you to use the (implementation-defined) intrinsics to do the same, which to me strongly indicates that this is the way this should be standardized. Also, writing such loops explicitly every time is unnecessarily verbose.

  24. Re: by JustNiz · · Score: 2

    I'm not sure how you think printf"(hello world\n"); uses any dynamic (i.e. user-created/maintained )memory but never mind thats not my point here.

    What I am saying is that you write your code such that once you created a buffer, your program knows its length and is written in such a way that it isn't possible to crash it.

    For example, only use bounded functions like strncpy() rather than unbounded ones like strcpy().

  25. OOP sucks by Weezul · · Score: 2, Informative

    What features do you want?

    Automatic memory management? Isn't this what makes C++ so fucking insanely complex? Bad idea.

    Overloading? Umm, that's extremely dangerous in subtle complex code like operating system schedulers, computational code, etc. Very bad idea.

    Inheritance? Nah. Almost as bad as overloading, but also useless for most most activities.

    Templates? No, they're even worse than overloading. I suppose Java interfaces or Haskell typeclass could provide a safe form of overloading. I certainly acknowledge the desire to parameterize a struct on another type, but that's extremely complex for a low level language.

    Lambda expressions, ala C++0x? Interesting proposal, not exactly sure how the memory management works out, but perhaps one could grant the compiler the ability to build closures in this way, but subject to the programer's memory management.

    Yes, I'll grant that lambda expressions make sense, but not C++0x's lambda expressions, since they impose a memory management scheme. In essence, lambda expressions in C should be just-in-time optimizations that the programer controls manually.

    In truth, most object oriented language 'features' are actually bad design choices, well unless your doing GUI work where the error object oriented programming creates aren't catastrophic.

    Yes, there are vaguely functional features like parametric polymorphism and lambda expressions that might aid low-level programming, but they're complex enough to require a proof-of-concept language first. C must avoid the mad dash into standardization that created C++'s complexity.

    --
    The Christian religion has been and still is the principal enemy of moral progress in the world. -- Bertrand Russell
    1. Re:OOP sucks by jgrahn · · Score: 2

      What features do you want?

      Automatic memory management? Isn't this what makes C++ so fucking insanely complex?

      No. Have you ever used C++?

    2. Re:OOP sucks by serviscope_minor · · Score: 3, Informative

      Automatic memory management? Isn't this what makes C++ so fucking insanely complex? Bad idea.

      You're doing it wrong, frankly.

      If your programs are full of new/deletes in mismatched pairs, then you're missing out on much of the point of C++.

      Overloading? Umm, that's extremely dangerous in subtle complex code like operating system schedulers, computational code, etc. Very bad idea.

      WTF? I write computational code for a living. Good numerics libraries full of operator overloading make my code much, much more simple, reliable and correct. So, I'll stick with overloading thankyouverymuch.

      Inheritance? Nah. Almost as bad as overloading, but also useless for most most activities.

      I've honestly no idea what you're talking about. Classic OOP inmheritance has its uses, and it's used throughout the Linux kernel for instance (see e.g. vtables). C++ just adds compiler support. Other inheritance is just aggregation of data which is an entirely reasonable thing to do.

        Templates? No, they're even worse than overloading. I suppose Java interfaces or Haskell typeclass could provide a safe form of overloading. I certainly acknowledge the desire to parameterize a struct on another type, but that's extremely complex for a low level language.

      Templates are what makes sane numerics libraries great, and container libraries. In fact you've just admitted that they're useful, but for some reason, you don't want expressivity in your low level language. Also, C++ allows parameterization on an int, as well as a type, which is an especially powerful featureand is missing from almost all other generics systems.

      Lambda expressions, ala C++0x? Interesting proposal, not exactly sure how the memory management works out, but perhaps one could grant the compiler the ability to build closures in this way, but subject to the programer's memory management.

      You tell the compiler whether you want the closure to capture by reference or by making a copy of the data. In the former case, the memory in managed in exactly the same way as normal (via destructors) in the referenced variables. In the latter case, the lambda justs acts like a class with a bunch of data members and calls the destructors when it goes out of scope.

      Yes, I'll grant that lambda expressions make sense, but not C++0x's lambda expressions, since they impose a memory management scheme. In essence, lambda expressions in C should be just-in-time optimizations that the programer controls manually.

      I don't think you understnd lambdas. A lambda is a shorthand for making a struct with a bunch of data members and an overloaded operator(). That is all. It interacts with the language in exactly the same way as all other structs.

      In truth, most object oriented language 'features' are actually bad design choices, well unless your doing GUI work where the error object oriented programming creates aren't catastrophic.

      Now we have a kernel of truth which doesn't apply to C++. Yes, OO concepts are somewhat limited in scope. They are useful for some things, but not for others. People have widely abused them to apply to everything either by choice or because languages often provide few other mechanisms. C++ does provide those other mechanisms and doesn't force you to make make everything a massive ovject heirachy.

      Apart from in a small number of libraries I use, I make very little use of classic OO concepts like polymorphism etc. I use classes and methods, but as an encapsulation and occasionally aggregation mechanism. That's a far cry from classic OO, though.

      Yes, there are vaguely functional features like parametric polymorphism and lambda expressions that might aid low-level programming, but they're complex enough to require a proof-of-concept language first. C must avoid the mad dash into standardization that created C++'s complexity.

      lolwut? C++ a mad dash in t standardisation? Good troll, sir.

      --
      SJW n. One who posts facts.
  26. Re:multithreading is too little, too late by tyrione · · Score: 2

    I suppose you're not into OpenCL, right?

  27. Re:D? by Anonymous Coward · · Score: 3, Informative

    no -- C was based on B, which was based on BCPL. So first came BCPL, then B, then C, therefore the next one will be P.

  28. Re:Really who does this crap by spitzak · · Score: 2

    Oddly enough all the _s crap seems to be driven by Microsoft. They proposed them, then modified their compiler to complain if you did not use them and instead used strcpy, etc. This includes functions such as snprintf which are *identical* to the _s versions, and a "safe" version of fopen that only checks if the FILE* argument is non-null (WtF?). For some reason no WIN32 api that could overflow buffers got a "_s" version and there was no warning for using them! The purpose appeared to be to piss off programmers and perhaps to discourage writing of portable software (though the warning was easily turned off).

    As you point out, there have been a million replacements for gets. The original K&R book had getline() which took the buffer length and was safe. All of them had more intelligent names and more useful behavior on overflow than gets_s.

    For strings there has been strlcpy and strlcat for years. Though the refusal to adopt these show the Glib maintainers have equaled Microsoft in their ability to be asses.

  29. Bah, Humbug! by RKBA · · Score: 3, Funny

    Anything but the pure C as defined in the sacred Whitebook pollutes the simple beauty of C and obscures the language's clarity and its similarity to the instruction sets of most common CPUs.

  30. Re:Slow Adoption of Current Standards by Ungrounded+Lightning · · Score: 4, Insightful

    Microsoft has publicly declared that they have no intention of supporting anything past C95

    I gave up on Microsoft back when Byte magazine was in, or recently beyond, single-digit issue numbers.

    A letter to the editor complained about Microsoft's support of their FORTRAN compiler: There was a bug in the floating point format handling that a customer needed to use. After several iterations of bug reports and fix requests, Microsoft had told the guy that not only had they not fixed it yet, but they were never going to fix it. IMHO that meant Microsoft had an institutional issue with customer support and adherence to standards.

    Avoiding Microsoft software and products has saved me immeasurable grief over the several decades since.

    --
    Bantam Dominique roosters crow a four-note song. Once you've heard it as "Happy BIRTHday" you can't NOT hear it that way
  31. Re:D? by stderr_dk · · Score: 2

    No, it's finally P.

    Is that the same as NP?

    --
    alias sudo="echo make it yourself #" ; # https://pipedot.org/~stderr & http://soylentnews.org/~stderr
  32. Re:Slow Adoption of Current Standards by makomk · · Score: 2

    Of course, the "safer" C library string functions are already supported by Visual Studio because they're part of Microsoft's cargo-cult approach to security. You know, the one where they're so busy making everyone rewrite all their existing code to new APIs that they don't think about little details like whether it's a good idea to hand out Microsoft certificates which have code-signing permissions for no real reason and can be used to sign fake Windows updates to anyone and everyone. And where they don't bother to upgrade the signing process for those certificates to something better than MD5.

  33. Re:Slow Adoption of Current Standards by serviscope_minor · · Score: 5, Interesting

    Yes, I totally think we should rewrite the linux kernel in C++

    I don't know if you're trolling, but I agree, it is the logical thing to do.

    Linux has many, many C++ features implemented in an ad-hoc and poorly specified way in C.

    It is very heavy on OO style with derived classes and virtual functions.

    TRhe C style objects are complex and require init and cleanup functions to be called.

    They have imlemented type-generic macros in order to reduce code duplication effectively.

    Basically, C++ takes those three things and integrates them into the language in a standard way so that everyone uses them in the same way, you get sane error messages and compiler support. C++ has one additionmal advantage that it has one global vtable per class, so each instance has a single pointer to the vtable. Linux's C-style OO has each instance having a pointer to every virtual method otherwise the syntax would be too unpleasant. This makes it less memory efficient in C and increaces the cache footprint.

    The only thing worse about C++ would be that the compile times would be increased.

    But that's a tiny price to pay for fewer bugs and faster code.

    --
    SJW n. One who posts facts.
  34. Re:Missing features by serviscope_minor · · Score: 3, Interesting

    gcc is pretty good at vectorisation, provided it can prove a lack of aliasing (which is very, very hard).

    If you make heavy use of statically sized C-style arrays allocated on the stack, proving a lack of aliasing is much easier, and gcc generates vectorised code pretty well.

    What gcc can't do is specially tag pointers allocated from malloc() as somehow similar to stack allocated arrays and assume that they don't alias in the same way. I think thbe intel compiler is much better at that, which is where many of the gains come from.

    GCC is getting better however. In some cases it can prove that malloc()/free() pairs haven't achieved anything and elides them entirely. However the functionality seems pretty new and incomplete and ti doesn't work with new/delete yet.

    --
    SJW n. One who posts facts.
  35. The road to hell is paved by arth1 · · Score: 2

    I blame the programmers not the language.

    I blame the program architects. C isn't the right choice if you want strong typing, bounds checking, auto-alignment, the concept of finite arrays and all the other safety nets.
    C is the right task for some jobs precisely because it doesn't have these features. And the wrong task for many jobs for the same reason.
    Adding features like this reduces C, by making it more like other languages that already are better suited for the job.

    Use C if you can handle all (and I mean all) checking yourself, be it through specs or by adding checks. Otherwise, choose a different language, don't try to transform C into something you want.

    Unfortunately, this fight seems to already have been lost - some of it with C99, and more with C11. So what's a good alternative low level cross-platform language that gives you as much rope as you could possibly want?

  36. Re:Still needed: integral support for SIMD by jeremyp · · Score: 2

    At its core, C is designed to be a sort of portable assembly language.

    No, it was designed as a replacement for assembly language. There's a difference.

    Most of its original features were intended to map directly to PDP-11 opcodes

    This is a myth. Most of C's original features are inherited or evolved from its predecessor languages.

    http://cm.bell-labs.com/who/dmr/chist.html

    Unfortunately, it hasn't really kept up with the improvements in modern instruction sets.

    C has never had any direct support for the instructions of any particular machine architecture. In this, of course, it is in good company with virtually every other non assembly language because, not being assembler, you wouldn't expect it to have direct support for any particular machine instruction.

    There really ought to be SIMD data types and functions built in to the language

    How would you do that in a portable way?

    --
    All I want is a secure system where it's easy to do anything I want. Is that too much to ask ~~ Randall Munroe
  37. Re: by JustNiz · · Score: 2

    >> Some how you went from "buffer" to "dynamically allocated memory"

    Yes because if you need a buffer of a length only known at runtime you should be using dynamic memory rather than statically define an array of some guessed length.

    >> 1) your string isn't actually a string because it isn't null-terminated.

    This is only true if you were stupid enough to make your buffer too small, which usually happens because junior or hacky programmers are often inexperienced or hacky enough to incorrectly think guessing a maximum length rather than calculating it is robust.

    >> 2) it is actually more work for you to implement the handling of the error,
    As opposed to what? allowing it to (possibly silently) corrupt memory?

    >> I can't think of too many situations where not having the whole string is useful.
    Nor can I thats why you dynamically create a buffer of suitable length.

    >> By explicitly checking buffer size, I can adjust my destination buffer to include enough space

    Ahh so now we are using dynamic memory?

    >> if it is such a hideous problem I can simply exit() or return

    Wow that must look great to the user. I hope you never write control or embedded software.

    >> At which point why even bother using strncpy() if I'm already checking buffer size manually?

    Both because its safer and can make your code more concise, and because the idea is that if you have a small buffer you should only read as much as you can buffer. The C and C++ language gives you exactly what you asked for. It does not generally coddle ignorant programmers by trying to second-guess everything. I personally love that, as I want a scalpel not plastic scissors.

  38. Re:Slow Adoption of Current Standards by serviscope_minor · · Score: 2

    Why do people keep modding up this old, tired tripe.

    Just about everything in the article is either correct and very out of date (amazingly, the world of C++ has changed in the last 20 years) or was never true in the first place.

    --
    SJW n. One who posts facts.
  39. Re: by hazah · · Score: 2

    Because it costs extra cycles, and you can't make the assumption that it's neglegable every single time? Because of C's promise that you don't pay for what you don't use? Because it's a logic error to begin with and you should fix your logic errors, program your intent, and not rely on the compiler to figure out what you meant? Because you want to control the binary output?

    Take your pick.

  40. Re:Slow Adoption of Current Standards by Viol8 · · Score: 2

    "Linux's C-style OO has each instance having a pointer to every virtual method otherwise the syntax would be too unpleasant. This makes it less memory efficient in C and increaces the cache footprint."

    Err, C++ vtables require a double pointer dereference - the C version requires 1. That alone is a good enough reason not to use C++. Aside from that when you;re writing an OS you want to know exactly how your memory is set up and used, not hope the compiler doesn't fuck something up when it tries to get clever.

    Stick to application programming and leave kernel dev to people who know what they're doing.