Stories
Slash Boxes
Comments

SoylentNews is people

SoylentNews is powered by your submissions, so send in your scoop. Only 19 submissions in the queue.
posted by CoolHand on Friday May 08 2015, @09:01PM   Printer-friendly
from the off-with-its-head dept.

Ladies and gentlemen, the C programming language. It’s a classic. It is blindingly, quicksilver fast, because it’s about as close to the bone of the machine as you can get. It is time-tested and ubiquitous. And it is terrifyingly dangerous.

The author's biggest issue with the C language seems to be security holes:

If you write code in C, you have to be careful not to introduce subtle bugs that can turn into massive security holes — and as anyone who ever wrote software knows, you cannot be perfectly careful all of the time.

The author claims that the Rust language is a modern answer to these issues and should replace C (and C++). It does look that Rust can run C code, so it looks like an interesting proposition. What do Soylent's coders think about this?

 
This discussion has been archived. No new comments can be posted.
Display Options Threshold/Breakthrough Mark All as Read Mark All as Unread
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
  • (Score: 5, Insightful) by Anonymous Coward on Friday May 08 2015, @10:56PM

    by Anonymous Coward on Friday May 08 2015, @10:56PM (#180541)

    Your string can't have any zeros in it. So you can't store an arbitrary binary blob like a JPEG picture in a C string.

    Stopped reading there. Clearly the writer of this article is incompetent in regards to C. You can store arbitrary 0x00 anywhere in a char[] just fine, you just can't use the built-in string manipulation functions on it, which you shouldn't if you aren't storing 0-terminated strings in the first place.

    Fundamental types in C represent fundamental types in your CPU. A char is defined as a byte. A char* is a memory address whose value can be represented as a byte. That's all it means. The standard library provides the means to handle char* as a 0-terminated string, but you are not required to, and in fact, it's very common not to.

    If you need to, you can create a compound string type which is length-preserving. This is what structs are for.

    Starting Score:    0  points
    Moderation   +5  
       Insightful=4, Informative=1, Total=5
    Extra 'Insightful' Modifier   0  

    Total Score:   5  
  • (Score: 2) by tangomargarine on Saturday May 09 2015, @07:31PM

    by tangomargarine (667) on Saturday May 09 2015, @07:31PM (#180841)

    Aren't zero-terminated and null-terminated usually two different things? In ASCII the number zero is stored as 32+whatever.

    --
    "Is that really true?" "I just spent the last hour telling you to think for yourself! Didn't you hear anything I said?"
    • (Score: 2) by tangomargarine on Saturday May 09 2015, @07:38PM

      by tangomargarine (667) on Saturday May 09 2015, @07:38PM (#180843)

      Blargh. s/number zero/character zero/g

      --
      "Is that really true?" "I just spent the last hour telling you to think for yourself! Didn't you hear anything I said?"