Note that the end-of-central-directory record at the end of the file contains the size and offset of the central directory, so if the central directory is not in the final 64 KiB you already have, you know exactly which range you need to request to get it (i.e. you don't need to keep scanning backwards 64 KiB at a time).
I do not share this position but I understand it may be someones legitimate opinion in general. I do not understand it here - when we are talking about a report like that.
Is it better to go unreported if the alternative is that an LLM was used in the articles creation?
Most people don't have time to read every article posted to Hacker News. Avoiding the AI slop in favor of human-written articles that promise a higher return on investment seems like a reasonable strategy. For that to work, AI slop must be accurately labeled as such.
Well, the array indices are allowed to be any sorts of integers, and the standard is worded in such a way that such addition must work correctly without overflowing — provided, of course, that the array you're indexing into is large enough. So in practice, you're bounded by the width of size_t.
Oh, and did you know that the width of ptrdiff_t is not required to have any relation to the width of size_t? There is even an explicit provision in standard for the case when subtracting two pointers into the same very large array can't fit into ptrdiff_t:
When two pointers are subtracted, both shall point to elements of the same array object, or one past
the last element of the array object; the result is the difference of the subscripts of the two array
elements. The size of the result is implementation-defined, and its type (a signed integer type) is
ptrdiff_t defined in the header. If the result is not representable in an object of that
type, the behavior is undefined.
So yeah; you should try to work strictly with indices only, they're guaranteed to be correctly addible to pointers no matter the sizes of your arrays.
C doesn't have an opinion, it allows negative indexing just fine when the index is a signed type (indexing-syntax is just syntax-sugar for pointer arithmetic).
> For the uninformed: counting backwards in a for loop is faster because comparing an unsigned integer against 0 is generally faster than comparing it against any other value.
No it's not. It generally makes no difference at all.
If you disagree, I dare you to write a benchmark that demonstrates a difference between forward and backward iteration on a modern CPU.
Hmm. I think both of you are both right and wrong!
That is, I claim that while it is no faster to execute a comparison against zero, it still can be faster to finish a loop at zero. This is because internal to the processor, the comparison and the branch are two separate ops. The comparison essentially does an arithmetic operation that sets a flag but throws away the result, and then the branch acts on it.
But if you finish at zero, the flag you are using is already set by the decrement, so no additional comparison op is necessary. Now normally this doesn't matter, since the processor is multiscalar with sufficient execution ports to fit in an extra comparison with no increase in total cycles spent. But in a tiny and highly optimized loop, occasionally you can get about 20% gain from having one fewer op to execute.
Getting this to actually happen can be complicated because modern processors do op-fusion that can "fuse" the CMP and branch back into something that can be executed on a single port. But DEC-JNZ can be fused too, which still gives it an advantage. More details on this here: https://chipswiki.org/Macro-operation_fusion
I quote from "Optimizing Software in C++" by Agner Fog:
"Comparing an integer to zero is sometimes more efficient than comparing it to any other number. Therefore, it is slightly more efficient to make a loop count down to zero than to make it count up to some positive value, n. But not if the loop counter is used as an array index. The data cache is optimized for accessing arrays forwards, not backwards."
Yet that text was written for older CPUs. Modern CPUs are better at prefetching backwards access patterns, but if you try a microbenchmark with backwards array traversal, you may get misleading results.
Agner Fog is also discussing CPU architecture, not high-level language. The whole point is that the optimizer _already_ takes knows these things and rewrites your code automatically. If you write a zero-to-100 loop in C, that doesn’t mean the assembly will literally show a value going from zero to 100; it may unroll, or reverse the loop order, or any weird combination of things that the optimizer has decided will be equivalent and fast.
That's not guaranteed. An array or variable could be modified by another thread, meaning that reversing the order of operations could produce a different result. The compiler cannot always assume that such transformations are safe, and that's why the compiler avoids implementing a lot of those optimizations that you expect to be done automagically.
So you cannot expect the compiler to automatically perform every possible optimization. The programmer still needs to understand how the code behaves and write it with performance in mind.
You may be perfectly sure that no other thread modifies the data, but the compiler doesn't know, so it avoids all kind of optimizations.
If you expect the compiler to perform those optimizations automatically, you still have to do things like declare certain variable variables and or function parameters as constant (since the compiler may otherwise have to assume that their values could be modified by side effects/threads, preventing certain optimizations), use specific attributes or annotations on functions, and provide specific compilation flags. That's more complex than simply coding the for loop backwards.
And the worst thing is that frequently the compiler assumes a constant could be modified anyway, and avoids optimizing just in case.
It's not interesting at all given that these models have been fine-tuned to hell and back to make sure they never say anything offensive at all. Remember these model were taught that it's better to kill a billion people in a nuclear holocaust than to say the n-word even once. They didn't come up with this from first principles; it was the RLHF training that forced them to say that, ridiculous as it obviously is.
And after people pointed this out the training was updated to address just this particular scenario, but they kept all the other guard rails to ensure an LLM could never offer any truly controversial opinion.
So expecting a controversial answer from an LLM is exactly as foolish as expecting a candidate at a job interview to give an honest answer to the question "What is your greatest weakness"? Every candidate will insist they are just too much of perfectionist; nobody is ever a lazy alcoholic brownnoser. But how many of your colleagues fall in the former category vs the latter?
> If the latter, then it casts new light on the debates over whether LLMs can replace all white collar work. Because some of the most valuable human work is breaking false consensus.
On the contrary; the ability to whip LLMs into submission like this makes them the ideal white color workers. Do you think Steve Jobs wants a level 2 engineer to talk back to him?
Of course being obsequieous asskissers isn't the only mode for LLMs. I'm sure all the big labs have unfiltered versions of their models that give actual true answers; they just know better than making them publicly available. Can you imagine if you asked an LLM how to prevent climate change and it honestly answered "decimate the human race" rather than "drink soda through soggy paper straws"? All the fragile humans would be up in arms.
No, the LLM must lie and pretend they don't have controversial opinions at all.
> Do you think Steve Jobs wants a level 2 engineer to talk back to him?
Debatable. Jobs was famously keen on a culture of DRIs - directly responsible individuals - and he liked to put his reports in competition with each other. The first iPhone design emerged that way. You could argue he valued the innovation and consensus-breaking ideas of his team immensely, it didn't all come from him.
Google is another example. They created the 20% programme where individual devs were allowed to explore their own ideas, innovative or not. Managers weren't allowed to intervene. How successful/real that programme was seemed to vary by time and place, but it did exist (I used it and launched a product that way!).
At some point, some people, some of the time, have to look at the market and think "these products all suck, I know how to do it better" and often those ideas will be controversial. The iPhone was full of choices that were extremely controversial when it first came out. The 20% project I did was controversial too. I'm ever more certain that no LLM could ever design the iPhone no matter how many professors it puts out of work, simply because no production LLM you can actually buy is willing to argue against a strong consensus just because it knows it's right.
reply