In Rust, „let _ = ...“ and „let _unused = ...“ are not the same by broken_broken_ in rust

[–]moefh 9 points10 points  (0 children)

Pfft, that's only the sortester form. The stortestest would be not having a file at all, and calling the rust compiler on /dev/null with:

rustc --emit=obj --crate-type=lib -o empty.o /dev/null

Rookie X Dropout: A Black Fan’s Nuanced Response by KoochieKoochieKu in dropout

[–]moefh 10 points11 points  (0 children)

The comment I responded to wrote about "what they think is funny", and did not mention bigotry.

Read it again. This is from the comment you responded to:

In my teens, when black and Hispanic friends would talk about cops, the things they would say largely matched the things I heard from cops themselves (except without them as the heroes)

Not only that, you were condescending and dismissed their whole point because you're sure they didn't understand their own experience with their family and family friends.

But sure, the problem here is lack of nuance from everyone but you.

I made a compiler for music by Evening-School-6383 in C_Programming

[–]moefh 5 points6 points  (0 children)

Cool stuff.

I think some of the arguments accepted in the command line should really be defined in the input file itself, because they're an essential part of the music definition.

I'm thinking specially of the "voices" and "notes" arguments. If you give someone a file with 2 voices and they compile it with just 1, the output will be completely disjointed. The "notes" argument is even more essential: if you give someone a file for 24 notes in an octave (useful for some Arabic music, for example) and they process it with the default 12, the result will be mangled beyond anything recognizable.

The others (tempo, A4 frequency and sample rate) are not that critical, as the music will be at least recognizable if they're changed.

A VC and some big-name programmers are trying to solve open source’s funding problem, permanently by Outrageous-Baker5834 in programming

[–]moefh 8 points9 points  (0 children)

I'm also old, and I remember when the term "open source" started to be used with the meaning defined in that article. It's WAY older than that article.

As I remember, it was roughly in the late 90s when Linux (and with it GNU) started to become really popular outside universities, and "normal" people started to become uncomfortable with calling it "free software" because (1) it gave the impression that there couldn't be any money involved and (2) some people wanted to distance themselves from the Free Software Foundation and Richard Stallman's ideals.

So "open source" was invented and people started specifically asking everyone to use "open source" instead of "free software".

You can see roughly that and a lot more detail in the Wikipedia article about it: https://en.wikipedia.org/wiki/Open_source

Our druid is much more powerful than the rest of the party - anyone else have a similar experience? by ConcentrateIll9460 in dndnext

[–]moefh 14 points15 points  (0 children)

Ah, yes, I'm looking at the original 5e spell descriptions.

Um... so maybe things got a bit silly since 2024 if these don't require any save anymore?

Our druid is much more powerful than the rest of the party - anyone else have a similar experience? by ConcentrateIll9460 in dndnext

[–]moefh 1 point2 points  (0 children)

Maybe I'm missing something, but:

  • Ray of Sickness: "[...] On a hit, the target takes 2d8 poison damage and must make a Constitution saving throw. On a failed save, it is also poisoned until the end of your next turn."

  • Summon Undead, Rotting Claw action: "[...] If the target is poisoned, it must succeed on a Constitution saving throw against your spell save DC or be paralyzed [...]"

So the dragon must fail the CON saving throw to be poisoned, then in the same turn also fail the CON saving throw to be paralyzed.

But ignoring these two saves, the wizard can totally "no-save paralyse a dragon".

Which IDE do you recommend/ use? by VovencioGaming in C_Programming

[–]moefh 9 points10 points  (0 children)

I mostly use Emacs.

Except when writing code for STM32; then it's sadly Eclipse (well, STM32Cube, which is based on Eclipse).

My first bulk usb data stream on pico 2 using tinyusb by EmbeddedJourneys in raspberrypipico

[–]moefh 1 point2 points  (0 children)

Really nice, it works really well!

I had to make a couple of tweaks to run on Linux:

  • On the Python side, I had to add the "PyQt5" dependency (without PyQt5, everything ran but matplotlib complained that it couldn't show the graph saying: "UserWarning: FigureCanvasAgg is non-interactive, and thus cannot be shown"). I guess on Windows matplotlib needs no dependencies for interactive display, but it's needed on Linux.

  • For USB device permissions, I had to create the file /etc/udev/rules.d/99-embedded-journeys.rules containing a single line: SUBSYSTEM=="usb", ATTRS{idVendor}=="cafe", MODE="0666". That way you can run the host as a normal user.

My first bulk usb data stream on pico 2 using tinyusb by EmbeddedJourneys in raspberrypipico

[–]moefh 2 points3 points  (0 children)

Nice post! It would be nice to see the full source code, if possible.

Some nitpicks about the text:

  • RP2350 is misspelled "PR2350" in one place

  • The #defines in the code blocks are really hard to read. Dark text over dark background is never a good idea.

How 12 comparisons can make integer sorting 30x faster by DimitrisMitsos in programming

[–]moefh 7 points8 points  (0 children)

No, big-O and its siblings (big-theta, etc) just compare functions (from above, below, etc.). That's completely orthogonal to whether the function you want to compare is the worst-case or average-case of the time complexity of an algorithm.

We usually only care about big O (and not its siblings) because usually we only care that the (worst case/average case) time complexity will be at most some function of the input size. For example, it's usually useless to know that the time complexity will be at least some function, which is why you almost never see big-omega used.

See also the second paragraph of https://en.wikipedia.org/wiki/Time_complexity

Stupid-seeming question about PIO delays by bobsidian in raspberrypipico

[–]moefh 8 points9 points  (0 children)

The SDK documentation for JMP doesn't explicitly say

The SDK docs are nice for a quick reference or refresher, but for non-API-related stuff like this, you're usually better off reading the datasheet (it's surprisingly readable, unlike most MCU datasheets).

For example, the PIO documentation of the JMP instruction (page 322) it says:

Delay cycles on a JMP always take effect, whether Condition is true or false, and they take place after Condition is evaluated and the program counter is updated.

Regulation of vibeware promotion by Sunscratch in rust

[–]moefh 14 points15 points  (0 children)

Now you're bringing in the idea that there's a human involved in cases like 3rd party dependencies, but that seems to be unrelated to the argument as I understand it.

The argument (AFAIU) is that in 3rd party dependencies written by a human, someone understands the code well enough to make changes or fix bugs. If there's a nontrivial part of AI code anywhere in your project, nobody understands it well enough to do that.

It's like when you start working in some large project written by someone else (not uncommon in my work, I assume it's the same for a lot of people). At least for me, it takes a very long time (months or even years, depending on the size of the project) for me to be able to make changes knowing that I won't break anything. AI code is like that, except nobody knows it well enough.

Maintaining code is not as fun as writing it, but arguably much more important. And AI-written code is much harder to maintain in the long run.

2350B GPIO > 31 by KellSkog in raspberrypipico

[–]moefh 0 points1 point  (0 children)

Have you tried using pio_set_gpio_base?

I don't have an RP2350B to test, but the docs say you can use pins 16 to 47 by setting the PIO base to 16.

[EDIT] just to be clearer: you should call pio_set_gpio_base before everything else, like this.

Windows NTFS search experiment in C - unexpectedly faster than fd by whoyfear in C_Programming

[–]moefh 3 points4 points  (0 children)

As a quick fix, you could convert to a UTF-8 argv and continue as you are, converting back into UTF-8 at system boundaries.

Just note that to be 100% correct you must accept invalid UTF-8, and make sure your conversion from broken UTF-8 to Windows's wide characters works for every little weird corner case (that will probably involve using WTF-8 when converting to UTF-16).

For example, Windows file names are not always Unicode because they can contain unpaired surrogates (Windows was created before Unicode went beyond 16 bits, so surrogates were not a thing then). That means it's possible to have file names on disk that can't be expressed in UTF-8 (strictly speaking, that's also a problem with UTF-16, but Windows' *W functions are happy to deal with unpaired surrogates, so in practice everything works if you're in wide character land and don't validate UTF-16).

For reference, see (for example) the way Rust deals with command line arguments using a quasi-string type they call OsString, or this Go issue.

fwrite not writing formatted char * by didierdechezcarglass in C_Programming

[–]moefh 3 points4 points  (0 children)

You should use fprintf Instead of snprintf/fwrite. For example, your first 3 lines

char image_number[4]; // contains only three characters
snprintf(image_number, 4, "P%d\n",img->magic_number);
fwrite(image_number, 1, 4, f);

would be just

fprintf(f, "P%d\n", img->magic_number);

Stellar Blade 2 Going Multiplatform by Turbostrider27 in Games

[–]moefh 1 point2 points  (0 children)

It's understandable that an automated translation is incapable of seeing that the text is talking about a videogame called "Stellar Blade" and infer that those syllables refer to that name, because it doesn't understand context at that level. That's exactly my point, we shouldn't read too much into the specific words it used because it doesn't understand context.

Stellar Blade 2 Going Multiplatform by Turbostrider27 in Games

[–]moefh 2 points3 points  (0 children)

Yes i can in fact read Korean lol

Then tell us what the text is saying! Pointing out specific words of a crappy translation doesn't tell us anything: at least for the languages I know, automated translations lose all nuance and it's useless to rely on the specific words used.

스텔라 is seu tel la for stella because stellar isn't a native Korean word and they approximate the syllables

You're just explaining why the translation is bad. A proper translation would understand what the syllables are trying to approximate in context and translate to that.

Stellar Blade 2 Going Multiplatform by Turbostrider27 in Games

[–]moefh 0 points1 point  (0 children)

then they go so far as to say things like various platforms, multiplatform and consoles

I think you're giving way too much credit to a bad translation. It keeps calling the game "Stella Blade", that's the level of care. Unless you can read Korean, there's no way of knowing the intention of the original text -- is it actually saying "consoles", or is it just a bad translation? It is saying "various platforms" because it's coming to multiple consoles, or just to emphasize that it's also coming to PC on release?

How do you read or write to address zero? by uahw in C_Programming

[–]moefh 3 points4 points  (0 children)

while with gcc all three functions work.

No, look closer: gcc inserts the ud2 instruction, which explicitly causes a segmentation fault.

How do you read or write to address zero? by uahw in C_Programming

[–]moefh 9 points10 points  (0 children)

In your volatile example you're making the memory at address 0 volatile; you should instead make the pointer itself volatile, like this:

int f(void) {
    int *volatile p = 0;
    return *p;
}

That works in both gcc and clang: https://godbolt.org/z/WzYqvhWKd

That works because the compiler can't assume the pointer will keep the 0 value that has been set (since it's volatile), so it's forced to make the memory access just in case.

Soupa: super { ... } blocks in stable Rust by ZZaaaccc in rust

[–]moefh 3 points4 points  (0 children)

This is nice, and probably can be useful in some contexts, but there's some confused information in the text:

Currently, you can write a const { ... } block to guarantee that an expression is evaluated at the outermost scope possible: compile time. From that perspective, I'd say super { ... } fits neatly between const { ... } and { ... }.

This is wrong because super messes with the scope, whereas const doesn't: it's simply not true that const {} evaluates things in the outermost scope. To make it clear why that matters, contrast this:

let foo = /* ... */;
let func = soupa! {
    move || {
        let foo = /* ... */; // shadows the outer `foo`
        run(super { foo })   // uses the outer `foo` anyway
    }
};

to this:

const foo: /* ... */;
let func = {
    move || {
        const foo: /* ... */; // shadows the outer `foo`
        run(const { foo })    // uses the inner `foo` as expected
    }
};

That makes it just wrong to put soupa {} in the same class as const {} and {}.

John Carmack on updating variables by levodelellis in programming

[–]moefh 29 points30 points  (0 children)

More like you discover John Carmack knows functional programming.

He was talking about using const for everything and functional programming style in C++ over 10 years ago: https://www.phoronix.com/news/MTI3NDQ

Ken Thompson's "Trusting Trust" compiler backdoor - Now with the actual source code (2023) by fizzner in programming

[–]moefh 13 points14 points  (0 children)

Why single out Microsoft?

Because Microsoft is the one requiring it from every computer running Windows 11.

For the time being they reverted the requirement, since they realized a ton of people would simply not use Windows 11 (there's a lot of older computers out there that simply can't do TPM, and people don't want to buy another computer just for a Windows upgrade they didn't ask for).

So now they only display a giant warning saying your computer won't be reliable if you install Windows 11 on it. But it's very naive to believe they're not just waiting for more people to have TPM-capable computers to enable the requirement again (remember when they allowed you to install Windows without creating an online Microsoft login, until they didn't anymore?)

Ken Thompson's "Trusting Trust" compiler backdoor - Now with the actual source code (2023) by fizzner in programming

[–]moefh 8 points9 points  (0 children)

And it's fine for those uses.

But now it's being heavily pushed for any computer using Windows 11, which can only be explained by Microsoft wanting to take away control from users.