HNHacker News
TopNewBestAskShowJobs

teo_zero

1,544 karma · joined August 14, 2022

submissionscomments
teo_zero··on Formatting code should be unnecessary
From TFA:

> Everyone had their own pretty-printing settings for viewing [DIANA] however they wanted.

teo_zero··on Untangling the myths and mysteries of Dvorak and QWERTY (2023)
For a keyboard that aims to the title of "Scientific", isn't it weird to offer the "zero" key after the "9" instead of its natural (mathematically speaking) position before the "1"?
teo_zero··on Bookmarks.txt is a concept of keeping URLs in plain text files
Reading through the comments in this thread, it looks like the population is split in two groups. The first group considers "bookmarks" as a directory of often-visited sites, and needs a way to avoid typing their URLs every time. The second group intends "bookmarks" as a wish list for sites that might need a second (deeper) visit.

It may be time to find another metaphor for this second group: "postcards" might work better than "bookmarks".

teo_zero··on Object-oriented design patterns in C and kernel development
In what scenario would this be useful? If foo() takes a struct A, it should be more generic and have no knowledge about the more specialized struct B.
teo_zero··on Object-oriented design patterns in C and kernel development
> Object oriented programming implies certain contracts that the compiler enforces

Sorry, but where did you got this definition from? I've always thought OOP as a way of organizing your data and your code, sometimes supported by language-specific constructs, but not necessarily.

Can you organize your data into lists, trees, and hashmaps even if your language does not have those as native types? So you can think in a OO way even if the language has no notion of objects, methods, etc.

teo_zero··on VIM Master
Isn't it exactly the same thing? If a:b=c:d then a:c=b:d.
teo_zero··on Optimizing FizzBuzz in Rust

  m3=m5=m7=1
  for ...
    ...
    m3 = m3==2?0:m3+1
    m5 = m5==4?0:m5+1
    m7 = m7==6?0:m7+1
teo_zero··on Left to Right Programming
Haha. Except in Arabic numbers are written as in English.
teo_zero··on Left to Right Programming
And we don't need navigation systems on our cars because we should know where we're going, right? ;)

Jokes apart, I think you're being too drastic. A good auto-complete is a nice feature, just like auto-indent, tab-complete, etc. Can it be abused? Sure. So what? Should we stop making it better for fear of abuse?

The reference to AI is far-fetched, too. We're talking about tools to help you with the syntax, not the semantic. I may forget if the function is called read, fread, or file_read, but I know what its effect is.

And finally, consider that if something is easier to parse for an editor, it most probably is for a human too. Not a rule, not working in 100% of cases, but usually exposing the user to the local context before the concept itself helps understanding.

teo_zero··on Left to Right Programming
> reverse assignment statements to capture the results

Interesting idea! However, I'm not sure I would prefer

"Mix water, flour [...] and finally you'll get a pie"

to

"To make a pie: mix water, flour [...]"

teo_zero··on Why Nim?
I can count multiple reasons why someone might dislike significant whitespace. The most evident is that whitespace is... not evident at all! By definition, it's a transparent character: it's extremely difficult to directly count spaces; they can be indirectly counted by comparison with text in the surrounding area. The same principle why we add commas or apostrophes or spaces every 3 digits in big numbers.

As of the "you're going to indent your code anyway" claim, this seems to completely ignore one-liners, either embedded in other documents (onClick=...) or fed to the shell as a quick way to get some work done without spawning new tools.

teo_zero··on Counting Words at SIMD Speed
I'm wondering what the gain would be if we considered "white space" every char <= 0x20. I know it's changing the rules of the game, but who would want to count the words in a text full of control characters?
teo_zero··on Mathematician Finds Easier Way to Solve Quadratic Equations
I don't get it. Isn't this exactly how the well-known formula is constructed? (With the example crafted to have integers, even solutions and a=1 so to conveniently hand-wave the last division.)

> Normally, when we do a factoring problem, we are trying to find two numbers that multiply to 12 and add to 8. Those two numbers are the solution to the quadratic, but it takes students a lot of time to solve for them, as they’re often using a guess-and-check approach.

Wait... don't students apply the closed-form formula? Do we teach them that maths is about guessing? Next what? that pi is a rational number equal to 22/7, maybe?

teo_zero··on Going faster than memcpy
I'm not here to defend zero- terminated strings, but I register that prefixed strings would be equally bad for the goal of OP, or even worse since you would need to inject int prefixes instead of zero bytes.
teo_zero··on Generic Containers in C: Safe Division Using Maybe
Clever, but it misses the very goal of option/maybe types: forcing the user to check the result. In this implementation nothing stops the user from omitting the "if (p.ok)" part and directly using "p.value".

It could work if "maybe(T)" is completely opaque to the user; both checking and accessing its payload must happen through helper macros; the checking macro ticks an invisible flag if ok; the accessing macro returns the payload only if the invisible flag is ticked, otherwise it triggers a runtime error/exception.

Not impossible. However, you would need to replace all "p.ok" with "maybe_check(p)", which is not unreasonable, and all "p.value" with "maybe_value(p)", which might be too much for the final user...

teo_zero··on Faster substring search with SIMD in Zig
How strange! I was about to add a comment that I would probably stick to SSE2 or something like that to be sure my code suits as large an audience as possible, including CPUs from more than 10 years ago, ARM, etc.

Case in point: I've been very disappointed lately when I wanted to try Ghostty on my laptop and the binary compiled for Debian failed to run due to an invalid instruction. I don't want to force the same experience to others.

teo_zero··on Debian 13 “Trixie”
Aren't firewall rules part of the "configuration" the OP talked about?
teo_zero··on A fast, growable array with stable pointers in C
I think the parent poster meant that a compiler might have a hard time understanding when sa_get(..., i) and sa_get(..., i+1) actually access contiguous memory locations, and will thus stop applying nice optimizations. Conversely, accessing a[i] for all 4 billion items of a regular array will be optimized to specialized instructions, not excluding SIMD or SWAR.
teo_zero··on Python performance myths and fairy tales
I don't know Python so well as to propose any meaningful contribution, but it seems to me that most issues would be mitigated by a sort of "final" statement or qualifier, that prohibits any further changes to the underlying data structure, thus enabling all the nice optimizations, tricks and shortcuts that compilers and interpreters can't afford when data is allowed to change shape under their feet.
teo_zero··on Writing memory efficient C structs
Neither TFA nor any comment mention using a struct of arrays instead of an array of structs. This technique alone eliminates all padding bytes!
teo_zero··on SIMD within a register: How I doubled hash table lookup performance
> Later version allowed to scan from arbitrary position by mirroring first bucket as last.

I don't think this would help. The real issue with arbitrary position is that you can't load 16 bye to a 128-bit SIMD register if the memory is not aligned. The solution I found is to unroll the first iteration and mask out the results found before the initial offset.

teo_zero··on Linux on Snapdragon X Elite: Linaro and Tuxedo Pave the Way for ARM64 Laptops
> the current Linux Kernel 6.15 already supports many commercial laptops: Lenovo Yoga 7x, Lenovo ThinkPad T14s Gen 6, Dell XPS 13, Asus Vivobook S15, HP Omnibook x14, Microsoft Surface 13/15

Has anybody had any first-hand experience with Linux on such laptops?

teo_zero··on Generic Containers in C: Vec
I agree, but the current specification is complex too: two identical "tagged" structs are compatible, two identical "untagged" structs are not. And before C23 it was even worse, depending on whether the two structs were defined in the same file or not.

We're applying a patch over a patch over a patch... no surprise the end result looks like a patchwork!

teo_zero··on Generic Containers in C: Vec
Sorry, I don't understand what macro you're referring to. Your post addressed "vec(int)", and suggested it will fail if repeated, which was true before C23 but not anymore. What functions are defined through vec(int)?
teo_zero··on Generic Containers in C: Vec
Not with C23.
teo_zero··on Generic Containers in C: Vec
You don't need an explicit allocator: you can create an empty object and vec_push() does the magic of (re)allocating the memory when needed.

Instead, what is missing is an automatic deallocator, one that's automatically called when the variable goes out of scope. For example:

  {
    vec(int) v={}; /* no extra room allocated */
    vec_push(v,1); /* space allocated */
    ... use v ...
  } /* here the space is dellocated, then v is released */
This example doesn't use the same definition of vec as TFA, but something more similar to 'span' by the same author.
teo_zero··on Generic Containers in C: Vec
Correct, complex types must be typedef'd. At least, until c2y integrates _Record as per N3332: https://thephd.dev/_vendor/future_cxx/papers/C%20-%20_Record...
teo_zero··on Generic Containers in C: Vec
Why do you need to pass the type to vec_push? Can't T be replaced by typeof(v->data[0]) ?
teo_zero··on Mwm – The smallest usable X11 window manager
It was not my intention to make you sad or angry. I assure you that I have nothing against who uses a different coding style than mine. But consider that, just like you, I too have the right to tell the world what my preference is. Should I have softened my post with more "IMHO", "I feel", "my taste"? Probably, and I apologize.

Please don't stop participating in social media just because a halfwit like me hasn't agree with you once!

teo_zero··on Mwm – The smallest usable X11 window manager
Change

  grab("n" ...
  map("n" ...
to

  grab("Tab" ...
  map("Tab" ...
← PreviousPage 11 of 31Next →