HNHacker News
TopNewBestAskShowJobs

unwind

12,395 karma · joined March 23, 2009

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.

submissionscomments
unwind··on Infinite pancakes, anyone?
Me too, from Firefox in Linux and no (!) blockers. Weird. Maybe geo-fenced for not being in the US, sometimes companies do that which is ... weird.
unwind··on Some C habits I employ for the modern day
Uh that piece of horror was not in the post. Phew.
unwind··on Douglas Adams on the English–American cultural divide over "heroes"
Brown in German is actually, wait for it, "braun".
unwind··on F-16 Falcon Strike
Cool!

I love seeing new games for "retro" machines, it's awesome that people keep pouring time and love into them after all these years.

I'm not super familiar with 8-bit Atari machines, and found the designation "classic unmodified 8-bit ATARI XL/XE" a bit imprecise. Tried looking up specs on Wikipedia [1] but was unsure what to settle on. Perhaps the original 1200XL would match? Or the 800XL which seems to improve on the 1200XL even though the naming suggests the opposite ... Or the 65XE, or both then I guess since the latter is compatible with the 800XL, but in an updated case?

[1]: https://en.wikipedia.org/wiki/Atari_8-bit_computers#1200XL

unwind··on 3D printing my laptop ergonomic setup
Very cool, nice effort and a good write-up!

If my math is right it seems the cost in material for the printed part is around $5 which seems ridiculously cheap for a custom-designed and adapted solution like this. Nice!

I wish the author had spent a few words extra to motivate why it needs to be in PETG filament for "heat resistance", is the regular PLA limit of ~55 degrees Celsius not okay for a desktop accessory? I guess if it's in direct sunlight that might be exceeded, or perhaps if the laptop runs very hot?

unwind··on Linux boxes via SSH: suspended when disconected
That sounded fascinating as a rather large difference in world view stemming only from using different languages.

It turns out that there are various models for the number of continents, and that is (phew) known in Spanish, too. See the Wikipedia page [1] (link to Spanish version) for instance. This is for European Spanish though, but I couldn't find a version of the page in es-AR.

[1]: https://es.wikipedia.org/wiki/Continente#Modelos_continental...

unwind··on The Z80 Mem­ber­ship Card (2015)
I think this is very cool, even though I have no historical connection to the Z80 it's of course a well-regarded and firmly entrenched/popular retro CPU.

But this really is a stretch:

The Z80 Membership Card itself is a stand-alone single-board computer that can "power up" your projects, like the Parallax BASIC Stamps or Arduino microcomputers.

Both of those are very commonly called microcontrollers, not microcomputers, since they have all of those extra chips merged into the single package of the CPU.

Take a look at the Arduino Uno [1] which is a very typical (if old) example: you will see that the board is not covered in ICs from edge to edge, since all of the main functionality is in the single-chip microcontroller. I think the second big-ish package visible is for the USB, but that also disappears on more modern controllers with on-board support for USB.

[1]: https://en.wikipedia.org/wiki/Arduino_Uno#/media/File:Arduin...

unwind··on Handy – Free open source speech-to-text app
Which one? I did a quick search but that didn't turn up anything so perhaps it's a partial word overlap or something.

I did find the projects "user-facing" home page [1] which was nice. I found it rather hard to find a link from that to the code on GitHub, which was surprising.

[1]: https://handy.computer/

unwind··on Handy – Free open source speech-to-text app
Ah, that was a typo: you meant "GPU" (Graphics Processing Unit, not "GUI" which of course is Graphical User Interface) since that is listed in the system requirements. Explained implicitly by an existing comment, thanks!
unwind··on Zen-C: Write like a high-level language, run like C
Agreed, that really stood out as a ... questionable design decision, and felt extremely un-ergonomic which seems to go against the stated goals of the language.
unwind··on Perfectly Replicating Coca Cola [video]
True story: I was once (late 90s, I think) made part of an impromptu taste-test in a 7 Eleven store in Stockholm [1], when a (probably bored) employee grabbed a Coke, a Pepsi and a Dr Pepper and some espresso-size paper cups and made me and some friends close our eyes and try to guess which was which.

I remember being upset since he claimed I failed to even point out Dr Pepper, which I still think is unbelievable since even its smell is super distinctive and way different from a cola.

[1]: https://www.mitti.se/nyheter/buset-pa-kungsgatan--butiken-bl... is the same store, article (in Swedish) about a recent prank someone did there

unwind··on Perfectly Replicating Coca Cola [video]
Interesting! According to [1] it's labelled as "less sugar" though, so it's not as if the original/standard Coke is different. There seems to be some widespread thinking that Singapore has issues with sugar consumption so I guess this is Coke's response (or perhaps they were forced by authorities).

[1]: https://www.coca-cola.com/sg/en/brands/coca-cola

unwind··on A4 Paper Stories
In Sweden, the lowest postage (one stamp, 22 SEK or around $2) is for max 50 grams.
unwind··on Modern SID chip substitutes [video]
At the speeds in question, I'm pretty sure the logic could be in a general-purpose microcontroller, too. But I'm not sure detailed schematics for the analog parts are available/open.
unwind··on Full Unicode Search at 50× ICU Speed with AVX‑512
Very cool and impressive performance.

I was worried (I find it confusing when Unicode "shadows" of normal letters exist, and those are of course also dangerous in some cases when they can be mis-interpreted for the letter they look more or less exactly like) by the article's use of U+212A (Kelvin symbol) as sample text, so I had to look it up [1].

Anyway, according to Wikipedia the dedicated symbol should not be used:

However, this is a compatibility character provided for compatibility with legacy encodings. The Unicode standard recommends using U+004B K LATIN CAPITAL LETTER K instead; that is, a normal capital K.

That was comforting, to me. :)

[1]: https://en.wikipedia.org/wiki/Kelvin#Orthography

unwind··on The biggest heat pumps
Heh came here to post the same comment, I was somewhat shocked by the alleged power of the almighty dollar ... but it's just a typo of course. Phew. :)

According to Google's built-in exchange rate calculator it should say $235m.

unwind··on Show HN: I designed my own 3D printer motherboard
I was confused by the prominent use of the word "stepstick", not something I was familiar with even though I try to expose myself to quite a lot of 3D printing material (having one is still more like a bucket list item, though).

I think the term is/was originally a product name for a small, rectangular module with a stepper motor driver on it [1] from 2012. Then it seems the term has been made more generic, with updated versions like the SilentStepStick [2] featuring a driver chip by Trinamic instead.

I guess my point is that for some readers, the stepper motor features on OP's board could be made more clear and perhaps use actual chip numbers, too. :)

Great job!

[1]: https://wiki.geeetech.com/index.php/StepStick_A4988_Stepper_...

[2]: https://learn.watterott.com/silentstepstick/

unwind··on Carrier Landing in Top Gun for the NES
Meta: Should have "NES" added to title to clarify it's about a game, not (as I thought) the movie.
unwind··on CapROS: Capability-Based Reliable Operating System
It's a family of microkernels.

https://en.wikipedia.org/wiki/L4_microkernel_family

unwind··on $5 whale listening hydrophone making workshop
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··on 4 billion if statements (2023)
Meta: Yeah, this should have a "(2023)" tag in the title. Thanks.
unwind··on The Cost of a Closure in C
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··on The Cost of a Closure in C
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··on The Cost of a Closure in C
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··on Joyboard is a balance board peripheral for the Atari 2600
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··on A supersonic engine core makes the perfect power turbine
That is the most William Gibson thing I've read today, at least. Wow.
unwind··on Brent's Encapsulated C Programming Rules (2020)
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.
unwind··on Brent's Encapsulated C Programming Rules (2020)
Where would you put it? The const of the pointer is not the main point, it's just extra clarity that the allocated pointer is not as easily overwritten which would leak the memory.
unwind··on Brent's Encapsulated C Programming Rules (2020)
Quite interesting, and felt fairly "modern" (which for C programming advice sometimes only means it's post-2000 or so). A few comments:

----

This:

    struct Vec3* v = malloc(sizeof(struct Vec3));
is better written as:

    struct Vec3 * const v = malloc(sizeof *v);
The `const` is perhaps over-doing it, but it makes it clear that "for the rest of this scope, the value of this pointer won't change" which I think is good for readability. The main point is "locking" the size to the size of the type being pointed at, rather than "freely" using `sizeof` the type name. If the type name later changes, or `Vec4` is added and code is copy-pasted, this lessens the risk of allocating the wrong amount and is less complicated.

----

This is maybe language-lawyering, but you can't write a function named `strclone()` unless you are a C standard library implementor. All functions whose names begin with "str" followed by a lower-case letter are reserved [1].

----

This `for` loop header (from the "Use utf8 strings" section:

    for (size_t i = 0; *str != 0; ++len)
is just atrocious. If you're not going to use `i`, you don't need a `for` loop to introduce it. Either delete (`for(; ...` is valid) or use a `while` instead.

----

In the "Zero Your Structs" section, it sounds as if the author recommends setting the bits of structures to all zero in order to make sure any pointer members are `NULL`. This is dangerous, since C does not guarantee that `NULL` is equivalent to all-bits-zero. I'm sure it's moot on modern platforms where implementations have chosen to represent `NULL` as all-bits-zero, but that should at least be made clear.

[1]: https://www.gnu.org/software/libc/manual/html_node/Reserved-...

unwind··on The Lost Machine Automats and Self-Service Cafeterias of NYC (2023)
it's been .. too long, but Amsterdam used to feature lots of food vending machines and it seems like they're still there [1]!

[1]: https://dutchreview.com/dutch-quirks/dutch-quirk-107-eat-foo...

← PreviousPage 2 of 34Next →