Readit News logoReadit News
moefh commented on The most famous transcendental numbers   sprott.physics.wisc.edu/p... · Posted by u/vismit2000
zkmon · a month ago
If a number system has a transcendental number as its base, would these numbers still be called transcendental in that number system?
moefh · a month ago
Yes. A number is transcendental if it's not the root of a polynomial with integer coefficients; that's completely independent of how you represent it.
moefh commented on Over 40% of deceased drivers in vehicle crashes test positive for THC: Study   facs.org/media-center/pre... · Posted by u/bookofjoe
dragonwriter · 2 months ago
> Feels like a low sample size

Its not a sample, it is the whole universe of analysis. (If you treat it as a sample of, say, US drivers killed in accidents in the same period, then errors due to sample size are probably the least of its problems.)

moefh · 2 months ago
We don't know that. We don't even know if there's selection bias.

The article says the research was "focusing on 246 deceased drivers who were tested for THC", and that the test usually happens when autopsies are performed. It doesn't say if autopsies are performed for all driver deaths, and it also doesn't say what exactly is "usually".

If (for example) autopsy only happens when the driver is suspected of drug use, then there's a clear selection bias.

Note that this doesn't mean the study is useless: they were able to see that legalization of cannabis didn't have impact on recreational use.

moefh commented on Checked-size array parameters in C   lwn.net/SubscriberLink/10... · Posted by u/chmaynard
Veserv · 2 months ago
I am actually not talking about the lack of fat pointers. That is almost entirely orthogonal to my point. I am talking about the fact that what would be the syntax for passing a array by value was repurposed for automatically decaying into a pointer. This results in a massive and unnecessary syntactic wart.

The fact that the correct type signature, a pointer to fixed-size array, exists and that you can create a struct containing a fixed-size array member and pass that in by value completely invalidates any possible argument for having special semantics for fixed-size array parameters. Automatic decay should have died when it became possible to pass structs by value. Its continued existence continues to result in people writing objectively inferior function signatures (though part of this it the absurdity of C type declarations making the objectively correct type a pain to write or use, another one of the worst actual design mistakes).

Fat pointers or argument-aware non-fixed size array parameters are a separate valuable feature, but it is at least understandable for them to not have been included at the time.

moefh · 2 months ago
> The fact that the correct type signature, a pointer to fixed-size array, exists and that you can create a struct containing a fixed-size array member and pass that in by value completely invalidates any possible argument for having special semantics for fixed-size array parameters.

That's not entirely accurate: "fixed-size" array parameters (unlike pointers to arrays or arrays in structs) actually say that the array must be at least that size, not exactly that size, which makes them way more flexible (e.g. you don't need a buffer of an exact size, it can be larger). The examples from the article are neat but fairly specific because cryptographic functions always work with pre-defined array sizes, unlike most algorithms.

Incidentally, that was one of the main complaints about Pascal back in the day (see section 2.1 of [1]): it originally had only fixed-size arrays and strings, with no way for a function to accept a "generic array" or a "generic string" with size unknown at compile time.

[1] https://www.cs.virginia.edu/~evans/cs655/readings/bwk-on-pas...

moefh commented on Checked-size array parameters in C   lwn.net/SubscriberLink/10... · Posted by u/chmaynard
jacquesm · 2 months ago
Interesting, I wasn't aware of that and thought the compiler would at least throw up a warning if it had seen that function prototype.
moefh · 2 months ago
It's not intuitive, although arguably conforms to the general C philosophy of not getting in the way unless the code has no chance of being right.

For example, both compilers do complain if you try to pass a literal NULL to `f1` (because that can't possibly be right), the same way they warn about division by a literal zero but give no warnings about dividing by a number that is not known to be nonzero.

moefh commented on Checked-size array parameters in C   lwn.net/SubscriberLink/10... · Posted by u/chmaynard
jacquesm · 2 months ago
It wasn't considered bad, it was considered ugly and in the context given that is a major difference. The proposed alternative in that post to me is even more ugly so I would have agreed with the option that received the most support, to leave it as it was.
moefh · 2 months ago
It was always considered bad not (just) because it's ugly, but because it hides potential problems and adds no safety at all: a `[static N]` parameter tells the compiler that the parameter will never be NULL, but the function can still be called with a NULL pointer anyway.

That's is the current state of both gcc and clang: they will both happily, without warnings, pass a NULL pointer to a function with a `[static N]` parameter, and then REMOVE ANY NULL CHECK from the function, because the argument can't possibly be NULL according to the function signature, so the check is obviously redundant.

See the example in [1]: note that in the assembly of `f1` the NULL check is removed, while it's present in the "unsafe" `f2`, making it actually safer.

Also note that gcc will at least tell you that the check in `f1()` is "useless" (yet no warning about `g()` calling it with a pointer that could be NULL), while clang sees nothing wrong at all.

[1] https://godbolt.org/z/ba6rxc8W5

moefh commented on You can't fool the optimizer   xania.org/202512/03-more-... · Posted by u/HeliumHydride
sureglymop · 2 months ago
With this one I instead wondered: If there are 4 functions doing exactly the same thing, couldn't the compiler also only generate the code for one of them?

E.g. if in `main` you called two different add functions, couldn't it optimize one of them away completely?

It probably shouldn't do that if you create a dynamic library that needs a symbol table but for an ELF binary it could, no? Why doesn't it do that?

moefh · 2 months ago
> It probably shouldn't do that if you create a dynamic library that needs a symbol table but for an ELF binary it could, no?

It can't do that because the program might load a dynamic library that depends on the function (it's perfectly OK for a `.so` to depend on a function from the main executable, for example).

That's one of the reasons why a very cheap optimization is to always use `static` for functions when you can. You're telling the compiler that the function doesn't need to be visible outside the current compilation unit, so the compiler is free to even inline it completely and never produce an actual callable function, if appropriate.

moefh commented on New magnetic component discovered in the Faraday effect   phys.org/news/2025-11-mag... · Posted by u/rbanffy
rhdunn · 3 months ago
Quantum Electro-Dynamics (QED) is the application of Special Relativity (non-accelerating frames of reference, i.e. moving at a constant speed) to Electromagnetism. Thus, the issue is with applying accelerating frames of reference (the General in GR) to QM.
moefh · 3 months ago
> Special Relativity (non-accelerating frames of reference, i.e. moving at a constant speed)

Sorry, but this is a pet peeve of mine: special relativity works perfectly well in accelerating frames of reference, as long as the spacetime remains flat (a Minkowski space[1]), for example when any curvature caused by gravity is small enough that you can ignore it.

[1] https://en.wikipedia.org/wiki/Minkowski_space

moefh commented on China has added forest the size of Texas since 1990   e360.yale.edu/digest/chin... · Posted by u/Brajeshwar
gorwell · 3 months ago
For context, here are the top 10 biggest footprints

1. China 26.16%

2 United States 11.53%

3. India 7.69%

4. Russia 3.75%

5. Brazil 3.16%

6. Indonesia 3.15%

7. Japan 2.15%

8. Iran 2.06%

9. Saudi Arabia 1.60%

10. Canada 1.54%

The top 10 countries account for about ~60% of global CO₂ emissions.

moefh · 3 months ago
That's not great context: China and India have huge populations, it's expected that they should be at the top.

Better context can be found here[1] (countries by emission per capita). It's still not great because it shows a lot of small countries at the top. For example: Palau is the first, but it has a population of a few thousand people, so their emissions are a rounding error when compared to other countries.

[1] https://en.wikipedia.org/wiki/List_of_countries_by_carbon_di...

moefh commented on Date bug in Rust-based coreutils affects Ubuntu 25.10 automatic updates   lwn.net/Articles/1043103/... · Posted by u/blueflow
whytevuhuni · 4 months ago
> This simply doesn't work.

I think it works, and quite well even. Defaults matter, a lot, and Rust and its stdlib do a phenomenal job at choosing really good ones, compared to many other languages. Cargo's defaults maybe not so much, but oh well.

In C, sloppy programmers will generally create crashy and insecure code, which can then be fixed and hardened later.

In Rust, sloppy programmers will generally create slower and bloated code, which can then be optimized and minimized later. That's still bad, but for many people it seems like a better trade-off for a starting point.

moefh · 4 months ago
> In C, sloppy programmers will [...]

> In Rust, sloppy programmers will [...]

You're comparing apples to oranges.

Inexperienced people who don't know better will make safe, bloated code in Rust.

Experienced people who simply ignore C warnings because they're "confident they know better" (as the other poster said) will write unsafe Rust code regardless of all the care in the world put in choosing sensible defaults or adding a borrow checker to the language. They will use `unsafe` and call it a day -- I've seen it happen more than once.

To fix this you have to change the process being used to write software -- you need to make sure people can't simply (for example) ignore C warnings or use Rust's `unsafe` at will.

moefh commented on Date bug in Rust-based coreutils affects Ubuntu 25.10 automatic updates   lwn.net/Articles/1043103/... · Posted by u/blueflow
pepoluan · 4 months ago
And how many software are compiled with zero warnings?

And how many C programmers ignore such warnings because they are confident they know better?

moefh · 4 months ago
It seems like you're trying to fix a social problem (programmers don't care about doing a good job) with a technical solution (change the programming languages). This simply doesn't work.

People who write C code ignoring warnings are the same people who in Rust will resort to writing unsafe with raw pointers as soon as they hit the first borrow check error. If you can't force them to care about C warnings, how are you going to force them to care about Rust safety?

I've seen this happen; it's not seen at large because the vast majority of people writing Rust code in public do it because they want to, not because they're forced.

u/moefh

KarmaCake day779June 8, 2011View Original