You don't write out the length of the string to the file just because you're using a different programming language. When implementing a design, your goal should be to make the output the same regardless of language. And if you think fixed length string languages need to "read in" a separate length then you need to learn some programming languages that don't have C in their name.
Are you making this up as you go? There's nothing about knowing the length of the string that makes writing to files harder. In fact it makes it easier because you can write out chunks at a time instead of one byte at a time.
The compiler argument is uninformed about how compilers work, and are permitted to work by the C standard.
When discussing the rationalizations for whether or not something should have been in the C standard, referencing the C standard for justification is circular logic.
if (test_1) {
foo;/* test_1 is now garbage */
bar_flag = 1; } if (bar_flag || test_2) {
bar; }
Would a simple "do this thing" flag not work? It does take an extra assignment and comparison but that might be faster than reading an address from memory and jumping to that address.
That's only if the string is passed to a separately compiled function. You're talking about implementation details. But even assuming an extra pointer is needed, those really don't take up a lot of space in comparison to the character data itself. Certainly today the benefits gained by knowing the length of the string far outweigh any drawbacks in memory usage. And even back when memory was scarce... well, if one byte is that much concern then even C is too much. Do it in assembly and pre-calculate your character array storage needs.
Constant strings are another matter, they don't have the malloc header so something else would have to be done. Probably the easiest would be to set the malloc length to zero, it's a constant after all so doesn't need to be freed or overwritten. That does mean 4.5 bytes overhead (including alignment) though.
For constant strings the compiler could keep track of the size. You could use even less memory than C.
The problem with C strings is the same problem everyone has with C and assembler. It requires you to be absolutely competent.... The vulnerabilities to specially crafted attacks aren't mistakes. They were design choices that were correct given the knowledge the designers had at the time. Times have changed and nobody wants to pay to redo the code
According to what you wrote, the problem with C strings is not that the original programmer has to be absolutely competent, it's that that burden is placed on all future generations who use the code as well.
With sized strings you need to know the length of the complete string before you begin streaming. So you'd stream the size first, followed by the content of the string. Not good if your string could be very long and memory is expensive.
With sized stings you do know the length of the complete string. That's the whole point. And it's even better with expensive memory because you only need to allocate the given size and not some "I'm not sure how big this is going to be, I hope it doesn't try to write past the end of the buffer" size.
May be, but IMOHO, because of how poor the education system has become in the US (largely thanks to the no child left behind movement), the majority of people don't understand the extreme importance of every amendment contained within the Bill Of Rights.
Most adult Americans were out of school when no child left behind became law. I understand your point but you don't have to be overly political about it.
If what is currently "dvd only" content was made available for streaming at the same time the price was hiked, then I believe most people would have been okay with it.
It's basically an anti-theft system. If someone steals Aaron's laptop they'll have a better chance of tracking that person down. I wish my own computer had that feature.
But in your example, the jury is attempting to rule on the basis of scientific fact. An "expert" in court is deemed to be as credible as the "expert" that wrote the textbook.
You don't write out the length of the string to the file just because you're using a different programming language. When implementing a design, your goal should be to make the output the same regardless of language. And if you think fixed length string languages need to "read in" a separate length then you need to learn some programming languages that don't have C in their name.
Are you making this up as you go? There's nothing about knowing the length of the string that makes writing to files harder. In fact it makes it easier because you can write out chunks at a time instead of one byte at a time.
When discussing the rationalizations for whether or not something should have been in the C standard, referencing the C standard for justification is circular logic.
if (test_1) { /* test_1 is now garbage */
foo;
bar_flag = 1;
}
if (bar_flag || test_2) {
bar;
}
Would a simple "do this thing" flag not work? It does take an extra assignment and comparison but that might be faster than reading an address from memory and jumping to that address.
Not all fixed string languages are Pascal.
That's only if the string is passed to a separately compiled function. You're talking about implementation details. But even assuming an extra pointer is needed, those really don't take up a lot of space in comparison to the character data itself. Certainly today the benefits gained by knowing the length of the string far outweigh any drawbacks in memory usage. And even back when memory was scarce... well, if one byte is that much concern then even C is too much. Do it in assembly and pre-calculate your character array storage needs.
The could have offered both solutions. But I'd argue the "known length" string operations would be faster than the "search for null" ones.
Really? How is Ada less powerful than C?
if (test_1) {
foo;
}
if (test_1 || test_2) {
bar;
}
Something like that?
For constant strings the compiler could keep track of the size. You could use even less memory than C.
According to what you wrote, the problem with C strings is not that the original programmer has to be absolutely competent, it's that that burden is placed on all future generations who use the code as well.
With sized stings you do know the length of the complete string. That's the whole point. And it's even better with expensive memory because you only need to allocate the given size and not some "I'm not sure how big this is going to be, I hope it doesn't try to write past the end of the buffer" size.
Text files are not the same as "strings". "String length" languages can handle standard ascii text files just as well or better than C.
my_string : strings := "Content-Length: 12345"; := my_function (my_string (17 .. my_string'length));
content_length : integer
Our country was founded on the backs of colonial empires who wanted the resources of the new world and weren't afraid to take them from the natives.
Most adult Americans were out of school when no child left behind became law. I understand your point but you don't have to be overly political about it.
There exists a lower bound to intelligence.
Some days I have my doubts about that assertion.
You might be having a latency issue. It works just fine in the US when I stream, PC or Wii.
If what is currently "dvd only" content was made available for streaming at the same time the price was hiked, then I believe most people would have been okay with it.
A photo of the criminal's face will help with prosecution.
It's basically an anti-theft system. If someone steals Aaron's laptop they'll have a better chance of tracking that person down. I wish my own computer had that feature.
Ditch the sig. Listing certs looks unprofessional. Let your posts stand or fall on their content.
KUKA robot language.
At first I thought it looked like BASIC too but after some Google-Fu I'm pretty sure it's KUKA Robot Language.
But in your example, the jury is attempting to rule on the basis of scientific fact. An "expert" in court is deemed to be as credible as the "expert" that wrote the textbook.