HNHacker News
TopNewBestAskShowJobs

teo_zero

1,544 karma · joined August 14, 2022

submissionscomments
teo_zero··on Branchless Quicksort faster than std:sort and pdqsort with C and C++ API
Nitpicking the C variant:

> #define BLQS_CMP(a, b) ((a) < (b))

A function that returns true when one operand is Less Than the other, should be called BLQS_LT. The CMP abbreviation is idiomatic for a function that returns -1,0, or 1.

teo_zero··on Branchless Quicksort faster than std:sort and pdqsort with C and C++ API
In modern CPUs a mispredicted branch is much more expensive than a memory write.

The unsaid assumption is that the array is filled with random values between 0 and 1000, so the "if" condition has a 50% of chances to be true. The branch is mispredicted 50% of times.

Of course this trick won't work when the statement protected by "if" is a more complex and costly action, or one that can't be undone (in the example, note that when the counter is not incremented, the value written to memory will be overwritten in the next cycle, so it's "undone" in a certain way).

teo_zero··on Preparing for KDE Plasma's Last X11-Supported Release
True. But it's often all or nothing: you can't surf the web without the ads.
teo_zero··on Preparing for KDE Plasma's Last X11-Supported Release
> doesn't allow windows to stay on top.

Are you sure that windows that, without your consent, are allowed to stay on top and grab your input are a good idea? And spawned by Chrome? As if we hadn't already enough ad-ware, click-harvesters, and spoofed dialogs popping up everywhere!

I know there is a couple of legitimate uses for this, but the ways it can be abused are vastly more.

I think the sensitive default should be to block it, and allowing it should be behind some user's conscious action. Yes, it adds some friction to some workflows and it takes a bit to get accustomed to. But it doesn't deserve the label "security paranoia".

teo_zero··on Preparing for KDE Plasma's Last X11-Supported Release
> unprivileged X11 programs that use the Scroll Lock light as an indicator

I didn't know such apps existed! What do they use it for?

teo_zero··on Bijou64: A variable-length integer encoding
UTF-8 notoriously doesn't prevent ambiguous encoding by construction, but only prohibiting it in the specs. It's known as overlong encoding. It's up to the encoder/decoder to prevent, correct, or reject it. This burden on the software is exactly what TFA tries to eliminate with the bijou64 format (unfortunately replacing it with another burden: overflow check).
teo_zero··on Adding Reflection to C
Nice. But you've just invented Zig!
teo_zero··on C array types are weird
> int c[] = ..., that is always going to be on the stack

Why? In the following code, only c will be allocated on the stack:

  int a[]={1,2,3};
  foo() {
    static int b[]={1,2,3};
    int c[]={1,2,3};
  }
teo_zero··on Ferrari Luce
Some EVs use them to let the driver change the "drag" of the electric motors. Imagine the "L" (sometimes "B") position of automatic gear but with finer control than all-or-nothing.
teo_zero··on Ferrari Luce
> cars don't need start buttons, physical keys

What would you rather have?

teo_zero··on The Eternal Sloptember
When digital cameras replaced traditional ones, we thought it would make photography more democratic: each of us would be Helmut Newton for 15 minutes. But it didn't give us the beautiful portraits and inspired lanscapes we expected, only millions of pictures of food.

How much will it take for AI agents to pass from distilling decades of collective wisdom to copying each other's worst mistakes?

teo_zero··on Key, in sight – A guide, of sorts, to keyboard customization
I'd love to have 3 extra keys to assign to Ctrl-c, Ctrl-v and Alt-tab, but I keep bumping into these issues: RGB lights and other typical gaming design; proprietary app to install; huge real estate occupied on the desk.
teo_zero··on Getting an old Computer online with Android Ethernet tethering
But how do you authenticate to the wifi if the old PC doesn't have WPA capabilities?
teo_zero··on Converting an Integer to a Decimal String in Under Two Nanoseconds
You assume that human consumption means immediate human consumption.

By this metric, there's no need for video encoders faster than the movie's own FPS, either.

teo_zero··on Making deep learning go brrrr from first principles (2022)
The author forgot to add "fused" here, like they did in other parts of the same section.

Non-fused:

  foreach i
    y[i] = cos(x[i])
  foreach i
    z[i] = cos(y[i])
Fused, no intermediate variable:

  foreach i
    t = cos(x[i])
    z[i] = cos(t)
The temporary "t" doesn't leave the GPU. Sweeping the array twice makes you twice as dependent on memory bandwidth.
teo_zero··on sp.h: Fixing C by giving it a high quality, ultra portable standard library
Interesting project! I'm eagerly reading through it.

Probably I would have made different choices. For example, I'd rather have many modules that can be individually included, than one giant file.

Also from a purely aesthetic point of view, I would have opted for more readable function and type names: no sp_ prefix, recognizable names like dict istead of ht, vec instead of da, etc.

And I know there are compilers out there still stuck in the 90s, but I would have targeted C23, these days.

But that would be my highly opinionated library!

P.S. be aware that word frequency is not what the standard 'wc' does.

teo_zero··on Everything in C is undefined behavior
Yes, some restrictions seem arbitrary. Just like why these two types are not compatible:

  struct a {int data;};
  struct b {int data;};
I know, I know, changing it would break existing code, etc.
teo_zero··on C++26 Shipped a SIMD Library Nobody Asked For
> If I want good results, I have to write intrinsics.

Any good book / article / tutorial to begin learning it? Most docs I've tried assume you already know what you can do and focus on how to express it in assembly or with intrinsics. However, I'm not even aware of what operations are commonly implemented in hardware. For example, FMA is not normally tought, is not expressed in higher-level languages... how am I supposed to imagine such a thing exists, even before looking it up in a reference manual?

teo_zero··on I love Linux, but I can't quit Windows
> > The idea that Windows doesn't have it's own weird, mysterious, issues is hilarious to me.

> That's not what the author said.

It is exactly what the author said. TFA makes a point that Windows' issues are well known and predictable. And the author would rather endure the daily nuisances infliced by Windows than fix the sporadic breakages that Linux might throw.

teo_zero··on A new hash table for Lwan
A tombstone must be distinct from an empty element. In your example, you wouldn't stop at "d" because you haven't found an empty yet.
teo_zero··on If AI writes your code, why use Python?
Now I'm curious: is a metric buttload much larger than an imperial one?
teo_zero··on PS3 Emulator Devs Politely Ask That People Stop Flooding It with AI PRs
Technical analysis tells you that a stock is in its upwards trend. You invest all your money on it without thinking twice. The price goes down and you lose thousands of dollars. Is it a tool problem?

LLMs spit out a sequence of tokens that is the most probable continuation of the input. LLMs don't lie any more than technical analysis does when it predicts the most likely trend of stock prices. It's up to you how to use this information.

teo_zero··on A new hash table for Lwan
Mmm... so when looking for a non-existent key you have to go through the whole table. Hardly O(1)!

A better strategy would be to first search the given range for the first empty slot, and exclude everything after that point. Then proceed looking for tophash in the thus-limited interval. The return value has 3 possible values: 1) key found, 2) reached end of interval without finding but it might be in the other half, 3) found an empty slot so the key is not present, not even in the second half.

teo_zero··on Over 97% of the 'Linux' Foundation's Budget Goes Not to Linux
To be fair, you should say that over 97% of the Linux Foundation's budget goes not to the Linux kernel.

There's more to Linux than the kernel.

teo_zero··on You gave me a u32. I gave you root. (io_uring ZCRX freelist LPE)
> Affected: Linux 6.15 – 6.19 [...] Fix: commit 770594e (not yet in any stable branch at time of writing).

Is it considered good pactice to publish a vulnerability not yet patched in any stable branch?

teo_zero··on Mercedes-Benz commits to bringing back physical buttons
And for those commands that do not deserve a physical button and are only accessible via touch, please adhere to a few simple rules.

1. Put them always in the same place. Especially the "back" or "exit" button!

2. Each button should do one thing, not switch between 3 or more modes that you should look to understand which one you've just activated. Negative example: one button to cycle from cuise control, to drive assist, to speed limit, and back to off.

3. The area where a tap is interpreted as a button press should not also be where a swipe is recognized. In moving vehicles it is too easy for your finger to swing just an inch before touching the screen.

4. The active area of a virtual button must be large, larger than the icon it displays, so large that you shouldn't be distracted from driving just to aim at it!

teo_zero··on You can beat the binary search
> I really can't stand the c-style naming conventions.

Honestly I don't see much difference between

  upb_MiniTable_FindFieldByNumber
and

  upb::MiniTable::FindFieldByNumber
teo_zero··on You can beat the binary search
TL;DR the author developed an algorithm to solve this specific problem:

> The popular Roaring Bitmap format uses arrays of 16-bit integers of size ranging from 1 to 4096. We sometimes have to check whether a value is present.

There's no claim that this algorithm is universal and performs equally well for other problems.

In fact, note how the compare operation on the data types involved (16-bit integers) is quite cheap for modern CPUs. A similar problem with strings instead of integers would get no benefits from the author's ideas and would actually fare worse, due to useless comparisons per cycle.

teo_zero··on Zed 1.0
To be fair, vi has got its dose of "modal editing is difficult to learn" criticism for years. Why shouldn't zed receive the same treatment if configuring LSP is a pain point for many newcomers?
teo_zero··on I have officially retired from Emacs
> There are going to be skilless vibecoders and then there are going to be experienced devs (like OP) who figured out their AI workflow to multiply their productivity 2-5x.

Are you sure OP belongs in the second group? He explicitly said he doesn't read all the code generated by his AI:

> I have not read most of the code, and instead focused on results, so you might say this was “vibe-coded.”

← PreviousPage 5 of 31Next →