HNHacker News
TopNewBestAskShowJobs

s_gourichon

556 karma · joined January 12, 2017

Software guy, unique combination of theory and practice, capable of debugging even on-site when everyone thinks a project is doomed, or maintaining/writing excellent software.

ParisTech engineer (École Polytechnique), Ph.D. in robotics, 15+ years industrial experience (including transportation and premises receiving general public). Missions for demanding contexts: consultancy, interim CTO, all missions dealing with software source code, with a strong bias towards very high quality. Freelanced for 10 years, now doing something else.

* Longer summary on https://www.linkedin.com/in/gourichon/ * Long list of experiences and technologies on https://fidergo.fr/expertise (French) * CV https://gourichon.org/stephane/cv (French) * Languages: English/French * Contact https://fidergo.fr/contact

submissionscomments
s_gourichon··on An AI Agent Published a Hit Piece on Me – The Operator Came Forward
Time to watch again this montage from the 1974 movie "Dark Star" by John Carpenter, parody of 2001 a space Odyssey.

Topic: "talking to the bomb"

https://www.youtube.com/watch?v=h73PsFKtIck (warning this is considered to spoil the movie).

s_gourichon··on Fp8 runs ~100 tflops faster when the kernel name has "cutlass" in it
Not sure it really has huge benefits, but I guess something like this should work:

``` #!/bin/sh N=20 msg_len=$(git log -1 --pretty=%B | wc -c) if [ "$msg_len" -lt "$N" ]; then exit 125 fi # Here you would run your actual test and report 0 (good), 1 (bad) as needed exit 0 ```

s_gourichon··on Show HN: Uprintf a universal stb-style printf implementation for C (no OS)
Be wary about using an AI that rejects a simple PR (change "return str;" into "return ptr;") based on false statements ("Your PR contains a critical error — the complete removal of return statements from the u_utoa function."). Details on https://github.com/Ferki-git-creator/Uprintf/pull/3#issuecom...

I encourage you to continue working on your projects.

s_gourichon··on Show HN: Uprintf a universal stb-style printf implementation for C (no OS)
Maybe the rabbit hole is much deeper than it seems.

Is it really possible to reconcile "no bloat" with "fully standard compliant"?

Maybe have a look at https://github.com/eyalroz/printf, if only for the test suite, which looks pretty comprehensive and still fails.

Maybe "key features" does not mean the same in all projects, making every project appear "unnecessarily bloated while missing key features" in every other context?

s_gourichon··on Show HN: Uprintf a universal stb-style printf implementation for C (no OS)
Created

https://github.com/Ferki-git-creator/Uprintf/issues/1

https://github.com/Ferki-git-creator/Uprintf/issues/2

https://github.com/Ferki-git-creator/Uprintf/pull/3

https://github.com/Ferki-git-creator/Uprintf/pull/4

s_gourichon··on Show HN: Uprintf a universal stb-style printf implementation for C (no OS)
Also floats seem to "forget" the integer part, and also have two minus signs when negative.
s_gourichon··on Show HN: Uprintf a universal stb-style printf implementation for C (no OS)
Nice. Comprehensive unit tests are indeed welcome. Even a simple test code that tests all features, flags combinations, etc, and outputs a log. It will make easy for anyone to run it and compare the logs.

I had a bug:

    u_printf( my_output_cb, NULL, "%d" NL, -42 );
prints:

--42

I may have found an explanation. In u_parse_format(), case 'i': calls u_itoa( value, buffer, 10, false ); which outputs minus sign.

Then if ( number ) does if ( sign ) { output_cb( '-', ctx ); chars_written++; } which outputs another minus sign.

s_gourichon··on Show HN: Flyde – an open-source visual programming language
> visual programming

25 years ago when I read that Microsoft has a software development environment named "Visual Studio" I imagined, well, something with graphs and nodes and flow and... Well something visual, right? Now it's 2024 and VS is still not visual.

Of course things are not as simple. Flyde (along with many alternatives mentioned) is visual IMHO. Keep up the good work!

s_gourichon··on ZX Spectrum Raytracer
> the 2-color limit per 8x8 block. It's already a big issue with just lights and shadows as it is :-/

Well, you impressed me (and others) with your simple bet that "hey, what if I simply choose the two most popular colors" and just code that in simple BASIC. The same could be done with the shading. It would probably pick a good compromise when bright yellow meets dark red: by choosing to have the few should-be-red pixels become yellow, you avoid a bigger obviously-square-grid-based clash of colors.

Next step: error diffusion dithering would IMHO be a good bet. But maybe that becomes really to much for Basic.

I've been considering doing Raytracing on the Amstrad CPC, but in C. Perhaps using integers only, for speed.

Done that instead: https://cpcitor.itch.io/just-get-9

Hey, found this https://bbcmic.ro/?t=9ctpk via "BBC BASIC raytracer in 432 characters (mastodon.me.uk)" https://news.ycombinator.com/item?id=39023056#39023768

s_gourichon··on ZX Spectrum Raytracer
Excellent! A similar program, apparently from 3 years ago, did similar things, in Basic also, on the Amstrad CPC, a machine with the same processor, a little more RAM and more (27) colors or shades of green, depending on the screen it was hooked to.

* colored spheres (like you did)

* (one) checkerboard surface

* self-shadowing (like you did)

* cast shadows (like you did)

* partial or total specular reflection!

See https://www.cpc-power.com/index.php?page=detail&num=19283

The webpage displays the color (left) and green (right) versions on hovering your pointer over the ribbon (above). Image 1 and 2 are okay in both cases, image 3 is clearly tuned for color screen, image 4 for green screen.

Or direct links to the relevant variants:

https://www.cpc-power.com/extra_lire_fichier.php?extra=cpcol...

https://www.cpc-power.com/extra_lire_fichier.php?extra=cpcol...

https://www.cpc-power.com/extra_lire_fichier.php?extra=cpcol...

https://www.cpc-power.com/extra_lire_fichier.php?extra=cpcol...

https://www.cpc-power.com/extra_lire_fichier.php?extra=cpcol...

https://www.cpc-power.com/extra_lire_fichier.php?extra=cpcol...

s_gourichon··on ZX Spectrum Raytracer
You mean, like this? https://www.youtube.com/watch?v=SJ79CdUMfVA

Also, not exactly the same type or rendering, but basically word for word what you wrote: the full-screen fully animated parts appear to be "a set of frames rendered out and stitched together to make an animated sequence"

https://www.youtube.com/watch?v=o59LrpzGUaE

s_gourichon··on Eardrum Suck: The Mystery Solved (2019)
In my opinion, you're spot on: being deprived of hearing the lowest frequencies typically occurs only when there's a pressure imbalance between the inner and outer ear. Therefore, when you experience silence at these lowest frequencies due to noise cancelling, your brain may assume a pressure imbalance must be the cause.

I've had the opportunity to use a variety of noise cancelling headphones over the years, from various brands, both in-ear and over-ear, and they all had this effect.

The good news is that you can become completely accustomed to it: after a while, the brain understands that there's no pressure imbalance, and it becomes a non-issue. Not hearing low frequencies is exactly what we expect from the product.

The article goes further to discuss some slope in a graph around 500Hz, which might be true, but I don't subscribe to that. It seems unnecessary to explain the observed facts and adds nothing.

What is not addressed at all is why all models seem to emit a subtle continuous shhhhhhh across a broad range of high frequencies. It's so subtle that you can only notice it when the outside environment is already quiet. I've never been certain whether it's just noise from the signal processing. My intuition is that it's artificially added to prevent inducing tinnitus in some users.

s_gourichon··on RunWithScissors() (2009)
IMHO this is the effect expected by the people who named the function, and the reason why the name is very well chosen.

Yes, it's funny but that's not the point. The important thing is that the name clearly conveys the message that you really shouldn't be calling it, as explained in the comments above the function definition.

The "funny but there's a real reason behind" aspect is a bit like https://xkcd.com/radiation/ : "It's for general education only. If you're basing radiation safety procedures on an internet PNG image and things go wrong, you have no one to blame but yourself." The sentence is funny but has a real purpose: protect readers and author.

s_gourichon··on Lesser known tricks, quirks and features of C
* Context: const and compile-time constants

Constructs fully determined at compile time have some benefits. But const in C is weaker than constexpr that C++ has.

As prog-fh summarizes on https://stackoverflow.com/questions/66144082/why-does-gcc-cl...

> "The const means « I swear that I won't change the value of this variable » (or the compiler will remind me!). But it does not mean that it could not change by another mean I don't see in this compilation unit; thus this is not exactly a constant."

One example of invalid C:

const int mysize = 2; const int myarray[mysize];

gcc: error: variably modified ‘myarray’ at file scope

clang: warning: variable length array folded to constant array as an extension [-Wgnu-folding-constant] const int myarray[mysize];

* Good news: C can do compile time constant structs and array with deep self-references.

Yes, in C you can define and fully declare complex data structures that are accepted as compile-time constants, including pointers to parts of itself.

See "self-contained, statically allocated, totally const data structure with backward and forward references (pointers)?" for a previous example at https://stackoverflow.com/questions/47037701/can-c-syntax-de...

-----------------

I used this for a game on a retro machine where such a data structure avoids code which would have been several times (perhaps 10 times) bigger: https://github.com/cpcitor/color-flood-for-amstrad-cpc/blob/...

Here's another take showing two variants: where overall construct is an array then a struct: https://gist.github.com/fidergo-stephane-gourichon/792c194e1...

s_gourichon··on Counterexamples in Type Systems: programs that crash, segfault or explode (2021)
> Welcome to Counterexamples in Type Systems, a compendium of horrible programs that crash, segfault or otherwise explode.

Many interesting quirks in type systems, surprising interference between separately innocuous type system features, but don't expect too many explosions.

Indeed, many of the tricks are years old (e.g., 2006) and are fixed in current versions of the language (or even are research paper involving experimental systems that were never released, e.g. Privacy violation in C# doesn't even use a syntax that released C# compilers use).

Mutable matching in Ocaml can be reproduced with ocaml 4.13, still, and cause a segfault.

s_gourichon··on First ROM Shadowing
With a nod to https://en.wikipedia.org/wiki/Ward_Cunningham#Cunningham's_L...

> it is possible to shadow the BASIC ROM on the Amstrad CPC 464 (1984).

The ROM and RAM run at the same speed on that machine, so speed gain is not a motivation.

> You could copy the ROM to the RAM and permanently switch in the RAM.

Permanently? In principle you might be able to do that, but it's certainly not easy. The firmware switches ROMs/RAM all the time (lower ROM 300 times per second, higher ROM often when BASIC runs). You would need to patch the routines that perform ROM switching to make them switch only lower ROM. Fortunately those routines are already copied in central RAM because they need to operate whatever the ROM configuration, so it is possible to patch them. Still, the patched version would probably be more complex, so you'd need to borrow some more bytes elsewhere. Also make sure that no change is needed to the first 64 bytes (address range 0x0000-0x003F) because when ROM is enabled there they don't have your RAM-based changes.

> That ROM is normally located at C000h, shared with bank-switched RAM storing the display at the same address.

Beware, the optional external disk drive on the CPC464 adds another ROM at the sames address. So, if you want to keep compatibility, do patch the routine right, so that they do bank-switch that ROM, but when targeting BASIC ROM they actually re-enable RAM (not the same hardware registers as explained on the reference you posted).

> Which allowed you to do stuff like modifying the error messages in BASIC to say rude words,

After all that hard work is done, yeah you could replace some strings with other strings of the same length, keeping the most significant bit set as separator, why not. But most strings aren't even stored as is, they are encoded in various ways to save bytes (Basic instruction names, for example), typically only portions of words are in plain 7-bit ASCII.

> You had to do another trick to move the display RAM elsewhere too

More than one trick as shown above.

The welcome message is in lower ROM, so hey, let's go crazy like "I don't need a reason, let's shadow all the ROM". The simplest bet would be to start with a CPC464 without a disk drive, copy both ROMs to RAM, tell firmware to use screen at 0x4000 instead of 0xC000 (easy compared to the rest), patch all areas that define low addresses to shift these by 0x8000 more (much less easy). Then you'd have a system running, with your free RAM for Basic programs around 10k instead of 42k. But hey, the welcome message on system "reset" would be yours.

> not that we would have ever done that.

Definitely. Thanks for the ride.

s_gourichon··on Bare Metal C++ Register Access API
This page is about memory-mapped hardware registers, not CPU registers.

It explains pitfalls in accessing these through low level C definitions, proposes a C++ encapsulation class and summarizes pros and cons.

s_gourichon··on Show HN: Bulk convert images online without sending to server
These points are only weakly in favor of such a web app. Don't like CLI? Use gimp or similar. Don't want to install anything? On some OS it might make sense. On that OS consider Paint. It probably does not support webp, but if you're serious about webp you have tools. Smartphone/tablet? Is there even a need to do conversion on those? Privacy? Use an operating system that has some reputation, like Debian stable, not a web app. IMHO this web app is a nice exercice for its author.
s_gourichon··on SkyLifter is an eVTOL air crane
Similar project? https://www.flying-whales.com/

(Not saying if any of those is viable, just mentioning in case it makes the conversation more interesting.)

s_gourichon··on NoJS – Creating a calculator with only HTML and CSS
? It doesn’t even allow non-integer numbers.
s_gourichon··on How to Prevent the Next Heartbleed (2020)
That fixes the problem of a buffer content after allocation by the language/runtime/platform. When a buffer is reused at the library/application level, no zeroing is done.
s_gourichon··on Average HN User
> This page will only work with JavaScript enabled

I guess the average HN user has Javascript enabled by default, yet I expected a longer and more informative page than that. ;-)

s_gourichon··on Canon is telling customers how to override counterfeit cartridge warnings
And even if the region-humidity thing was true, the printer could just print a warning. That would not justify a plain refusal to print, would it?
s_gourichon··on Commodore 900: Unix-like workstation/server that was eclipsed by Amiga (2020)
It can do similar things: https://hackaday.com/2020/04/15/logging-into-linux-with-a-19...
s_gourichon··on Surviving the desert by building a motorcycle from a broken car? (2017)
From the photos and videos, the guy is indeed a 2CV hacker. I think the contraption is real.

Source: my father owned several cars of the 2CV family and we rode in them for years.

Did he actually build it in the desert? Without tools it seems rather difficult.

Here's the central point of https://sahara-overland.com/tag/emile-leray/

> I believe the 2CV bike was indeed built in the desert, much as Leray claims, but he set out from France with the explicit intention of performing this task. Otherwise he’d have walked out like any normal person in a similar situation.

> His claimed unease about leaving his stricken car doesn’t ring true, let alone the spontaneous idea of making it into a two-wheeler. Tellingly, in 2006 Leray went on to build a ‘2CV boat’ in Mali. He clearly likes mucking about with 2CVs. Fair play to him!

s_gourichon··on Sharper mipmapping using shader based supersampling (2019)
Generally not the point. Depending on your video player you might only get aliasing artifacts (and virtually always higher resource consumption).

The point of selecting a higher definition video stream can be to circumvent bandwidth limitation, if the platform happens to compress too much what it sends by default.

s_gourichon··on Sharper mipmapping using shader based supersampling (2019)
Interesting article.

> Warning: this page has about 72MB of Gifs! Medium also has a tendency to not load them properly, so if there’s a large gap or overly blurry image, try reloading the page. Ad blockers may cause problems, no script may make it better. It’s also broken in the official Medium app. Sorry, Medium is just weird.

There may be a fix: vote with your choice, stop publishing on Medium, publish elsewhere?

This content is worth it.

s_gourichon··on SimpleWall
SimpleWall is open-source but Windows-only

> Platform architecture: 32-bit/64-bit/arm64 > Supported OS: 7 SP1, 8, 8.1, 10, 11

while Portmaster https://safing.io/portmaster/ is open-source, offers precompiled packages for Windows 10/11, Debian/Ubuntu and Fedora and is reported to work (sometimes not perfectly) on many kernel/desktop environment combinations, see https://docs.safing.io/portmaster/install/linux .

s_gourichon··on Thousands of coma patients may be conscious
Tom Scott imagined something similar 8 years ago, see https://youtu.be/IFe9wiDfb0E
s_gourichon··on A couple of bees opening a bottle
This is probably real, although I'm not certain this can often happen.

Still, bees with their hard-coded set of neurons have surprising cognitive abilities: explore, memorize position of food source (angle and distance from the hive) and communicate the information to their peers.

Also, keep knowledge of absolute direction based on the sun or polarization pattern of even a small patch of blue sky, and use that information even many hours later, compensating for the change of the sun position in the sky.

https://en.m.wikipedia.org/wiki/Waggle_dance https://en.m.wikipedia.org/wiki/Bee#Navigation,_communicatio...

Related: I did a Ph.D. in mobile robotics inspired from short range navigation in bees, based on biologists' reports of systematic experiments on what elements bees uses to find their way.

Page 1 of 9Next →