Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×

Comment Re:Human hubris is to blame... (Score 1) 663

Where do you put gas in your gas when the power grid is down as all pumps need electricity to pump?

All the fuel stations near me continue working when the power is down. What kind of backwards regressive area are you in where businesses that run on electricity don't have backup generators?

Comment Re:Good compilers (Score 1) 102

After their last standard they were dumbfounded to learn that the changes they made to the C99 standard turned memcpy into undefined-behaviour.

I am not sure what you are talking about. memcpy is defined as part of the standard library so certainly not causing undefined behaviour when used as intended.

From this link over here:

That last sentence in 6.5 Para7 is a hack added when the Committee realized it had made it impossible to write memcpy in C

Their solution was to add a footnote with an exception for memcpy, meaning that you can't implement memcpy() in C (your implementation has no exception).

It gets worse though:

Yes, according to the C Standard, malloc cannot be written in C. In fact, the example of malloc in K&R 2cd edition is not written in C according to the standard under current interpretations. Instead there is special treatment for malloc as a mystery library function so it can return pointers to data of “no declared type” even though malloc is defined to return pointers to void. What if you want to write an allocator, not called malloc/free? I don’t know, perhaps you are supposed to use Rust or Swift.

So, once again, the standard crippled the implementors by making sure they can't use standards-compliant C to write the malloc/memcpy implementation, then turned tons of existing legal code into illegal code.

It actually gets a lot worse when you start reading up on the current interpretations of the standard.

C persists for a reason, and that reason is simplicity and ease of understanding.

There are several other reasons such as: widely support on all kinds of architectures, very lightweight, and a large existing code base.

C11 took the C++ approach and made well-understood C99 constructs confusing. There is no value in a C that is hard to read.

I am not a fan of C11 myself but it did not change much and I am not sure what it made more confusing. Can you clarify?

Yeah, they added annex K (a good thing) then made it optional, so now there are C11-conforming programs which compile under one conforming implementation but not under another conforming implementation. They should've left it out completely or made it mandatory.

But, even mandatory, it still has problems (this is from a committee member, btw):

As a result, adopting the APIs in an existing code base requires non-trivial changes that are far more intrusive than the simple edits envisioned in the TR 24731-1 Rationale. Testing the return value of each call to the APIs and handling runtime-constraint violations is particularly intrusive. Such changes have been observed to be a source of new defects introduced into the code base in the process, undermining the very purpose their adoption is intended to achieve. .... The paradox is that knowing how to trigger the violation would imply that the programmer who wrote the code knew of the flaw in the code he or she wrote, a highly unlikely scenario. ... The close similarity of the names and effects of the APIs to those of their standard counterparts belies some subtle differences in their behavior that tend to lead to mistakes and misuses.

There's more but you'll have to search the interwebs cos I'm too busy and/or lazy to go looking for the myriads of articles I've read over the years complaining about the additions (like threads.h/thrd_t being incomplete) or the changes to existing behaviour (like malloc/memcpy). You can start by reading the proposal here which was eventually discarded anyway. Many good ideas for C are dead on arrival due to UB (super-optimisers, static+dynamic checking, etc).

The real problem is that a few tiny changes to the C standard could make a big difference, instead the committee is giving us crap (like annex K) which they make optional anyway[1]. If every new C standard removed one existing point of UB by clarifying the behaviour of that point we'd have a pretty solid language after only a few standards (Rumours are that a few members did propose to standardise signed-integer representation as twos-complement for C2x which makes a lot of security issues go away).

[1] The only reason annex K is in is because Microsoft, and Microsft alone, pushed (and pushed hard) for it to be included. Then when it was, they made their versions of the annex K functions behave differently to the annex K spec so if you use any of the annex K functions in MSVC, then even though your code will compile error-and-warning-free on every other conforming (annex K) compiler, it will have bugs and buffer overflows. Pretty sneaky, that.

Instead of reducing UB, they add new UB to the standard.

Comment Re:Good compilers (Score 2) 102

C is at the top of the list

I credit improvements in compilers and other tools for this, primarily. Clang is amazing at flagging little problems at compile time — and newer releases of GNU C/C++ aren't bad either.

Amazing, certainly, but also a little sad. Many of the optimisations that can be done (or warnings that can be generated) are not being done/generated because of the huge body of code out there that will get broken/flagged, respectively.

Unfortunately, you cnanot blame the compiler writers nor can you blame the programmers themselves - the ANSI committee is filled with morons who have no intention of making the language spec less ambiguous. After their last standard they were dumbfounded to learn that the changes they made to the C99 standard turned memcpy into undefined-behaviour.

C persists for a reason, and that reason is simplicity and ease of understanding. C11 took the C++ approach and made well-understood C99 constructs confusing. There is no value in a C that is hard to read.

Comment Re:Sigh (Score 1) 102

This doesn't explain why C has no problem properly supporting static arrays defined *inside* the function

What do you mean "properly" supporting? I know that sizeof only works in the scope that a static array is defined in, because the compiler has that information even though the array does not know its own size. When that same array is passed to a function, the compiler does not have that information because the array does not know its own size.

When you pass arrays into a function in C, they become a pointer to memory, just as if they were malloc'ed

I hate to be the one to break it to you, but arrays are a pointer to memory even before they are passed to a function. I don't know why you think that arrays magically change when they are passed - they are passed as-is, untouched by any processing, so they are exactly the same for the callee as they are for the caller.

Comment Re:ROM? (Score 1) 31

This week, a ROM of a canceled 2007 Xbox 360 remaster of the game appeared online [...]

I don't think they know what "ROM" means. If talking about a DVD dump, people usually call that a "disc image" or an "ISO". But "ROM"? Come on now.

I don't think you know what ROM means (hint - it is not a synonym for 'cartridge').

This week, a ROM of a canceled 2007 Xbox 360 remaster of the game appeared online [...]

That makes perfect sense if you know what ROM means:

This week, a Read-Only Memory of a canceled 2007 Xbox 360 remaster of the game appeared online [...]

Comment Re:Developers! Developers! (Score 2) 169

> You don't run an infrastructure on it any more than an infrastructure runs on VI. Emacs, Eclipse or Notepad++.

Ah, I see we have an inexperienced emacs user here.

There are no experienced emacs users. I think the current record for comprehension of the full feature set is about 13%.

So, about double the record for C++ then.

Comment Re:Is this the beginning of microunionization? (Score 1) 41

It seems like maybe we are seeing that small groups of people, currently on reddit, are realizing the power of organized numbers. Except now it is for achieving temporary or short-term goals. All it takes is 1. come up with an appealing idea 2. have a plan for how multitudes of like-thinking people can leverage it and 3. post in your special interest group and then bam! ??? profit!

To be fair, this was on the wall ever since we saw over the last decade how a vocal minority can have a disproportionate silencing effect on the majority. Four butthurt snowflakes can get someone banned? Imagine what three million redditors can do. And now we don't have to imagine anymore, we saw what they did to Melvin Capital (and, indirectly, Robinhood, which can kiss 75% of their users goodbye).

To put things in perspective, the WSB mob probably had more actual support than BLM (more people poured their money into the cause for GameStop than for BLM)

Things are going to be interesting in the near future - the mob has discovered how strong it really is, and it's more likely that they will attempt a repeat of this, again and again.

Comment Re:Yet another null-terminated string bug... (Score 1) 166

It’s yet another "null-terminated sting buffer bug".

This isn't a null-terminated string error. This error would have occurred even if you *were* using length indicators because it depends on overrunning the buffer due to the final character being an escape character.

It's really time to put the idiotic null-terminated buffer paradigm behind the barn and shoot it in the head.

It's no longer 1972 where memory is so expensive that you have to scratch everywhere to save memory as much as possible!

What's wrong with strings (or buffers) with a separate length indicator?

How does having a length indicator prevent buffer overruns that using strlen() doesn't?

Comment Re:Offensive/Etical/Politically Correct... (Score 1) 258

While I agree that this licence is flawed it has to be said that lots of orgs do require and define ethical behaviour. Doctors, universities, militaries, even politics. Imperfectly but they do try with some success sometimes.

Doctors' ethical code enables them to provide services to anyone, even Hitler. This "ethical" forbids services to those some puritanical regressive deemed "immoral".

If you can't see the difference, you're part of the problem.

Comment Re:It is kind of fun to own history, esp. side pat (Score 1) 84

As much as the Zune at the time just couldn't measure up to an iPod, having one now is kind of interesting to have a little bit of history where you see a bit of an alternative path of technology, never taken...

I own a few random things like that myself, like an old internet appliance with a small detached keyboard and small monitor. It's just interesting to see what people tried back then. I also had a number of really old alternative consoles (though I eventually got rid of those so someone else could actually use and enjoy them).

In a way it's also a service to the future, as you figure unpopular side products like that were mostly discarded and probably not that many were kept in excellent condition. So my hat is off to the Zune collectors keeping history intact.

You own a cuecat too?

Slashdot Top Deals

He has not acquired a fortune; the fortune has acquired him. -- Bion

Working...