News for hackers. Stuff that matters.

nightcracker

Re:QOI: Lossless Image Compression in O(n) Time on Wednesday November 24, 2021 @12:10PM (#29332315)
Yes, I am aware it has been 'superseded' but in my experience for lossless compression it's still usually better.
Re:QOI: Lossless Image Compression in O(n) Time on Wednesday November 24, 2021 @07:11AM (#29329195)

    QOI_DIFF24 {
        u8 tag  :  4;   // b1110
        u8 dr   :  5;   // 5-bit   red channel difference: -15..16
        u8 dg   :  5;   // 5-bit green channel difference: -15..16
        u8 db   :  5;   // 5-bit  blue channel difference: -15..16
        u8 da   :  5;   // 5-bit alpha channel difference: -15..16
    }
It bothers me more than it should that the 5-bit signed differences aren't -16..15 matching two's complement but -15..16 instead.
Re:QOI: Lossless Image Compression in O(n) Time on Wednesday November 24, 2021 @07:00AM (#29329127)
You could still stream the pixels, you'd just have to stream them in Z order. This may seem pedantic, but this applies to any mismatch between the order in which you store pixels and the order in which the format stores pixels.

E.g. some file formats may be row-major, others column-major, some block-based (like JPEG) or a fancy interleaving scheme (like Adam7). Some might store the channels interleaved, others separate the channels. If any of these choices doesn't match the desired output format, it breaks streaming.

Re:Hackerrank DMCA Notice on Tuesday November 16, 2021 @08:00AM (#29240004)
Copying the question text verbatim certainly is copyright infringement (and I would guess unlikely to be fair use, but I'm not a lawyer). If you give the problem in your own words, it won't be, just like your solution isn't.
Re:Rust data structures with circular references on Saturday November 13, 2021 @01:53PM (#29212212)
I don't know, only have some theories.

1. The name isn't particularly catchy or descriptive. It is the correct name for the data structure, but not too many people know the data structure.

2. People don't even know what they're missing. It's not a very Google-able problem to begin with. Slotmap provides an interesting solution to (circular) ownership and safe allocator / weak pointer design problems, but people don't recognize that they're having them or that slotmap could help.

As an example of this, the doubly linked list example (https://github.com/orlp/slotmap/blob/master/examples/doubly_...) can safely remove nodes from the linked list given their handle, in O(1), even from the middle, completely safely and correctly, even in the presence of double deletions or ABA memory re-use. You can't replicate this with just pointers, without introducing heavy refcounting solutions.

Re:Rust data structures with circular references on Saturday November 13, 2021 @01:43PM (#29212137)
SlotMap literally cannot, because it must keep track of versions of the used slots, and the slots include the memory space for the data.

DenseSlotMap sort of can. It still can't reclaim the memory used by empty slots for the same reason (at a cost of 8 bytes per slot), but can reclaim the memory used by the actual elements stored.

So if you store 1 million items at one point in a DenseSlotMap, and then clear them all and then shrink to fit (which is actually missing from the API, but I'll fix that soon) you will waste 7.6 megabytes on the empty slots but nothing on the actual data that used to be stored.

Re:Rust data structures with circular references on Saturday November 13, 2021 @09:14AM (#29209856)
There is no fragmentation whatsoever in the traditional sense (unusable gaps left due to size mismatches), because a slotmap only stores a single type of value. Thus every slot is interchangeable and memory can always be reused.

For iteration however, there can be holes that need to be ignored, if the current number of elements in the slotmap is significantly lower than the the maximum capacity. If iteration needs to be very fast (for e.g. game engines) I do have a solution for that, which is the DenseSlotMap. It uses one extra layer of indirection for random access, but stores the actual data values contiguously in a vector, thus iteration is always fast.

Re:Hop: Faster than unzip and tar at reading individual files on Thursday November 11, 2021 @07:25AM (#29187157)
> It's not hard being faster than zip if you are not compressing/uncompressing

Actually, since CPUs are so fast and disk IO is so slow, it is essentially impossible to beat a properly tuned program that reads data from disk and decompresses it on the fly using one that doesn't use compression at all.

If a significant amount of your new customers find your physical shop through Google maps, what can you do? If someone wants to find a hardware store near them, good chance they'll just write "hardware store" on Google maps. The entry point of people's search is Google - you've already lost the game before it ever started.
I did miss that, oops. That said, it's again unclear if that curve is pre- or post- biased sampling. If it is on the original data it is quite good, but with a heavy biased sample fairly meaningless.
Very sloppy statistics. A lot of explanatory analysis on the model is done but the model is hardly justified in being predictive in the first place.

The paper (https://journals.plos.org/plosone/article?id=10.1371/journal...) [does not mention the sensitivity or specificity of the model at all, only mentions a '91% accuracy' number]* on a biased dataset (where the number of suicidal cases is oversampled and non-suicidal cases are undersampled), without even mentioning exactly how much they over/undersampled.

* I missed the ROC curve on page 7. However it's not clear if this ROC curve was computed on the under/oversampled dataset or the original.

Re:Why is Excalidraw so good? on Friday November 05, 2021 @04:33AM (#29116743)
No, it is a Pokémon reference to the very similarly named Excadrill.
Re:Why is baseball the most literary of sports? on Tuesday November 02, 2021 @05:55AM (#29079058)
Softball is a bigger ball, yes. But it's not lower velocity, at least if you consider the relevant metric: time from pitcher to plate. Because softball also pitches a lot closer to the plate.
See my other comment, it would also immediately be constructive: https://news.ycombinator.com/item?id=29022963
Regarding (b), a non-constructive proof of P=NP does not exist. Because such a proof is immediately constructive.

You can create an enumeration over all Turing machines, and run each of them on the problem, 'diagonally', so we perform one step of computation on machine 1, then 1, 2, 1, 2, 3, 1, 2, 3, 4, etc. This will eventually run each Turing machine for an arbitrary amount of steps. As soon as one of the Turing machines accepts, we also accept.

Suppose the nth Turing machine is our poly time machine we have proven to exist (although we don't know n). It takes n steps of our meta algorithm to run this machine 1 step, then n+1 metasteps for the next step and so forth. In total it takes n + n+1 + ... + n+k = O(k^2 + kn) metasteps to run the nth Turing machine k steps.

But here's the crux... n does not depend on the input size, only on our problem! Thus it is a constant. In other words, this meta algorithm is quadratically worse (due to k^2 steps) than the optimal algorithm, but it is poly time.

Note that the above algorithm doesn't work for co-NP, in which we require that the "no" instances get solved in poly time (in NP we only require the "yes" instances to get solved in poly time).

Re:Apple Joins Blender Development Fund on Thursday October 14, 2021 @02:06PM (#28867761)
From what I have read (I don't do 3D modeling myself) Blender has overhauled its UI significantly over the past couple of years to great praise of a lot of people.
Re:Ireland joins OECD International Tax agreement on Saturday October 09, 2021 @05:21AM (#28808266)
I would guess that India is too large to meaningfully include in such a statistic. On average in the country English literacy could be quite poor while in the relevant tech hubs it is quite good. But that's just a hypothesis.
Rust sidesteps issues like this entirely through its Editions. Code from different editions can all each other, but editions can introduce breaking changes.

For example, in Rust 2018 and earlier calling arr.into_iter() on an array type would result in an iterator over references of elements of arr (which is the expected result of .iter(), but not .into_iter()). In Rust 2021 this is fixed and arr.into_iter() will take ownership of the array and return an iterator over the values themselves. But old crates that are specified to compile using Rust 2018 will still work, and you can still call them from Rust 2021 without problems.

If the C++ committee ever wants to fix its language it must introduce such backwards-incompatible changes. With the advent of modules this should be possible, you could compile each module using different editions yet still call each other.

Re:All 16,777,216 RGB colours (2005) on Saturday September 25, 2021 @03:05PM (#28655408)
> I can zoom in and see lots of different colors

If you zoom in further, you'd soon realize your screen is nothing but pure red, green and blue subpixels at varying intensities.

Re:All 16,777,216 RGB colours (2005) on Saturday September 25, 2021 @02:40PM (#28655212)
PNG is lossless, so it really does.
Re:All 16,777,216 RGB colours (2005) on Saturday September 25, 2021 @01:39PM (#28654838)
Here in the Netherlands it's the exact opposite. We have infinite water, just not a lot of space.
Re:Turing Oversold? on Wednesday September 15, 2021 @06:15AM (#28537330)
> and proving that a very simple physical machine can perform any computation (Turing completeness)

Not proving, conjecturing. It's not proven until this day: https://en.wikipedia.org/wiki/Church%E2%80%93Turing_thesis

Which begs the question: without the fifty-move rule (only threefold repetition), what is the longest legal chess game?
Re:Dogs distinguish human intentional and unintentional action on Sunday September 05, 2021 @09:04AM (#28424034)
Experimental science is all based around ruling out the null hypothesis. For that it needs to be falsifiable.

The hypothesis 'the dog can differentiate between A and B' is very hard to falsify. Because the dog could differentiate, but choose to not act. You would need a fairly complete understanding of the dogs mental workings, and scanners to study them.

On the other hand, 'the dog can't differentiate between A and B' is much easier to falsify. If you repeat an experiment a sufficient amount of times and the dog consistently has different behavior between A and B, you can rule this null hypothesis out.

That is the real reason we always 'assume the worst'. Because 'assume the worst' is the easiest to scientifically rule out.

EDIT: I would suggest this video by Veritasium, which also touches on this, at a very fundamental level: https://www.youtube.com/watch?v=vKA4w2O61Xo.

One thing that is very hard if not impossible for the human mind is to 'unsee' stuff. Once you have learned a certain method or theory it becomes almost impossible to think creatively about a problem and attack it from different angles, because you already know what works.

Repeated exposure also reduces skepticism. The writing world has already long known this, you can not proofread your own work. You will read 50 times over a silly mistake without ever noticing it. Software engineering is understanding this more and more through code review as well, but academia is slow on the uptake. Groups or individuals will spend months on their work without anyone else to check on it.

The young are not yet cursed with knowledge. They can look at things with a fresh look. They can poke holes in stuff others are 'reading over', and find completely new approaches.

It's a bit of a catch 22. On a surface level one might say that they are faking having Tourette's, and that they are completely healthy. But look a bit deeper and you realize that a mentally sane person would not copy the tics from a YouTube personality and keep the schtick up all the way to the doctors. So no, it's not Tourette's but yes, these people need help.
Other slurs include "man", "woman", "israel", "socialism" and "communist".
Re:Windows 11: a survey of text boxes on Friday September 03, 2021 @09:56AM (#28404293)
80% of the time if I want to change something in the Windows 10 settings all my time is spent trying to find out which magic words I need to recite and which buttons I need to click to get to the old Windows 7 / XP style configuration dialogs.

E.g. you have to navigate through this garbage: https://i.imgur.com/W1txUAK.png to find the one link (named "Sound Control Panel", hidden somewhere down the page) that opens the actual useful config panel: https://i.imgur.com/zDnnMPE.png

Re:Nuitka: An extremely compatible Python compiler on Thursday September 02, 2021 @06:46AM (#28390508)
I think the idea behind Nuitka is to compile Python into an executable, rather than interpret a script using a fully generic interpreter, but without (or with minimal) limitations, falling back to libpython's implementation if necessary.

> In the future Nuitka will be able to use type inferencing based on whole program analysis. It will apply that information in order to perform as many calculations as possible in C, using C native types, without accessing libpython.

I believe the difference with PyPy is that PyPy tries to do this using just-in-time compilation and nuitka uses ahead-of-time compilation.

Older »