Slashdot Mirror


How Linux's Kernel Developers 'Make C Less Dangerous' (hpe.com)

Hewlett-Packard's Enterprise blog summarizes a talk by Linux kernel developer Kees Cook at the North America edition of the 2018 Linux Security Summit. Its title? "Making C Less Dangerous." "C is a fancy assembler. It's almost machine code," said Cook, speaking to an audience of several hundred peers, who understood and appreciated the application speed resulting from C... Over time, Cook and the people he worked with discovered numerous native C problems. To deal with these weaknesses, the Kernel Self Protection Project has worked slowly and steadily on protecting the Linux kernel from attack. In the process, it has worked to remove troublesome code from Linux....

With its operational baggage and weak standard libraries, C contains a great deal of undefined behavior. Cook cited -- and agreed with -- Raph Levien's blog post "With Undefined Behavior, Anything Is Possible." Cook gave concrete examples. "What are the contents of 'uninitialized' variables? Whatever was in memory from before! Void pointers have no type, yet we can call typed functions through them? Sure! Assembly doesn't care: Everything can be an address to call! Why does memcpy() have no 'max destination length' argument? Just do what I say; memory areas are all the same!" Some of these idiosyncracies are relatively easy to deal with. Cook commented, "Linus [Torvalds] likes the idea of always initializing local variables. So, you should 'just do it....'"

The long-term solution? More security-savvy open source developers... While at times, the idea of coming up with a Linux C dialect has been attractive, that's not going to happen. The real issue behind the problem of dangerous code is "people don't want to do the work to clean up code -- not just bad code, but C itself," he said. As with all open source projects, "we need more dedicated developers, reviewers, testers, and backporters."

LWN.net has its own run-down of Cook's talk, as well as a link to a PDF file of his slides.

"Sound good," posted one of their commenters, "though ultimately I'd like kernel devs to adopt Rust as their main Linux kernel development language. Beats the crap out of C and C++ combined."

509 comments

  1. Why not use Rust? by BitterOak · · Score: 0, Redundant

    Rather than trying to make C "less dangerous", why not use a language like Rust? Wasn't it designed to essentially be a less dangerous C?

    --
    If I can be modded down for being a troll, can I be modded up for being an orc, or a balrog?
    1. Re:Why not use Rust? by gweihir · · Score: 1

      If you ask that, then you do not understand the target application.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    2. Re:Why not use Rust? by hackus · · Score: 5, Insightful

      Because the statement is hollow: "Sound good," posted one of their commenters, "though ultimately I'd like kernel devs to adopt Rust as their main Linux kernel development language. Beats the crap out of C and C++ combined."

      You have no scientific proof. It is your opinion.

      People have been attempting to replace C since it was conceived.

      Sort of like the idiocy in configuration management systems I see today.

      Lets throw RPM and well know configuration management tools we have used for the past 20 plus years like bash shell scripting and invent a way to configure boxes by adding not required additional daemons, Oh lets also throw in different languages and screwy config formats like YAML. That way we can boost the requirements on our resumes for higher salaries so we can make things incredibly overly complicated, to even updated a single .conf file in etc.

      I call BULLSHIT on you CF Engine, Puppet and Chef admins.

      Like these management systems such as puppet..etc....you have no proof these systems like rpm and C should be replaced for build, configuration or programming.

      Other than the fact it wasn't invented by a very naive generation of idiots out of college who like to pretend the last 20 years of the computing industry was a mistake and really doesn't exist.

      Just my opinion, but everyday I manage thousands of boxes with bash and rpms for config management. I also patch using the C language.

      Works great, and I don't need to learn Ruby, YAML, or create daemons for clients, or secure their firewalls...or...

      Well, you get the idea.

      --
      Got Geometrodynamics? Awe, too hard to figure out? Too bad.
    3. Re:Why not use Rust? by russotto · · Score: 5, Insightful

      For one, Linux is written in C already. For another, Rust comes with an ideology. C doesn't care.

    4. Re: Why not use Rust? by Anonymous Coward · · Score: 0

      Yeah, I get the idea. You still use telnet instead of SSH because who the fuck has time to learn to use expect, let alone chef. You think containers are shit. Because who the fuck has time to learn Docker when I have thousands of hosts to patch? You shit all over your security team for rejecting your request to open 20,000 UDP ports for 10.0.0.0/8 because who has time to figure out what hosts are involved? And you sure as fuck hate AWS and Azure because everyone has time to bypass your fief building, BOFH acting, business retarding ass.

      Yeah, we get it.

      And you do not.

    5. Re:Why not use Rust? by gweihir · · Score: 2

      Looks to me like these people just want their "safe space" in the kernel, where nobody tells them off for having coded something stupid.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    6. Re:Why not use Rust? by zieroh · · Score: 4, Insightful

      For another, Rust comes with an ideology. C doesn't care.

      Oh, C definitely has an ideology: Do anything you want, but beware the consequences.

      Mind you, I'm quite comfortable with that. It's the kids raised on Java that shit their pants when they realize that C won't protect them from themselves. Since you can't (or at least shouldn't write an operating system in Java, they keep casting about for a suitable language that isn't C. But since nearly every operating system of note is written in C or a C derivative, I think we can safely assume for now that they're just chasing their own tales.

      --
      People who say "sheeple" have about as much sophistication as an AOL user, and in fact are probably actually AOL users.
    7. Re:Why not use Rust? by Billly+Gates · · Score: 1

      And GNu doesn't?

      It is silly as Linus is not a communist nor does Linus or any of the Linux developers need to be part of the Mozilla Rust team and be under their guidelines to use their products.

      I am not saying moving to rust is a good idea. The reason Linux is in C is because Unix was written in C and Linux has conservative users and developers.

    8. Re:Why not use Rust? by ooloorie · · Score: 1

      Rust makes a bunch of choices (static type safety, static memory safety, reference counting, etc.) that have been made again and again before. They may or may not be slightly better than C, but they are not so much better that it's worth the enormous investment to switch over, retool, and retrain. To put it differently, if people are going to switch out of the C/C++ family, it will have to be to something that's substantially better than Rust.

      One of the things that I think is absolutely idiotic in Rust is its lack of a real-time garbage collector, instead relying on a mix of static analysis and reference counting.

    9. Re:Why not use Rust? by WaffleMonster · · Score: 1

      Rather than trying to make C "less dangerous", why not use a language like Rust? Wasn't it designed to essentially be a less dangerous C?

      All these "safe" languages do is impose constraints limiting what you can do.

    10. Re:Why not use Rust? by AHuxley · · Score: 1

      Why not Ada?

      --
      Domestic spying is now "Benign Information Gathering"
    11. Re:Why not use Rust? by Aighearach · · Score: 0

      Looks to me like these people just want their "safe space" in the kernel, where nobody tells them off for having coded something stupid.

      That exists. It is called Hurd.

      Well, or really any microkernel.

    12. Re:Why not use Rust? by Tough+Love · · Score: 1

      People have been attempting to replace C since it was conceived.

      With some success. Today, C is relegated to a small number of (important) niches, like OS kernel, base libraries and... the list gets very short. Free free to add to it if you like.

      Even embedded is mostly C++ now.

      --
      When all you have is a hammer, every problem starts to look like a thumb.
    13. Re: Why not use Rust? by Anonymous Coward · · Score: 0

      C isnt the problem, its the programmer

    14. Re:Why not use Rust? by Anonymous Coward · · Score: 0

      "Even embedded is mostly C++ now."

      Not even, it's regular C for the most part (and you can tell that by how often it crashes because of poor garbage collection practice by the coder.)

      Source: Every single tab and string machine, robotic arm, and conveyor system in my shop uses C, and they were made last year.

    15. Re: Why not use Rust? by Anonymous Coward · · Score: 0

      Java just pretends out to protect you, but itâ(TM)s really out to fuck you. You see, just because your code runs on todayâ(TM)s java runtime, doesnâ(TM)t mean that it will run on tomorrowâ(TM)s. Or maybe tomorrowâ(TM)s will introduce a new security vulnerability in your code.

      Nobody likes java, itâ(TM)s just something they put up with. Iâ(TM)ve personally put up with java fucking over one of my servers with an update that broke the application that needs it. It was an automatic update that I had disabled, but it updated itself anyways.

    16. Re: Why not use Rust? by Anonymous Coward · · Score: 1

      I donâ(TM)t know what I hate more...iphones, or the fact that slashdot doesnâ(TM)t support Unicode.

    17. Re:Why not use Rust? by AmazingRuss · · Score: 1

      Mostly because "I code in Rust" sounds pretty dumb, I would suspect.

    18. Re:Why not use Rust? by EmeraldBot · · Score: 1

      On Linux, C most certainly does. The most widespread and popular compiler for C is GCC, a project that was formed *entirely* for ideological purposes, by a group that was formed entirely for ideological purposes, by one of the most ideologically die hard people in the software sphere. Hate it when people try to use euphemisms and dogwhistles instead of just saying what they mean.

      --
      "Set a man a fire, he'll be warm for the rest of the night. Set a man afire, he'll be warm for the rest of his life."
    19. Re:Why not use Rust? by Anonymous Coward · · Score: 1, Informative


      <p>Even embedded is mostly C++ now.</p></quote>

      (start rant)

      I <i>wish</i> it was mostly C++. It may be C++ in the higher power MPU world where software more complexity brings in people with more opinions, but in the smaller world (sub 512k ram, 1m flash) it's still mostly C. In the even smaller embedded world at the sub (16k ram, 32k flash) you'll find it is all done in assembly code. And that world is inhabited with programmers who have their heads stuck up their asses so much they wouldn't know an object if it slapped them in the face.

      I help with a framework for 32-bit controllers. The sub 200Mhz, sub 2mb flash type, and its all done in C. Why? 'Our customers are afraid of c++'. So we try to write complex code that works like OOP in C. You can do it, but its soul crushing.

      Namespaces in C++ are worth switching from C to C++ alone, even if you don't use objects. If you're talking about a mildly complex system, the name mangling that comes with C++ and namespaces help to reduce collisions in names. Or else you start doing what we're forced to do, build the namespace into the function and variable names.

      The syntactical sugar of objects, overloading and polymorphic code is just gravy when you have 40+ developers working on code and colliding name spaces. And when you start to deal with the requirements of supporting n-number of hardware devices and drivers using interface classes are better than naming your function pointer tables that you use under the hood something something vtable.

      No, customers are afraid of C++. So we jump though hoops writing objects in C to satisfy the fears, and take 10 times as long to write code.

      I'll agree there are some aspects of C++ that should never come near an embedded project, especially with, lets say less experienced engineers (templates), but all this can be solved with proper code discipline and with people who know what they're doing.

      Even our tools don't support C++. Well I lie, they do support C++ officially, but in my mind the support is so broken that its better off not supporting it at all. When you're debugging a child class, you want to see all the members, including the members of the parent classes. But no the debugger is so broken it can't do that. Stepping through a virtual function causes the debugger to get lost. How can you even say you support C++ in your debugger/IDE if it can't even do that? And its suppose to be a premiere embedded IDE?

      (end rant).

      IoT is still expanding, so maybe more complex things will become most of the embedded world, but there will still be a lot of really small embedded areas that are needed. I really do hope that things progress and C++ starts to handle most of embedded coding, at least for the 32-bit embedded world, I really do. Used right C++ is just as fast and optimized as well optimized C code. It's a tool like any other, and requires skilled people to use it well.

    20. Re:Why not use Rust? by Anonymous Coward · · Score: 0

      Yes!!! The olde stuff has been working great for decades!

      I read the "fine article" and when I clicked on one of his example commits using the fall through comment,
      immediately above the comment was an unbraced if statement which has been the cause of more bugs -
      (and that infamous one a short time ago) --

      @@ -7235,6 +7235,7 @@ sk_reuseport_is_valid_access(int off, int size,
                case offsetof(struct sk_reuseport_md, eth_protocol):
                        if (size < FIELD_SIZEOF(struct sk_buff, protocol))
                                return false;
      + /* fall through */
                case offsetof(struct sk_reuseport_md, ip_protocol):

      So I'm less sympathetic to his argument now.

      I guess any article that talks about C's inherit danger - how "dangerous" it is feels very sophomoric.
      Though nothing's impossible in any programming language, I've found that unless you're using some
      scripting language for more high-level "stuff", C is really good at exposing and making the nitty-gritty
      details of a algorithm clearer to identify and code. Despite the lack of {}'s scoping the return false;,
      is there any other programming language where you can "naturally" do things like case offsetof(...)?

      (crickets)...

      CAP == 'surplus'

    21. Re:Why not use Rust? by Tough+Love · · Score: 1

      Source: Every single tab and string machine, robotic arm, and conveyor system in my shop uses C, and they were made last year

      Do you actually know that, or are you guessing? I think you are guessing. Here is an actual survey. That was 2012, I am sure the gap is much wider now. A quick survey of job postings on dice.com supports this assessment.

      You sound sincere enough, but you really ought to admit: 1) you are guessing and 2) your sample size is one.

      --
      When all you have is a hammer, every problem starts to look like a thumb.
    22. Re:Why not use Rust? by Z00L00K · · Score: 2

      Regardless of which language you use you'd end up with C or Assembly in the bottom.

      I'm not sure if Rust is the way to go or if some different language is better. VMS/OpenVMS is using a large chunk of BLISS.

      Another alternative I'd think of is Erlang. Or Prolog.

      For the future - think outside the box. And that may not mean C, C++ or any of the traditional procedural languages.

      --
      If builders built buildings the way programmers wrote programs, then the first woodpecker would destroy civilization.
    23. Re: Why not use Rust? by jma05 · · Score: 0

      > Or maybe tomorrowâ(TM)s will introduce a new security vulnerability in your code.

      Well, of course. JVM is after all written in C/C++ :-).

    24. Re:Why not use Rust? by DamnOregonian · · Score: 1

      Totally agree on all points except one... I use YAML/JSON for all my configs these days. It's pretty damn useful to have a well-defined and well-known structured data representation format that you can edit with emacs

    25. Re:Why not use Rust? by DamnOregonian · · Score: 1

      Eh, that's like saying a dude with an AK-47 in Syria subscribes to the ideology of Kalashnikov.
      Your logic is borked, amigo.

    26. Re:Why not use Rust? by Tough+Love · · Score: 1

      I wish it was mostly C++. It may be C++ in the higher power MPU world...

      You put your finger on it, it is strongly dependent on how powerful the embedded platform is. This may alarm you

      In that survey, C++ and C are in a dead heat. Obviously, C++ will be ahead of C next year and Python will probably be even further ahead. Shudder.

      For my part, I was coding embedded for a 16KB part in C++ back in 1999, I think the compiler was Wind River. The development environment was the lap of luxury, that is, source level debugging using one of those JTAG wigglers. Operating system just coded inline, maybe about 300 lines. I had no idea this was unusual, so thanks much to whoever had the foresight to set that environment up.

      The embedded world isn't like that any more. Now people think that a NUC is embedded. Now you typically run Linux, I think Linux is even running in my thermostat now. It certainly is running in all my TVs. Yes, there are still tiny embedded processors out there, particularly in toys, but it's a rapidly shrinking world, and there isn't a lot of new blood flowing into it. That may explain why you see a lot of attachment to old ways of doing things, like straight up C. And you see a lot of EEs in there, I think you know pretty much how open to change they tend to be.

      --
      When all you have is a hammer, every problem starts to look like a thumb.
    27. Re: Why not use Rust? by Anonymous Coward · · Score: 0

      Ring0 to be exact.

    28. Re: Why not use Rust? by Anonymous Coward · · Score: 0

      What's so bad with having some principles and ideals? Is it better to have none? What did Linux + GNU become today?

      Look forwards man.

    29. Re: Why not use Rust? by Anonymous Coward · · Score: 0

      Start porting some drivers.

    30. Re: Why not use Rust? by jd · · Score: 1

      Is Rust less dangerous than Verified C Dr the Verified Software Toolchain?
      Do I have anything equivalent to Why3 to verify correctness?

      The kernel, in C, can have critical components modified to fit the constraints. It's still C, GCC will still compile it, but I could then verify it. Without impacting performance.

      Linux is big, if you want to convince me you cod write an OS kernel in Rust (remember, no standard libraries), start with rewriting SEL4. Whilst retaining or improving on the defect ratio and performance.

      If you can't do something that small, you can't do Linux.

      --
      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)
    31. Re:Why not use Rust? by iampiti · · Score: 2

      At the end it boils down to "you must know what you're doing".
      Kernel development deals with very low level concepts and most people don't undestand them. If you don't know what you're doing you will undoubtely make mistakes and since the OS is the layer on which everything runs mistakes in kernel code have rippling effects throught the system and all the software you run on it.
      You could write Linux (the kernel) parts in something other than C but that won't save you from having to know the gory details

    32. Re: Why not use Rust? by dargaud · · Score: 1

      Is there even a single line of rust in the kernel? There used to be some c++, but I think it's long gone now, or maybe left for some specific architectures...

      --
      Non-Linux Penguins ?
    33. Re:Why not use Rust? by Megol · · Score: 0

      And as usual your comment is utterly stupid... Are you actually a troll going for the long game?

    34. Re: Why not use Rust? by Anonymous Coward · · Score: 0

      Because it didnâ(TM)t fucking exist when they started and they donâ(TM)t feel like redoing the whole damn thing now.

    35. Re: Why not use Rust? by Anonymous Coward · · Score: 0

      Always felt more like Java was trying to protect me from implementing the obvious, efficient and safe solution in my head. A language designed to make you use it's creators solutions however inappropriate or even unsafe.

    36. Re:Why not use Rust? by Anonymous Coward · · Score: 0

      ...it's regular C for the most part ... garbage collection ...

      You're doing it wrong.

    37. Re: Why not use Rust? by Anonymous Coward · · Score: 0

      You have survey data for the machines in his shop?

    38. Re:Why not use Rust? by F.Ultra · · Score: 2

      What is wrong with a simple "key value" config?

    39. Re:Why not use Rust? by Anonymous Coward · · Score: 0

      Because no one wants to wait an hour to compile the kernel.

    40. Re:Why not use Rust? by mikael · · Score: 1

      That problem was happening with C++ and Eclipse as well. We had a debugger for the PC version of an application. When it came to debugging code, the IDE would refuse to display the values of the variables you most wanted to see. Why? Because the build framework had all the optimization settings turned on, the compiler would optimize those variables into registers, but not store that in debug information. So the IDE couldn't figure out what the values were.

      Companies are moving from embedded to mobile simply because the licenses are more expensive for a raw Linux embedded system than they are for Android. Plus Android offers all sorts of connectivity by Bluetooth for keyboards and gamepads as well as Wi-Fi.

      --
      Vintage computer adverts: http://www.vintageadbrowser.com/computers-and-software-ads
    41. Re:Why not use Rust? by Anonymous Coward · · Score: 0

      Not to mention that the pool of people who are qualified to write kernel code in C is quite limited. Changing over to a marginal language like Rust would make that pool even smaller, virtually 0 probably.

    42. Re: Why not use Rust? by Anonymous Coward · · Score: 0

      Don't you have to agree not to insult people, if you use Rust?

    43. Re: Why not use Rust? by Anonymous Coward · · Score: 0

      Kernel principles:
      Simple as possible
      Easy to review
      Safe
      Performant

    44. Re: Why not use Rust? by Anonymous Coward · · Score: 0

      I like java. Why did your server have outbound internet access?

    45. Re:Why not use Rust? by Anonymous Coward · · Score: 0

      Try and write a parser for it sometime. My favourite tutorial on that is still "Let's Build A Compiler". Instead of emitting code, just have it set variables, and you have a configuration parser. The point of the exercise is to show you where the difficulties in the format are.

      I don't know about YAML but I do know XML is completely fucked in the head. And, amazingly, so is JSON. Just go look at that survey of failure modes in the various JSON parsers. Suddenly you'll no longer think of it as "well-defined".

    46. Re:Why not use Rust? by gweihir · · Score: 1

      No. Unlike you, I have actual insight.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    47. Re: Why not use Rust? by Anonymous Coward · · Score: 0

      RPM works so well on Windows. But seriously, it's hard to give up a decades long investment in e.g. SMS/SCCM for something like Puppet.

    48. Re:Why not use Rust? by Dasher42 · · Score: 1

      Great point. I like YAML as a format, but when it's the only exposed interface for a black box that doesn't even give you control of order of operations, it's a curse. I'm specifically thinking of a case involving buildpacks for cloud architectures, and boy is that a circus of things Unix/Linux have long had right being reinvented badly.

    49. Re:Why not use Rust? by DamnOregonian · · Score: 1

      I did, and hence why I use it...
      JSON/YAML is actually *very* easy to parse.

      XML- ya, I'm with you there.

    50. Re:Why not use Rust? by DamnOregonian · · Score: 1

      Absolutely nothing.
      But it's also very useful to be able to add structured data within those KVs.

      I wrote my own parser that has very lax rules.
      For example, quotes not required, nor even commas.
      JSON can actually have correct formatting inferred very easily.

    51. Re:Why not use Rust? by Anonymous Coward · · Score: 0

      Nope. C's ideology is "Do many things you want, and beware of the consequences". There are lots of things which C can't do and other languages allow doing. For example: dynamic code generation and compilation (JIT). Of course you could theoretically use libraries to do this in C, but: 1. They don't exist and 2. It would be extremely unwieldy.

    52. Re:Why not use Rust? by HiThere · · Score: 1

      Rust is quite unpleasant to use (when last I checked) and was recently changing rapidly. It's also difficult to properly implement. C is easy to use (with problems), easy to port, and has lots of decent libraries.

      FWIW, I don't like C, and consider it unreasonably dangerous, but my use case is very different. I do think that projects should adopt a subset of C rather than full C, and have a strong "super lint" to ensure that casting is done properly and void pointers have proper typing. (A macro preprocessor could be used to handle ensure that void pointers had semantic casts, that would be ignored by C.) This would take a bit of custom work, but not a huge amount....nothing like that required by the Mortran preprocessor for Fortran back in the day, as the notations would be a lot simpler...things like macros that translated into empty replacements, but which were recognized by the preprocessor. The terms would need to be defined by the preprocessor, so you could write something like:
      a = func (C_INT_PTR p)
      where p is a void pointer, and func requires an int pointer argument. This is something that could be done by convention, but you need the preprocessor to ensure compliance.

      How far you want to take this is a matter of taste, but you could have a preprocessor that did a full type check if you wanted to put in the effort, and still have final output that is pure C code.

      Perhaps the best way to do it would be to start off with a C to C compiler, and slowly add in additional checks, constraints, pre-defined semantic macros, etc.

      --

      I think we've pushed this "anyone can grow up to be president" thing too far.
    53. Re:Why not use Rust? by weberjn · · Score: 1

      > nearly every operating system of note is written in C

      z/OS is written in assembler ..

    54. Re:Why not use Rust? by chrish · · Score: 1

      My startup implements cryptography that's safe against attacks by quantum computers. https://www.isara.com/ if you're interested.

      This is relatively low-level stuff where we don't use much of the standard library, and we want decent performance. Part of our performance comes from doing clever things with the algorithms and the math behind them, but there's a lot of things that just take however long they take.

      This is great for portability. From the start we've built on multiple platforms using multiple compilers and ports have mostly just been setting up the build environment.

      When we started, I knew portability would be really important. I also wanted our code to be secure and correct. I looked into using Go and Rust but decided to stick with C for portability, mostly because they weren't ported to several of the platforms we thought we might need to support. We've also got a strong set of coding guidelines and a possibly obsessive-compulsive code review regime.

      Since it was 2015, we decided to standardize on C99. Seems reasonable, a 16 year old spec should be widely supported... well, we build on Windows using gcc because Visual C's standards support is half-assed. We've run into platforms where you have to use the vendor's toolchain, and it's C89. Yeah, people are shipping new products built with customized gcc versions from almost 30 years ago.

      We can't afford to have a tools group who can maintain ports of llvm and whatnot to various terrible platforms. So we do the best we can with C.

      --
      - chrish
    55. Re:Why not use Rust? by Anonymous Coward · · Score: 0

      hierarchies are nice, so you don't wind up with

      widgetA_length value
      widgetA_width value
      widgetA_size value

      widgetB_length value
      widgetB_width value
      widgetB_size value

      instead you can have (no particular syntax chosen or implied here.
      widgetA{
          length value;
          width value;
          size value
      }
      widgetB{
          length value;
          width value;
          size value
      }

      Of course, there's always XML

    56. Re:Why not use Rust? by F.Ultra · · Score: 1

      Or you have sections as in INI-files or most other key value configs.

    57. Re:Why not use Rust? by Anonymous Coward · · Score: 0

      If you look at popular software that has been created through the years, you'll find that GCC isn't at all the most popular compiler. It might well have been popular in the Linux and unix landscape in more recent times, and probably also amongst amateurs, but compilers from Borland, Microsoft, Watcom and numerous others have been used for a lot more popular software than GCC.

      Nowadays, GCC is in decline, with CLang moving on its territory. Most interest in the C/C++ community is headed in that direction.

      Either way, GCC has never been the only option. Nor has it even been the default option, or the option that people were pushed to. Even in the Linux world, Intel's compiler has been a solid option for a great many years.

      So no, there's no ideology here.

  2. Here's why...Not invented here syndrome by bogaboga · · Score: 0

    Rather than trying to make C "less dangerous", why not use a language like Rust? Wasn't it designed to essentially be a less dangerous C?

    It's because of the Not invented here syndrome (NIHS) - A mindset or corporate culture that favors internally-developed products over externally-developed products, even when the external solution is superior.

    Disclaimer: Not my own words but as defined by some technology site.

    1. Re:Here's why...Not invented here syndrome by jma05 · · Score: 2

      No one refuses to use Rust because of NIHS because they would not have invented C either.

      The real reason is entrenchment. People are just used to old ways. Rust's borrow checker has a learning curve. C programmers are used to old imperative style programming, not things like pattern matching.

    2. Re:Here's why...Not invented here syndrome by Aighearach · · Score: 3, Insightful

      The exact same thing could be said about them wanting to switch to something new instead of learning C! In fact, if you're infected with NIHS you'd never be able to use an older generation of tools, you'd always need to adopt a new tool even when the old tools are better.

      Like people who need to use an app from some company so they can communicate, because email is "old."

    3. Re:Here's why...Not invented here syndrome by gweihir · · Score: 5, Insightful

      Nonsense. It is "if it is not broken, do not fix it." C is not broken and the majority of the kernel is already written in it. It is just a tool that requires you to know what you are doing. But that applies to kernel development anyways. Rust is for morons with delusions that do not have what it takes but think they can write advanced code anyways. They cannot. The language is not the main difficulty here.

      Incidentally, the believers in "just use this great new tool and all your problems will be solved" have been around forever, and they have been just as stupid way back as they are today. Brooks already had a chapter on it: "There is no silver bullet." Yet time and again, some people with little understanding of what matters claim that their pet-tool is that silver bullet.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    4. Re:Here's why...Not invented here syndrome by willy_me · · Score: 0, Troll

      Rust is for morons with delusions that do not have what it takes but think they can write advanced code anyways.

      Oh please... Rust is for people that want to be more productive with their time at the expense of some additional system resources. For the majority of software projects it is a good deal.

      Operating Systems are a bit different. Every bit of performance and every bit of memory matter. The OS is being run in enough places, on different hardware, that even a small difference is performance can be noticeable. The code is important enough such that the additional time and effort required to ensure the C code is done correctly is time well spent. For most other applications, it would be wasted effort.

      Now let us not forget that Rust is also dependent on LLVM so it has limited hardware support. I suppose such support could be added but it is far too soon to be suggesting that an OS, which is supposed to be able to run on almost anything, should be using it.

    5. Re:Here's why...Not invented here syndrome by gweihir · · Score: 0

      Oh please... Rust is for people that want to be more productive with their time at the expense of some additional system resources. For the majority of software projects it is a good deal.

      Nonsense. That is just the propaganda the Rust fanatics put out.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    6. Re:Here's why...Not invented here syndrome by zieroh · · Score: 2

      It's because of the Not invented here syndrome (NIHS) - A mindset or corporate culture that favors internally-developed products over externally-developed products, even when the external solution is superior.

      WTF? Unless you're working at Bell Labs, choosing C doesn't seem to fit into the "NIHS" you describe. Not even a little bit.

      --
      People who say "sheeple" have about as much sophistication as an AOL user, and in fact are probably actually AOL users.
    7. Re:Here's why...Not invented here syndrome by mikael · · Score: 3, Insightful

      At the level of kernel programming, you want a direct mapping of source code to assembly language, with no surprises or unexpected compiler optimisations - some early day compilers would pad out variables in C structures or even rearrange the order so it didn't match the source code.

      With Rust, something like macro overloading would be a code obfuscatory dream.

      --
      Vintage computer adverts: http://www.vintageadbrowser.com/computers-and-software-ads
    8. Re:Here's why...Not invented here syndrome by Tough+Love · · Score: 1, Insightful

      Have you written anything in Rust?

      --
      When all you have is a hammer, every problem starts to look like a thumb.
    9. Re:Here's why...Not invented here syndrome by gweihir · · Score: 1, Troll

      Ah, the old "you don't know it until you try it" fallacy so dear to fanatics of all kinds.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    10. Re:Here's why...Not invented here syndrome by Tough+Love · · Score: 0

      It was a yes or no question.

      --
      When all you have is a hammer, every problem starts to look like a thumb.
    11. Re: Here's why...Not invented here syndrome by Anonymous Coward · · Score: 0

      I take it you are open minded about eating out a hairy manâ(TM)s asshole, since you have not tried it?

    12. Re: Here's why...Not invented here syndrome by Anonymous Coward · · Score: 0

      IPHONE FAGGOT PHAIL!

    13. Re:Here's why...Not invented here syndrome by Anonymous Coward · · Score: 0

      He was pointing out the question itself is meaningless.

    14. Re:Here's why...Not invented here syndrome by aticus.finch · · Score: 1

      It was a yes or no question.

      So is "Have you stopped beating your wife?". A refusal to answer "yes" or "no" doesn't indicate anything useful.

    15. Re:Here's why...Not invented here syndrome by Tough+Love · · Score: 1, Offtopic

      I pointed out that the answer was an evasion. I believe it is apparent that the real answer to my question is "no". Is there shame in that simple answer, and if so, why? Nothing stops anybody from following up with "no, but..." However, evasion... just don't do it. The message you send is "the true answer to the question would be harmful to my argument".

      In this case, "no I have never used it" could be followed up with "however I have researched the question a lot, and I have these other data points I can also offer..." But that didn't happen. So now I am left with the impression that the anti-Rust argument was just rhetoric, based on nothing more than personal prejudice.

      For the record, I have not written anything in Rust, however I have researched it a fair amount, I have installed it, and I do intend to try some toy programs in it. So far I mostly like what I see, especially the rather impressive performance.

      I understand that some significant parts of Firefox have been re-implemented in Rust from the original C++. And I notice that Firefox has improved a lot in recent months, particularly in terms not leaking like it used to.

      --
      When all you have is a hammer, every problem starts to look like a thumb.
    16. Re:Here's why...Not invented here syndrome by DamnOregonian · · Score: 1

      Don't engage that guy. He will throw illogical questions at you until you die of old age, and all the while think that every one you refuse to engage is a point in his favor. It's exhausting.

    17. Re:Here's why...Not invented here syndrome by Anonymous Coward · · Score: 0

      Here, you can learn a lot about writing decent C code from this project:

      openbsd.org

      You don't need a master, you just need to bust your ass and work hard.

    18. Re:Here's why...Not invented here syndrome by Tough+Love · · Score: 0

      I pointed out that the answer was an evasion. I believe it is apparent that the real answer to my question is "no". Is there shame in that simple answer, and if so, why? Nothing stops anybody from following up with "no, but..." However, evasion... just don't do it. The message you send is "the true answer to the question would be harmful to my argument".

      In this case, "no I have never used it" could be followed up with "however I have researched the question a lot, and I have these other data points I can also offer..." But that didn't happen. So now I am left with the impression that the anti-Rust argument was just rhetoric, based on nothing more than personal prejudice.

      For the record, I have not written anything in Rust, however I have researched it a fair amount, I have installed it, and I do intend to try some toy programs in it. So far I mostly like what I see, especially the rather impressive performance.

      I understand that some significant parts of Firefox have been re-implemented in Rust from the original C++. And I notice that Firefox has improved a lot in recent months, particularly in terms not leaking like it used to.

      There is no "-1, disagree" moderation option.

      --
      When all you have is a hammer, every problem starts to look like a thumb.
    19. Re:Here's why...Not invented here syndrome by Anonymous Coward · · Score: 0

      What the heck are you talking about? Kernel developers know about structure padding, holes etc that they know when to use #pragma pack

      Furthermore, this padding business is fairly newer than the old style of keeping things exactly how they are meant to be kept.

    20. Re:Here's why...Not invented here syndrome by Tough+Love · · Score: 0

      So, according to you, "have you written anything in Rust?" is an illogical question. Gotcha.

      --
      When all you have is a hammer, every problem starts to look like a thumb.
    21. Re: Here's why...Not invented here syndrome by Anonymous Coward · · Score: 0

      It's iFone you phaggot.

    22. Re:Here's why...Not invented here syndrome by DamnOregonian · · Score: 2
      Well, it's a loaded question. With it an implied argument that having not used something means he is not qualified to know The Truth about it.
      He was therefore on solid ground in implying that your question was meaningless, or at best, baiting him.

      Let's recap.

      Oh please... Rust is for people that want to be more productive with their time at the expense of some additional system resources. For the majority of software projects it is a good deal.

      The comment he was replying to. That is rhetoric. You know what rhetoric is, quite obviously, because you accused this poster of exactly that.

      Nonsense. That is just the propaganda the Rust fanatics put out.

      This was his reply. It was factually correct. He called out rhetoric for what it was- propaganda.

      You followed that up with your loaded question, giving no one reading any reason to think that you're doing anything but trying to fool a high-school aged kid into walking down that illogical chain of discussion.

    23. Re:Here's why...Not invented here syndrome by Tough+Love · · Score: 0

      I thought you said don't engage.

      --
      When all you have is a hammer, every problem starts to look like a thumb.
    24. Re:Here's why...Not invented here syndrome by serviscope_minor · · Score: 1

      Incidentally, the believers in "just use this great new tool and all your problems will be solved" have been around forever, and they have been just as stupid way back as they are today. Brooks already had a chapter on it: "There is no silver bullet." Yet time and again, some people with little understanding of what matters claim that their pet-tool is that silver bullet.

      I think this is in many ways not correct, but there's quite a lot to unpick.

      Fanbois aside (let's ignore them because they muddy all sides of the argument), no one is claiming Rust will solve all problems.

      C, C++ and Rust all provide essentially the same machine model. Arguably Rust's is closer to C than C++ is to C since it doesn't need as much runtime support (for exceptions). But there's not much to it.

      C++ provides a while load of automation on top of C and by virtue of that protects you from a lot of common errors if you use it in a vaguely modern way. Rust provides s buch of compiler enforced restritions which prevent a large class of errors (memory errors and data races).

      You very likely have those problems if you write in C, and you won't if you write in Rust. You can abvoid those problems in C with one or more of formal methods (the seL$ model, very hard), large amounts of reviewing (the OpenBSD model---also hard), lots of runtime checking (imprecise). Or you can use a language which does it for you, though the penalty is that now ownership (which you can wing in C) is now front and centre because it turns out you can't magic hard problems away. You can however make them much less hard.

      great new tool and all your problems will be solved" have been around forever, and they have been just as stupid way back as they are today

      I think this is both wrong and right at the same time. Yes people don't change. Why then can we produce much cooler stuff at a much faster rate now than 10, 20, 50, 100 years ago? The answer is of course better tooling.

      Switching from a foot pedal lathe with hand forged carbon steel tooling to a 6 axis CNC machine with auto loading, and auto switching of it's carbide insert tooling certainly won't solve all your problems. It still leaves you with the difficult poblem of designing something nice looking which works with real wood, and that people want to buy. But it certainly alleviates the tedium and hard work of continually cranking that foot pedal and sharpening the tools every five minutes. Which is what it's like programming in C.

      It's a bad idea to dismiss tools that solve a lot of your problems merely because they don't solve all problems and while they're at it make you 6 inches taller, move like Jagger and turn you from 8==D to 8======D.

      If you're expecting to make people smarter you may as well ask for that.

      Brooks already had a chapter on it: "There is no silver bullet."

      and yet, I can write programs of vastly greater complexity and that do far more stuff than almost anyone, possibly anyone at all in the 1960s. Why? It sure isn't because I'm some sort of megagenius. No, it's because the tooling is so many orders of magnitude better now than then.

      There's nothing that will magically make a bad, badly managed, demotivated team start cranking out good software overnight. That's the silver bullet you're talking about. On the scale of decades however there certainly are things that mean ordinary programmers can vastly outperform maybe all but the best of previous years.

      New languages are a way for very smart people to slowly trasfer productivity to much les smart people by creating things that mitigate human frailties.

      And OSS has a real C fetishism. It's weird. I mean we have these vastly programmable machines operated ostensibly by programmers who are in essence people who automate things. and yet they are incredibly reluctant to automate any of the day to day tasks they do. I don't get it.

      Funy thing of course is that now all that C code is dependent on C++. No good C compler remain that are written in C.

      Rust is for morons

      Well, good to know you;re thinking about these things carefully.

      --
      SJW n. One who posts facts.
    25. Re:Here's why...Not invented here syndrome by serviscope_minor · · Score: 1

      So is "Have you stopped beating your wife?".

      No, because that question implies a prior state, which a "yes" or "no" answer implicitly confirms. The "have you written anything in Rust" implies no prior state and a yes or no answer does not implicitly confirm aything.

      --
      SJW n. One who posts facts.
    26. Re:Here's why...Not invented here syndrome by K.+S.+Kyosuke · · Score: 1

      old imperative style programming, not things like pattern matching

      Pattern matching is a control construct. How is it exclusive with imperative programming?

      --
      Ezekiel 23:20
    27. Re:Here's why...Not invented here syndrome by serviscope_minor · · Score: 1

      Oh please... Rust is for people that want to be more productive with their time at the expense of some additional system resources.

      [citation needed] on the latter. AFAICT C, C++ and Rust have more or less exactly the same model of how computers work. I don't see any evidence that any one of them is more resource hungry than the other (possible arguments about C++ exceptions aside).

      --
      SJW n. One who posts facts.
    28. Re:Here's why...Not invented here syndrome by serviscope_minor · · Score: 2

      With Rust, something like macro overloading would be a code obfuscatory dream.

      And C macros aren't? So here's the cognitive dissonance that seems to exist with C advocates. It was applied to C++ and appears to applied unchanged to Rust too.

      On the one hand the attitude is that good programmers don't need the hand-holding of Crust++. On the other hand Crust++ lets you write other kinds of bad code.

      Make up your mind! Do you have good programmers or bad ones? And why on earth don't you have some form of code review?

      --
      SJW n. One who posts facts.
    29. Re:Here's why...Not invented here syndrome by DamnOregonian · · Score: 1

      Agreed... That is why I called it out as rhetoric/propaganda?

    30. Re: Here's why...Not invented here syndrome by Anonymous Coward · · Score: 0

      I've tried. Hired two teams of qualified developers with 20 years of experience in c and rust, for the same money each, on a duplicate implementation of the same thing. Was a bit hard to find people to work in rust. Result was that c beat rust by a huge margin.

    31. Re: Here's why...Not invented here syndrome by Anonymous Coward · · Score: 0

      Why then can we produce much cooler stuff at a much faster rate now than 10, 20, 50, 100 years ago? The answer is of course better tooling.

      The answer is of course more processing power.

    32. Re: Here's why...Not invented here syndrome by Anonymous Coward · · Score: 0

      Please post details.

    33. Re: Here's why...Not invented here syndrome by Megol · · Score: 1

      ... with 20 years of experience in c and rust ...

      Impressive. Should we read this as combined (19 years of C + 1 of Rust), combined total (10 developers each with 1 year of C and 1 year of Rust) or perhaps that you hired some time travelers?

    34. Re:Here's why...Not invented here syndrome by serviscope_minor · · Score: 1

      Oops! Yes. My apologies.

      --
      SJW n. One who posts facts.
    35. Re:Here's why...Not invented here syndrome by jma05 · · Score: 1

      It isn't exclusively.
      But it is generally considered one within the functional paradigms - paradigms which are increasingly incorporated outside the traditional functional languages.

    36. Re:Here's why...Not invented here syndrome by Joce640k · · Score: 1

      C programmers are used to old imperative style programming, not things like pattern matching.

      Surely C programmers can learn to use things like C++ compilers and std::vector / std::string.

      Just using those three things would eliminate most of the problems highlighted in the article. The article is mostly about adding more layers of things to the code to avoid problems. The problem is that humans still have to remember to add those things every single time.

      They should be trying to automate them away instead of adding more things to remember.

      --
      No sig today...
    37. Re: Here's why...Not invented here syndrome by Anonymous Coward · · Score: 0

      ... with 20 years of experience in c and rust ...

      Impressive. Should we read this as combined (19 years of C + 1 of Rust), combined total (10 developers each with 1 year of C and 1 year of Rust) or perhaps that you hired some time travelers?

      Only a team in India could conceivable persuade me that they had the required 20 years of experience. They seemed pretty happy to get the same outrageous wages need for the C developers. And they failed spectacularly.

      Not much is in Rust yet because its too new. There's not many experienced people. And not enough time has passed to do anything of significant size in it. And there's not many known issues, because no-one has found them yet.

      I hate having to explain jokes.

    38. Re:Here's why...Not invented here syndrome by Zero__Kelvin · · Score: 2

      It has nothing to do with "entrenchment" in a particular language. The kernel is written in C. Nobody is rewriting it an another language because that wouldn't just be stupid, it would be impossible.

      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
    39. Re:Here's why...Not invented here syndrome by jma05 · · Score: 1

      Not talking about the use of C in kernels, drivers etc. C is good for that.
      However, C is widely used beyond that since C skills are widely available, even if it is not ideal for many projects.

    40. Re:Here's why...Not invented here syndrome by Pseudonym · · Score: 1

      Rust is for morons with delusions that do not have what it takes but think they can write advanced code anyways.

      Rust is for programmers who are willing to live with the fact that their codebase may have to be completely rewritten in that time as the idioms of the language are solidified.

      If you're a startup which may not even be around in five years, the extra static analysis that Rust gives you over C may be worth paying that price. If you're maintaining a 25 year old several million-line codebase it obviously isn't.

      Incidentally, the believers in "just use this great new tool and all your problems will be solved" have been around forever, and they have been just as stupid way back as they are today.

      I'm pretty sure that nobody said that. What they said is that the specific problems outlined in this talk are mostly taken care of in Rust.

      Contrary to popular belief, Rust isn't a moron language. Rust is the beneficiary of people who have been working on the "safer C" problem for decades; see, for example, Cyclone. It has a lot going for it, but it doesn't have the critical mass of long-term maintained code which makes it a safe bet.

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    41. Re:Here's why...Not invented here syndrome by gweihir · · Score: 1

      Thanks, at least one person gets it.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    42. Re: Here's why...Not invented here syndrome by Anonymous Coward · · Score: 0

      I don't look at it as them adding layers. It's more like design principles and experienced
      Built up over the years. They are basically applying what they have learned and making it safer.

      When I think "more layers" I think of stuff like systemd, or node.js. Things I have no control over that try to take the wheel from me.

    43. Re: Here's why...Not invented here syndrome by Anonymous Coward · · Score: 0

      Memory is cheaper and more plentiful, but CPUs aren't much faster than they were 10 years ago. No one who writes software really worries about memory consumption now. People who run software, however....

    44. Re: Here's why...Not invented here syndrome by Anonymous Coward · · Score: 0

      Absent pragmas, most C compilers pad struct members to storage alignment.

    45. Re:Here's why...Not invented here syndrome by gweihir · · Score: 1

      "Have you written anything in Rust" is the the starting point of a manipulative and fundamentally dishonest propaganda technique step here. Well, sure, the question looks innocent. It is designed to look innocent. What will build on any answer is not. "No": Next is some variant of "you don't know what you are talking about". "Yes": "You are doing it wrong" or "you have not gotten to the inner mysteries yet, continue to pray and you will be enlightened". It is all so transparent and inept, it is utterly revolting.

      And it is completely wrong. The answer to that question is totally irrelevant here. Its only possible purpose is as described above. I am just ahead of you here and I have seen this despicable type of dishonesty enough to recognize it early. And I have seen it used to hype numerous other "silver bullet" technologies, none of which have delivered over time.

      Which brings us the one important reason not to use Rust: The cult-followership it has. Such communities are utterly toxic and eventually destroy everything they touch, if not decisively rebuffed. And these cults do not even ensure long-term availability of their currently chosen holy tool. They may just move on to some other hype at any time and then anybody that really built on the old hype is screwed.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    46. Re: Here's why...Not invented here syndrome by gweihir · · Score: 1

      1.) Obvious lie is obvious. Nobody has that kind of budget these days, unless the "team" is so small as to be irrelevant.
      2.) Even if really done, border conditions are critical. Cheap coders will produce utter crap in C that does not even compile. They will screw up more subtly in Rust, which makes the code worse in actual reality, but it will look better with regards to the usual bad software metrics.
      3.) This hugely depends on the problem space and surrounding environment.
      4.) "Was a bit hard to find people working in Rust": That already removes any scientific validity due to faulty sample selection. You would have needed to look for C people that were "a bit hard to find" at the very least.

      Just look at the scientific literature here. It will claim things (with evidence) like that C++ is going to solve all problems of C or that Ada is really the language everybody will be coding in by the year 2000 and that it will fix everything, or, going back, that C will finally remove all the problems of assembler. Nothing like that has ever materialized, but all these claims can and have been "proven" with the right, scientifically invalid, studies.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    47. Re: Here's why...Not invented here syndrome by gweihir · · Score: 1

      Opps, sorry. I read your claim the wrong way round. This way I get the joke. My apologies.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    48. Re:Here's why...Not invented here syndrome by Anonymous Coward · · Score: 0

      Even with no entrenchment, you're assuming there's some great argument for writing a kernel in Rust. I've yet to hear it.

    49. Re:Here's why...Not invented here syndrome by amorsen · · Score: 1

      The Linux kernel could be compiled in C++ mode for quite a while, a long time ago. The option was removed because g++ generated lousy code compared to gcc. (This is from memory, details may be wrong).

      --
      Finally! A year of moderation! Ready for 2019?
    50. Re:Here's why...Not invented here syndrome by HiThere · · Score: 2

      To say "C is not broken" is to close your eyes to it's real problems. But it's only broken in the same sense that assembler is broken. It has features that tend to lead to code that is unsafe, difficult to debug, and difficult to understand.

      C is an excellent design for a computer language, just not an excellent design for a programming language. And arguments about what makes an excellent programming language are never-ending, because different use cases yield different answers. If you need resizable arrays you have a different answer than if you need fixed length strings, and that's different than if you need immutable values to access between different processes.

      But for the basic C use case I generally think certain features should be forbidden. Writing beyond the bounds of allocated storage sounds good, but is expensive to check for...and sometimes needs to be allowed in special cases (e.g., and array within a struct that isn't the final element), but in other cases (e.g. when the array isn't the final element) it should be normally forbidden....except that when it's a pointer based overlay on other storage...

      C is full of misfeatures that are inherently dangerous. They allow you to do useful things, but those things should be done through some alternate mechanism, that isn't so liable to errors or abuse. I'm really dubious about all the features that allow you to address an indefinite amount of memory. I'm not sure that there IS a safe way to do that that is also efficient. (One way to handle that would be to allow the program to be loaded with a specified amount of reserved RAM, and if you need to exceed that, to do a save state, and then reload it with a larger specified amount...but allocation on the heap is probably less expensive.)

      --

      I think we've pushed this "anyone can grow up to be president" thing too far.
  3. How about Visual Basic? by Anonymous Coward · · Score: 2, Funny

    I hear that's a very lean and robust language.

    1. Re: How about Visual Basic? by Anonymous Coward · · Score: 0

      I can understand why a person who uses Rust would think that.

  4. Don't be lazy programmers by Rick+Schumann · · Score: 5, Insightful

    C/C++ is not an 'amateur night' programming language, it's not 'child proofed', it doesn't hold your hand like you're a child, you can write entire operating systems in it, and as such it's supposed to have access to anything and everything, and that just so happens to include mucking up the OS of the machine you happen to be testing your code on. 'Sanitizing' it, 'child proofing' it would take away that power and make it useless. At that point you may as well just be writing things in BASIC or some other interpreted language that doesn't allow you access to anything terribly powerful or important. I've never heard anyone refer to C/C++ (or languages of similar power) as 'dangerous' before. I think it more likely that programmers have become lazy, or just aren't educated enough to be responsible with a powerful programming language, and as a result we end up seeing code that's sloppy, ill-behaved, and 'dangerous' because of it. Just like people complaining about how bad drivers are (and that we should ban humans from driving and make them use automation instead, which is stupid), someone wants to take the power away, when the real, rational solution is better education/training/testing. Have schools become lazy in how prospective programmers are educated and how their knowledge is tested? Then lets fix that problem rather than making decent programmers (and drivers) live in a world where the ability to really be behind the wheel and in control of the machine is taken away from them, because some people can't cut it.

    1. Re:Don't be lazy programmers by Zontar+The+Mindless · · Score: 4, Funny

      I've never heard anyone refer to C/C++ (or languages of similar power) as 'dangerous' before.

      I took a Numerical Linear Algebra class in which you were expected to use C. First thing the instructor said was, "This is not a class for children, and so you will write your assignments using C. If you can't be trusted with a pair of scissors, you definitely cannot be trusted with a chainsaw. C is a chainsaw. Deal with it, or come back next semester when the other guy will let you use the blunt scissors known as 'Pascal'." This was in 1986, BTW.

      --
      Il n'y a pas de Planet B.
    2. Re:Don't be lazy programmers by jma05 · · Score: 2, Insightful

      > it's not 'child proofed'

      Programming languages, in general, need to be human proofed. We have a ton of empirical data to support this for decades.

      > 'Sanitizing' it, 'child proofing' it would take away that power and make it useless.

      No, it does not. Programming languages like Rust allow you to do all the unsafe stuff you want. It is just that they are safe by default, but you can step out anytime you need to.

      > I think it more likely that programmers have become lazy, or just aren't educated enough to be responsible with a powerful programming language

      Programmers don't use a safe programming language like Rust because they are indeed "lazy, or just aren't educated enough" - your words. Learn Rust. Then, by all means, reject it if it does not suit the project. Most reject Rust, only because they don't understand it yet.

    3. Re:Don't be lazy programmers by jma05 · · Score: 1

      Yeah, in the 80s, they were having silly holy wars between C and Pascal. Fortran was the better tool for linear algebra code then.

    4. Re:Don't be lazy programmers by The+Evil+Atheist · · Score: 1

      Not going to help with a project like an OS kernel. Almost everything needs to be "unsafe".

      --
      Those who do not learn from commit history are doomed to regress it.
    5. Re:Don't be lazy programmers by jma05 · · Score: 1

      Yes, there is a case for C in kernels, drivers etc.

      But most of the C in the wild is for things that should never have been written in C in the first place - hence a lot of avoidable security holes.

    6. Re:Don't be lazy programmers by gweihir · · Score: 1

      Unfortunately, the believers in silver bullets will not die out.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    7. Re:Don't be lazy programmers by gweihir · · Score: 0

      I like that! Very appropriate.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    8. Re:Don't be lazy programmers by gweihir · · Score: 0, Troll

      > it's not 'child proofed'

      Programming languages, in general, need to be human proofed. We have a ton of empirical data to support this for decades.

      No, you do not. Sure, when you let incompetents write advanced things, it will lead to them making harder to find bugs. But that is something else entirely. Now go back to play with VB or JavaScript.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    9. Re:Don't be lazy programmers by novakyu · · Score: 1

      Back then? There are linear algebra libraries still in use which is written in Fortran. Other languages just link to it, rather than re-implementing it natively.

    10. Re:Don't be lazy programmers by gweihir · · Score: 1

      And that is just the point. Kernels, drivers, high-performance software all are inherently unsafe. The only thing that can make them save is coders that really know what they are doing. These seem to be slowly dying out and the mediocre ones that follow want their safe space instead.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    11. Re:Don't be lazy programmers by UnknownSoldier · · Score: 1

      > I've never heard anyone refer to C/C++ (or languages of similar power) as 'dangerous' before.

      It is obvious you haven't been using C/C++ very long, Bjarne Stroustrup said this about C and C++

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

      There is even a famous book:

      Enough Rope to Shoot Yourself in the Foot: Rules for C and C++ Programming

    12. Re:Don't be lazy programmers by Aighearach · · Score: 1

      Well, you sure as heck don't want to use something like R for that, the class would be too easy. With the code in C, you'd have to actually implement the whole algorithm!

    13. Re:Don't be lazy programmers by zieroh · · Score: 2

      I think it more likely that programmers have become lazy

      This. I've spent the last five years hiring software engineers. I've phone screened more than I can count. The Java programmers being churned out by university CS programs today are atrocious.

      Pro Tip: If you mostly studied Java in college, you should go back to your alma mater and ask for a refund. No, seriously.

      --
      People who say "sheeple" have about as much sophistication as an AOL user, and in fact are probably actually AOL users.
    14. Re:Don't be lazy programmers by zieroh · · Score: 1

      Programming languages, in general, need to be human proofed.

      I call bullshit, and I'll put my decades of industry experience on that. Programmers need to fucking pay attention to what they're doing. There are no languages in the world that prevent the programmer from making serious structural mistakes. It's up to the programmer to know what the fuck they're doing.

      Fuck Rust. Seriously.

      --
      People who say "sheeple" have about as much sophistication as an AOL user, and in fact are probably actually AOL users.
    15. Re:Don't be lazy programmers by zieroh · · Score: 0

      But most of the C in the wild is for things that should never have been written in C in the first place - hence a lot of avoidable security holes.

      Citation, please.

      --
      People who say "sheeple" have about as much sophistication as an AOL user, and in fact are probably actually AOL users.
    16. Re:Don't be lazy programmers by jma05 · · Score: 3, Insightful

      Dude, just search any software engineering journal. Unsafe languages make for more bugs. The design of the tool determines safety and performance as much as training, if not more.

      > Now go back to play with VB or JavaScript.

      Unfortunately people who happen to do unsafe code have this "eliteness" delusion. You are not smarter than anyone else. Write a large enough codebase and you will miss that buffer overflow somewhere, even though you know exactly what it is and have been on the lookout. Time and again, audits of well known software, written by very experienced programmers, show this.

      People are not machines and make mistakes. The only solution is to design tools and paradigms where entire classes of mistakes are not likely to occur in the first place. The checks need not be runtime checks with performance penalties, but if you want safety and security in the end product, the machine checks must be quite robust. Don't ever rely on humans for that, pretending you have "competent" programmers. Prove, don't assert.

      If programmers can't design languages that have safety features (with low costs) that everyone knows they need, how can anyone trust them to solve other domain problems?

    17. Re: Don't be lazy programmers by Dixie_Flatline · · Score: 1

      This is a ridiculous and terrible argument. The rest of the world advances both the tools and the education to make better systems that are more fault tolerant. The infrastructure in this world is built using better tools with what we learned from doing it the old way. You're asking for airplanes to be built only using hammers and screwdrivers instead of power tools and robots. C has it's place in this world. It will always be a great teaching language or for people that like to tinker close to assembly, but it makes no sense to continue using languages that require such overwhelming attention to the wrong details just so you can claim some sort of intellectual superiority or purity. There are thousands of really incredible programmers that have been working on trying to make safe, robust software with C for decades, and it's STILL incredibly hard to do. It's not because they're dumb, it's just that C has stopped being the right tool for the job.

      It's 2018 and we still end up tracking down null pointers and weird memory overwrites all the goddamn time. It's time to move on.

    18. Re:Don't be lazy programmers by Tablizer · · Score: 1

      The "be a big boy" argument dodges the real question here: can a programming language be efficient (stay close to the metal) yet have sufficient checks and balances on itself? Would making it safer automatically make it more resource intensive*?

      If there is an inherent and fundamental trade-off, and C (as it is) merely chooses the close-to-metal far spot on this spectrum, then the be-a-big-boy argument makes sense (assuming you want Linux "fast"). However, I've yet to see anyone make a strong argument that there is a fundamental trade-off. If there is not a fundamental trade-off, then the question of C being the wrong tool for the job carries more weight, and the be-a-big-boy argument deflates.

      Using the pre-initialize example given, if a language automatically pre-initializes all variables, that adds to execution time. One may want that for some applications/domains but not others. For example, for gaming, you might not care much if there's a risk some execution paths might use garbage bits in order to get the most speed. (Distorted aliens may even add to the game's fun.)

      I wonder if C or another language could not rely on API's or API-like expansion macros. A given shop would select the API's that fit its trade-off profile. If you wanted to skip pre-initialization for speed, you'd use the skipping version of an initializer API. And on the flip side, don't include the non-init API in the shop stack if you don't want accidental naked bits.

      The API approach allows control over risky trade-offs without having to make a new language for each domain or shop. I just wonder if using or allowing such a layer itself hurts performance. Does the "choice layer" itself have to hurt performance? It's back to the unanswered "fundamental" question above. If you prove it one way or the other, you deserve a Turing Award.

      * Including possibly having unpredictable execution speed, which in some domains is as bad as "slow".

    19. Re:Don't be lazy programmers by mikael · · Score: 1

      That brings back memories. Our database theory lecturer absolutely hated any language with pointers or had to be compiled (C, C++, Fortran, Modula-2) and would constantly state that 4GL's like SQL, Prolog and Microsoft Basic were the future

      --
      Vintage computer adverts: http://www.vintageadbrowser.com/computers-and-software-ads
    20. Re:Don't be lazy programmers by Anonymous Coward · · Score: 0

      No, it does not. Programming languages like Rust allow you to do all the unsafe stuff you want. It is just that they are safe by default, but you can step out anytime you need to.

      It allows you to do whatever you want yet the consequences of doing whatever you want are just as bad... so ... um... what's ... the point?

      Programmers don't use a safe programming language like Rust because they are indeed "lazy, or just aren't educated enough" - your words. Learn Rust. Then, by all means, reject it if it does not suit the project. Most reject Rust, only because they don't understand it yet.

      If you expect someone to spend their time on something you need to sell it and explain what they get for their trouble in return. I can avoid "unsafe" things in C simply by imposing similar limits to limits Rust imposes on what I am allowed to do.

      Calling people lazy and stupid and suggesting that only if they do what you want them to do they won't be lazy and stupid is not a winning strategy for getting anyone to care.

    21. Re:Don't be lazy programmers by mikael · · Score: 1

      The one thing that could be done (and was done in the past), was to allow each thread to sandbox the areas of memory that it was working with. You could use a couple of instructions that the programmer could use to instruct the virtual memory manager to lock out and unlock regions of memory that shouldn't be touched, so only the memory used by class objects could be accessed. Or it could be done intrinsically.
      Any memory access errors would be trapped.

      --
      Vintage computer adverts: http://www.vintageadbrowser.com/computers-and-software-ads
    22. Re:Don't be lazy programmers by Aighearach · · Score: 1

      IME nothing creates a security hole faster than the programmer thinking that just choosing Virtuous tools will somehow protect them from making mistakes.

      The reality is that mistakes flee the light, but you still make just as many, being human. Like trying to reduce crime by increasing the policing of places with the most reports; it is easy to push the criminals from one street to another street, but much harder to reduce the crime rate.

      Only an approach where the programmer has increased knowledge at both high and low levels will actually decrease the rate of mistakes.

      There are cases where it makes sense to try to chase the mistakes away from certain places; like the way Go-lang tries to make the nuts and bolts of concurrency easy. In the datacenter it makes sense to want to chase the bugs away from the infrastructure, make them hide in the application logic. But for a non-virtualized environment like a desktop OS, it doesn't make much difference where exactly they're hiding. You get more benefit just by fighting against new features, since bugs are introduced as a rate of mistakes in new code. The bug rate is normally much less than 100%, so fixing bugs tends to introduce less bugs than the original code had, but new features throws away that progress.

    23. Re:Don't be lazy programmers by jma05 · · Score: 2

      > I call bullshit, and I'll put my decades of industry experience on that.

      I don't care for your claims of experience. I have been programming for decades as well.

      > Programmers need to fucking pay attention to what they're doing.

      Of course they do. "Attention" however has very weak reliability. This is a very well established fact by psychology studies.

      > There are no languages in the world that prevent the programmer from making serious structural mistakes.

      There are however programming languages that make mistakes much less likely - including structural mistakes. Don't you think Haskell does not provide more tools to express structure and prove safety than an assembler? I am going for extreme contrasts to illustrate the point.

      I find it amusing that programmers, of all people, the very people who are supposed to understand how tools make a difference, argue that they don't. The people who are supposed to ever build better and better tools, insist that whatever tools they made a learning investment in, argue that they don't need to be improved any further.

    24. Re:Don't be lazy programmers by Aighearach · · Score: 0

      The secret to writing unsafe code in C that doesn't blow up in your face:

      Use baby-C. Don't try to learn language features. Ever. Avoid becoming experienced; always code with the manual open.

      Another tip: Stop whining and just type it out long-form. Stop wishing for shortcuts.

    25. Re:Don't be lazy programmers by jma05 · · Score: 1

      Unfortunately, C and C++ are used heavily beyond the kernels and drivers.

    26. Re: Don't be lazy programmers by Anonymous Coward · · Score: 0

      rust is political correctness, c is the common sense way.

    27. Re:Don't be lazy programmers by gweihir · · Score: 1

      Dude, just search any software engineering journal. Unsafe languages make for more bugs. The design of the tool determines safety and performance as much as training, if not more.

      I read these papers. For a while. Then I stopped, because that is not actually what matters. Counting bugs is pretty worthless, even when you only do reliability and resilience. With security, it is basically completely meaningless. This is not the only area where counting-metrics give meaningless numbers.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    28. Re:Don't be lazy programmers by hey! · · Score: 4, Insightful

      You know what really sets mature adults apart from wet-behind-the-ears kids? They accept that they're fallible.

      Language safety got a bad reputation back in the 70s when I learned to program because language designers didn't know how to do it without getting in the way of ordinary work. So back then given a choice of K&R C or the Pascal dialects available, I'd have chosen K&R C because Pascal's strict type checking made common use-cases awkward. But there's absolutely no question that modern ANSI C's stricter type-safety makes it far better than K&R C.

      You can't rely on a language to do your job for you, but you can certainly rely on a language to make your job easier.

      --
      Post may contain irony: discontinue use if experiencing mood swings, nausea or elevated blood pressure.
    29. Re: Don't be lazy programmers by WaffleMonster · · Score: 1

      This is a ridiculous and terrible argument. The rest of the world advances both the tools and the education to make better systems that are more fault tolerant. The infrastructure in this world is built using better tools with what we learned from doing it the old way. You're asking for airplanes to be built only using hammers and screwdrivers instead of power tools and robots

      The problem I have with this line of thought is lack of apparent outcomes commensurate with claims.

      Obviously airplanes are built with modern technology using complex tooling. Some of the major assembly plants offer public tours where you can witness a small portion of it in action with your own eyes.

      If "C" is just hammers and screwdrivers where is the equivalent of the modern plant maximally leveraging technology to churn out airplanes that couldn't possibly be done with hammers and screwdrivers? It seems in 2018 every major operating system and associated technology stack that people actually use every day are written in some form of C. Why? How many decades have to pass before the typical inertia excuses exceed their sell by dates?

      If alternatives are so great ... where are the outcomes? Where can I buy a useful general purpose operating system that is inherently safe because it is written in (insert language here)? Where can I buy a usable web browser that isn't full of security holes? AAA games? Video and audio codecs? Network stacks? GPU stacks? RDBMS?

      Like aliens there is always an excuse for why these things never seem to materialize.

    30. Re:Don't be lazy programmers by Rick+Schumann · · Score: 1

      Apropos of nothing: yours is the lowest user ID I've ever had comment on one of my comments before; hail, Centurion! :-)

      I remember the first time I ever heard that some actual high-end commercial application software was written in BASIC; I think I almost fell on the floor laughing, thinking it was some sort of crude joke. Then imagine my face when I found out it wasn't a joke. :-/

    31. Re:Don't be lazy programmers by jma05 · · Score: 1

      > I can avoid "unsafe" things in C simply by imposing similar limits to limits Rust imposes on what I am allowed to do.

      Sure, except you can't do that reliably (you may think you do, that is not of consequence). Moving those rules from paper to software makes them enforced reliably.

      > Calling people lazy and stupid and suggesting that only if they do what you want them to do they won't be lazy and stupid is not a winning strategy for getting anyone to care.

      Read the post I was responding to. The OP was calling anyone who does not choose C to be "lazy, or just aren't educated enough". I simply turned it around.

    32. Re: Don't be lazy programmers by jma05 · · Score: 1

      > rust is political correctness

      Rust is machine correctness. The forums are more about political correctness.

      > c is the common sense way.

      Nothing common sense about it. People just think whatever makes sense to them is universal common sense. C is the least "correct" (in terms of software engineering safety/proving etc) high level language.

    33. Re: Don't be lazy programmers by Anonymous Coward · · Score: 0

      The declining popularity of C has nothing to do with the fact that it is unsafe; it is because all of the problems it was designed to solve have already been solved. By and large new software projects deal with Unicode, networking, graphics, user interfaces, sound, XML, and a ton of other things which are much more easily tackled in languages with built in support (or have well written libraries) for these.

      They could be done in C, but why would you do that? Itâ(TM)s like cutting down a redwood with a whittling knife.

    34. Re:Don't be lazy programmers by Rick+Schumann · · Score: 1

      If I already knew how to use C properly, already know better than to use uninitiallized pointers, not return heap space when I'm done with it, etc etc etc then why would I even need it?

    35. Re:Don't be lazy programmers by Anonymous Coward · · Score: 0

      *SMACK!*

      Yeowch, that looked painful, glad *I* wasn't on the receiving end of that!

    36. Re:Don't be lazy programmers by Rick+Schumann · · Score: 1

      By your logic we shouldn't be able to have anything as complex and large as Windows or Linux (or even larger works than those) without them leaving a heap of molten slag where the computer they were run on was sitting. Are you a programmer? Jaded and cynical more than a little? I can understand, but take as step back and give some people more credit than you're giving them, maybe?

    37. Re:Don't be lazy programmers by Rick+Schumann · · Score: 1

      Back when my non-work-hours hobby was sitting there all night long writing software for one project or another of mine, everything I did was in C, and I managed to not melt the computer into a heap of slag on the desk in the process. Guess I lucked out. xD

    38. Re:Don't be lazy programmers by Anonymous Coward · · Score: 0

      I've spent an entire career with C, and I'm more than happy to say that it's the most dangerous programming language I've ever used. 'C' is a loaded and cocked handgun; in the hands of an experienced, trained user it only occasionally causes accidental deaths.
      I still remember the project where every function call was indirect through a function pointer (OK, quick test: Write a syntactically valid C prototype for a pointer to a function that takes a pointer to a function as a parameter, and returns a pointer to a function that returns an integer. Then call it, and call the returned function pointer). That's about as dangerous as it gets. But, remarkably, 99% of our bugs didn't have to do with the function pointers - they were run-of-the-mill bugs, improper handling of external input, race conditions, uninitialized (or badly reinitialized) variables, etc. But no other language would have enabled us to do what we needed to do.

    39. Re: Don't be lazy programmers by Anonymous Coward · · Score: 0

      "C is the least "correct" (in terms of software engineering safety/proving etc) high level language."

      No, it is the most correct. You are forced to actually THINK when you code in C. If you don't have to think, then it's essentially idiot technology.

    40. Re:Don't be lazy programmers by Rick+Schumann · · Score: 1

      Sure I haven't, buddy. Never mind that this book was where I taught myself C, back in the early 90's.
      You got room in your mouth for the other foot? Help yourself.

    41. Re:Don't be lazy programmers by Rick+Schumann · · Score: 1

      Actually just remembered: I've got FIRST edition of that, still, not SECOND edition. My bad.

    42. Re: Don't be lazy programmers by Rick+Schumann · · Score: 1

      Gee I wonder what this 'Rust' everyone keeps mentioning was written in? xD

    43. Re:Don't be lazy programmers by theweatherelectric · · Score: 1

      you can write entire operating systems in it

      You can write entire operating systems in many languages. C\C++ isn't special in this regard.

    44. Re:Don't be lazy programmers by Anonymous Coward · · Score: 0

      Sure, except you can't do that reliably (you may think you do, that is not of consequence). Moving those rules from paper to software makes them enforced reliably.

      Of course such limits must be automated and I very much advocate for the availability of such tools. Quite a lot of really good tooling already exists.

      Personally what I really want is for a software to constrain me into paths that can be systematically verified by machine and help to visualize paths that would render such checking computationally infeasible. Obviously there are cases where this can't work but it can for the most part because I do this manually anyway.

      Personally I use low level languages but don't typically care about normal stack/buffer shit because I use only inherently safe functions to manipulate resources. Functions provide such guarantees so long as they and only they are used to manipulate resource. The underlying function or hardware would have to be defective to expose risk and I'm cool with that.

      My own personal opinion is that language itself is an irrelevant syntactic shell game. It's what's on top of it and tooling around it that makes or breaks a system. If all of the stack/buffer shit went away overnight very little would actually change in terms of threats and systems security outcomes generally. Currently in excess of 90% of compromises are achieved by exploiting people rather than software defects.

    45. Re:Don't be lazy programmers by EmeraldBot · · Score: 2

      Sounds like one hell of an asshole professor. Reminds me of those managers who insist on using whatever JS trend is in vogue rather then what's actually appropriate for the job, just trades out the willful ignorance for self-centered edginess. Honestly, the amount of selfishness it takes to potentially screw over his student's academic schedules just to fulfill his own self-importance about a programming language, which isn't even fundamentally part of the course, is just astounding to me.

      --
      "Set a man a fire, he'll be warm for the rest of the night. Set a man afire, he'll be warm for the rest of his life."
    46. Re:Don't be lazy programmers by jma05 · · Score: 2

      > give some people more credit than you're giving them

      Hey, I am not the one insulting people - OP thinks only C programmers are adults and the rest are children. I am saying that people are not that different. We all make mistakes.

      > Jaded and cynical more than a little?

      From psychology studies. I place low trust on human actors in any system. This is an empirically supported position.

      > By your logic we shouldn't be able to have anything as complex and large as Windows or Linux

      Not at all. C is intentionally unsafe by design, delegating that responsibility to humans. For specific projects, this is a rational choice (kernels, drivers etc). For many others, it isn't. Look, I don't want my Office Suite to be written in C# either.

      C programmers do catch obvious bugs immediately and things seemingly run fine. They catch some more using code analyzers and reviews. But it is a matter of record that most programmers don't have extensive training in writing secure code, including C programmers who may think they write good secure code. At one point, Microsoft had company-wide drives to teach security to its programmers and made certain books required reading.

      Popular public projects like Linux get a lot of audits and MS can afford such for its own. But much of C code in the wild does not have this. And whenever they are conducted, it is usual to find bugs that simply don't happen in other languages.

      I am saying that C should be regarded as a special tool, not as the default tool. There wasn't much choice 20 years ago, but the alternatives are increasingly attractive. The performance penalties for increased safety are quite minuscule now.

    47. Re:Don't be lazy programmers by jma05 · · Score: 1

      Who is talking about melting computers?
      I am talking about bugs and security holes.

    48. Re:Don't be lazy programmers by Anonymous Coward · · Score: 0

      Yeah, Missouri Life Flight had some gal who wrote their system in BASIC. It of course bogged and died regularly as the services increased and they wanted someone to fix that. However, they insisted it not be done in other than BASIC. I gave it a hard pass.

      It has since been replaced.

    49. Re:Don't be lazy programmers by Durrik · · Score: 1

      I blame Moore's Law and smaller transistors. And that might end sooner rather than later.

      Most coders get to deal with fast processors, fast ram, and its always getting faster and faster. So sloppy programming can be covered with more overhead provided in more recent languages. Java & C# don't really have the concepts of memory allocation and clean up, that's all handled by the overhead. Python & Perl and other similar languages don't even need to worry about what types are passing through the system. Its all handled by the overhead.

      I'm from an old school of programming. I can barely tolerate Java & C#. I've been poisoned by C/C++ and assembly. I always have to know when memory is allocated and when it is deallocated. I always have to know when something goes from memory to cache and into registers. I always have to know how much memory a chunk of data takes up. How it flows through the processor. I start to twitch when I try to use a typeless language, because I was trained to know where everything is in memory, and to always clean up after yourself. I can't trust the compiler or run time to do it right. Why? Because I can't see the bits in memory, or toss a logic analyzer onto the memory bus and see what is going on.

      Recent machines give the power to wrap recent programmers in bubble wrap. C/C++ gives programmers enough rope to hang themselves and will jerk on the rope if they aren't careful. But with C/C++ you can tune things down to sub microseconds in your drivers (which I've done). I don't think you can expect the same determinism with more recent languages, not with runtimes that can randomly garbage collect or other overhead things.

      I deal with embedded parts, microcontrollers, with fixed RAM and Flash and cycles. I can't rely on the overhead to cover my ass. I just don't have the resources to do it. I think that when processor efficiency improvements start to slow down that coding will slowly turn back to less overhead as the software will have to make up the speed differences that the hardware can no longer provide. I saw that when I was programming for game consoles. When a new generation of consoles came the code was sloppy, but as the console cycle went on the code needed to get more and more optimized, the sloppiness needed to go as customers always demand more.

      I'm waiting for the new optimization wars to start. I'll be happily sitting back in my rocking chair with my lemonaid and popcorn as a new generation of coders have to fight for microseconds like I did. I'll probably be retired before physics really starts to impact performance efficiency enhancements.

      --
      Software Engineer & Writer of Military Science Fiction and Fantasy Blog: petermwright.com Twitter: WrightPeterM
    50. Re:Don't be lazy programmers by jma05 · · Score: 2

      > IME nothing creates a security hole faster than the programmer thinking that just choosing Virtuous tools will somehow protect them from making mistakes.

      To me, that would be like arguing that we should not have guard rails because they will make people complacent or that seat belts might make people drive recklessly or that if we make smoking expensive or inconvenient, people will still get cancers by other means.

      Of course, there will always be the case of automation complacency and there will be other ways to make errors. But generally, safety features do increase safety. They may not solve everything, but the net effects are quite clear.

    51. Re:Don't be lazy programmers by William+Baric · · Score: 1

      Remember Ada or the multitude of languages that wanted to "human proof" programming? Why do you think Rust is different? Why do you reject Ada?

    52. Re:Don't be lazy programmers by Anonymous Coward · · Score: 0

      OK, so which OS would you suggest we examine?

    53. Re: Don't be lazy programmers by DamnOregonian · · Score: 1

      I think sometimes people lose sight of the base of it all.
      No matter how you swing it, eventually somewhere in that manufacturing chain, someone had to build something with hammers and screwdrivers, thus it is with C.
      My perspective is probably skewed because I have written a lot of code to run directly on bare hardware with no runtime or operating system. I find myself wondering how I'm supposed to access memory-mapped registers "safely" when the idea of void pointers and uninitialized variables are the devil. How I'm supposed to write code that deals with bootstrapping a processor's MMU. How I'm supposed to write an interrupt handler when different processors have different requirements for ISR stacks.
      Writing software in that domain isn't well suited to any tool that thinks it can define what "safety" is for all platforms.

      That being said, I definitely think writing larger programs at higher layers seems a little bit quixotic in this day and age when done in C, unless you need to be ridiculously performant, for example, something like DPDK where your goal is to process network packets at the highest conceivable speed.

      For the same reason we still have hammers and screwdrivers, the world will continue to need C.
      For the people who have the luxury of working on a project where they can use table saws with fancy arresting devices that prevent them from chopping their fingers off- that's awesome. For the people building watches, quit trying to tell them what kind of tool they should be using when you have no fucking idea what they even do.

    54. Re:Don't be lazy programmers by jma05 · · Score: 1

      I would expect every professional C programmer to know these things and they follow these cautions most of the time, expect when they don't.
      The issue is not not knowing. It is about human lapses. Following rules are what computers are good for and humans aren't.

    55. Re:Don't be lazy programmers by religionofpeas · · Score: 1

      > Well, you sure as heck don't want to use something like R for that, the class would be too easy

      You say that like it's a bad thing. If people solving real life problems use 'R', then it should also be used in the classroom. If that makes the class easy, then give them more advanced problems.

    56. Re:Don't be lazy programmers by Tom · · Score: 1

      I think it more likely that programmers have become lazy, or just aren't educated enough to be responsible with a powerful programming language

      Sadly, that isn't true.

      I was the course assistant for the C programming lab back in my university days, and that was in the 90s. I hope that I taught everyone lessons in input validation, but some of those teams I sent back a dozen times (no kidding) because I could make their code crash with unexpected input. Not a number - crash. Negative number - crash. Zero - crash. Buffer overflow - crash. And so on.

      It isn't new that programmers are lazy. The core flaw of teaching programming is that you are being taught to make it work. Not to make it right.

      --
      Assorted stuff I do sometimes: Lemuria.org
    57. Re:Don't be lazy programmers by Anonymous Coward · · Score: 0

      Fyi, the fact you cut your teeth on the 1st edition C bible does not invalidate UnknownSoldier's claim that you're still effectively a C newbie if you aren't aware that almost everyone industry thinks both C and C++ are extremely dangerous. And actually, if programming in (or managing programmers for) C or C++ is part of your day job, then you're actually a danger to everyone else if you're not aware of the dangers hidden in the languages. I assume your ignorance on this matter actually means that you don't use either language regularly.

      p.s. Languages like Rust and D were created in an attempt to provide the same low level performance with less danger.

    58. Re:Don't be lazy programmers by Anonymous Coward · · Score: 0

      typedef int (*intFnPtr)();
      typedef void (*voidFnPtr)();
      typedef intFnPtr (*yourFunction)(voidFnPtr);

      void Test(){}
      int InnerTest(){ return 2; }

      intFnPtr TestImpl(voidFnPtr xyz) {
            return InnerTest;
      }

      int main(){
              voidFnPtr x = Test;
                      yourFunction y = TestImpl;
                      intFnPtr z = y(x);
                      printf("%d\n", z());
                      return 0;
      } //There you go! In case someone wants to answer that question

    59. Re: Don't be lazy programmers by jma05 · · Score: 1

      Absurd reasoning. Use assembler or machine code then. It will make you think even more.

      The point of using a tool that takes care of mundane problems is that you take your biologically constrained mental capacity and apply it more effectively to other aspects of the problem.

      The lower-level tool you use, the more limited you are from solving problems that need higher abstractions. You will just be caught up in the plumbing details.

    60. Re:Don't be lazy programmers by theweatherelectric · · Score: 1

      Try a couple Pascal ones such as Toro or Ultibo. Or try a couple of Rust ones such as Redox or Nebulet. OSDev is a good resource for operating system starting points in various languages. You can take one of their bare bones OS examples and build from there.

    61. Re:Don't be lazy programmers by Ultra64 · · Score: 1

      Get off your high six digit horse.

    62. Re: Don't be lazy programmers by theweatherelectric · · Score: 1

      OCaml originally, but Rust is now self-hosting.

    63. Re:Don't be lazy programmers by Anonymous Coward · · Score: 0

      lol "hardcore" man

      you using C?
      - yeah.
      holy shit man, you bad motherfucker
      - thats how we roll baby dont play the game if you cant stand the heat

    64. Re: Don't be lazy programmers by Anonymous Coward · · Score: 1

      The Rust compiler is written in Rust. It has been self hosting since since 2011.

      Well, except it use LLVM to do all the hard work of optimization and code generation for multiple targets. Which is written in C/C++...

    65. Re:Don't be lazy programmers by Anonymous Coward · · Score: 0

      Heartbleed: https://www.theregister.co.uk/2014/04/09/heartbleed_explained

      Holes in SSH https://www.cvedetails.com/vulnerability-list/vendor_id-120/product_id-202/SSH-SSH.html

      There are millions of other such vulnerabilities that have been found in C programs over the years.

      Google can find them for you.
       

    66. Re:Don't be lazy programmers by Uecker · · Score: 1

      I don't think there is a fundamental trade-off.

      All the undefined behavior in C can be used for a compiler to optimize the code and then fail horribly if the undefined behavior is triggered at run-time. Alternatively, compilers could just insert runtime checks. To some degree this can be done with the undefined-behavior sanitizer. So a language with a lot of undefined behavior such as C can be both: relatively safe or fast depending on the compiler options. In the past, the later option has been neglected by compiler writers but this is changing.

      There are some deficiencies in C which I think can be fixed by adding a couple of minor features (e.g. certain attributes which can provide information for static analysis). The biggest problem in my opinion is that the standard library is so small, so programmers often write there own open-coded alternatives which then tend to be buddy and unsafe instead where other languages offer well-defined APIs and carefully implemented algorithms.

    67. Re: Don't be lazy programmers by jd · · Score: 1

      The developers of FRAMA-C, the Verified Software Toolchain and the SEL4 operating system disagree.

      Why should I take your word over the experts?

      --
      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)
    68. Re: Don't be lazy programmers by jd · · Score: 1

      Then how come I can use formal methods with C (the ultimate test of correctness) but not Rust?

      --
      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)
    69. Re: Don't be lazy programmers by theweatherelectric · · Score: 1

      Don't worry. There's a Rust Verification working group aimed at developing formal verification methods for Rust. See also RustBelt.

    70. Re: Don't be lazy programmers by jd · · Score: 1

      That's why we have NASA's Power of Ten, formal methods, coloured Petri nets, implementing to test harnesses, mock objects, FRAMA-C, Why3, Verified C and documentation.

      Programmers can use one or more of these, to develop code that's as good as they want it to be. You don't have to use all of those methods, proper use of any one would suffice in many cases.

      Programmers are either psychologically primed, through inept schooling or hostile management, to avoid these. Schooling and management aren't affected by the language you choose. If they're unfit for purpose, they'll remain so whatever the language.

      Can't do much about schools people have finished with, but management is another matter. Bad management can be disciplined. Individually, we can't pull a Feynman, we have to start thinking a bit more collectively.

      As long as we squabble like rats, managers will treat us like rats and the code will look like it's a nest for rats.

      --
      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)
    71. Re: Don't be lazy programmers by jd · · Score: 1

      Ada is interesting, as is Spark (the secure subset). What do you think of Eiffel?

      I am trying to get Occam-Pi working. Had no luck tracking down Guppy, Occam's successor. That, too, has a place in the world.

      --
      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)
    72. Re: Don't be lazy programmers by jd · · Score: 1

      So you're saying the authors of SEL4 chose the wrong language or paid attention to the wrong details?

      Fine. Using their abstract theorems as your starting point, write an OS in, say, Rust or Nim that has equal or superior performance that complies with the same theorems.

      If you can't, or the man-hours effort required would match or exceed those expended by the developers on the code alone, then I postulate they paid attention to the right details.

      --
      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)
    73. Re:Don't be lazy programmers by Anonymous Coward · · Score: 0

      He replied to your " I've never heard anyone refer to C/C++ as 'dangerous' before" which is an obvious nonsense. So your "I taught" and "got FIRST" self-patting is just ridiculous.

    74. Re: Don't be lazy programmers by jd · · Score: 1

      I see limited evidence of a trade-off.

      There are things in C11 that are missing in Verified C.

      There are things in C11 you are advised against using under the CERT Secure Programming standards, MISRA and JSF.

      Most of the tasks can still be done, they just have to be done differently, which is why the trade-off is only limited. If you can still solve the problem, just with different syntax, then the trade-off is not in capability but in expediency. That just requires a library of helper routines and I'm sure you can find those.

      --
      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)
    75. Re: Don't be lazy programmers by jd · · Score: 1

      Strict type checking isn't all bad, as long as the code is properly designed and you write the test procedures first.

      The problem is that schools and industry discourage testing, minimalize it and place it last - usually after deployment. As for design... hah!

      --
      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)
    76. Re:Don't be lazy programmers by serviscope_minor · · Score: 1

      I think it more likely that programmers have become lazy

      Many of the best programmers are the laziest for the right kind of brutally applied laziness.

      Never solve the same problem twice.

      --
      SJW n. One who posts facts.
    77. Re:Don't be lazy programmers by serviscope_minor · · Score: 1

      You know what really sets mature adults apart from wet-behind-the-ears kids? They accept that they're fallible.

      You can't rely on a language to do your job for you, but you can certainly rely on a language to make your job easier.

      Yes. 100% this. Sub thread over. If you disagree with the parent then you are (a) wrong and (b) a menace behind a keyboard.

      --
      SJW n. One who posts facts.
    78. Re:Don't be lazy programmers by Raenex · · Score: 1

      Unfortunately, the believers in silver bullets will not die out.

      Unfortunately, the believers in the mythical "better programmer" solution will not die out.

    79. Re: Don't be lazy programmers by jd · · Score: 1

      And now you're going to compare them against SEL4, FreeRTOS, Linux and OpenBSD?

      No comparison on defect density, security, performance and features means that for all we know those choices you offer are toys. You don't have to produce the comparison, a link is fine. Someone has to have shown that these OS' are worth it.

      --
      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)
    80. Re: Don't be lazy programmers by jd · · Score: 1

      +6 Insightful.

      I was taught many of the rules that were eventually compiled into NASA's Power of Ten, which I'd consider a minimal set of principles, but neither schools nor industry emphasize or enforce code quality.

      --
      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)
    81. Re: Don't be lazy programmers by theweatherelectric · · Score: 1

      Reread the thread. The claim was that C\C++ is somehow special because "you can write entire operating systems in it". In reality many languages can achieve the same things as C\C++, such as operating system development. We're comparing languages, not operating systems.

    82. Re: Don't be lazy programmers by Raenex · · Score: 1

      I find myself wondering how I'm supposed to access memory-mapped registers "safely" when the idea of void pointers and uninitialized variables are the devil. How I'm supposed to write code that deals with bootstrapping a processor's MMU. How I'm supposed to write an interrupt handler when different processors have different requirements for ISR stacks.
      Writing software in that domain isn't well suited to any tool that thinks it can define what "safety" is for all platforms.

      Might want to check out Redox. I saw this mentioned elsewhere in the comments. I don't have any personal experience with it, but it looks like they've come pretty far.

      PS: The concept behind Rust is to keep your unsafe areas clearly marked as such. Presumably not every piece of code needs to do unsafe things. The Linux kernel has over 10 million lines of code.

    83. Re: Don't be lazy programmers by jd · · Score: 1

      Good. I approve. But until it's there, I can provide quality controls in C that aren't in Rust.

      I absolutely applaud bringing Rust to the formal methods table. They talk of unsafe Rust and there's only one way to find out if any given Rust is unsafe (unless it's something trivial like a dangerous instruction).

      Until there is hard evidence as to what actually is unsafe, in terms of more complex constructs, arguments over language safety are speculative.

      I actually use Rust (and C and Ada, Occam, Java...) but I am very careful over boasts. I might well help out the project you mentioned.

      It shouldn't be hard to make CPN Tools output Rust code, and then you could design state machines, but not sure if that would be accepted. It would still be helpful.

      --
      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)
    84. Re:Don't be lazy programmers by lucasnate1 · · Score: 1

      I am not a lazy programmer, and because I am not a lazy programmer, I use a computer as it was meant, as a tool to reduce work from humans. Manually checking everything and being proud of it, even when it gives no major speed benefit, is not being hard working, it is being mentally lazy.

    85. Re:Don't be lazy programmers by angel'o'sphere · · Score: 1

      'Sanitizing' it, 'child proofing' it would take away that power and make it useless.
      And yet the article is about writing sanitized C code, so that the kernel is kinda "child proof".

      It seems you simply don't get it ...

      I think it more likely that programmers have become lazy, or just aren't educated enough to be responsible with a powerful programming language, and as a result we end up seeing code that's sloppy, ill-behaved, and 'dangerous' because of it.
      Programmers make assumptions. Those assumptions can be wrong.

      e.g. there is nothing inherently dangerous, lazy or sloppy with the following code.

      char* strcpy(char* dest, char* src) {
          while (*dest++ = *src++)
              ;
            return *dest;
      }

      However the assumption that that code will always be called with a 0 terminated string, or that dest will point to enough memory, might not hold.

      So if we talk about the library function above, the sloppy code might be the caller ... but calling him lazy is most likely wrong.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    86. Re:Don't be lazy programmers by angel'o'sphere · · Score: 1

      Well,
      for Numerical Linear Algebra classes I had suggested Fortran, or indeed Pascal. Using C makes not much sense. It only makes people fail the class, because they have to spent more time focusing on C than focusing on Numerical Linear Algebra.
      It is like going to a driving class and the instructor demands you learn swimming first in case you drop the car into a river ...

      We did stuff like numerical algebra and stochastic: on paper! And still about 50% of the students failed the classes. If we would have needed to use C, 99% probably had failed (at least if compiling and correctly running programs would have been expected).

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    87. Re: Don't be lazy programmers by Anonymous Coward · · Score: 0

      The one thing that could be done (and was done in the past), was to allow each thread to sandbox the areas of memory that it was working with.

      You mean like a MMU protected virtual memory sandbox that cant overwrite the memory of another process without explicit shared memory requests.

      Gee whiz sir. You've just reinvented the modern process model.

      It's too bad that most modern programmers didnt grow up with the Unix philosophy and that Windows made IPC difficult and slow once upon a time.

      So now we have the heavy concurrency using threads in a shared memory space with all the issues arising from that.

    88. Re:Don't be lazy programmers by garlicbread2 · · Score: 1

      Typically different languages are engineered towards different purposes
      High level languages are good for quick scripts or GUI Applications
      Low level languages are good for speed, drivers, getting as close to the bare metal as possible.

      That being said It is possible to get both the benifits of a low level language and checking of code by the compiler at the same time.
      C / C++ was designed a long time ago, long before the internet and before a lot of tools, methodologies and ideas which are now available.
      The problem is making changes to it now isn't a possibility simply because of old cruft / backwards compatibility.
      I know quite a few here have suggested Rust, although my favourite is DLang - https://dlang.org/ since it more closely resembles C / C++
      They seem to have solved a lot of problems recently associated with the runtime, in that you can now more easily replace it with your own implementation.

    89. Re:Don't be lazy programmers by angel'o'sphere · · Score: 1

      Pro Tip: If you mostly studied Java in college, you should go back to your alma mater and ask for a refund. No, seriously.
      Why? If you only work with Java (or C#) then extended knowledge about C, Fortran etc. is most likely not required for any Job such a person ever will apply, too.
      On the other hand, in a typical university in Germany you cover half a dozen languages anyway. But what good is it to torture students with Lisp and Prolog when they never will use it in a job either? Sure, those things are interesting, especially if you are aiming for an academic career.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    90. Re: Don't be lazy programmers by jd · · Score: 1

      My point is that the languages are not equivalent if you cannot provide the same proofs of correctness, the same hard real-time guarantees, the same compactness, the same level of performance and the same underlying capabilities.

      This isn't about operating systems, this is about language equivalence.

      In mathematics, equivalent isn't the same as equal. If you can't match SEL4's proofs, you can't claim the same or better defect density and you can't claim the software satisfies the design constraints. All you can do is test and claim that it's not failed so far. Those aren't the same thing.

      If you can't write a hard real time OS that can guarantee that the start and end deadlines are satisfied at least as well as the best of those I've listed, your underlying language is not equivalent. It cannot do the same things done in C/C++. There's latency and latency is an often ignored factor in programming.

      If you can't put your OS onto an FPGA, it lacks the compactness that is possible in C. Space is another ignored factor, owing to most environments being huge. In fact, as SystemC is a C dialect, I can compile an OS onto an ASIC. Can you do likewise?

      Performance isn't just about latency. It's about efficiency. Occam is far more efficient than C, at a lot of things, and should be the ideal language for an OS. But because it relies on certain properties being static, it's very inefficient at highly dynamic loads. I love Occam but you'd need to modify it to run Linux as well as C despite it being a bettera language. I have seen claims Rust would be better, but no evidence. I'm offering the chance for you to show me some.

      Underlying capabilities. C is happy with me using RDMA to transfer data directly into my program without the program knowing about it. The whole point of Java is the sandbox, RDMA would negate it. In C, I can switch processor rings and put data directly onto the PCIe or PCI-X bus, edit the contents of flash memory chips and upload new microcode to fix yet another defect in silicon. I can write code for managing the hot-swapping of CPUs or memory. Can I do all this in Rust?

      If there's anything I can't do in this list in Rust, it can be an excellent language (it is) but it's clearly not able to reimplement feature-for-feature the operating systems I've listed.

      --
      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)
    91. Re:Don't be lazy programmers by angel'o'sphere · · Score: 1

      I know two people, one a man and one a woman, who have the strange talent to crash plenty of programs.

      The man would somehow systematically put unusual input into input fields, like $name into a field that accepts a string as first name, and would of course put random special chars into a numeric field etc. I don't even know how you can write code that crashs in such circumstances (obviously not being able to parse a number might led crashes, though)

      The woman would simply open dialogs, close them again, click on random buttons, even disabled ones ... and suddenly produce a crash. She never kept track what she did, so they only let her "test" with a debugger attached ... (I guess she most likely produced memory leaks in GUI apps, that did not clean up "closed dialogs" etc.)

      Anyway, it was quite funny, everyone dreaded them instead of thinking why their code is so bad that it crashed in the first 5 minutes when one one of those two touched the program.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    92. Re:Don't be lazy programmers by phantomfive · · Score: 1

      Haha that's the first time I ever heard of Microsoft Basic as a 4G language. They must have been marketing it that way or something.

      --
      "First they came for the slanderers and i said nothing."
    93. Re:Don't be lazy programmers by phantomfive · · Score: 3, Interesting

      I wonder if C or another language could not rely on API's or API-like expansion macros. A given shop would select the API's that fit its trade-off profile. If you wanted to skip pre-initialization for speed, you'd use the skipping version of an initializer API. And on the flip side, don't include the non-init API in the shop stack if you don't want accidental naked bits.

      I worked for a company that did something similar......they wrote their own version of malloc() etc to avoid memory leaks. About a year after I started working there, the Javascript coders had to spend several weeks fixing all the memory leaks in their code. The C coders had none. Ignoring the problem doesn't make it go away.

      --
      "First they came for the slanderers and i said nothing."
    94. Re:Don't be lazy programmers by angel'o'sphere · · Score: 1

      Well,

      lets roll back time 20 years, just before the advent of Java.

      The simple rule of thump was that a competent programmer, will write about X lines of code during a day. Researchers distinguished between 3 kinds of programs or code:
      a) Application Code, e.g. a game like nethack, a mail or news client etc.
      b) Utility Code, e.g. a command like vi or ls, or even cc
      c) System Code, aka Kernel or Drivers

      The interesting thing is how does X look for a), b) and c)
      a) was something like 25 - 100 LOC/d
      b) was something like 5 - 25 LOC/d
      c) was less than one LOC/d

      And now the interesting point comes: this numbers are nearly independent from the language used. Obviously 25 lines of C have less functionality than 25 lines of LISP, and 25 lines of assembly have even less functionality than C. Languages like SmallTalk and ML or OCaml express even more functionality.

      Now think how much "functionality" you can express in 25 lines of SQL.

      I went 20 years back, because modern IDEs, for languages like Java and C#, blur this extremely. Or all the stuff you can do with annotations.

      Anyway, higher abstractions, and that is what Java versus C is, yield higher productivity. Partly in exchange for raw speed, but if people know what they do, there is usually no big difference. And you expect people to know what they do, regardless of language, right?

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    95. Re: Don't be lazy programmers by theweatherelectric · · Score: 1

      I'm offering the chance for you to show me some.

      Gosh, I'm ever so grateful. If you want a Rust-based operating system on small hardware, try Tock. Read some papers on it.

    96. Re:Don't be lazy programmers by Anonymous Coward · · Score: 0

      We're all lazy children to a certain degree. There is no good reason for a language to not make safe defaults (bounds checking, no multithreaded access to read/write data etc etc) easier to express than dangerous code, or to not put the dangerous code behind unsafe keywords so those sections are easily identified for extra review.

      There is only inertia and illusion of control ... C programmers are the motor cycle drivers of programming.

    97. Re:Don't be lazy programmers by Anonymous Coward · · Score: 0

      Bullshit. Some of it won't be able to use bounds checking for performance reasons, you won't know which parts till you profile it. Some of it implements primitives which need to be implemented with unsafe code, most of the code only uses those primitives though.

      A ton of the code in the kernel can be bounds checked with negligible performance impact and doesn't need unrestricted shared memory.

    98. Re:Don't be lazy programmers by jma05 · · Score: 1

      I recall reading similar old research that a programmer can reliably maintain just around 10K LOC, regardless of the language.
      I am not sure how that number is effected by tool factors. I haven't looked up newer research either.
      This is the case for productivity.

      Wonder what the results were for safety.
      I would expect Ada or Eiffel, which had more safety features to be less bug prone than say, C++98. But this is to be determined empirically since the results can be counter-intuitive.

      Haskell should not have much in runtime errors once it compiles. OCaml and Rust should be a little less reliable since they are not pure. I wonder how Mozilla fared on bug counts with Quantum, relative to their earlier C++ implementation.

    99. Re:Don't be lazy programmers by phantomfive · · Score: 1

      The core flaw of teaching programming is that you are being taught to make it work. Not to make it right.

      That's basically what Dijksktra was trying to change.

      --
      "First they came for the slanderers and i said nothing."
    100. Re:Don't be lazy programmers by jeremyp · · Score: 1

      You've got decades of industry experience and yet you still think that it is reasonable to expect programmers to always pay attention to what they are doing.

      A lot of the worst security bugs don't come from "serious structural mistakes" but from things like assuming a buffer is bigger than its really is or the type of a thing pointed to has a certain format and various other trivial looking issues that could be detected by using a modern language with a good compiler.

      --
      All I want is a secure system where it's easy to do anything I want. Is that too much to ask ~~ Randall Munroe
    101. Re:Don't be lazy programmers by Anonymous Coward · · Score: 0

      There's no silver bullet, but this will get you 99% of the way:

      1. Know your language and tools
      2. Know your problem domain
      3. Read "Writing Solid Code" by Steve Maguire
      4. Test-driven development

    102. Re:Don't be lazy programmers by Anonymous Coward · · Score: 0

      Not really. A relatively small portion of the kernel would have to be unsafe. Just some of the weird little data structures like list, and various network buffers, and the memory management parts, and obviously low level arch and mach support. Most of the drivers, bus core, etc. could all be written in safe rust.
      The big problem (besides completely rewriting everything) is that rust is slow as fuck to compile even a small program.
      Compiling something the size of the kernel would take forever.

    103. Re: Don't be lazy programmers by mikael · · Score: 1

      This was memory mapping at the class object / structure level / lightweight thread level, not the heavyweight process level.

      --
      Vintage computer adverts: http://www.vintageadbrowser.com/computers-and-software-ads
    104. Re:Don't be lazy programmers by Anonymous Coward · · Score: 0

      You've got decades of industry experience and yet you still think that it is reasonable to expect programmers to always pay attention to what they are doing.

      Well, that is what they're paid for...

    105. Re:Don't be lazy programmers by lucasnate1 · · Score: 1

      But what good is it to torture students with Lisp and Prolog when they never will use it in a job either

      A university is not a trade school.

    106. Re: Don't be lazy programmers by drinkypoo · · Score: 1

      Occam already killed the transputer, don't let it kill your project too.

      --
      "You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
    107. Re: Don't be lazy programmers by Anonymous Coward · · Score: 0

      Wow! You're hired!!

    108. Re:Don't be lazy programmers by spongman · · Score: 1

      FYI. Windows is written in C++. Not modern C++, but C++ nonetheless (no exceptions, RTTI, std, few templates)

    109. Re:Don't be lazy programmers by spongman · · Score: 1

      Why not C++? Seriously. You can disable exceptions, RTTI, audit template usage and still get tons of benifits from the language that's missing from C.

    110. Re:Don't be lazy programmers by Anonymous Coward · · Score: 0

      > A university is not a trade school

      Maybe not for liberal arts majors. For engineers and pretty much everyone else, it bloody well is.

    111. Re:Don't be lazy programmers by angel'o'sphere · · Score: 1

      And?

      If you don't get a good grade in an unrelated topic in a trade school, no one cares.

      If you get a bad grade in a mandatory, but completely unimportant class in university, it reflects on your diploma grade. Would you rather hire one with an A or an B? And how would it influence you if you knew the B was because of unrelated topics? I mean for a highschool diploma in Germany some people pick religion, art and music (or whatever) because they get a guaranteed A in it. Then they go and study some business administration at an university that requires an A in the diploma. What is the point of that? For an BA I would expect two or three foreign languages, math skills and perhaps another science. But certainly I don't care about his gradse in sports or religion.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    112. Re:Don't be lazy programmers by Anonymous Coward · · Score: 0

      I've been poisoned by C/C++ and assembly. ... I start to twitch when I try to use a typeless language

      I find that a curious juxtaposition, because IMO one of the biggest weaknesses of C and assembly is that they are essentially typeless. It's possible to write type-safe C if you heavily restrict casts, eliminate void *, eliminate union types, ... But then would you still want to use it?

    113. Re:Don't be lazy programmers by spikeysnack · · Score: 0

      100% correct.

    114. Re: Don't be lazy programmers by DamnOregonian · · Score: 1

      PS: The concept behind Rust is to keep your unsafe areas clearly marked as such. Presumably not every piece of code needs to do unsafe things. The Linux kernel has over 10 million lines of code.

      I don't disagree with you, here.
      There are certainly subsystems that can be cordoned off to be written in a safer language. OSX does this with their DriverKit stuff.
      One could, if they wanted, implement parts of the kernel in a safer language, but many parts of it will simply always need to be done in C.

      Redox is a good example, look at the low-level parts like the bootloader.
      What was the point of writing it in an esoteric safe language when literally 95% of the lines in that section are marked unsafe?

      It would have been cleaner and easier to read in C.

    115. Re:Don't be lazy programmers by gweihir · · Score: 1

      Ada is a complex mess that has long ago started being a huge problem. Eiffel is really nice, but only if you write good contracts for the Design-by-Contract part. That is time consuming and often really hard and probably negates the positive aspects with most coders (the majority is bad at it) on the market today.

      Also, contracts do not eliminate bugs. They just allow detection at run-time (as long as the contracts do not have the same bugs) if you actually get test-coverage. I found that DbC works very well for things like complex data structures that you then can simply fuzz over a weekend and basically end up bug-free. But the same you can do by having a slow, safe implementation in a language well-suited for prototyping (say, Python) and the actual optimized target-implementation (say, C) and just comparing them on a randomized sequence of operations for a while. Still, you need good test-cases or that effort is worthless. As soon as you have an external part of the system (Database server, web-server or client, etc.) DbC becomes far less effective during development and the biggest advantage is that you get a nice trace with contract violations when things go south in use.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    116. Re:Don't be lazy programmers by Anonymous Coward · · Score: 0

      Fuck Rust. Seriously.

      Huh? Why would you not want an extra tool in your tool chest?

      I too have decades of programming experience, using many languages. I make a point to always be learning something new. Rust is on my TODO list.

    117. Re:Don't be lazy programmers by gweihir · · Score: 1

      That explains a lot.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    118. Re:Don't be lazy programmers by yet+another+SanTiago · · Score: 1

      Checked first 5 holes in SSH in the list you mentioned, all of them seems like semantic errors that would not be prevented by Rust.

    119. Re: Don't be lazy programmers by Raenex · · Score: 1

      Redox is a good example, look at the low-level parts like the bootloader.
      What was the point of writing it in an esoteric safe language when literally 95% of the lines in that section are marked unsafe?

      It would have been cleaner and easier to read in C.

      Presumably Rust provides other benefits over C, like modules. Also, I imagine you're going to have other parts of the code that are more like a 50/50 safe/unsafe split, or 75/25. What then? You might as well just stick with one language that handles it all.

    120. Re: Don't be lazy programmers by DamnOregonian · · Score: 1

      We don't disagree at that the point where you're code requires less work arounds than actual code, you're on solid ground considering using other code, but the core of Redox is just that- more work-arounds than code. It's a POC to build a system from the ground up using assembler and Rust, purposefully avoiding C. I see little advantage in it, and the class of programming errors it protects against does *not* in the slightest imply systems security, since most of the domains where those problems exist in require unsafe {} Rust code.

    121. Re: Don't be lazy programmers by DamnOregonian · · Score: 1

      *your code
      d'oh.

    122. Re: Don't be lazy programmers by DamnOregonian · · Score: 1

      Also, I need to put this here- safe/unsafe are loaded terms.
      "unsafe" code is not unsafe. "safe" code is not safe.
      Those words mean statically verified to not succumb to a certain set of programming errors.
      You can write unsafe "safe" code in Rust, and you can write "safe" code in C.
      Rust's "safety" is compiler training wheels. I'm all for buying into the argument that the world at large needs compiler training wheels. But I think the argument that all things can be accomplished easier and better with those training wheels is brain-dead, and made by people who don't do actual low level programming.

    123. Re: Don't be lazy programmers by Raenex · · Score: 1

      I think you're being dismissive of both the modern benefits of a "not C" language, like modules instead of #include, and parts of the code where it's no so obviously a 95/5 split of unsafe to safe.

    124. Re:Don't be lazy programmers by Anonymous Coward · · Score: 0

      > That explains a lot.

      like what?

    125. Re: Don't be lazy programmers by DamnOregonian · · Score: 1

      That's a fair opinion to hold.

      And I think you are overestimating their utility, while failing to acknowledge the drawbacks of attempting to fight Rust's "safety" mechanisms in a low-level environment.

    126. Re:Don't be lazy programmers by Anonymous Coward · · Score: 0

      you obviously haven't done Numerical Analysis, though I wouldn't have recommended C for that. Control of precision errors is crucial.

    127. Re:Don't be lazy programmers by Anonymous Coward · · Score: 0

      Modern C++ cannot be compared to C in terms of safety. It requires a lot less attention and discipline to maintain safety (for example: You can easily avoid allocating and freeing memory, or risking dereferncing null pointers because you didn't check for NULLness).

    128. Re:Don't be lazy programmers by jma05 · · Score: 1

      Well, Julia is expected to be the next step forward for linear algebra projects that demand performance. We'll see how it will play out.
      Yes, Fortran code is everywhere.

    129. Re:Don't be lazy programmers by Anonymous Coward · · Score: 0

      Hypothetically, you can write an OS in pretty much anything.
      But I think the distinguishing feature is that people actually DO write operating systems in C/C++.

    130. Re:Don't be lazy programmers by Anonymous Coward · · Score: 0

      Sounds like one hell of an asshole professor. Reminds me of those managers who insist on using whatever JS trend is in vogue rather then what's actually appropriate for the job, just trades out the willful ignorance for self-centered edginess. Honestly, the amount of selfishness it takes to potentially screw over his student's academic schedules just to fulfill his own self-importance about a programming language, which isn't even fundamentally part of the course, is just astounding to me.

      I would argue that learning how to program effectively and correctly in a language that likes to bit you in ass.. is a great learning experience and as such
      makes it much easier to pick up all the nanny languages ... as you are more attentive to you work from that point forward.

    131. Re:Don't be lazy programmers by Anonymous Coward · · Score: 0

      No, it does not. Programming languages like Rust allow you to do all the unsafe stuff you want. It is just that they are safe by default, but you can step out anytime you need to.

      > I think it more likely that programmers have become lazy, or just aren't educated enough to be responsible with a powerful programming language

      Programmers don't use a safe programming language like Rust because they are indeed "lazy, or just aren't educated enough" - your words. Learn Rust. Then, by all means, reject it if it does not suit the project. Most reject Rust, only because they don't understand it yet.

      The problem is two fold. Those that have grown up with gui based IDEs are so used to point and click development they don't know how to "step out" and do something dangerous and conversely, said IDEs make it basically impossible to do so.

      I cut my teeth developing on ttys.. strictly ascii and vi/emacs ... funny thing, I can still create code faster than every IDE centered developer I have had the opportunity to work with. So much fun to see their face when I finish my assignments in half the time it takes them. :-)

    132. Re:Don't be lazy programmers by serviscope_minor · · Score: 1

      I find it amusing that programmers, of all people, the very people who are supposed to understand how tools make a difference, argue that they don't. The people who are supposed to ever build better and better tools, insist that whatever tools they made a learning investment in, argue that they don't need to be improved any further.

      It's even better. Programming is at its core automation. It seems a startling number of programmers are absolutely dead set against automation though when it comes to the actual thing they do day to day (code).

      I don't get it.

      --
      SJW n. One who posts facts.
    133. Re: Don't be lazy programmers by jd · · Score: 1

      Your sarcasm has a defect.

      Yep, nothing obvious to show it's anything other than a toy os or that it can do anything I asked. If you're going to pull the sarcasm, best be sure there's some meat on the bone.

      I take it, then, that you cannot show me an OS that can perform the operations listed, or that has the level of provable reliability, or that has similar performance characteristics.

      Much better just to say so.

      --
      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)
    134. Re: Don't be lazy programmers by Anonymous Coward · · Score: 0

      Rustc is written in Rust...

    135. Re: Don't be lazy programmers by theweatherelectric · · Score: 1

      Nope. All you're doing is arguing yourself into a niche. Like I say, read the papers on Tock. It already out delivers FreeRTOS.

    136. Re:Don't be lazy programmers by Tom · · Score: 1

      Anyway, it was quite funny, everyone dreaded them instead of thinking why their code is so bad that it crashed in the first 5 minutes when one one of those two touched the program.

      Everyone should be thankful to them. If this happens during QA, it is at least one order of magnitude cheaper compared to happening after shipping at the customer side.

      --
      Assorted stuff I do sometimes: Lemuria.org
    137. Re: Don't be lazy programmers by Tom · · Score: 1

      There is also a brilliant article about the NASAs coding and error analysis practices. I forgot the title and link, it went something like "they write ... code". The main lessons there was to figure out actual root causes for bugs.

      That's probably one of the most abused bullshit-bingo terms in the world, but used correctly, so powerful. Don't stop when you found the line in the code that contains the bug. Check the revision history to find out when the bug was added, by whom (not to punish them, but to ask their thoughts) and with what comment (i.e. why). Try to understand how and why the bug was introduced. Which wrong thinking lead to the wrong code? How it passed QA? Then fix not just the line of code, but the process leading up to the bug.

      Most business monkeys just think that truly professional work takes too much time.

      --
      Assorted stuff I do sometimes: Lemuria.org
    138. Re:Don't be lazy programmers by DarenN · · Score: 1

      Java is not a good teaching language. In particular, when learning to program, having a garbage collector is not a great idea because it abstracts away one of the most important underlying details of programming, which is memory management. This is the basic type of resource management and the aim of teaching programming in university should be the application of underlying principles over the syntax of a particular language. Java tries to prevent you doing too many things to make a good teaching language.

      Also it enforces an object orientated view of programming which is not the only way to program.

      I am disappointed at the move away from C/C++ as a teaching tool. It was easy to start with C for imperative programming, then easy to move on to C++ for object orientation. Java is a useful tool and good to learn as a follow on (the syntax is fairly close and it's in many ways simpler than C++ so it's easier to learn once you have the basics) and having it as a follow on allows greater understanding of the limits it imposes and also why they were imposed - you'll definitely have run into some C++ bugs that you simply can't do in Java when you're learning. That's a great springboard to the wider world of programming languages and their different philosophies, strengths and weaknesses.

      --
      Rational thought is the only true freedom
    139. Re:Don't be lazy programmers by angel'o'sphere · · Score: 1

      Depends on what you want to teach. I agree that Java is a bad teaching language, but because of its verbosity (every attribute needs 'private' and every method 'public' - that should be the default!), not because of other things.
      In CS you usually want to abstract away stuff like memory management. I actually don't know anyone who learned C++ in the university out of a requirement.
      My university evolved from Pascal to Java (in CS). Only special projects used C or if the students wanted, C++.
      Basically everyone I know who does/did C++ is self taught.

      It was easy to start with C for imperative programming, then easy to move on to C++ for object orientation.
      That is actually for many people not easy. It is much simpler to start with objects/classes right away.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    140. Re:Don't be lazy programmers by Anonymous Coward · · Score: 0

      Just the opposite. The kernel needs to be the safest of all! Let the compiler do the heavy lifting, and let programmers focus on what matters.

      Fast OS written in a "safe" language: https://www.redox-os.org/

    141. Re:Don't be lazy programmers by Anonymous Coward · · Score: 0

      Why not let the compiler keep track of shit so I don't have to? Do I "delete" or "delete[]" this pointer? If I pass my pointer to this other function, is it going to delete it when it's done or do I have to? Is it going to make a copy so I can immediately delete it or not? etc, etc, etc. The compiler/language can eliminate so much tedium.

    142. Re:Don't be lazy programmers by Anonymous Coward · · Score: 0

      In the early days of Windows programming, I wrote the memory allocator to use individual processor memory segments for every memory block in debug mode. Hardware-enforced bounds checking. It was so nice not having to worry about a whole class of bugs.

    143. Re: Don't be lazy programmers by Anonymous Coward · · Score: 0

      The Rust compiler is written in...Rust.

    144. Re:Don't be lazy programmers by paavo512 · · Score: 1

      There is no such language as C/C++. These are two totally different languages, especially regarding type safety, compile-time diagnostics and automated resource management, and the Linux developers have chosen the hard one.

    145. Re:Don't be lazy programmers by Aighearach · · Score: 1

      Right, when somebody tells you that their magic process will save the world, you just assume that means it is just like seatbelts, and there is no need to find out if it is true or not.

      What if it turns out that there is data suggesting that adopting a new programming process will not improve your software quality? Would adopting Virtuous processes still be the same as a seatbelt, or not?

      Or are you suggesting that the value in seatbelts is in the feeling of Virtue that you get in wearing it, and that they're not actually effective?

      Does calling a feature a "safety feature" actually tell me that it improves safety, or does it merely communicate your intent without telling me anything at all about the results of adopting your process?

    146. Re:Don't be lazy programmers by Shark · · Score: 1

      Settle down, children.

      --
      Mind the frickin' laser...
    147. Re: Don't be lazy programmers by Dixie_Flatline · · Score: 1

      I actually agree with this take, by and large. Maybe some things will need to be written in C or some other low level language—I assume there's actually a fair amount of hand-turned assembly out there as well, honestly. But in the end, not everything needs to be done in C and the problem isn't that the people writing these systems are bad or lazy programmers. We're talking about fairly enormous systems with a great deal of complexity, and it's starting to get away from them at a time where it's more and more important that it doesn't. Security as a concept was considerably more abstract 20 or 30 years ago than it is now.

      Certainly the attitude that we absolutely can't find a better tool and we'd best not try isn't helping matters.

      The attitude that everything is fine right now and the programmers just need to get good is obnoxious; they're already very, very good. So whether we've run to the end of programmers' ability to write correct code in these enormous systems without introducing (hidden) unsafe errors, or we've come to the end of the line for C as a language that's sufficiently safe for many tasks, the solution is honestly the same, to develop new and better tools that limit the mistakes that can be made. I've been a C/C++ programmer my entire professional life and I love C (C++, not so much), but it's so trivial to write software that is secretly broken, even if you have 2 or 3 other people reviewing it. We need some better tools here.

    148. Re: Don't be lazy programmers by MobyDisk · · Score: 1

      Could it be Personal observations on
      the reliability of the Shuttle, by R.P. Feynman

    149. Re: Don't be lazy programmers by Tom · · Score: 1

      found the old article:

      https://www.fastcompany.com/28...

      --
      Assorted stuff I do sometimes: Lemuria.org
    150. Re:Don't be lazy programmers by DarenN · · Score: 1

      That is actually for many people not easy. It is much simpler to start with objects/classes right away.

      Well, yeah, except that OO is not the only way to program. And the goal of CS is not to teach programming, but to teach underlying principles which Java makes more difficult by abstracting away. The most active areas of CS research are basically all about resource management and timing. Java hides all of that.

      --
      Rational thought is the only true freedom
    151. Re:Don't be lazy programmers by angel'o'sphere · · Score: 1

      The only resource Java is "hiding" is memory.

      And that do all high level languages, like Python, Lua, Lisp, Prolog, Erlang etc.

      There are plenty of universities that never even teach C or C++ ... because they teach "Computer Science", not "programming". If you want to learn C, you have t take a special class. But if a CS student can not learn it from a book, he probably should not be in CS anyway.

       

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    152. Re:Don't be lazy programmers by DarenN · · Score: 1

      I'm not stuck on C/C++ except that when you're learning there is a progress that I personally feel is easier using C++ than any other teaching language.

      A language that abstracts away memory management is not a good teaching tool for a computer science student because that is precisely what they should be learning about and experience always beats theory. Reading about memory corruption/underflow/overflow is different from experiencing it. Python, Java, Lua, ECMAScript, Erlang, Prolog, Fortran, BASIC, C, C++, Rust, PERL - they're all tools with strengths and weaknesses. I'm not advocating that one is "better" than the other in general, they all have applications that suit them or not. But for teaching I strongly believe that you have to start with a language that does not abstract too much away because the experience of working with Java gives a different perspective than working with other languages and I believe that C++ allows students to experience a wider range of problems.

      They'll end up learning Java, and Rust, and ECMAScript and Python, but for the same reason I would not recommend teaching programming with loosely typed language, I think that memory management abstraction is not a positive. If nothing else, you end up appreciating the convenience later!

      --
      Rational thought is the only true freedom
    153. Re:Don't be lazy programmers by strikethree · · Score: 1

      First, use paragraphs.

      Second, your "rant" is mostly correct.

      Third, I have to nitpick:

      At that point you may as well just be writing things in BASIC or some other interpreted language that doesn't allow you access to anything terribly powerful or important.

      Someone does not remember PEEK and POKE being used to punch machine language into memory locations to get high performance computing from ancient processors using BASIC as an operating system of sorts.

      --
      "Someone needs to talk to the tree of liberty about its ghoulish drinking problem." by ohnocitizen
    154. Re:Don't be lazy programmers by strikethree · · Score: 1

      I'd have chosen K&R C because Pascal's strict type checking made common use-cases awkward.

      Back then, I was using "prototyping" to ensure I used my variables like I intended. Sure, prototyping was optional, but I chose to protect myself from a class of mistakes that can be made by simply making a typo. I had a typo in a PHP program and instead of using the intended variable, I had created a new one. If PHP had allowed prototyping at the time, that mistake would have been caught immediately instead of when weird values started showing up during testing.

      All that being said, I prefer the programmer choose practices which minimize errors rather than the language itself. A fully functional language will "allow" the most hideous and heinous mistakes without a complaint.

      --
      "Someone needs to talk to the tree of liberty about its ghoulish drinking problem." by ohnocitizen
    155. Re: Don't be lazy programmers by DamnOregonian · · Score: 1

      I love high level languages. Even terrible ones, like Perl- my by and far favorite language, period.

      That being said, I cut my teeth in C and Assembler on a 68000 (Commodore Amiga)
      And have done most of my work at the embedded sub-kernel to kernel level.
      There is only one reasonable alternative to Assembly at that level, and that is C.
      We generally use assembly as little as possible, because A- it's 100% non-portable, even among SOCs of the same general architecture- there just isn't a great standardized macro or header file format for "assemblers", B- because it's impossible to fucking read, and C- because C (heh) can generate deterministic code that in many cases operates just as well as hand-tuned assembler. In fact, most uses of assembler at that level are not for optimization, but for doing the few things that you can't really do easily within the constructs of the language.

      I would never ever write a large program in C. But it feels like the people attacking C don't actually know all the places it's used, and they use their limited understanding of its failures in a certain domain to advocate for its complete replacement, in a way that is comically ignorant.

  5. Flummox the interviewer by Snotnose · · Score: 4, Interesting

    Some 20 years ago I was consulting for a company that needed $BigCompay approval to release software. While at $BigCompany I ran across an old boss, who flat out said "interview with us, you're in". I did.

    One guy asked the standard string reversal question, in C. I put a pointer at each end of the string and walked them together. The guy was completely flummoxed, it was like he'd never encountered an answer he hadn't thought of. This was like the second question he asked me, we spent the rest of the interview me explaining my solution, he never understood it.

    Guy turned out to be my sorta boss (matrix management means the guy you report to has no say in your performance review). He was a good guy, one of the early employees of the company, but as time went on I realized he did not understand C pointer arithmetic.

    Mind you, this guy was smarter than me, and more driven. But he had never done assembly programming, hence he never really understood C pointers.

    Me? Started with Z-80 assembly, moved to 8080, 8086, then 80386, which is when I learned C. Took to C pointers like a duck to water.

    FWIW, the company I was consulting for never paid me for my last month (2 bi-weekly paychecks). Lots of phone calls, meetings, and fights. Huge reason I quit consulting and went back to working for companies.

    1. Re: Flummox the interviewer by Anonymous Coward · · Score: 0

      God you're old as fuck.

    2. Re:Flummox the interviewer by Anonymous Coward · · Score: 0

      Why would you need assembly experience to understand pointers?

    3. Re:Flummox the interviewer by Aighearach · · Score: 1

      I use C pointers every day.

      And I try hard not to accidentally learn to understand them. I've seen the code those people write.

    4. Re: Flummox the interviewer by jd · · Score: 1

      Youngsters!

      The problem with such a solution, indeed the problem with safe programming in general, is that it has to be documented. You obviously knew how to explain it and were meticulous. That's good. And rare.

      Too many are taught to hate properly documenting or explaining their code, with the result that you've unmaintainable code. They're also taught to hate designing and testing, with the same result.

      In industry, programmers are often banned from performing all four key tasks because of deadlines and the manager wanting to look good.

      --
      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)
    5. Re:Flummox the interviewer by Anonymous Coward · · Score: 0

      Compilers today mostly optimize pointer arithmetic and using them with array syntax to yield the same assembly. It can now be somewhat readable and fast at the same time.

    6. Re:Flummox the interviewer by Anonymous Coward · · Score: 0

      brilliant! i miss these kinds of posts on slashdot

  6. rockets red glare babys bursting in air.. by Anonymous Coward · · Score: 0

    cease fire stand down.. leave the stinking oil in the ground.. the colonels of the kernel would do well to compile even 1 distribution that included what us lamo users use by default?.. thanks..

  7. Don't give professional tools to amateurs by gweihir · · Score: 4, Insightful

    That is basically the thing that applies to C code and has applied to it from the beginning. In the hands of somebody that knows what they are doing, C is not more dangerous than any other language.

    --
    Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    1. Re:Don't give professional tools to amateurs by jma05 · · Score: 1

      They are all "professional" tools by definition. Don't use unsafe tools unless absolutely necessary is the lesson.

      > In the hands of somebody that knows what they are doing, C is not more dangerous than any other language.

      Completely wrong. Even people who "know what they are doing" (most think they do, but really don't. C enables entire classes of problems that simply don't exist elsewhere), still make avoidable errors with C because they are only human. This is not really an opinion. We know matter-of-factly that there are "no true Scottsmen".

      Personally, I like Nim. C is great, when machine generated. I get most of the benefits of C, with almost none of the risks. Unlike Rust, Nim does have some costs for the safety and productivity it enables, but these are quite marginal.

    2. Re:Don't give professional tools to amateurs by dfghjk · · Score: 2

      Yes, and C is neither a "fancy assembler" nor "almost machine code". These are statements of an ignorant person.

      Yes, "we can call typed functions through" "void pointers" but we do so by declaring what that the pointer type is, and this is not possible because "Assembly doesn't care" but because it is useful. Seriously, this guy is an idiot. While I have no doubt "Cook and the people he worked with discovered numerous native C problems", I also have no doubt that countless programmers discovered them long before these fools did, including me before they even saw puberty.

    3. Re:Don't give professional tools to amateurs by gweihir · · Score: 1

      You overlook that the language brings in a very small part of the difficulty of any software project. And, incidentally, depending on the application pretty much every tool is "unsafe". The advantage of C is that the incompetent coders fail early and obviously.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    4. Re:Don't give professional tools to amateurs by gweihir · · Score: 3, Insightful

      Having used a fancy assembler, I agree. C is in a whole different class, because with that fancy assembler, most of what you do is find out about the target CPU and and low-level I/O. And you do that again for every hardware architecture. With C you just need to know the coding model of the language and the language itself is way more powerful than even the most souped-up assembler. Sure, there are a few fine details in C where being able to do any assembler variant is really helpful in understanding then, but that does not make C some kind of assembler at all.

      I do agree that this guy is an idiot. He carters to all the coders that fancy them bad-ass but that cannot write solid C code and blame the tool for that.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    5. Re:Don't give professional tools to amateurs by jma05 · · Score: 1

      > The advantage of C is that the incompetent coders fail early and obviously.

      Actually, it is the opposite. With C, bugs exist silently without generating either compile time errors or obvious runtime errors.

    6. Re:Don't give professional tools to amateurs by Anonymous Coward · · Score: 0

      Yes, and C is neither a "fancy assembler" nor "almost machine code". These are statements of an ignorant person.

      IKR, this is a pet peeve of mine. Programming in C is *nothing* like programming in assembly.

      I've even heard C called a "low-level language" by ignorant programmers who don't know what a HLL is (they just assume they know).

      What does C have in common with assembly? You can write directly to memory addresses and do bitwise operations. That's about it; everything else is classic structured high-level language.

    7. Re:Don't give professional tools to amateurs by gweihir · · Score: 0

      And if you believe that, you just clearly indicated that you are not worth talking to.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    8. Re:Don't give professional tools to amateurs by jma05 · · Score: 1

      What do you mean - "believe"? That is not an opinion. That is a well-known fact. Unless you write exhaustive (and I do mean mathematically) test cases, you can have danglers and buffer overflows that can go undetected for years. Audits show this over and over.

      C gets its performance by simply not doing much in machine checks. It expects the human to take over that responsibility. This is by design. The consequences follow naturally.

      > you just clearly indicated that you are not worth talking to.

      Ran out of arguments?

    9. Re:Don't give professional tools to amateurs by Anonymous Coward · · Score: 0

      Actually, it is the opposite. With C, bugs exist silently without generating either compile time errors or obvious runtime errors.

      These "incompetents" just keep typing. Doesn't work? Type more. Still doesn't work? You probably need to type more. Still doesn't work after all that typing? Don't go back and think about what's going on... just fucking type more, don't stop typing until it's working!

      That type of code monkey exists in every company. If they fling enough poo at the problem for long enough, eventually some of it sticks and the customer is happy.

      It doesn't matter that the code is full of latent bugs or even blatantly obvious ones - as long as it does what it's supposed to in a straight line and doesn't fall over too often then it'll fly.

    10. Re:Don't give professional tools to amateurs by DamnOregonian · · Score: 1
      A C compiler's most simple implementation is quite literally almost a macro expander for a particular architecture's assembly language.
      Now- the fact that a modern C compiler is mind-bogglingly more complicated doesn't change the fact that C is, in itself, a structured representation of assembly.

      This isn't the statement of an ignorant person, this is the statement of someone who has literally written a lightweight C compiler for the PDP-11/04.

      Yes, "we can call typed functions through" "void pointers" but we do so by declaring what that the pointer type is, and this is not possible because "Assembly doesn't care" but because it is useful.

      No- this is possible quite literally because "assembly doesn't care". Your function pointer with all of its static typing information in the end is just a memory address, and the function call, with all of its static typing information, just a branch instruction. C allows you to cast it as you wish, regardless of whether it is correct (by you telling it that this arbitrary function has this type, really, i promise, i swear) and just make the fucking jump. This is possible because your processor's branch instruction just don't give a fuck.

      The rest of your comment wasn't worth reading given that your beginning premise was so ridiculously fucking dumb.

    11. Re:Don't give professional tools to amateurs by DamnOregonian · · Score: 1

      There is merit to the argument that it is a fancy assembler however, even though I see where you're coming from in saying that it is not.
      It really is a structured representation that was designed to be converted directly into assembly language in a deterministic fashion.
      The first C compiler I wrote was little more than a fancy and intelligent macro expander.

      The fact is, a C compiler can produce code that will run on bare hardware with no runtime, and a very very tiny assembly loader.
      That makes it, IMO, a de facto low level language, regardless of what the varying various subjective opinions are.

    12. Re:Don't give professional tools to amateurs by Anonymous Coward · · Score: 0

      every tool is "unsafe".

      Yes, every tool is unsafe. That doesn't mean every tool is equally unsafe.

      Have you ever seen a discussion about the safety of table saws? People yell about how they the guards and splitter stops them from doing some particular operation, therefore they take those off the saw and never use. The result is many people get hurt by something that was preventable, and doing something where the guards wouldn't have been in the way anyway. Yet, some bozo will always say something very parallel to discussions here, "If you're not careful enough to use the saw without the guards, you shouldn't use it anyway, it makes you pay attention," or, "you can still hurt yourself with the guard, so it is still dangerous."

      The guards aren't welded on, they are removable. In the end, it is laziness that people insist you need to never have the guards instead of only removing them when they need to. People make mistakes, even experience ones. If anything, much work has shown that mistakes can follow a bathtub like curve vs. experience, because experienced people become complaisant and think they are above slip ups.

      So yes, every tool is unsafe, and every programmer needs to be aware of what they are doing. But they should be spending their brain power worry about the hard problems that can't automatically be checked/handled, instead of resolving the same problems that have bitten programmers many times before, including ones with vast amount of experience and intelligence.

      I've worked with the programmers that have decades of experience doing firmware and close to the metal programming, where they know the hardware better than what is in the manual/datasheet, and they still make a rare typo. I would rather there be a system in place that helps catch those typos, even if it only catches half of them.

    13. Re:Don't give professional tools to amateurs by Anonymous Coward · · Score: 0

      There are more statements to take an issue with.
      Like memcpy having no destination length. It only has a destination length.
      What it doesn't have is a source length, the number of bytes will be copied into the destination regardless of the source size.

      If you happen to have access to two lengths and they happen to be different I don't really see how passing them to memcpy would make things better. Copying the shortest length will still mean that the data you wanted copied isn't. It doesn't matter what kind of input validation you did beforehand, your data i no longer valid.
      You need to handle it outside and the check for it is shorter than what higher languages uses for catching an exception.
      You could also just "assert( srclen == dstlen );" since it seems to be a pretty serious error with your code if you have different lengths here but that doesn't really seem viable for kernel code.

      Also, there already are several standards to make C safe.
      To my knowledge GCC doesn't support MISRA, but a couple of professional compilers do and if you use a compiler that doesn't there are always external tools to look for compliance.

    14. Re:Don't give professional tools to amateurs by Anonymous Coward · · Score: 0

      Safe guards in code clutters up the code showing the intended behavior. Java folks just rely on exceptions for those cases, keeping the relevant parts clean from such clutter. In C such clutter more often than not helps to hide bugs, not detect them, making things worse.

      In the initialize-to-zero example in the pdf, there is a possibility for a static code checker to find the error (non-initialized is even caught by some compilers). There is a larger possibility to detect the error with a random initial value (some of them may finally cause a catastrophic behavior so the bug is detected) than with a default initialization to zero (which would always cause an almost correct (!?) but still wrong behavior).

      Bottom line is, if something is broken no compile- link- run-time check is going to fix it. At best it may help to detect (typical for checks at compile-time), at worst hide (can easily happen with run-time checks) problems.

    15. Re:Don't give professional tools to amateurs by angel'o'sphere · · Score: 1

      The advantage of C is that the incompetent coders fail early and obviously.
      I would not call an exploding Ariane or a crashing Mars probe: fail early.
      Obviously, yes indeed.

      And then again: I understand that you are fed up with incompetent programmers. So am I. However the failures above are failures of the software development team as a total. That means: programmers, requirements engineers, testers, reviewers, they all failed together

      Singling a a specific programmer out, who wrote the line in question: that is incompetent. Making that error was expensive. But has nothing to do with incompetence. It most likely always is just a mere oversight.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    16. Re:Don't give professional tools to amateurs by Anonymous Coward · · Score: 0

      p>I do agree that this guy is an idiot.

      I find the thought that a key Linux kernel developer is an idiot quite disturbing.

    17. Re:Don't give professional tools to amateurs by angel'o'sphere · · Score: 1

      Yes, and C is neither a "fancy assembler" nor "almost machine code". These are statements of an ignorant person.
      Cough, Cough, Cough ...

      You might be interested in reading this: https://www.bell-labs.com/usr/...

      Perhaps you might want to use the search function and jump to "essentially, as a portable assembly language" ... you might want to note one of the first lines of the text, too: Dennis M. Ritchie

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    18. Re:Don't give professional tools to amateurs by Anonymous Coward · · Score: 0

      Could you provide me the name of a C programmer with non trivial output who has never made a buffer overflow or use after free error.

    19. Re:Don't give professional tools to amateurs by Anonymous Coward · · Score: 0

      Context: Ritchie was talking about the role of C, using it to do things you would normally (at that time) have done with assembly.

    20. Re:Don't give professional tools to amateurs by Anonymous Coward · · Score: 0

      Now- the fact that a modern C compiler is mind-bogglingly more complicated doesn't change the fact that C is, in itself, a structured representation of assembly.

      No more so than any other compiled language. It's all assembly at the bottom.

    21. Re:Don't give professional tools to amateurs by gweihir · · Score: 1

      You "well known fact" is not a fact. It is just something you believe.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    22. Re:Don't give professional tools to amateurs by gweihir · · Score: 1

      The advantage of C is that the incompetent coders fail early and obviously.
      I would not call an exploding Ariane or a crashing Mars probe: fail early.

      Now you are just being dishonest. The exploding Ariane was not a coding problem, but an integration and system test problem. Even one simulated launch with the code would have shown it. "Management" though that was too costly. This was not an engineering problem at all, but a business-process problem. And incidentally, that code was Ada, a "safe" language. The crashing Mars probe was a confusion between some obsolete and ancient units on one side and metric on the other. Again, not a coding problem and certainly not a coding language problem.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    23. Re:Don't give professional tools to amateurs by angel'o'sphere · · Score: 1

      Both are coding problems.

      In the Adriane they assigned a 16bit value to a 32bit variable, or was it a 32bit to 64bit, does not matter. Which lead to an overflow. Ah, it was opposite around, here is a link: https://archive.eiffel.com/doc...

      The Mars lander had to convert one unit into an other, but did not. That is obviously an oversight, not language related.

      My point is: errors don't show up early necessarily. OpenSSL was buggy for a decade or longer until someone realized it. And the fact that we have such errors have nothing to dow with "is the programmer competent", or "is the programmer lazy".

      However they made a bad impact analysis. Bottom line programmers simply rely still much to much on build in data types and their automatic conversion. C++ and operator overloading, cornering in what can be assigned to what, would have had zero overhead and completely made it impossible to assign incompatible types to each other. Both in the Ariane case as in the Mars lander case.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    24. Re:Don't give professional tools to amateurs by gweihir · · Score: 1

      No, they are not. And they are both most definitely not related to the language used. Maybe actually read the official investigation reports.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    25. Re:Don't give professional tools to amateurs by DamnOregonian · · Score: 1

      Untrue. Take a language like C++ for example. Those instructions do *not* translate directly to assembly. There are constructs that require a runtime to work.
      C does not. That is both a barrier to it being a good design choice for higher level applications, and a requisite for being able to write code that runs on bare metal.

    26. Re:Don't give professional tools to amateurs by jma05 · · Score: 1

      Sigh. Yeah, these are "beliefs" most of the programming world shares: aka consensus.

      Let me paste some quotes for you from the linked article:

      "The C language is very powerful, widely used—particularly in the Linux kernel—and very dangerous. One of the Linux engineers outlines how developers can cope with the programming language's security weaknesses."

      "C code runs quickly, but it has no safety belt. Even if you're a C expert, as are most of the Linux kernel developers, you can still make killer blunders."

      "the C language itself has fundamental, unfixed bugs that await the unwary. "

      "With its operational baggage and weak standard libraries, C contains a great deal of undefined behavior. "

      "C comes with some worrisome baggage, undefined behaviors, and other weaknesses that lead to security flaws and vulnerable infrastructure."

    27. Re:Don't give professional tools to amateurs by Anonymous Coward · · Score: 0

      What GP meant was, that you believe that in languages like Rust or Java you _do_ get compile time warnings or obvious run-time errors. You don't. That's just for the obvious bugs GP was referring to. Your assumption that all bugs are so obvious is the reason GP believes you are unworthy of discussion.

    28. Re:Don't give professional tools to amateurs by jma05 · · Score: 1

      > Your assumption that all bugs are so obvious

      Where did you get that idea? Of course there will always be logic errors. Our tools can't read our minds. But at least let the compiler catch everything that can be caught. Rust isn't Haskell. As an impure language, it cannot reason as much. But it is heck of a lot better than the bare minimum C does, all while not imposing any costly abstractions.

      I find the GPs reasoning here and elsewhere, that we should not have nice things because non-masochists are not L33t enough ("The advantage of C is that the incompetent coders fail early and obviously" - He seems to think of C users as sort of an upper caste of programming who should protect their position by keeping this hard), is silly. We should bring as much machine assistance as we can into our work.

    29. Re:Don't give professional tools to amateurs by Anonymous Coward · · Score: 0

      No HLL translates "directly to assembly," in that case. If it did, it would BE assembly. It's all about layers of abstraction, and C has them no matter how you like to spin it.

    30. Re:Don't give professional tools to amateurs by HiThere · · Score: 1

      This depends on the class of error. Some C errors are blatant, others sneaky. And some are "merely" stylistic, and don't cause a problem until someone else has to deal with the code. One guy I worked with had a passion for macros with names that meant something to him, but not to anyone else. He left. The only way to deal with the code was to run it thorough the preprocessor, and then try to figure out what it was doing without comments to help. (Well, the original code was "sort of" commented, but again, cryptically. And the preprocessor changed things around a lot.) I'd be more explicit, but *I* didn't end up dealing with it, only watching someone else try to deal with it.

      --

      I think we've pushed this "anyone can grow up to be president" thing too far.
    31. Re:Don't give professional tools to amateurs by HiThere · · Score: 1

      Yes, but the only way to deal with many of those problems is with a language with semantic, as opposed to simply syntactic, validity checking. And we don't know how to do that yet.

      The thing is, we can to *parts* of semantic checking, but the languages we use don't facilitate this, and actually act as roadblocks. Languages have types for things like int and float, but not for things like dollars and inches....but it's the dollars and inches that are important. The floats and ints can be represented in any way that's appropriate to the semantics....but we can't handle the semantics. It's not even a question of "Can we handle it efficiently?", as our languages can't handle it at all. Some specialized libraries can handle parts of this, but when they link into our languages, the results come in a ints, floats, strings, or some combination. A few decades ago I started trying to figure out how to do that kind of thing in ADA for units of length (both metric and imperial). It's quite easy to state the rules, but implementing them in a usable way appears impossible. In most languages I can't even specify them in an unusable way that will catch erroneous uses.

      --

      I think we've pushed this "anyone can grow up to be president" thing too far.
    32. Re:Don't give professional tools to amateurs by Anonymous Coward · · Score: 0

      C programmers write a lot of bugs...

    33. Re:Don't give professional tools to amateurs by DamnOregonian · · Score: 1

      No HLL translates "directly to assembly," in that case.

      Precisely. That's why only a fool calls C a "HLL".

      and C has them no matter how you like to spin it.

      C the language? No, it does not.
      The closest you can get, is perhaps with TLS extensions which require some library support built into the language itself.
      You need to accept that you simply have no idea what the fuck you're talking about.

    34. Re:Don't give professional tools to amateurs by Anonymous Coward · · Score: 0

      >> No HLL translates "directly to assembly," in that case.
      > Precisely. That's why only a fool calls C a "HLL".

      Another idiot who doesn't know what an HLL is. *sigh*

      >> and C has them no matter how you like to spin it.
      > C the language? No, it does not.

      C has no abstraction from the machine? Are you high?

      I think we're done here.

    35. Re:Don't give professional tools to amateurs by DamnOregonian · · Score: 1

      Another idiot who doesn't know what an HLL is. *sigh*

      Another idiot who thinks a spectrum can be defined as a boolean. *sigh*.
      C is a third-generation language, one step above assembly, and was designed to map directly to assembly for the PDP-11.
      Your move, fuckstick.

      C has no abstraction from the machine? Are you high?

      Sure, as far as assembly is also an abstraction from machine code.

      I think we're done here.

      Indeed. You're too fucking ignorant to know how ignorant you are.

    36. Re:Don't give professional tools to amateurs by Anonymous Coward · · Score: 0

      >> C has no abstraction from the machine? Are you high?
      > Sure, as far as assembly is also an abstraction from machine code.

      Blocks, variable scoping, expressions, functions, types, modules, macros, arrays, switch statements, structures, unions, bitfields, headers, typedefs, etc.

      ALL of those things are abstractions that don't exist in asm.

      > Indeed. You're too fucking ignorant to know how ignorant you are.

      Back at you in spades.

    37. Re:Don't give professional tools to amateurs by Anonymous Coward · · Score: 0

      >> Another idiot who doesn't know what an HLL is. *sigh*
      > Another idiot who thinks a spectrum can be defined as a boolean. *sigh*.

      There is no "spectrum," fool. There is a definition for HLL, which today's code monkeys have either forgotten or never learned:

      high-level language
      (HLL) A programming language which provides some level of abstraction above assembly language. These normally use statements consisting of English-like keywords such as "FOR", "PRINT" or "GOTO", where each statement corresponds to several machine language instructions. It is much easier to program in a high-level language than in assembly language though the efficiency of execution depends on how good the compiler or interpreter is at optimising the program.

      http://foldoc.org/hll

    38. Re:Don't give professional tools to amateurs by Anonymous Coward · · Score: 0

      C is a third-generation language, one step above assembly, and was designed to map directly to assembly for the PDP-11.

      C does not "map directly to assembly" any more than Pascal or Fortran or Algol or any other compiled language does. C has to be translated to machine code, just like every other HLL. That's what compilers are for.

      Honestly, I don't know where these myths about C come from, but they seem isolated to C partisans who want their language to have some "special" status or advantage over other languages to give it magical performance properties. C has ONE advantage, and that is its simplicity. It has a limited grammar, and simple typing, and very little syntactic sugar. Pointers are all that makes it "closer to the machine."

    39. Re:Don't give professional tools to amateurs by angel'o'sphere · · Score: 1

      That is why every software I was involved, where I had something to say, has a Currency type, and a type for everything else, like Energy and Power, or Length.

      It's quite easy to state the rules, but implementing them in a usable way appears impossible.
      In C++ it is relatively easy. I guess in Scala, as well.

      The problem comes when you want to cover everything, or most of everything.

      You have "Dimensions" like "Length", "Energy", "Power", "Speed", "Time", then
      you have "Systems" like, "Imperial" and "Metric" then
      you have "Units" like "m" and "foot" or "light second" or "plank length" and then finally
      you have the "Representation" as in int, float, double or BigDecimal or even String.

      Complicated it gets, if you have different "Interpretations" of a Dimension, e.g. "Length" can be length, width and even height. And then height X * width Y would give you an "Area" which e.g. can be passed to an algorithm calculating or dealing with wind resistance/air drag, while an "Area" made from length and width would give you a surface which is probably meaningless for air drag, but can be used to calculate e.g. expected rain gathered over a year.

      Time gets nasty anyway, already distinction between a point in time or a duration is difficult, as we use the same units ... hence you need own Dimensions for that (I mean, duration and time as a point in time).

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    40. Re:Don't give professional tools to amateurs by HiThere · · Score: 1

      No, actually it isn't. You can easily do a half-assed implementation, but not a real one. A real one wouldn't quite be beyond the state of the art, but pretty close. And it still wouldn't be a full semantic analysis.

      As for your currency type, how does it handle conversion between dollars and yen? Does it forbid conversion of dollars to inches? What about hours to dollars? And even that's just talking about matching types, and requiring argument agreement. Yes, I understand that you can do the type matching kind of thing with struct declarations and macros to hide the messiness, but that's syntactic, not semantic.

      OTOH, a multi-level template system might approach semantic analysis as closely as we can now manage. Maybe. But you need to distinguish between things that have a fixed conversion and those that have a varying conversion. E.g. dollars to yen conversion depends on when you do it, so it's quite probable that no compiled code could handle it without referring to an external source for the current conversion rate. This still isn't semantic, but it's more than syntactic.

      The reason that it's easier to do a half-assed version in C++ than in Ada is that C/C++ allows you to do unchecked conversions without noting an error. Ada is so picky it detects errors even when they aren't there, but C++ just lets them through until they cause a run-time problem. Well, Ada lets you say "This isn't really an error, even though it looks like one", and you can write extra logic in C++ to validate your code...neither approach is very nice. D is closer to ideal in this respect, but it doesn't allow you to specify (at declaration time) what range a variable is allowed to have, only how much storage it uses. This variable is a long int, and that one's a byte and...etc. Ada allows you to specify ranges of permissible values at the time the variable is declared...e.g. this variable must be between 3.1415 and 9.4245 inclusive. It also allows modular types that aren't multiple of 2. Not always useful, and a bit expensive to implement, but sometimes quite useful. (OTOH, I once had to write a program that used a 36 hour day with overlaps between days. It was tracking jobs from when they started rather than by the calendar date.)

      Semantics is tricky, and actual semantics is beyond the state of the art, so any approach used would need to allow itself to be overridden. But the default should be to catch errors.

      --

      I think we've pushed this "anyone can grow up to be president" thing too far.
    41. Re:Don't give professional tools to amateurs by DamnOregonian · · Score: 1

      All a C compiler does, at its most basic, is map addresses to names, and allocate registers and stack space for function calls, and generate the assembly for the basic control constructs.
      May I suggest the Dragon Book, so that you actually know what you're talking about in the future?

    42. Re:Don't give professional tools to amateurs by DamnOregonian · · Score: 1

      There is a definition for HLL

      No, there most certainly is not. There are about a thousand.

      which today's code monkeys have either forgotten or never learned:

      Sorry, but as I said previously, I wrote my first C compiler for a PDP-11/04 that I rescued from a trash bin in the late 90s from outside DECs offices in Redmond, WA as they went defunct.
      A C compiler does only a few things (modern optimizing compilers excluded). It maps control primitives to assembly, assigns names to addresses depending on whether they're static, or to stack space if they're local, and allocates registers for function calls. That's it. You're free to call that high level until you're blue in the face, but it just demonstrates how ignorant you are.
      Unoptimized C can be *perfectly* decompiled using nothing but a map (names lost, of course). One day, when you become a big boy, you may even learn that on your own.

    43. Re:Don't give professional tools to amateurs by DamnOregonian · · Score: 1

      Blocks, variable scoping

      C has 2 scopes, global and stack.

      expressions

      You think assemblers don't support expressions? Sure, they're limited, but they absolutely allow expressions.

      functions

      A name that has been mapped to an address that can be jumped to using standard C calling conventions, no more, no less.

      types

      Yes, there are different instructions in assembly for working with different "types" as well. A language needs some kind of construct to decide what kind of instructions to generate.

      typedefs

      Now I *know* you don't know what the fuck you're talking about.
      Different assemblers have all kinds of macros and other abstractions like labels. A typedef is nothing but syntactic sugar. It abstracts nothing at the assembly/machine level.

      ALL of those things are abstractions that don't exist in asm.

      Ya, OK. So C has more "abstractions" than your-favorite-assembler. What's your point?
      Everything beyond pure opcodes has some kind of abstraction.

      Sure, as far as assembly is also an abstraction from machine code.

      Hm. It's almost as if I already said that. It's no fucking wonder American software firms are hiring from India, if you're any kind of example of the 'new blood'.

    44. Re:Don't give professional tools to amateurs by DamnOregonian · · Score: 1

      There is no "spectrum," fool. There is a definition for HLL, which today's code monkeys have either forgotten or never learned:

      Whoops. I'll quote for you if you have a reading difficulty.

      C is terse, low-level and permissive

      Oh shit, there's more!

      BCPL is low-level, typeless and block-structured, and provides only one-dimensional arrays

      BCPL is what C was written to replace, also considered a low-level language at the time.

      Next stupid argument, shit stain.

    45. Re:Don't give professional tools to amateurs by Anonymous Coward · · Score: 0

      By the original definition, "low-level languages" were machine code and assembly. That's it. LLL's were bound to the architecture; HLL's were not. That's why it's silly to call C a "portable assembler," it's a contradiction in terms. Assemblers by definition require ISA-level control and one-instruction-per-statement.

      As for HLL's, the term has shifted somewhat. I suggest reading this article:

      http://wiki.c2.com/?HighLevelLanguage

      The term "High Level Language" was originally used to distinguish things like FortranLanguage from things like assembly language. Therefore, originally "high level language" very much included Fortran, Basic, COBOL, PL/I, and a little later, C.

      Observing that such languages are not very high level compared with e.g. Prolog, YACC, Lex, ML, Haskell, etc, some people started calling the older high-level languages "low-level languages", or qualifying them as "higher level languages", etc. This is often erroneously thought to be revisionism, but is the very basis of much of Computer Science, and such terminology while not universally accepted among all programmers, is at least understood by those with a broad understanding of the relevant foundations of the topic at hand.

      A more diplomatic approach to the topic, while sacrificing accuracy to appeal to the less-disciplined mind, would be to simply call more sophisticated languages "very high level languages", if a distinction is needed, rather than trying to snidely imply (or state outright) that there's no difference between assembler and Fortran, Basic, COBOL, PL/I, C etc.

      No one who has done extensive programming in assembler would ever make the mistake of calling such things "low level languages"; there is a very sharp and painful difference.

    46. Re:Don't give professional tools to amateurs by Anonymous Coward · · Score: 0

      >> There is a definition for HLL
      > No, there most certainly is not. There are about a thousand.

      There's the original definition which I learned in university back in the mid-70s, and there are about a thousand subjective impressions based on misunderstanding of that definition.

      The stuff you're describing is the same as what any 3GL compiler does, and they're ALL high-level in terms of offering abstractions beyond assembly, that is the WHOLE POINT of structured programming and HLLs.

      Now I will leave you to wrestle with your insecurity, overinflated ego and massive anger management issues.

    47. Re:Don't give professional tools to amateurs by Anonymous Coward · · Score: 0

      Maybe that's what C used to do, but as you pointed out, that PDP-11 model is long dead. C compilers are more complicated now because the computing environment and CPU designs are more complicated.

      C is not close to the metal - that's largely a myth perpetuated by C hackers.

    48. Re:Don't give professional tools to amateurs by angel'o'sphere · · Score: 1

      Obviously you would not allow conversions from one "dimension", e.g. "length" into another dimension, e.g. "urrency".

      However, you can add conversion methods, that is the nice thing in C++. E.g. if you only need yen and dollar, you make two subclasses inheriting from the currency template, add a "toDollars()" method to the Yen class, and a "toYen()" method to the Dollars class.

      A unit/dimension system as sketched in the previous post would only allow conversions/assignments inside of the same dimensions, e.g. metric to imperial, by using a common reference unit.

      Everything else can be type safe implemented by global operators, e.g. "operator=()" and mathematical operators like "operator*()"

      operator=() could be used if you really want to convert hours into dollars, but I rather would express what you really want to do: result = hoursWorked * hourlyWage; Why use a strange conversion?

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    49. Re:Don't give professional tools to amateurs by Anonymous Coward · · Score: 0

      > Precisely. That's why only a fool calls C a "HLL".

      Fools like Dennis Ritchie and Brian Kernighan, you mean?

    50. Re:Don't give professional tools to amateurs by HiThere · · Score: 1

      OK. If you want to argue that C++ is Turing Complete, I can't disagree with you. That, however, is not the language understanding semantics. That's the program doing it.

      FWIW, I suspect that actual semantic analysis is not formally possible, but will always demand heuristics, and a reasonable chance of reaching the wrong conclusion.

      Also, an approach that could work in both C and C++ to do what you are suggesting is to define a struct for each type, and then operators between the types. But that's not the language being semantically aware, that's the programmer doing it, and is riddled with problems with misapplication, pointer conversion, etc. Making things overly complex and then asking a human rather than a computer to do this is begging for problems. People are fairly good at simple thing, terrible at precise complex things and very good at pattern recognition. Computers are extremely good at simple things, extremely good at precise complex things, and horrible at pattern recognition. It's probably partially an optimization problem, but it's also our technical limitations. The computers handle a lot fewer transactions/second than do human brains, but the software is more precise.

      Still, a simple to use approximation to a semantic analysis could help a lot. E.g., I really appreciate the spell checker that is built into my browser...but I need to be able to override it when a word that it doesn't recognize shows up. The grammar checker, however, is so bad that I have it turned off.

      --

      I think we've pushed this "anyone can grow up to be president" thing too far.
    51. Re:Don't give professional tools to amateurs by angel'o'sphere · · Score: 1

      Of course you would use structs or classes and user defined operators. That is the point!

      But what have pointers to do with that?

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    52. Re:Don't give professional tools to amateurs by HiThere · · Score: 1

      Pointers are one way in which C/C++ loses track of semantics. There are others, but it's been well over a decade since I was a heavy C++ programmer. Still, I'm rather certain that old C++ code still usually works with recent versions of the compiler, so the effects should still happen.

      --

      I think we've pushed this "anyone can grow up to be president" thing too far.
    53. Re:Don't give professional tools to amateurs by angel'o'sphere · · Score: 1

      We talked about a datatype that carries a dimension, a unit and a value, that has nothing to do with pointers.
      You cyn have a pointer to such an instance, no one would care.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    54. Re:Don't give professional tools to amateurs by DamnOregonian · · Score: 1

      And that's a largely incorrect argument.
      Using the constraints the author chooses to demonstrate that C is not close to the metal, neither is direct Assembly or even direct machine code.
      He's arguing that the microcode is the only thing that is truly close to the metal. A valid argument, from an academic viewpoint, but completely irrelevant beyond that.

  8. Optimisations by dohzer · · Score: 0

    Aren't most of the security issues with C related to crazy compiler optimisations?

    1. Re:Optimisations by gweihir · · Score: 0

      No, most are related to incompetent coders. Compiler optimizations are more interesting though, so they get more press.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    2. Re:Optimisations by Anonymous Coward · · Score: 1, Informative

      Yes. They added defects to the language in the name of "undefined behavior" (aka UB). It's basically impossible to write a program in C or C++ that's 100% free of UB. The industry average is about 15-50 bugs per KLOC, and even the best companies openly admit that their code probably contains at least 7 bugs / KLOC.

      Segfaults and signed integer overflow are the most common UBs infecting most of all C and C++ programs. But on the one in a million chance that your program doesn't contain one of those UBs, then the odds are good that you still have UB caused by type punning / pointer aliasing that "works on my computer," but will eventually cause your program to emit nasal demons when a new compiler assumes you didn't alias.

      Personally I think optimizations around null pointer dereferences are symptoms of the worst form of brain damaged stupidity and/or intentional malice in compiler developers: basically, the compiler is allowed to remove branches testing for segfaults if it can prove that you will unconditionally dereference the same pointer later. And instead of emitting an error and telling you at compile time that it has statically proven that you messed up, the compiler writer is happy to just silently emit code he knows contains UB, and that he knows will result in nasal demons.

    3. Re:Optimisations by Oligonicella · · Score: 1

      No, most are related to incompetent coders.

      Making them not language specific.

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

      Nope.
      Everyone who compiles their old functioning code with the new buggy compiler will have their code suddenly not work but when they compile with the old version everything is fine.
      If things are really wonky it is also not uncommon to turn off optimizations so that your breakpoints and code execution actually is in the order you wrote them.
      You catch compiler errors pretty quickly.

      Most security issues comes from inexperienced programmers who doesn't use the languages features to write robust code.

      Read through the find print in the C specification and in particular the Portability Issues appendix and you will avoid a lot of problems.
      Not because you will write more portable code, but because you start to think more of what you are actually telling the compiler that you want to do.
      A language isn't just syntax. It is a way of thinking when it comes to dealing with problems.
      Once you think they way of C your code is going to be really robust.

      I also don't really think that using a language with a lot of safety features will help you that much.
      The difference is that your bugs won't be crash bugs or cause buffer spill, but the bugs will still be there.
      Instead the bugs will lead to the program not doing as intended but without being detected.
      If your code is doing anything important that can be even more dangerous.

    5. Re:Optimisations by Anonymous Coward · · Score: 0

      They aren't.

      Its just that their bugs tend to go undetected in higher level languages.

    6. Re:Optimisations by serviscope_minor · · Score: 1

      Personally I think optimizations around null pointer dereferences are symptoms of the worst form of brain damaged stupidity and/or intentional malice in compiler developers

      Lots of people think this. Those people are astonishingly arrogant. That means you.

      Compiler writers aren't some cackling evil genius masterminds in some shadowy cabal figuring out how to make programmers hard due to language pedantry.

      That's not how compilers work.

      Optimisers are code analysers and theorem provers. First you write a code analyser which figures as much as it can about any piece of code, such as range of values, data flow, aliasing, etc. Then you plug in the rules (which is the language spec). You then provide a list of transformations known to improve speed.

      The theorem prover then crunches on the data to figure out which transformations it can apply which don't change any of the known properties of the code.

      Theorem are not human. They have no way of knowing which null pointer dereferences are bugs and which are not.

      What you are asking is for the compiler vendors to do all those handy optimisations but then insert human-like intelligence into the theorem prover so it can know when one particular deduction at the end of a very long series of inferences should be flagged and when another is valid. You're then ragging on because they're not magicians.

      they're not intentionally emitting UB they're emitting code that is correct provided that UB has not already happened.

      --
      SJW n. One who posts facts.
    7. Re:Optimisations by Anonymous Coward · · Score: 0

      They have no way of knowing which null pointer dereferences are bugs and which are not.

      Um, what? When is a null pointer dereference not a bug?

    8. Re:Optimisations by Anonymous Coward · · Score: 0

      they're not intentionally emitting UB they're emitting code that is correct provided that UB has not already happened.

      It's my position that his is not a reasonable assumption, given that nobody on the planet is capable of writing a program that's free of UB.

      It's a shame that -Wunreachable-code does not differentiate between if (CONSTANT) and if (p == NULL), because most code contains hundreds to thousands of instances of former, which makes the warning useless for detecting the latter. I'd love to see it split into two, so we could use -Wno-unreachable-code-const and -Werror=unreachable-code-inferred ... as compiler defaults.

  9. I like this by Anonymous Coward · · Score: 0

    it makes more sense to just raise the bar and make security consciousness a part of being a programmer than to rely on 'safe'-ty obssessed newage languages, imho, since a better idiot will always be made.

    as far as C itself goes, it would probably be a good idea to incorporate a lot of the best practice idioms into the language itself. we already got #pragma once for example, but it could be taken further with compiler extensions, then from there let the ISO formalise the popular ones. C11 already has done a lot of modernising, so may as well keep the ball rolling.

    1. Re:I like this by Anonymous Coward · · Score: 0

      What he's saying is that the C standards (variadic arrays) are broken. C89 on the other hand does not have the same problems he talks about.

      Essentially, if C went back by a few years, where sane people wrote the specs, it just might be worth it.

  10. Yes, it is a machine language by theurge14 · · Score: 1

    So treat it like one. JavaScript coders should go work on Atom or something.

    1. Re:Yes, it is a machine language by shoor · · Score: 1

      I was going to post a complaint about calling C an assembly language. As someone who did a lot of assembly language programming back in the day, I really dislike that kind of remark because it is so misleading.

      Calling C a 'machine language' on the other hand. Hmmm. Programming in machine language for me was when you actually toggled code in from switches on the front panel (Yeah I go back that far.) But I don't think anyone will confuse C with that kind of machine language. So yeah, in the sense of being a language to communicate with the machine at the machine's level, maybe it is.

      --
      In theory, theory and practice are the same; in practice they're different. (Yogi Berra & A. Einstein)
    2. Re:Yes, it is a machine language by Oligonicella · · Score: 1

      I've coded in machine language. C is not machine language.

  11. Never Ignore Warnings/Have Strong Coding Rules by mykepredko · · Score: 4, Insightful

    Before I read TFA, I was expecting to learn something about C coding that I didn't before.

    I learned years before to NEVER, NEVER, NEVER ignore warnings. Very smart people put in those warnings and you should take heed of them. The example given (initializing a local variable in a switch) is something that you should never do - initialization must always be done outside of conditional code. If the initialization value changes according to conditions, then initialize the variable at the define with an invalid value and then test for it when you use the value outside the switch statement.

    Demanding that there must be a clean build with no warnings before code goes to QA is a great way of minimizing unexpected problems down the road (I have found that before QA tests any code, they build it and send it back if any warnings come back). It doesn't take a lot of work to fix warnings and if the coder doesn't understand the reason for the warning, then they should be educated as to the reasons why it is a problem.

    There are a number of APIs and constructs (like strncpy, memcpy and VLAs) mentioned in the article that never be used as a matter of course. Their use should be laid out clearly in the coding rules/guidelines and it only takes a few seconds to add grep statement to a make file to look for specific APIs and terminate the build if they're found. I've done this for years for teams that I've lead and there's usually a bit of grumbling but when you explain the reasons why you should always get compliance.

    From my experience, inadvertent coding (security) issues comes from not having a strong set of build (acceptance) and coding rules right from the beginning of a project.

    1. Re:Never Ignore Warnings/Have Strong Coding Rules by gweihir · · Score: 1

      Yes. At least "-Wall" and when some warning is really not an error (it happens), tell the compiler explicitly to ignore the thing at the specific place where it happens.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    2. Re:Never Ignore Warnings/Have Strong Coding Rules by Aighearach · · Score: 1

      I can't count the number of times I downloaded some open source that didn't work out of the box, or had some bug, and when I went to fix it the compiler spit out pages of warnings... well, I don't roll like that, so I usually resolve all of those first. And the original bug is gone, like 85% of the time.

      Of course, that means sending in a patch would be useless, but that is a whole different ball of earwax.

    3. Re:Never Ignore Warnings/Have Strong Coding Rules by Tom · · Score: 4, Insightful

      I learned years before to NEVER, NEVER, NEVER ignore warnings.

      This.

      Amateurs fix their code until all errors are gone.
      Professionals fix it until all warnings are done.

      --
      Assorted stuff I do sometimes: Lemuria.org
    4. Re:Never Ignore Warnings/Have Strong Coding Rules by Anonymous Coward · · Score: 0

      Why would a compiler issue warnings?

    5. Re:Never Ignore Warnings/Have Strong Coding Rules by Anonymous Coward · · Score: 0

      I like to avoid initializing local variables. Compilers will nowadays warn if one of the code branches leaves it uninitialized. This in turn lets me find out about forgotten initialization code branch at compile time rather than at runtime when the behavior is wrong.

    6. Re:Never Ignore Warnings/Have Strong Coding Rules by angel'o'sphere · · Score: 2

      Professionals fix it until all warnings are done.
      By writing

      #pragma ignore warning 101

      above every offending line ;D

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    7. Re:Never Ignore Warnings/Have Strong Coding Rules by phantomfive · · Score: 1

      Oh yeah, you reminded me why I haven't seen an "uninitialized variable" bug in a loooooong time. It's because the compiler gives you a warning if you do it. It's mostly not a problem anymore.

      --
      "First they came for the slanderers and i said nothing."
    8. Re:Never Ignore Warnings/Have Strong Coding Rules by mykepredko · · Score: 1

      Pragma'ing out a warning/error is a firing offence in my book and that's why I have QA build the code before they test it.

    9. Re:Never Ignore Warnings/Have Strong Coding Rules by angel'o'sphere · · Score: 1

      I hope you did not mean a firing squad?!!

      Actually if you know what you are doing, a pragma might be the exact right thing to do. I don't rewrite comprehensible _correct_ code into a harder to understand variation, just because there is a warning (emphasize on _correct_).

      Warnings are warnings, not errors, for a reason. And putting a pragma on top of it means: I have examined the point in question and have decided the code is ok.

      Anyway, probably you did not see my smiley in my previous post, so I repeat it ;D

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    10. Re:Never Ignore Warnings/Have Strong Coding Rules by Anonymous Coward · · Score: 0

      >> I learned years before to NEVER, NEVER, NEVER ignore warnings.

      Oh, bull pucky. The standard library headers generate a gajillion warnings. You're telling me you've investigated and disabled/mitigated every one of them?

    11. Re:Never Ignore Warnings/Have Strong Coding Rules by Anonymous Coward · · Score: 0

      what do you call someone who fixes it until it compiles

    12. Re:Never Ignore Warnings/Have Strong Coding Rules by strikethree · · Score: 1

      There are a number of APIs and constructs (like strncpy, memcpy and VLAs) mentioned in the article that never be used as a matter of course.

      I think you (they?) meant strcpy, not strncpy.

      That being said, using strcpy is perfectly fine. Yeah, using it as a generic copy function is not merely dangerous, but stupid as well; however, I would argue that if you control all of the conditions that strcpy operates under, it is perfectly safe to use. The issue is that programmers rarely try to control all of the conditions that it operates under and use it as a generic copying mechanism. That is going to bite you in the ass sooner or later. Especially when dealing with multi-threaded programming.

      --
      "Someone needs to talk to the tree of liberty about its ghoulish drinking problem." by ohnocitizen
    13. Re:Never Ignore Warnings/Have Strong Coding Rules by strikethree · · Score: 1

      Amateurs fix their code until all errors are gone.
      Professionals fix it until all warnings are done.

      Merely getting 'rid' of the warnings is not sufficient. You have to understand the warnings and WHY they are being triggered. If you merely get rid of the warning without understanding why it was triggered, it will lead to very-hard-to-troubleshoot bugs that are incredibly subtle in nature.

      I fundamentally agree with the position of "get rid of all warnings". I am only adding that you need to fully understand WHY those warnings were triggered. Used an ANSI 99 construct and didn't use the appropriate compiler flags? You will get warnings.

      --
      "Someone needs to talk to the tree of liberty about its ghoulish drinking problem." by ohnocitizen
    14. Re:Never Ignore Warnings/Have Strong Coding Rules by mykepredko · · Score: 1

      strcpy is not a concern compared to strncpy because the destination string ALWAYS ends with '\0' (ASCIIZ). With strncpy, the destination string may not be terminated with a '\0' character.

      Say you had the line in your code:

      strncpy(destArray, "myke", strlen("myke")); // Apparently a perfectly reasonable way to copy a string to a destination

      // But, "destArray" is loaded with "myke"/NOT "myke\0" which IS a valid ASCIIZ string produced by "strcpy(destArray, "myke");"

      and if the code after the statement was reading to the terminating null character, it wouldn't find it and continue to read which should lead to a seg fault and application crash, but that doesn't always happen in different systems and this becomes an intrusion vector.

      Not using "strncpy" is part of a coding philosophy/strategy/rules which eliminates or at least minimizes the opportunity for security and other problems down the road.

  12. Horrible Arguments by Anonymous Coward · · Score: 0

    People who do not know to build secure things with C should be prevented from talking about it.

    This is the worst kind of a talk I've seen in YEARS. Mission critical systems have been written in C and they all work without idiots like him having to talk bad about it.

    1. Re:Horrible Arguments by Tough+Love · · Score: 0

      Mission critical systems have been written in C and they all work without idiots like him having to talk bad about it.

      Spoken as someone who has never written a mission critical system, or in C.

      --
      When all you have is a hammer, every problem starts to look like a thumb.
    2. Re:Horrible Arguments by Anonymous Coward · · Score: 0

      I'd have to say the same for you given my entire solar manufacturing shop is (excepting the desktop computers) using 100% C code in the embedded robotic systems.

    3. Re:Horrible Arguments by Tough+Love · · Score: 1

      And did you write that C code?

      --
      When all you have is a hammer, every problem starts to look like a thumb.
    4. Re:Horrible Arguments by Anonymous Coward · · Score: 0

      Yes, if you were the one to speak about it.

      Disclosure: I've worked on the Linux kernel.

    5. Re:Horrible Arguments by Tough+Love · · Score: 1

      Disclosure: I've worked on the Linux kernel.

      Here, you never know who you're really talking to, do you? (Interpret that as you wish.) And do you support the claim "they all work" in reference to mission critical systems written in C?

      My take on it: past a few thousand lines you basically need to be a rocket scientist to develop mission critical code, whatever the language. C makes it harder than C++. But C makes it easier than assembly.

      --
      When all you have is a hammer, every problem starts to look like a thumb.
    6. Re:Horrible Arguments by Anonymous Coward · · Score: 0

      Across this entire fucking thread, you moron: Learn to write some C code and troll other developers.

    7. Re:Horrible Arguments by Tough+Love · · Score: 1

      Have you been drinking?

      --
      When all you have is a hammer, every problem starts to look like a thumb.
    8. Re:Horrible Arguments by Anonymous Coward · · Score: 0

      Every rocket scientist/insert one of your choice knows that C makes it possible to exactly build what they want as precisely as possible.

      C is concise and perfect. It is not meant for kids like you know think rust is a solution for problems. Rust/C/any language at the lowest level will be hardcoding constants, including what's the memory adddress ranges to map, what registers to save -> than rely on some elegant high level construction that will clearly just not work on every piece of hardware.

      The first rust implementation was not written in rust, but in C++ https://github.com/rust-lang/rust/tree/0.1/src/rt

      The first C++ implementation was not written in C++, but in C http://www.softwarepreservation.org/projects/c_plus_plus/cfront/release_e/src/cfront.pdf

      Here's what I am saying: You need to learn a lot of things before you come here and start trashing other people about your made up knowledge on what C is and isn't. People have built a lot of things on C and if you do not know, you should go out there and learn.

    9. Re:Horrible Arguments by Tough+Love · · Score: 1

      You show every sign of being intermediate level programmer who believes they have nothing left to learn. And remember, here you never know who you are talking to.

      --
      When all you have is a hammer, every problem starts to look like a thumb.
    10. Re:Horrible Arguments by Anonymous Coward · · Score: 0

      No, I've been reading your replies. It's worse than drinking.

    11. Re:Horrible Arguments by Anonymous Coward · · Score: 0

      Excuse me, You're a random dumbass on the Internet. You comment on people's ability to code, who the fuck are you anyway?

    12. Re:Horrible Arguments by Anonymous Coward · · Score: 0

      And did you fuck your sister?

    13. Re:Horrible Arguments by Anonymous Coward · · Score: 0

      The first rust implementation was not written in rust, but in C++ https://github.com/rust-lang/r...

      No, the first Rust compiler was written in OCaml, as someone already mentioned upthread. What you've linked to is the language runtime, needed in that form because the 2012 Rust was a very different language, with things like green threads and a garbage collector, and yes, that runtime was written in C++. The compiler was self-hosted by then, though.

      Most of that should be obvious if one consults the readme file one level above the linked directory. So, why haven't you? If not seeking to wilfully misinform others, that level of carelessness doesn't instill confidence in your knowledge of the matter.

    14. Re:Horrible Arguments by Anonymous Coward · · Score: 0

      There's literally a commit there and you keep blabbering about it. GTFO

    15. Re:Horrible Arguments by Anonymous Coward · · Score: 0

      Actually, you should see commit #g6b7c9 and you'll find lib.ml, main.ml etc

      However, Ocaml itself is written in C. So the guy who pointed out the problems with the Ocaml still did not see the irony in the argument.

    16. Re:Horrible Arguments by jma05 · · Score: 1

      > Every rocket scientist/insert one of your choice knows that C makes it possible to exactly build what they want as precisely as possible.

      Scientists avoid C every chance they get. Too much plumbing. They prefer Fortran, Julia, Python, MATLAB etc.

      > than rely on some elegant high level construction that will clearly just not work on every piece of hardware.

      Rust just leaves that to LLVM.

      > The first rust implementation was not written in rust, but in C++ https://github.com/rust-lang/r...

      Actually, it was first written in OCaml. This was before it hit GitHub.

      > You need to learn a lot of things before you come here and start trashing other people about your made up knowledge on what C is and isn't.

      And you need to read the online Rust book before you understand what Rust is. Right now you don't.

    17. Re:Horrible Arguments by Anonymous Coward · · Score: 0

      I think what the author of that meant was that your high level LLVM still relies upon hardcoded instructions, offsets and system specific offsets (syscalls, segments and the like) than create everything out of thin air. If anything strives to do exactly that (what C does) it essentially replaces C. But no, we don't have anything close to it yet.

      The only reason to use rust to write system code today is if it's ABI compatible with C. No argument for rust holds good unless rust can literally replace C (and does exactly what C does). Then what has been created is just C, with extra steps. Which may as well, be in C.

      Nobody needs to learn rust just so that trolls like you want it to be rewritten from C. And frankly, it does not require a rewrite because insert-hipster-language-of-your-choice is available.

    18. Re:Horrible Arguments by jma05 · · Score: 1

      > The only reason to use rust to write system code today is if it's ABI compatible with C.

      Again, you don't understand Rust. Most C++ code today is better written in Rust.

      > No argument for rust holds good unless rust can literally replace C

      That's probably because you have not written any Rust code. You will like it, if you have some functional programming background. Else, it may take longer to understand what it brings to the table.

      Rust does not have to replace C. C can stay C. But outside a very small selection of software that is best written in C, C is overused. Rust is a replacement for C in those areas.

      > Nobody needs to learn rust

      People just need to write non-buggy code and C is not helping. Rust is not the ultimate language. I can imagine better. And either Rust will further evolve or we will get other alternatives. But C is a dinosaur that only people who have invested decades of their lives and can't see beyond can love.

      My main argument is not promoting Rust. It is about NOT using C, when it can be avoided. Too many people use C who should not be, for things that don't need C. I personally favor Nim, a somewhat obscure language and transpile it to C, over Rust. It better suits my needs. But I appreciate the amount of thought that has gone into Rust.

      There will be a lot more expressive, high-performance languages coming out, thanks to LLVM making it easy to create them. These will replace both C and C++ in a number of areas.

    19. Re: Horrible Arguments by Anonymous Coward · · Score: 0

      Teaching people to write non buggy code is better than telling them: here, use a language and the bugs will be gone.

      That is exactly what happens when people who don't know C program in C, or talk about it without realizing that they have to git gud at it.

    20. Re: Horrible Arguments by jma05 · · Score: 1

      Writing non-buggy code in Haskell is very different from writing non-buggy code in Assembler. Completely different strategies and paradigms.

      Programming languages do significantly promote or reduce errors. You haven't even bothered to read the article (nor the Rust book). Yet you think you have an opinion.

      Even experienced C programmers make errors that users of other languages simply don't make. You can have a lifetime of C experience. You will still make errors in C because it is an unsafe language by design. You can't eliminate all bugs, but you can eliminate entire classes of bugs by a more thoughtful language designs. We have learnt a lot in the decades since C about programming language design. You just haven't caught up.

      If you think you are writing bug free code in C, it is only because either you are writing fairly simple code or your code has not been audited by a security expert.

      You don't sound like you used any modern languages with sound type systems, let alone Rust.

      Quotes from the article:
      "Even if you're a C expert, as are most of the Linux kernel developers, you can still make killer blunders."

      "C language itself has fundamental, unfixed bugs that await the unwary"

        "C comes with some worrisome baggage, undefined behaviors, and other weaknesses that lead to security flaws and vulnerable infrastructure."

      These aren't my opinions. These are consensus positions of C experts. They still use C because they have to. Most don't.

    21. Re: Horrible Arguments by Anonymous Coward · · Score: 0

      There used to exist a system of engineering where those who wrote correct code went on to build bigger better peojects.

      As that got lost with businesses trying to squeeze features out of engineers, that system gradually lost to one with bugs where tools, not crafstmanship became the mainstay of coding.

      Hence emerged a generation of rotgen engineers who would be absolutely clueless about how everything worked and would only focus on the high level things.

      It has nothing to do with the language, merely working with the wrong people causes people to write shitty code.

      True C experts never forget how harsh it is and what writing production quality code means.

    22. Re: Horrible Arguments by Anonymous Coward · · Score: 0

      These undefined behaviors are what C experts try to avoid. Not learning why C works the way it is, makes a person a noob, not an expert.

      If you believe the idiot who gave the talk is an expert, you are free to do so. If you believe that C experts do not understand the conveniences of modern hipster languages, you are free to do so.

      And you are free to get back shit that you're slinging around as well.

    23. Re: Horrible Arguments by jma05 · · Score: 1

      You sound like an old timer wistfully looking at some glorious past where you had a nice station.

      The entire point of system design is to create tools that prevent errors. It should not take talent to do anything. We should take art and reduce it to a science.

      If we know that people keep making certain errors, the solution is not to find the elite of the elite who have fewer cognitive lapses. It is to understand why the errors occur in the first place and eliminate them at the machine level, where we can reliably control things. This is system engineering.

      Please don't be a craftsman. Be an engineer. Think like one.

      "Civilization advances by extending the number of important operations which we can perform without thinking of them." - Alfred North

      Make things easier so that we can advance to the next level of problems, rather than getting stuck in the old ones.

    24. Re: Horrible Arguments by Anonymous Coward · · Score: 0

      There are no old problems. Just made up new problems where people tried to abstract things away and then complain when their abstractions just won't work anymore.

    25. Re: Horrible Arguments by jma05 · · Score: 1

      > These undefined behaviors are what C experts try to avoid.

      Don't try to avoid them at personal level. Fix them, at the tool level. Else, people will choose better tools.

      > Not learning why C works the way it is, makes a person a noob, not an expert.

      C is just a tool. If it is not improving itself to handle the more complex problems the world provides, it will get discarded and people will look for other alternatives. It is a free world.

      If C or C++ programmers want their investments to stay relevant, they have to innovate. But they have stagnated and others are picking the ball. The C/C++ communities are so lethargic that asking for even simple conveniences that do not impose any additional costs is too much. I think C and C++ will be generational things. Younger programmers will just move on to more modern, better designed tools. They won't put up with archaic ways of doing things.

      I'll ignore the rest of the post because it is just frustration without arguments.

    26. Re: Horrible Arguments by jma05 · · Score: 1

      https://ruudvanasseldonk.com/2...

      Again, what is this abstracting away? It outputs the exact same machine code as C compilers do. It is more mathematical. It is safer. It is more concise and readable. It is more explicit. It is better typed. Exactly, what is the complaint?

      > people tried to abstract things away and then complain when their abstractions just won't work anymore.

      Not sure what you have in mind. We are not talking about something like Haskell here, where abstract stuff is a goal onto itself, not the machine.

      Cost free abstractions are good. There is no excuse in not having more of them available to reduce avoidable errors.

      C control structures are abstractions. Why do you declare that we must stop adding further cost free abstractions to the toolbox? Is C some holy standard that must never be improved further? Is the risk of falling off arrays and strings so much more edgy, even when we now can avoid that at no cost? That way, we can call ourselves real men or women? This is like laughing at seat belts and air bags in the face of accident statistics.

      No, accepting bitter empirical evidence for safety and employing safeguards is the mature, professional thing to do.

    27. Re: Horrible Arguments by Anonymous Coward · · Score: 0

      Your argument is like saying, your hardware is bad, fix it by writing a tool for it.

      And then someone uses the tool in the worst possible way and complains about it. That person is you. If you had learnt to use that tool properly you wouldn't have problems.

      Do you want a child to walk into a machine shop and play around and not get hurt? Then get them a toy box. That is what young programmers are. But if they need to step up and see reality, do not mask it from them.

      You need to rethink your statements.

    28. Re: Horrible Arguments by Anonymous Coward · · Score: 0

      Let's say you're on a vacation and you're near a canyon. You have a baby that if you want to safeguard, you have to look after. You cannot expect a baby to be bubble wrapped and survive a fall.

      You should take steps and be careful. It's the right thing to do.

    29. Re: Horrible Arguments by Anonymous Coward · · Score: 0

      Except, the baby here is the Junior Programmer, not you.

    30. Re: Horrible Arguments by Anonymous Coward · · Score: 0

      And the canyon is the real world, bubble wrap is rust.

    31. Re: Horrible Arguments by jma05 · · Score: 1

      Sigh. It isn't just junior programmers who keep shooting themselves in the foot, it is also the senior ones. It is their exploit-ridden code that makes the news, not a young man's college project.

      My argument is: Your hammer is useful, but we found out that a lot of people are getting hurt using it, even experienced users. We know what we need to do to make it so that it does not hurt people. With some changes, it will be just as efficient, but safer. No, we don't need to dumb it down. This modern material is better and costs the same as your current one. Also weird: somehow, the users seem to think they can solve every problem with it. They even keep banging on screws. They think screwdrivers are for sissies. Anyway, there is this other hammer in the market with a rubberized grip.

      Your response is: Nah! This is a classic design. It must always be like this, frozen in time, more or less. Users should just man up and blame themselves. Yeah we know; we made our hammer super slippery that it keep flying out of hands at the slightest distraction. But we won't provide a better grip. It is your job to find the right gloves if you need. Post alert signs. Wear helmets if you must, but that is your problem and choice. Join a special hammering class so that you can learn all complicated rules to measure humidity, sweat factor, swing speed, striking angle - things that increase the incidence of hammer incidents and oh mental exercises so that you stay alert and always on your toes. Hammering is for Jedis. We can't just put a grip and have it be safe for average Joes. We have a reputation to protect.

    32. Re: Horrible Arguments by Anonymous Coward · · Score: 0

      There are two things about every computer: hardware is frozen, hence the interface is frozen (C); the software on top (OS/application/library) should work between theoretical (better grip) vs practical (lack of it). This has been because one is trying to find solutions for: do exactly what I say vs. protect me, I don't know what I am doing.

      One needs both. The interface cannot dictate the implementation.

    33. Re: Horrible Arguments by jma05 · · Score: 1

      This isn't about the baby.
      This is about the dads who keep walking off the cliff, all the same.

      Quote: "Even if you're a C expert, as are most of the Linux kernel developers, you can still make killer blunders."

      This is saying that there have been enough deaths that the canyon needs some guard rails - for child and adult alike.
      This is saying that simply warning people and posting signs has proven inadequate over 4 decades. Time for new measures.

    34. Re: Horrible Arguments by Anonymous Coward · · Score: 0

      Those developers need to start writing better code in C then.

      There's no reason to move away from C, just add safeguards like you said. Iff they require it.

    35. Re: Horrible Arguments by Anonymous Coward · · Score: 0

      Those safeguards are actually simple, just move back to good old C, without any of the fancy abstractions, like allocate n elements from a stack - and we might see better behavior all around.

  13. Look at Embedded. by 0100010001010011 · · Score: 2

    We have MISRA and the Barr Group Embedded C Coding Standard

    Start producing code that passes those checks and I bet a lot of the 'issues' go away.

    1. Re:Look at Embedded. by Anonymous Coward · · Score: 0

      Had a look at the Barr one.
      Most of what they have to say is good, but then they go on about aligning things and using spaces instead of tabs.
      I disagree very much.
      Aligning things means that you have to update the alignment of all items every time you add one that is longer than previous.
      Using spaces instead of tabs is a choice, but one they make purely because they want aligned declarations.
      Even if you have a tool that automatically fixes alignment, it creates excessive churn in patches, making it harder to identify what actually changed.
      Other than some small differences on how exactly to indent case statements, where to place {, it pretty closely matches existing kernel coding guidelines.

    2. Re:Look at Embedded. by Anonymous Coward · · Score: 0

      So we should stop using dynamic memory allocation completely? Sounds like a good idea (sarcasm)

    3. Re:Look at Embedded. by Chelloveck · · Score: 1

      Tabs are fine IF AND ONLY IF you use them exclusively for indentation, and you use exactly one tab per indentation level. You CANNOT use tabs anywhere beyond the first non-tab character in the line, though. Doing so screws up all the presumed benefit of tabs as indentation. Having never met a programmer who was successful at meeting these constraints, I have to throw my hat onto the "spaces" side of the debate.

      Whether or not alignment is a good thing is orthogonal to the use of tabs. You can use tabs to indent and use spaces to align. The complaint about unnecessary churn is well taken, though. That's a real problem. Personally I think alignment gives enough of an improvement to readability to make the churn worthwhile but I can see where others may disagree.

      --
      Chelloveck
      I give up on debugging. From now on, SIGSEGV is a feature.
  14. Why is this even a thing? by Anonymous Coward · · Score: 0

    This sounds like an argument for spending 10x the effort of what it would take to, uhh, just learn C.

    There is a growing culture of trying to use various techniques to save you from making simple and silly errors, at the expense of putting you into a fantastic position to make much deeper and more serious errors, by virtue of allowing you to handwave away having to understand the complexities of the overall system at hand. Most such techniques are usually nothing more than vastly overrated shims and hacks (looking at you, RAII).

  15. Rust propaganda by Anonymous Coward · · Score: 0

    I laugh every time one of these articles comes out. Someone, in at least a moderate position of respect, gives a talk/writes an article about safer C programming, and some Rustards try to spin it. This will dry up and be forgotten and we'll be right back to writing C. All hail the One True Language, C, and pour a hot bowl of grits down the front of your pants.

  16. AKA.... by GerryGilmore · · Score: 2

    ....kernel developers actually know how to use C.
    Seriously...C is an extremely efficient and powerful language, but it must be wielded by thos who know how to use its power.
    Every time I thought I knew a little C, one of my programmers - who really knew his shit - would just blow my mind with some of his routines. Function calls that returned pointers to the next function (state-machine type stuff) just blew my mind first time I saw it used. Blindingly fast, but damned difficult to debug.
    Even with my background in assembler, some of their stuff was just amaizing.
    OTOH, I would never consider writing, say, an ERP app in C, but for kernel work, interface routines, etc. it just cannot be beat.

    1. Re:AKA.... by jma05 · · Score: 2, Insightful

      > Function calls that returned pointers to the next function (state-machine type stuff) just blew my mind first time I saw it used. Blindingly fast, but damned difficult to debug.

      The article is partly about avoiding such cleverness.

      From the article: "You can do almost anything with C, but that doesn't mean you should. "

      C is a "dangerous language" (in the words of the kernel developer) as is. The last thing one should be doing is to make it worse with black magic like this. If you want to get clever with passing around functions, use Lisp/ML.

  17. Kookie, Kookie! by Anonymous Coward · · Score: 0

    Lend me your comb!

  18. If only... by technosaurus · · Score: 1, Informative

    C could be a lot better at being closer to the machine. It actually lacks several features in order to placate defunct architectures.

    * stdint-style types for size_t, ptrdiff_t, etc...
    . - allows better portability for embedded
    . . 1. ex. size8_t for indices that won't exceed 255
    * lacks largest integer register type
    * vector types and extensions - use arm's naming (optional?)
    * only single word tokens (ex. unsigned long long double complex)
    * ascii only (ebcdic et.al are defunct) => 'z'-'a'==26
    * 2s complement
    * iee-754
    * big/little endian
    * define , >>>, >> and to remove undefinedness
    . -- differentiate between logical and arithmetic shift * standardize functions for common ops
    . - ror, rol, ctz, clz, parity, popcount, etc...
    * switch for "strings"
    . - use ~strcmp and ~bsearch (or if tree for small number of cases)
    . . 1. *simplified versions of bsearch + strcmp
    . . 2. compiler internally sorts strings
    . . 3. could be extended to other non-integer types
    * ability to define bit size of parameters and enums.
    * function pointer types are inside out ... unless you typedef them - WTF
    * function pointers != lamba/block/etc... could be more efficient (ex. qsort)
    * _Generic provides 10% functionality with 90% of the work (it sucks)

    To name a few. Anyone else know of a "saner C" standard that makes most of the undefined-ness go away?

    1. Re:If only... by Anonymous Coward · · Score: 1, Informative

      Uhm, C has like half of those and a fourth of them just doesn't make sense.

      Like, size_t isn't an index, why would you want to have a size8_t? Use uint8_t instead. It is exactly what you want.
      You have single word tokens if you use the stdint.h types like you should.

      The logical/arithmetic shift isn't there specifically to cater to older architectures that doesn't have a barrel shift.
      If you want arithmetic oeprations you should use division and let the compiler replace with an arithmetic shift.
      If it doesn't then the compiler doesn't do it's job and it has nothing to do with the language.

      Like really. Many of your points are addressed in the C standard and the C99 rationale. You should read them.

      Also, claiming to want C to be close to the machine while suggesting switch for strings and a plethora of features that would cause function calls with multiple loops in them on a bunch of architectures is more than just a little bit inconsistent.

      Many features are omitted specifically because they would be hard to implement on many architectures, like the parity one.
      It would be great for Z80 maybe, but since 8080 doesn't treat the parity bit the same and many processors doesn't have them using it would force the compiler to insert a function call that loops through your data to get the parity. (Or use a folding algorithm.)
      Since it isn't portable anyway, you could just use inline assembly for that part.

    2. Re:If only... by Anonymous Coward · · Score: 0

      What a load of crap. Please don't talk about things you don't understand.

    3. Re:If only... by Anonymous Coward · · Score: 0

      Which ASCII table has 27 letters in the lowercase alphabet? 'z'-'a' should be 25, right?

    4. Re: If only... by Anonymous Coward · · Score: 0

      Do not compare C, the language to C, the Library.

      As such, I hate the newC specifications. C89 or go bust.

    5. Re:If only... by technosaurus · · Score: 1

      Uhm, C has like half of those and a fourth of them just doesn't make sense.

      Like, size_t isn't an index, why would you want to have a size8_t? Use uint8_t instead. It is exactly what you want.

      Nope it would work as expected on 8 bit systems, but on 32 and 64 bit architectures it can cause an unnecessary instruction

      The logical/arithmetic shift isn't there specifically to cater to older architectures that doesn't have a barrel shift. If you want arithmetic oeprations you should use division and let the compiler replace with an arithmetic shift. If it doesn't then the compiler doesn't do it's job and it has nothing to do with the language

      By not having a standardized method to do arithmetic/logical shift or rotation, it forces programmers to use equivalent idioms to hopefully coerce the compiler into optimizing it into the intended operation ... it _usually_ does, but when it doesn't, it can have negative effects on performance and/or security. What you end up with is a 10 line encryption algorithm that becomes 20kb worth of #ifdefs for various architectures and compilers that is difficult to audit and port to new architectures.

      Like really. Many of your points are addressed in the C standard and the C99 rationale. You should read them.

      The standards want to maintain backward compatibility with architectures that are less and less relevant. Architectures that don't use 2s complement, ascii and iee754 are becoming extinct. By having a subset of "sane" architecture definitions, 90% of the undefined-ness goes away.

      Also, claiming to want C to be close to the machine while suggesting switch for strings and a plethora of features that would cause function calls with multiple loops in them on a bunch of architectures is more than just a little bit inconsistent.

      That one is more a matter of portability (from other languages), simplicity and maintainability (vs. a tree of if (!strcmp(s,"foo") foo(); else if ...) a roll your own state machine, jump table or binary search. It isn't difficult to implement on the compiler side and would produce cleaner, more maintainable and typically more performant code.

      Many features are omitted specifically because they would be hard to implement on many architectures, like the parity one. It would be great for Z80 maybe, but since 8080 doesn't treat the parity bit the same and many processors doesn't have them using it would force the compiler to insert a function call that loops through your data to get the parity. (Or use a folding algorithm.) Since it isn't portable anyway, you could just use inline assembly for that part.

      That is well covered in hacker's delight for architectures that do not support it (and many others) Using inline assembly is a total bullshit argument if you want portable code - besides the inline assembly not being portable itself, you'd end up with pages and pages of #ifdefs for a single line of code (depending on the number of architectures, compilers etc...) AND the compiler wouldn't be able to optimize it.

      For the AC comment "Which ASCII table has 27 letters in the lowercase alphabet? 'z'-'a' should be 25, right?" ... typo - friggin slashdot's inability to display a less than sign without writing the html entity - I switched it to equal and didn't change the value - noticed after I submitted as well as the left shift operators.

      Having a largest integer register type is important now that we have ILP32 for 64 bit capable architectures (long doesn't work) - Neither c99 or c11 provide an equivalent - You cannot just use long long because that can be a compiler implemented aggregate type on some architectures.

      Since many compilers already implement vector extensions, having common type definitions and an optional support macro to indicate support, would drastically simplify a lot of code

    6. Re:If only... by ls671 · · Score: 1

      C could be a lot better at being closer to the machine. It actually lacks several features in order to placate defunct architectures. ....

      * ascii only (ebcdic et.al are defunct) => 'z'-'a'==26 ....

        To name a few. Anyone else know of a "saner C" standard that makes most of the undefined-ness go away?
         

      you forgot to mention off by one errors; 'z'-'a'==25, not 26 as far as I know...

      --
      Everything I write is lies, read between the lines.
    7. Re:If only... by Anonymous Coward · · Score: 0

      He already commented on that - chock another one up to slashdot's inability to edit posts or convert characters to html entities or use any type of markdown for code. How many stray trademarks are there in just this one thread because of a single quote?

  19. same old, same old by magzteel · · Score: 2

    There's nothing new here.

    Different languages have their strengths and weaknesses. I've coded professionally in assembly, Plus, Pl/1, C, C++, C#, Perl, Python, Basic, Visual Basic, Java, Javascript, Bash, TCL, TK, and probably a few more I've long forgotten. Right now Java is a great fit for the problem domain I'm working in. Fortunately I can express myself well in it and the Java developer tools and ecosystem are great.

    When C is the appropriate tool I don't hesitate to use it. But I don't hesitate to use my chainsaw when I'm cutting up trees either.
    You just have to know what you are doing before you start the engine.

  20. C is dangerous... by hcs_$reboot · · Score: 1

    ...to the incompetent.

    --
    Slashdot, fix the reply notifications... You won't get away with it...
    1. Re:C is dangerous... by jma05 · · Score: 4, Insightful

      RTFA: "Even if you're a C expert, as are most of the Linux kernel developers, you can still make killer blunders."

      If you think you are immune to C dangers, you aren't an experienced programmer at all.

    2. Re:C is dangerous... by hcs_$reboot · · Score: 2

      If you think you are immune to C dangers

      Never said that. Would be more like "If you pretend to be immune to C dangers...". Of course C has its dangers, but even more so when people think they can program in C because they're used to Java or another high level language.

      --
      Slashdot, fix the reply notifications... You won't get away with it...
    3. Re:C is dangerous... by phantomfive · · Score: 1

      My favorite is people who say, "You don't need to worry about memory because you're not using C." Almost guaranteed that those people have memory leaks all over their code no matter what language their using.

      --
      "First they came for the slanderers and i said nothing."
  21. C was a great language 30 years ago. by TiggertheMad · · Score: 2, Insightful

    C is broken. Here is my analogy to prove to you why: C is a very powerful low level language, that has few guard rails to get in the way of whatever it is you are trying to do. It is like a giant wood chipper, in that it will easily eat up anything you feed into it: Oak trees, 2 x 4's, old couches, anything. It also has no safety mechanisms, like guard rails, kill switches, occasional mechanical inspections, etc. Would you consider ever going near such a device in the real world? Of course not, it would be far too easy to make one mistake and die horribly.

    Why would you choose a language that is the virtual equivalent of a huge dangerous tool, when there are better options available, like Rust or Go? Oh, sure, you are a skilled and expert level coder and you would never make rookie mistakes with void pointers or buffer copies, but are you writing all the code at your org yourself? What about all the other bozos that you work with, you trust them not to screw up?

    I grew up with C/C++, and it has a special place in my heart, but I also know that much better things have come along in recent years. Just because you grew up driving a 57 Chevy, doesn't mean it is better than a modern car with ABS, Air Bags, Cruse control and 42 mpg.

    --

    HA! I just wasted some of your bandwidth with a frivolous sig!
    1. Re:C was a great language 30 years ago. by Anonymous Coward · · Score: 0

      No, you did not grow up with C/C++. And C++ isn't C.

      C is like metal. If anyone knows how to build a guardrail with it, they are the ones who should build railroads and then the trains on them.

      C is clearly not for some whiner who complains about not having a guardrail to run their toy car on it.

    2. Re:C was a great language 30 years ago. by Anonymous Coward · · Score: 0

      I recall back when C++ came out and I played around with it. At that time there were a bunch of folks on CompuServe arguing about how C++ was so much better than C.

      It was funny watching those C++ acolytes (much like today's Rust acolytes) telling everyone how C++ was better better because what it was doing you couldn't do in C. That was until someone pointed out that C++ was a fancy preprocessor (CFront) that generated C code that was fed into a C compiler and others demonstrated classes using structures with function pointers and some fancy macro tricks.

      So same discussions, different forums. I actually wouldn't mind a resurgence of CFront to write "C++ style code" but not have the baggage of the C++ compiler or libraries.

    3. Re:C was a great language 30 years ago. by Anonymous Coward · · Score: 0

      Oh lord! Slashdot needs an upvote button. You, sir, have mine.

    4. Re:C was a great language 30 years ago. by jma05 · · Score: 1

      > That was until someone pointed out that C++ was a fancy preprocessor

      So what? C++ is a new language, even when it was written on top of C.

      I like Nim and transpile it to C. I don't like to write raw C - too error prone, not enough productivity features. But Nim on top of C is fine.
      Likewise, there are plenty of languages (Elm) written on top of Node.js that are nothing like Javascript.

      Ultimately, everything is machine code. That does not mean the programming experience is the same - not even close.

      You haven't made a point.

    5. Re:C was a great language 30 years ago. by Jane+Q.+Public · · Score: 1
      That doesn't make it "broken" at all.

      That makes it a very powerful tool that you do not have the wherewithal to use carefully enough, so you should not be allowed near it.

      Why would you choose a language that is the virtual equivalent of a huge dangerous tool, when there are better options available, like Rust or Go?

      Because it's far faster and far smaller than either of them. WTF? How old are you?

      Yes, it's dangerous. And that's why rookies like YOU should never be allowed to run free with it.

      They aren't "better". They're "different". They have their own problems too. You're trading careful integrity for ease of use. Watch out, cowboy.

    6. Re: C was a great language 30 years ago. by Anonymous Coward · · Score: 0

      C is to be as close to the machine code and meant to interact with machine code through a well defined ABI.

      That's the real purpose. If the machine doesn't expose bounds checking, C does not. For everything like that, there is a cost and C does not mask it.

      Now if you're telling me rust does exactly that, it is just another dialect of C.

    7. Re: C was a great language 30 years ago. by jma05 · · Score: 2

      > Now if you're telling me rust does exactly that, it is just another dialect of C.

      That is not at all what I am telling you.

      https://ruudvanasseldonk.com/2...

      It generates the same machine code as C, except with safer and more concise constructs.

      I would say that you are arguing that we learnt no better way to do things in the last 4-5 decades in programming language research in terms of generating safe and efficient machine code. That is just absurd. C is a dinosaur that exists mainly for legacy and compatibility reasons.

      This is about being a luddite, hanging on to 45 year old way of doing things. This is not a religion. Let there be more Rust alternatives with other paradigms, not just the borrow checker. But it is time to wake up and catch up with modernity.

      Again, read the Rust book, examine the machine code it generates and decide for yourself. If you really are smarter than an average programmer, you should pick up Rust in no time and take it for a spin on a small project. This is not mind-bending Haskell. It is easier than OCaml. All your machine awareness from C still carries over. You are just less likely to shoot your foot. Oh and C programmers do keep shooting their foot (which is the point of the article). They are like diabetics who don't often realize that they have and keep telling they feel perfectly fine.

    8. Re: C was a great language 30 years ago. by Anonymous Coward · · Score: 0

      There is no safety mechanism that is zero cost unless there is a machine feature / instruction for it. If C doesn't provide that, it's because the hardware doesn't. If rust provides that, it may be overkill for those who want to not incur that cost. Simple.

    9. Re: C was a great language 30 years ago. by Anonymous Coward · · Score: 0

      Math is more than 45 years old and if it's not broken don't try to fix it. Go and find someone else to bother.

    10. Re: C was a great language 30 years ago. by jma05 · · Score: 1

      Once again, you refused to read the article.

      The language and compiler technology are two different things.
      The language has nothing to do with the machine. The language is a cognitive tool. It targets humans.
      The compiler targets the machine.
      You can absolutely have languages that prevent human lapses and errors while generating the same efficient machine code.

    11. Re: C was a great language 30 years ago. by jma05 · · Score: 1

      And C is a very lousy language to express math.

      Math is abstract and eternal.
      C is a historical technology artifact from when programming language theory was in its infancy.

      > if it's not broken don't try to fix it

      When C enables more errors than every major non-scripting language (other than the assembler), it is broken.
      The response? Oh, it is just that you are not l33t enough child. Now run along.

      The C community did not bother fixing it and instead rested on its laurels.

    12. Re: C was a great language 30 years ago. by Anonymous Coward · · Score: 0

      It's like with bounds checking. I don't get how people fail to see that it takes TIME to check every array access; that's function call overhead.

    13. Re: C was a great language 30 years ago. by Anonymous Coward · · Score: 0

      C is not broken. Why fix it?

      C was of this philosophy: You do the very basics, leave the decisions higher up. If you want to optimize for security, you optimize for it. If you want to optimize for performance, you optimize for it, if it means removing conditionals.

      It's the wisest thing to do.

      If people prefer one way of doing things (say, security at the cost of performance and generality), they should build those abstractions on top of C (what rust is) and just stick to it.

    14. Re: C was a great language 30 years ago. by jma05 · · Score: 1

      Again, you did not read the article.
      https://ruudvanasseldonk.com/2...
      Rust compiler did not include bounds checking overhead (not function call overhead. Just as with C, you can also inline functions in Rust) in the machine code either.

      There is no overhead. This is why Rust is different from all the other C/C++ alternatives that preceded it. This is what is meant by "zero cost abstractions".
      By using modern abstractions over the old, naive and primitive ones that directly translate in C, Rust has more information to do better compile time checks. But it keeps the runtime code exactly as lean as C compilers generate.

      Quote:
      "All overhead is gone completely. What happened here? First of all, no loop is used to compute the inner product. The input slices have a fixed size of 12 elements, and despite the use of iterators, the compiler was able to unroll everything here. The element-wise computations are efficient too. There are 12 movslqs which load a value from the buffer and simultaneously widen it. There are 12 multiplications and 12 additions, 11 for the inner product, and one to add the delta after arithmetic shifting (sar) the sum right. Note that the coefficients are not even loaded inside the loop, they are kept in registers at all times. After the sample has been computed, it is stored simply with a mov. All bounds checks have been elided. The final three instructions handle control flow of the loop. Not a single instruction is redundant here, and I could not have written this better myself."

      If C can be seen as a high-level assembler, so can Rust.

      C is primitive, naive translation to machine code since its 70s bare bones constructs don't have enough information for the compiler to better understand your code. Modern languages like Rust benefit from decades of Computer Science research in compiler technology. Its newer constructs give more information to the compiler to perform static checks but strips these from runtime. To make C safer, you need additional frameworks that supply that metadata. But most don't use those or even know about them. And they are very tedious to use because they are bolt-ons.

      Till now, modern languages generated good code, but they didn't stop there. They took it further and made the code even more concise and safer by including a few inexpensive runtime checks and not inexpensive garbage collection. But this meant that they were not strict C alternatives even if they were generally better general purpose languages.

      Rust avoids all those enhancements in the core that cost anything and only keeps things that don't prevent it from generating C like machine code, while providing better safety and productivity at compile time. It is not as safe or concise and elegant as Haskell or OCaml code. But it eliminates the excuse that only C allows you to squeeze out every ounce of performance. Earlier, only C++ kept the strict principle of zero-overhead abstractions. But it has become so unwieldy that no one really understands all of C++. Rust is a cleaner re-imagining of C++ using modern design from ground up. There is nothing in Rust that prevents you from generating machine code as lean and light as C does.

      You can however choose to forgo that and use higher abstractions. With Rust, you can write very high-level code like Scala or extremely low-level code for a micro-controller. The overhead is what you decide it should be.

      http://pramode.in/2018/02/20/p...

    15. Re: C was a great language 30 years ago. by Anonymous Coward · · Score: 0

      It's easy to actually unroll code in C, if using Macros. Also, C compilers do perform unrolling, function versioning and function multiversioning. You're naive if you assume that people do not know how to compile C code into target with as few conditionals as possible.

      The lower level interfaces written with C - such as the kernel are usually written with very few abstractions / optimizations as possible, as opposed to much higher level libraries, where a lot more can be achieved with your modern compilation techniques.

      The original argument was that even allocating dynamic number of elements from the stack (subl %esp) had issues that plagued security. Pretty sure this argument will be applicable once a kernel is written in rust.

      Let them complete writing the kernel in rust and let it work in production, then people will pretty much realize the same thing that is wrong with C is wrong with rust as well.

  22. C is not broken. C will not replace * by Anonymous Coward · · Score: 1

    C was never made to give you everything you could build on top of it, just the bare minimum so that you could build stuff on top of it, like better libraries, tooling, higher order abstractions and all that.

    If you believe anything, believe that the bootstrap for many of today's languages came from C, including C++. And if you think any magical new language can solve any problem, you should know that this is proof that C can solve any problem, because if can create a magical new language (or any abstractions thereof).

    So suck on that and come back when you childish programmers learn to program with C.

  23. C is beautiful by Tom · · Score: 4, Insightful

    Oh, I love C. In my mind, you cannot call yourself a programmer unless you have delivered at least one non-trivial piece of software in C.

    Why?

    Because C is the no-training-wheels programming language. It is the "I'm not saving you from yourself" language. And more importantly, it is the "I will do what you say, not what my compiler writers think that you maybe meant" language. C will do what you tell it to do, it is the original embodiment of the Unix philosophy. It doesn't second-guess the programmer. If I do that, the computers job is to execute, not to think I'm an idiot and can't write code. I probably meant to dereference that pointer, I probably somehow made sure that it's safe and if the compiler can't see it then it assumes that it is wrong, not me.

    Such beauty.

    Of course, like professional tools in the physical world, in the hands of amateurs they instantly become dangerous. Don't give a chainsaw to a five year old, ok? Not a good idea. And don't give dynamite to a teenager, or something will get blown up and you don't know what.

    So is it dangerous? You bet it is. Does it produce insecure code? Almost certainly because very, very few people can actually handle that stuff safely. And no, I don't count myself among them, it's been way too long since I actually wrote code in C.

    But there is something to the beauty and the immediacy of having a computer not trying to think for you.

    --
    Assorted stuff I do sometimes: Lemuria.org
    1. Re:C is beautiful by phantomfive · · Score: 1

      C is beautiful because it reaches its goal in a very clear and concise way. There aren't many languages like that. PHP is basically the opposite: reaches its goal in the most confusing way possible.

      --
      "First they came for the slanderers and i said nothing."
    2. Re:C is beautiful by Anonymous Coward · · Score: 2, Interesting

      But there is something to the beauty and the immediacy of having a computer not trying to think for you.

      There’s something beautiful and immediate about driving without power steering, ABS, traction control, etc. too, but at the end of the day we need to admit that’s best left on a track, for sport and entertainment, and not every day use.

    3. Re:C is beautiful by Tom · · Score: 1

      Thereâ(TM)s something beautiful and immediate about driving without power steering, ABS, traction control, etc. too, but at the end of the day we need to admit thatâ(TM)s best left on a track, for sport and entertainment, and not every day use.

      Yes, there is beauty to actual driving, and if you are a professional driver I fully expect you to be able to drive without power steering, ABS, traction control and all the other systems. Even if I hire you to drive me around in a limo. Because those systems might fail. Because you call yourself a professional. Because it teaches you a lot about driving.

      Ordinary people during their daily commute should be supported by as many assistance systems as possible. Because driving is not their profession, it is just a means to an end.

      So for scientists doing some data analysis, for executives doing some business calculations, we absolutely need tools and we need easy, fail-safe, protects-you-from-mistakes programming languages. As well as for amateurs, people scripting something in a game, modding their favorite FPS or just wiping up a quick website with a scores list for their local sports club.

      Now when it comes to professional programmers, whose actual job it is to write code, we need to be able to pick the tool that does the job, and that can be a different tool for different jobs. And yes, sometimes you need to get dirty. Sometimes the oil needs to be changed or the gears need to be greased. And if you are unable to do that, then who are you talking about "coding" ?

      --
      Assorted stuff I do sometimes: Lemuria.org
  24. Re:Have you ever stuck a fork under your fingernai by Tough+Love · · Score: 2

    The only way you get buffer overflows these days is if you turn OFF the standard warnings, and use deprecated functions, while writing C.

    Hooboy is that ever wrong. You are scary.

    --
    When all you have is a hammer, every problem starts to look like a thumb.
  25. C is bad by Anonymous Coward · · Score: 1

    At work we write tons of C++ code. No memory leaks or memory corruption.

    Someone had to write a utility handling some hardware and bought that it had to be C. Now customers complain that they have to reboot every few months...

    1. Re:C is bad by Anonymous Coward · · Score: 1

      You guys know how to bitch, how to write C++ code but do not know how to hire. Too bad.

  26. Memcpy max length by Anonymous Coward · · Score: 2, Informative

    Yep. The source of numerous buffer overruns.

    Many, many years ago, I wrote a function that solved that problem. Internally, it called 'memcpy' but with a max number of items that was supplied in the call OR if it was missing, it used an application wide declaration which was usually '80'.
    Worked well for me for 20+ years.
    Other solutions are available and acceptable to me.

  27. Local variable initialisation by lyakh · · Score: 3, Informative

    "Linus [Torvalds] likes the idea of always initializing local variables." That's new to me. I've seen and often requested myself many cases of redundant local automatic variable initialisation, don't remember seen any backlash against them.

  28. VST by jd · · Score: 1

    Already used in operating systems, so we know it's powerful enough.

    Verified C has three important features, of which two cover the issues from the original article.

    First, it eliminates the ambiguities, although the current C specification has very few left.

    Second, it is possible to guarantee correctness. Technically, this has been true for any C dialect for some time, provided you avoid ambiguous constructs, but this is easier.

    The third feature, probably of greatest interest to embedded developers, is that the binaries can be proven to match the source in behaviour.

    Because it is a dialect of C, with a known ABI, GCC will compile the code - sans the binary proof. Further, ld should be easily coaxed into linking VST-compiled kernel code with GCC-compiled code if it can't already.

    So, if we went this route, we keep everything in C, we simply modify the more critical functions to use the Verified C dialect. Everything compiles as it did before, behaves as it did before, but we can now use formal methods to examine those functions.

    Because you can use GCC, there's no risk of a performance hit although Verified C is said to be comparable to GCC.

    Because we can do this one function at a time, you're not looking at a kernel rewrite but a normal-sized patch with each development cycle.

    Just as security only requires a security kernel to be correct, you don't need to do safety checking over the kernel. So this approach needs only a tiny number of functions verified.

    Is this the best solution? I don't know, but it's a proof that C can be made as safe as you like without impacting speed or functionality.

    An alternative approach is for the Big Three (Red Hat, SuSE and Ubuntu) to agree to jointly fund two projects - one to properly document Linux internals, and one to properly test the hell out of it.

    The cost would be peanuts to them, but systematic testing and systematic documentation would make finding and fixing bugs a lot easier. It isn't C that's the problem, it's digging around in C in the dark.

    --
    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)
    1. Re:VST by Raenex · · Score: 1

      It isn't C that's the problem, it's digging around in C in the dark.

      C is a big part of the problem. It's a rotten default, which is why you need all those methods on top of it before you get something approaching sanity.

    2. Re:VST by jd · · Score: 1

      Formal methods are needed to provide sanity in any language. Don't leave home without them.

      Z is as much a mainstay of the Ada community as the C community.

      Verified C has less syntax than C11.

      So I'm unsure what you're referring to.

      --
      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:VST by Uecker · · Score: 1

      What exactly are you talking about if you say "Verfied C"? I know of verified compiler such as CompCert.

    4. Re:VST by jd · · Score: 1

      CompCert specified a language called Verified C. It is implemented by their compiler in the Verified Software Toolchain. It is all explained on their website.

      --
      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)
    5. Re:VST by Raenex · · Score: 1

      Formal methods are needed to provide sanity in any language. Don't leave home without them.

      I don't foresee them gaining mainstream traction. They've been around a long time, but are still very niche.

      Verified C has less syntax than C11.

      Sure, you can take a subset of C, removing the nasty bits, but it's not C anymore.

      So I'm unsure what you're referring to.

      I'm referring to standard C.

    6. Re:VST by Uecker · · Score: 1

      Thanks

    7. Re:VST by jd · · Score: 1

      Software capable of running theorems on software haven't been around that long, to the point of being usable I'd say they're newer than Rust.

      There is no "standard C", there are only C standards. And almost nobody complies with them. So your argument is a little dubious. Everything out there is a subset.

      And, yes, subsets are a valid dialect as long as there's enough of the core there to be that language and not another. Verified C and SystemC are dialects. You understand, I hope, that programmers have recognized language dialects as being versions of the language since the 1960s. You don't get to come along and just blow away the concept because you don't like it.

      Especially when it means there are no C compilers, if you do that.

      --
      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)
    8. Re:VST by Raenex · · Score: 1

      Software capable of running theorems on software haven't been around that long, to the point of being usable I'd say they're newer than Rust.

      Maybe the caveat there is "usable". I've looked into formal methods over 10 years ago and came away non-plussed.

      There is no "standard C", there are only C standards. And almost nobody complies with them. So your argument is a little dubious. Everything out there is a subset.

      This is disingenuous. I'm talking about mainstream features that every C compiler supports. If you have to radically alter your approach to writing C programs to a subset of C, you just aren't in C land anymore, and trying to say, "See, the problem isn't C!" is a farce.

    9. Re:VST by jd · · Score: 1

      Ah. So you're saying I can drop a GCC program in Green Hills, PGC or Intel?

      Optimist.

      --
      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)
    10. Re:VST by Raenex · · Score: 1

      Ah. So you're saying I can drop a GCC program in Green Hills, PGC or Intel?

      I didn't say that. I said, "I'm talking about mainstream features that every C compiler supports. If you have to radically alter your approach to writing C programs to a subset of C, you just aren't in C land anymore, and trying to say, "See, the problem isn't C!" is a farce."

      Please avoid the Cathy Newman strawmen. Thanks.

  29. Ada would be interesting by jd · · Score: 1

    Spark (a subset of Ada for mission-critical work) would seem better, given that safety is apparent the concern.

    I say apparently as I see no evidence safety is of interest at all.

    --
    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)
    1. Re:Ada would be interesting by AHuxley · · Score: 1

      The history of computing has solved so many of the "new" problems.

      --
      Domestic spying is now "Benign Information Gathering"
  30. The problem is this by DrXym · · Score: 1, Interesting
    Approximately 50% of all CVEs related to the kernel are DIRECTLY caused by the language the kernel is written in - buffer overflows, double frees, null pointers etc. If arguably some of the most seasoned, experienced programmers of C can make these mistakes what does it say of code written elsewhere? And that's with the benefit of code reviews, coverage tools, and independent scrutiny.

    So all this talk of C/C++ being big boy's language and only a manly man should program it and it's your own fault if you write bugs is just so much bollocks. C and C++ are old languages and they have flaws that can be mitigated but not eliminated. That's Rust is so worthy of consideration - it eliminates that 50% of bugs by design and compiles with performance equivalent to C. Rust also makes it easier to write safe concurrent code, so performance can even exceed C/C++.

    That said, I understand why the Linux kernel is kind of stuck where it is, but for new projects, or existing projects undergoing major rewrites, I would at least evaluate Rust first before defaulting to a C language.

    1. Re:The problem is this by Anonymous Coward · · Score: 0

      Rust - a language pushed by a single vendor. A language without a formal specification. Yeah, I think I'll wait and watch it die, all the same to you.

    2. Re:The problem is this by iggymanz · · Score: 1

      Rust? how an I going to call into the nifty set of C++ libraries built up for my profession over decades? I realize young weenies love to think they're smart enough to roll all that from scratch but of course in reality between the bugs, misconceptions and lack of experience they'll screw things up.

      best stick with something that has solid and deep foundation

    3. Re:The problem is this by DrXym · · Score: 1

      Perhaps you should read what I wrote again. I didn't say rewrite everything from scratch.

    4. Re:The problem is this by DrXym · · Score: 1

      Maybe you should read how C and C++ started life before writing something so dumb.

    5. Re:The problem is this by iggymanz · · Score: 1

      most places would have to if they used Rust.

      I hate C and C++ by the way, did them for a couple decades...

      outside of kernel / device driving seeing more opportunity for Julia to be honest...

    6. Re:The problem is this by DrXym · · Score: 1
      It isn't true that you have to write from scratch. Rust and C link together quite easily allowing code to be a mix of both. e.g. Mozilla ripped out the mostly single threaded CSS engine written with C and C++ and replaced it with a multi-threaded one written in Rust. Mercurial is replacing chunks of Python and C over time with Rust with the end goal of making hg a compiled binary. And so on. A C compiler just sees a lib with a header and compiles and calls it, even though the code inside was written in Rust and therefore a lot safer.

      As for Julia, we'll have to see but I visited the project's site and it seems designed more as an academic / mathematical replacement for C, Fortran, R etc.

    7. Re:The problem is this by iggymanz · · Score: 1

      Rust and C, yes

      Rust and C++, no

  31. Re:Have you ever stuck a fork under your fingernai by serviscope_minor · · Score: 4, Insightful

    The only way you get buffer overflows these days is if you turn OFF the standard warnings, and use deprecated functions, while writing C.

    That's bullshit. All you have to do is access an array with an incorrect index. You won't get a warning for that. And you won't even get it flagged with a run-time check until you feed it the wrong data. You know like heartbleed.

    IOW your claim is flat out false and implies you either don't program C or you're so misinformed about it that you're a menace if you do program it.

    Like almost all languages, Rust won't normally have buffer overflows. They've hyped that so much it would make PT Barnum blush, acting like that's something special.

    It's really not the most important thing about Rust. Though in fairness it seems that so many C hackers are so misinformed about their own language and still struggling that it apparently matters.

    the borrow checker actually prevents a wide class of memory errors and data races. The former are interesting enough, though not common in C++ (I occasionally have some). The latter is much more interesting though. If I was writing high performance (multithreaded) software with irregular structure then I'd be very seriously considering Rust since it seems to be the only language up to the task.

    I'm not though, so I'll stick to C++. I'm not naive enough though to think my language is perfect just because I learned it 20 years ago.

    every modern language is safe from buffer overruns assuming a competent programmer.

    That's a foolish claim because it's tautologically true while being misleading. Assembly language is free from buffer overrnus with a sufficiently competent programmer. In practice however everyone makes mistakes.

    --
    SJW n. One who posts facts.
  32. "C is a fancy assembler. It's almost machine code" by Anonymous Coward · · Score: 0

    No.

  33. Re:Have you ever stuck a fork under your fingernai by goose-incarnated · · Score: 1

    It's really not the most important thing about Rust. Though in fairness it seems that so many C hackers are so misinformed about their own language and still struggling that it apparently matters.

    That's irrelevant. Rust isn't going to replace C. It's converting C++ devs not C devs. All the C devs who wanted a new language moved to C++. Since C++ has all the same faults of C while adding a few more, those same devs will move to Rust.

    The rust proponents (popping up everywhere to announce what they've written) who've written new packages in Rust were not C devs, they were C++ devs. C isn't going anywhere, but C++ is in danger of becoming irrelevant.

    --
    I'm a minority race. Save your vitriol for white people.
  34. EditorDavid tips his hand, or is an idiot. by Anonymous Coward · · Score: 0

    Anytime someone brings up rust in a C discussion it (and s/h/it) can be safely ignored. Instead bringing up random idiot comments from other sites and elevating them to the summary here brings up the question of Hanlon's razor.

    I say "both", in the case of our esteemed current crop of idiot editors.

  35. Re: Have you ever stuck a fork under your fingerna by Anonymous Coward · · Score: 0

    Every language from assembler up has always been safe assuming infallible programmers. Competent is both too low a requirement and rarely true anyway. No programmer is ever infallible, we struggle to manage competent all the time.

  36. Re:Have you ever stuck a fork under your fingernai by serviscope_minor · · Score: 1

    That's irrelevant. Rust isn't going to replace C. It's converting C++ devs not C devs.

    Yes very likely. I think at this point nothing will shift the C diehards except for retirement.

    Since C++ has all the same faults of C while adding a few more, those same devs will move to Rust.

    That's only technically correct (isn't that the best kind?). In practice C++ mitigates a lot of the faults of C (though technically doesn't remove them).

    but C++ is in danger of becoming irrelevant.

    Eventually perhaps? Obviously there's a lot of momentum in C++ right now, and it won't fade to obscurity any faster then C. Rust can certainly make things possible/practical that aren't in C++. Whether that's compelling enough remains to be seen, but it's certainly an interesting direction for native code.

    Rust's still behind C++ in some important places, like nontype parametrics.

    --
    SJW n. One who posts facts.
  37. Why not use XXX? ... Here's why: by Qbertino · · Score: 1

    The Linux Kernel is the most valuable piece of software on the planet, by a wide margin. It powers the vast majority of all computing devices and work on it was started when C was a perfect choice for system programming. Now finally some new system languages are coming along, but they are decades behind C and even more behind on big software projects like the kernel.
    Before rust or anything other can take over we are more likely to see a shift in CPU architecture. Rust or something like that will probably take over when some new purpose built FOSS kernel come around and does away with truckloads of legacy stuff Linux has to deal with.

    C is basically assembler in "a tad more readable" with assembler being nothing other than opcode in "a tad more readable". That the kernel still works seems to prove that their choice of sticking with c can't be all that wrong. And should c eventually be replaced, the whole kernel will be replaced, that just about a no brainer.
    Linux thinks you shouldn't be using a debugger, because of you're doing kernel code you should know what your are doing at all times and if it turns out you didn't you should backtrack manually to find every aspect of the fault. This is hardcore shit not intended for wussies, this is the foundation those wonderful python applications run on. And I for one trust that the kernel team knows what it's doing. Their installbase seems to agree.

    My 2 eurocents.

    --
    We suffer more in our imagination than in reality. - Seneca
    1. Re:Why not use XXX? ... Here's why: by iggymanz · · Score: 1

      sorry but writing a kernel in C is too complicated a problem for even the smartest kernel coders to handle, they've made hundreds of horrible mistakes over the years. the kernel teams doesn't always know what they are doing. kernel is a rube goldberg contraption.

    2. Re:Why not use XXX? ... Here's why: by Anonymous Coward · · Score: 0

      " kernel is a rube goldberg contraption."

      So it has something in common with the hardware onwhich it runs..

  38. C != C++ by Anonymous Coward · · Score: 0

    C/C++ is not an 'amateur night' programming language,

    I stopped reading right here. C and C++ are NOT the same damn language. There is no language called "C/C++" either.
    It's the first sign you have ZERO clue of what you're talking about. They might have a common ancestry, but they're not the same.

    It's about the same if you had say a brother named Robert and I just decided one day to start calling you Rick/Robert. Since you know, the two of you look pretty similar, right?

  39. Re:Have you ever stuck a fork under your fingernai by phantomfive · · Score: 1

    every modern language is safe from buffer overruns assuming a competent programmer.

    Even for incompetent programmers, ASLR and other protections in the OS layer protect you from buffer overflows to a surprising degree.

    A good programmer will write good code in any language. A bad programmer will write bad code in all of them.

    --
    "First they came for the slanderers and i said nothing."
  40. The trouble with... by Anonymous Coward · · Score: 0

    The trouble with making bridges is that you have to know what you are doing. If you don't know when to weld, where to weld, or where to place an arch, well its just dangerous. Arguably, you could just make a bridge-building kit that takes away most of the design work and every bridge would be exactly the same.

    Yet, we make bridges various ways. We expect engineers to know their craft and avoid the mistakes. We use various simulation tools to test the designs. The same is true with all disciplines...doctors, space engineers, etc. It's important that we not remove skill from the software development process because a disturbing trend today is to make all things accessible to anyone who has not learned the necessary skills. No one wants to pay for a $250K engineer with 2 decades of experience, they want someone fresh out of school at $90K because now you can throw them in some managed code and get a result that still runs. It's hard to think of other skilled trades where the job market favors the inexperienced and unproven with highly complex engineering tasks.

  41. Another added problem. by Anonymous Coward · · Score: 0

    Who will be migrating the giant software from a C language to a 'stronger C' language?

    1. Re:Another added problem. by Anonymous Coward · · Score: 0

      Can't AI and other Automated tool do that? That's why it is called a COMPUTER, i guess. To automate things.

  42. Re: Have you ever stuck a fork under your fingerna by Anonymous Coward · · Score: 0

    The implication here seems to be its not possible to meaningfully improve on C. Which is absurd, the question is whether it improves on C enough, not whether it's an improvement in the first place.

    Nice in theory to have a team where all programmers are competent, but on large projects this does not happen, and even competent programmers have lapses.

  43. an algorithm to 'Make C Less Dangerous' by NikeHerc · · Score: 1

    This is a simple algorithm: find better C programmers! What idiot programmer uses a variable before setting it? When a programmer is "omitting break in a switch," https://www.hpe.com/us/en/insights/articles/making-c-less-dangerous-1808.html that's not a shortcoming of C, it's a shortcoming of the programmer.

    From the provided link: 'Why does memcpy() have no "max destination length" argument?' Seriously? If you want to copy "a" to "b" and avoid overrunning "b", do something akin to memcpy (b, a, min (bytes_in_a, sizeof (b))), where min() returns the lesser of its two arguments. This isn't rocket science, people, it's skilled coding.

    If you are a C coder who is too lazy or stupid to follow sound programming principles, then you should switch to a less demanding language and leave C to the expert coders.

    --
    Circle the wagons and fire inward. Entropy increases without bounds.
    1. Re:an algorithm to 'Make C Less Dangerous' by Anonymous Coward · · Score: 0

      You see what you just did there? You made C slower than BASIC with that type of code like: memcpy (b, a, min (bytes_in_a, sizeof (b)))
      That's the argument of TFA, Make C less Dangerous but with those safety checks, it will make C slow and almost similar to 3G or 4th G languages.

    2. Re:an algorithm to 'Make C Less Dangerous' by NikeHerc · · Score: 1

      You made C slower than BASIC...

      Troll, min() coded as a #define means (roughly) five instructions (load/compare/conditional branch/load/push) vs. two instructions (load/push) when the third argument is a variable or constant. Nice try, though.

      --
      Circle the wagons and fire inward. Entropy increases without bounds.
  44. Delphi Object Pascal outperformed MSVC++ by Anonymous Coward · · Score: 0

    Delphi Object Pascal outperformed MSVC++ in Sept./Oct. 1997 Visual Basic Programmer's Journal issue titled "Inside the VB5 Compiler" in 4/6 tests (tying 1 w/ MSVC++ (both MSVC++ & Delphi lost to VB5 in ActiveX form loading)) - especially in MATH (by double) & STRINGS (by 4-5x) & EVERY program works on those.

    * NO C/C++ BUFFER OVERFLOW POSSIBLES EITHER due to null-terminated string use - Pascal has length built-in to strings = why (so Object Pascal's safer - especially since even modern C++11 or better std. is NOT fully available in ALL C++ compilers fully implemented).

    APK

    P.S.=> It's the reason I chose it for my hosts file engine (better performance by default - ESPECIALLY in STRINGWORK) - hosts file work is largely stringwork (safer too due to the above)... apk

    1. Re:Delphi Object Pascal outperformed MSVC++ by HiThere · · Score: 1

      Standard Pascal strings were limited to 255 ASCII-7 characters. IIUC FreePascal has a variant kind of string that allows longer strings, and another variant for Unicode. Also a version for binary blocks. The Pascal strings could contain embedded null chars. (Well, so could the C strings, but the utilities would end the string a the first null.)

      --

      I think we've pushed this "anyone can grow up to be president" thing too far.
    2. Re:Delphi Object Pascal outperformed MSVC++ by theweatherelectric · · Score: 1

      Standard Pascal strings were limited to 255 ASCII-7 characters.

      But this hasn't been the case for decades. Try FreePascal or the community edition of Delphi to see the current state of Object Pascal.

  45. Re:Have you ever stuck a fork under your fingernai by bingoUV · · Score: 1

    It was actually a yes or no question.

    --
    Bingo Dictionary - Pragmatist, n. A myopic idealist.
  46. Re:Have you ever stuck a fork under your fingernai by gweihir · · Score: 1

    Rust has done one thing EXTREMELY well - hype. Like almost all languages, Rust won't normally have buffer overflows. They've hyped that so much it would make PT Barnum blush, acting like that's something special.

    The only way you get buffer overflows these days is if you turn OFF the standard warnings, and use deprecated functions, while writing C. So Rust's "claim to fame" really just comes down to "on one very specific point, it's safer than C used to be back in the 1980s".

    I've looked at Rust enough to know I don't want to use it any more than I want to wipe my ass with a cheese grater. I don't have to test that out to know it's not a good idea. They have done a phenomenal job of hype, though, comparing it to 1980s C. Guess what - C in 2018 also isn't 1980s C, every modern language is safe from buffer overruns assuming a competent programmer.

    I fully agree on this. And I do write software in C, including, for example, some long-running pretty large multi-threaded demon recently for a customer. You only code buffer overflows in C these days when you are reckless or incompetent. The problem the Rust fanatics cannot see is that reckless or incompetent people will write bad Rust code too. The bugs will just be much harder to find than buffer overflows, which are pretty easy to find with modern tools. Fuzzing, higher compiler warning levels, looking for use of known-to-be-unsafe library functions (strcpy, e.g.), code-review of candidate code snippets, etc. all work well.

    Getting rid of buffer-overflows in a language causes as much and possibly more problem than it solves and just makes some people think they can write complex code in Rust "safely". Not so. For example, botched access right handling in business code (something I see regularly when reviewing code) is a much worse problem than a buffer overflow and Rust can do exactly nothing about that. It is hard to find, but if somebody finds and exploits it, there is no warning. No crash to indicate something went wrong. The promises made by the Rust propaganda are mostly lies, often not directly, but in what is implied.

    Rust does not turn a bad coder into a good coder. It does make bad coders much more dangerous, because now the bad coder cannot make some obvious mistakes anymore that would nicely point out their lack of skill. Now the bugs become subtle and the code runs just fine when somebody attacks them. The problem really is that the designers of Rust do not understand code security at all and that the "leadership" behind Rust probably believes they can now hire even cheaper coders than the incompetent bunch they were using before. Buffer overflows in code are a problem, but much more and much more importantly they are a symptom of bad coders.

    Now, I am well aware that Rust does some other things and some of them are quite interesting for assessing code quality. They are a complete fail at improving code quality, because they miss the root-cause entirely. What Rust essentially does is allow bad coders to hide longer.

    --
    Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
  47. Re:Have you ever stuck a fork under your fingernai by gweihir · · Score: 1

    C++ is also a much worse language than C. Its design is overly complex, its performance when you really use OO is problematic, the access rights are a mess, it suffers massively from the "second system effect", etc. You can basically only use it as an example how to not design a language. IMO C++ should definitely not be used by anyone. Going from C++ to Rust, I can see why people mistakenly believe Rust is their salvation. They flee a disaster area for something that works moderately well. And probably a lot of them believe the marketing lies that come with Rust and think they can now finally produce good code. Competent C coders do not care though.

    --
    Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
  48. Re:Have you ever stuck a fork under your fingernai by gweihir · · Score: 1

    A good programmer will write good code in any language. A bad programmer will write bad code in all of them.

    And that is the key insight. The Rust fanatics think that they can magically change that, like countless other morons in the history of coding. It never was a tool problem and, unless we get AI that can code well one day, it never will be a tool problem. It is a problem of insight and skill. What I really din't get is how these people can ignore all the evidence. In all other engineering fields, it is well known that the primary safeguard against problems is a competent engineer and that everything else just helps to improve efficiency, and can only moderately improve safety and certainly cannot replace insight and understanding. Just some larger faction of the coders believe in their technological field is completely different and that eventually there will be a "silver bullet" (Brooks, 1975), that finally will make coding an activity where they do not screw up. Well, of course they will continue to screw up, because they are mistaken about where the core problem is.

    --
    Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
  49. Re: Have you ever stuck a fork under your fingerna by Anonymous Coward · · Score: 0

    Your last sentence PROVES why rust will never be used mainstream.

    Good programmers who write for the kernel CHOOSE to use C still to this day. Decade after decade we keep asking "why don't we write the kernel in...it's safer". And the kernel devs keep telling you guys NO. We write good code in C and like it. Deal with it.

  50. Re:Have you ever stuck a fork under your fingernai by goose-incarnated · · Score: 1

    but C++ is in danger of becoming irrelevant.

    Eventually perhaps? Obviously there's a lot of momentum in C++ right now, and it won't fade to obscurity any faster then C.

    C++ doesn't have a flagship project that is currently one of the most important and foundational projects of the software world like C does (Linux kernel), which means it can easily fade into obscurity and be relegated to niche projects. The ongoing work on the Linux kernel ensures that C isn't going to fade until the kernel code is replaced with something else.

    --
    I'm a minority race. Save your vitriol for white people.
  51. Great news for QA by Anonymous Coward · · Score: 0

    Keep programming in C, folks, you will keep QA engineers employed forever!

    1. Re: Great news for QA by Anonymous Coward · · Score: 0

      QA was literally invented when incompetent folks started programming.

  52. Re:Have you ever stuck a fork under your fingernai by jma05 · · Score: 1

    > Rust does not turn a bad coder into a good coder.

    The point of Rust is to allow good coders actually write better (not perfect) code. With C, good coders still manage to write bad code while thinking they are golden. That is the entire point of the article, which you seem to have glossed over.

    Don't worry. No business coder is going to pick up Rust and start writing bad kernels and drivers. That won't happen.

    I suggest you actually read the Rust book.

    https://doc.rust-lang.org/stab...

    It is a good read even if you don't plan to ever use it.

    For someone who has clearly not given Rust a proper look, you have way too strong opinions.

  53. Re:Have you ever stuck a fork under your fingernai by serviscope_minor · · Score: 1

    C++ doesn't have a flagship project that is currently one of the most important and foundational projects of the software world like C does (Linux kernel)

    All that C code is compiled with GCC which is now written in C++. Sometimes it's compiled with LLVM which the clang front end and the back ends are in C++.

    --
    SJW n. One who posts facts.
  54. Re:Have you ever stuck a fork under your fingernai by serviscope_minor · · Score: 1

    C++ is also a much worse language than C

    that's an opinion and a wrong one at that.

    Its design is overly complex, its performance when you really use OO is problematic, the access rights are a mess,

    Sure, bt it's still a much better choice than C.

    You can basically only use it as an example how to not design a language. IMO C++ should definitely not be used by anyone.

    Yes, well your opinions are silly becase it seems you'd rather micro-manage your computer than automate the task of managing it. Whatever floats your boat I guess.

    --
    SJW n. One who posts facts.
  55. RUST programmers are worse than Vegans by Anonymous Coward · · Score: 0

    > "Sound good," posted one of their commenters, "though ultimately I'd like kernel devs to adopt Rust as their main Linux kernel development language. Beats the crap out of C and C++ combined."

    Said the zealot without offering anything concrete to back up his beliefs.

    Q: What's the difference between a militant fundamentalist and a RUST programmer? A: You can reason with the militant fundamentalist .

    Is it true Alt-Right are terrified of RUST Programmers?

    1. Re:RUST programmers are worse than Vegans by Anonymous Coward · · Score: 0

      LOL.

      How do you spot a Rust programmer?
      They'll walk up to you and tell you to replace C with it.

  56. You're an idiot by Anonymous Coward · · Score: 0

    Sorry but we're too busy to learn every technology some opinionated asshole tells us we absolutely must learn. I did look at RUST and decided it's overrated and not worth learning. A case of 'who ordered that?' Far better ways I can use my time.

    RUST beat people who decline to get on the RUST hypetrain sticks and pitchforks. Python is extremely popular but Pythonites don't need to to use sticks and pitchforks because Python sells itself.

    Your arrogant zealotry only turns people off.

  57. Not the case for decades... apk by Anonymous Coward · · Score: 0

    See subject (others told you the same) & I used shortstrings 255 char length (the limit of hosts/domain names in hosts) & I got more performance actually using those + short int length where possible (vs. std. integer or bigger sizes) to keep them on the local stack & if/when possible, in the CPU L1/L2/L3/L4 cache for data also so it processes faster (vs. going to global heap slower system RAM).

    APK

    P.S.=> So what you said WORKS FOR ME for better performance (but it's not the default to be 255 char ShortString in Pascal (FreePascal OR Delphi))... apk

  58. C evaluated by Anonymous Coward · · Score: 0

    I once read a (semi) humorous list in a local computer publication. I was in the 80's so I can't attribute and beg forgiveness. The comment was basically that C could be thought of as a 5,000 hp motorcycle, being the single fastest way from point A to point B, if you knew what you were doing. If not, it was the single fastest way into REALLY, REALLY, REALLY BIG TROUBLE.

  59. Really? Uninitialized variables? by strikethree · · Score: 1

    We were discussing the issues of uninitialized variables before C ever was an ANSI standard. The consensus was that you initialized your variables on declaration and if for some reason you could not initialize the variable upon declaration, you did not use the contents of the variable until you did assign it a value.

    So how is this a problem today? Powerful tools are absolutely dangerous. If you can't work with powerful tools safely, then don't.

    When I repaired electronics for the military, I had to work around devices that would operate at millions of volts (Electronic Warfare devices). If I screwed up, I would become ash instantly. You just can't do powerful things without dangerous tools. Untrained personnel should not be working on such devices and yet with software, we have the equivalent of 5 year olds working with millions of volts.

    Not everything can be made safe, childproof, or foolproof and if you try, you will find that you have restricted yourself so much that you can't get anything done.

    --
    "Someone needs to talk to the tree of liberty about its ghoulish drinking problem." by ohnocitizen