Readit News logoReadit News
unwind commented on Carrier Landing in Top Gun for the NES   relaxing.run/blag/posts/t... · Posted by u/todsacerdoti
unwind · 6 hours ago
Meta: Should have "NES" added to title to clarify it's about a game, not (as I thought) the movie.
unwind commented on CapROS: Capability-Based Reliable Operating System   capros.org/... · Posted by u/gjvc
NooneAtAll3 · 11 hours ago
what does L4 mean here?
unwind · 11 hours ago
unwind commented on $5 whale listening hydrophone making workshop   exclav.es/2025/08/03/dina... · Posted by u/gsf_emergency_6
unwind · 11 hours ago
TIL about "plug-in power", that seems to be a thing that some sound recording devices with 3.5 mm "phono" jacks can provide.

Here [1] is a page at Klover, and here [2] is one at Shure. Not sure if there's a formal specification for this, or if it's just something that manufacturers started doing.

[1]: https://www.kloverproducts.com/blog/what-is-plugin-power

[2]: https://service.shure.com/s/article/difference-between-bias-...

unwind commented on 4 billion if statements (2023)   andreasjhkarlsson.github.... · Posted by u/damethos
thewisenerd · 3 days ago
discussed 2 years ago,

https://news.ycombinator.com/item?id=38790597

4B If Statements (469 comments)

unwind · 3 days ago
Meta: Yeah, this should have a "(2023)" tag in the title. Thanks.
unwind commented on The Cost of a Closure in C   thephd.dev/the-cost-of-a-... · Posted by u/ingve
kreco · 4 days ago
That's a very weird comment, your spreading your knowledge and not really addresse what could have been changed in the article.

If I follow your comment, you mean that he could have use a non-static global variable instead and avoid mentioning "static" keyword afterward?

unwind · 4 days ago
Oh! Thanks, I was not being as concrete as I imagined. Sorry.

Yes, the `static` can simply be dropped, it does no additional work for a single-file snippet like this.

I tried diving into Compiler Explorer to examine this, and it actually produces slightly different code for the with/without `static` cases, but it was confusing to deeply understand quickly enough to use the output here. Sorry.

unwind commented on The Cost of a Closure in C   thephd.dev/the-cost-of-a-... · Posted by u/ingve
unwind · 4 days ago
This was very interesting, and it's obvious from the majority of the text that the author knows a lot about these languages, their implementation, benchmarking corners, and so on. Really!

Therefore it's very jarring with this text after the first C code example:

This uses a static variable to have it persist between both the compare function calls that qsort makes and the main call which (potentially) changes its value to be 1 instead of 0

This feels completely made up, and/or some confusion about things that I would expect an author of a piece like this to really know.

In reality, in this usage (at the global outermost scope level) `static` has nothing to do with persistence. All it does is make the variable "private" to the translation unit (C parliance, read as "C source code file"). The value will "persist" since the global outermost scope can't go out of scope while the program is running.

It's different when used inside a function, then it makes the value persist between invocations, in practice typically by moving the variable from the stack to the "global data" which is generally heap-allocated as the program loads. Note that C does not mention the existence of a stack for local variables, but of course that is the typical implementation on modern systems.

unwind commented on The Cost of a Closure in C   thephd.dev/the-cost-of-a-... · Posted by u/ingve
tapete2 · 4 days ago
It doesn't even make sense to use strchr for determining the position of 'r', when the code checks that the position of '-' is at index 0.

Your solution is perfectly fine. Even if you don't have access to strchr for some reason, the original snippet is really convoluted.

You could just write (strlen(argv[1]) > 1 && argv[1][0] == '-' && argv[1][0] == 'r') if you really want to.

unwind · 4 days ago
Of course, `&&` in C is short-circuiting so it's safe without the `strlen()` too, as long as the argument is there i.e. not NULL.

Also, the use of a convoluted `if` to conditionally assign a literal boolean is a code smell (to me), I would drop the `if` and just use:

    in_reverse = argc > 0 && argv[1][0] == '-' && argv[1][1] == 'r';
if a more forward-thinking/strict check is not needed.

unwind commented on Joyboard is a balance board peripheral for the Atari 2600   en.wikipedia.org/wiki/Joy... · Posted by u/doener
unwind · 5 days ago
Wow!

I vaguely remember a reference to some balance game as the origin story for the Guru Meditation, but that was so long ago and I never looked it up!

Meta: it would have been nice to include this reference in the submission title, since it's least as interesting as the fact that the peripheral was for the Atari 2600. Something like "The Joyboard: Atari 2600 balance peripheral that inspired Guru Meditation", perhaps. Probably too late now, and this is not exactly tearing down the front page, anyway. :)

Thanks!

unwind commented on A supersonic engine core makes the perfect power turbine   boomsupersonic.com/flyby/... · Posted by u/simonebrunozzi
fpoling · 6 days ago
In Texas a lot of natural gas is wasted/burned away as it is not profitable to collect and transport it from all oil fields. These days quite a few places put small turbines to generate electricity to do cryptocurrency mining.

This will serve a similar use case just on a bigger scale.

unwind · 5 days ago
That is the most William Gibson thing I've read today, at least. Wow.
unwind commented on Brent's Encapsulated C Programming Rules (2020)   retroscience.net/brents-c... · Posted by u/p2detar
jandrese · 6 days ago

    This:

    struct Vec3* v = malloc(sizeof(struct Vec3));

    is better written as:

    struct Vec3 * const v = malloc(sizeof *v);
I don't love this. Other people are going to think you're only allocating a pointer. It's potentially confusing.

unwind · 6 days ago
Uh, okay, but if you need to constantly write code as if people reading it don't understand the language, then ... I don't know how to do that. :)

It's not possible to know C code and think that

    sizeof *v
and

    sizeof v
somehow mean the same thing, at least not to me.

u/unwind

KarmaCake day12299March 23, 2009
About
Bearded hacker from Sweden. Learned M68k assembly on the Amiga in the late 80s. Compiling C on a 7 MHz CPU was slow. Working as a contracting software developer since almost 10 years, enjoying visiting various parts of the software world.

I hang out a lot on Stack Overflow: http://stackoverflow.com/users/28169/unwind, mainly answering questions about C. I love C.

View Original