News for hackers. Stuff that matters.

yccs27

Re:Much Ado About None: Sentinel Values in Python on Saturday October 31, 2026 @06:10PM (#50320746)
If you have a map, get(key) returns Option[ValueT]: None if the key is missing, Some(value) otherwise. If the value type itself is, say, Optional[String], your return type is Optional[Optional[String]]. Here None still always means the key is missing, while Some(None) means the value is just None.
Re:Wax Motor on Friday September 18, 2026 @06:58AM (#49752587)
I always wondered what the actuator in the exhaust air valve for my apartment ventilation was - now I'm pretty sure it's a wax motor! You can use a switch to increase the airflow, but it takes a few seconds to react and opens/closes very slowly and quietly.
Re:Amazon pilots ad services in ChatGPT on Thursday September 10, 2026 @10:49AM (#49644721)
Paid tier just means you're a more lucrative ad target.
It's just the opposite side of the same mountain, used as a case study for modeling GLOF risk. In fact, they prominently cite "Potentially dangerous glacial lakes across the Tibetan Plateau" [1], which includes Gyirong Port and the downstream valley as a high risk of GLOFs and notes that many buildings there are exposed to potential flash flooding. Take a look at Fig. 5 [2] - the upper left cluster of dangerous lakes and exposed buildings is the site of the disaster. They also name Jilong, Nyalam, Dingri and Kangding as the Tibetan counties with the highest lake danger; the glacier collapse happened at the border of Jilong county.

[1] referenced as Allen et al. (2019), https://doi.org/10.1016/j.scib.2019.03.011

[2] https://ars.els-cdn.com/content/image/1-s2.0-S20959273193015...

They might be trying to get into the context of long-running chat sessions.
Yes, editions are a great mechanism. It still has its limits, especially if you want easy edition migrations. All existing Rust code assumes it can drop any type whenever it wants, and that is not something you can just change across editions. You have to be very careful with defaults if you don't want conflicts when crossing edition boundaries.
Yes, destructuring is typically the only allowed way to get rid of linear/indestructible values. If the type has private fields, this is only possible in the same module, so commit(txn) and rollback(txn) would have to be implemented in the same module as the Transaction type.
Ah, thanks, I didn't realize "pin ergonomics" was the Rust Project name for @withoutboats' pinned places.
There's a different proposal by @withoutboats to make immovability a property of the place/reference instead of the type:

https://without.boats/blog/pinned-places/

Does this project goal mean that the rust maintainers have decided to implement @yoshuawuyts' immovable types proposal in favor of pinned places?

Re:Elevators on Saturday August 01, 2026 @11:06AM (#49135095)
You could also detect when the elevator call button gets pressed again right after the elevator has left a floor. That means someone wasn't able to get on the elevator (and is now waiting for the next one).
Re:How Many Elementary Particles Are There, Really? on Saturday June 27, 2026 @12:32PM (#48699625)
The gluon with color (|g1> + |g2> + |g8>) / √3 is just a superposition of the gluons with colors g1, g2 and g8, the same way you can make superpositions of any other particles. You are right that the choice of basis vectors is arbitrary, but that doesn't make it wrong to count the number of dimensions. It also doesn't make it fundamentally different than, say, polarizations of photons or even flavors of quarks. You can have superpositions of photon polarizations or quark flavors.

All of these are continuous properties in an n-dimensional vector space.

Re:Correlated randomness in Slay the Spire 2 on Tuesday June 16, 2026 @08:12AM (#48553997)
I guess it's mainly a limit to savescumming.
Re:Bias Compounds, Variance Washes Out on Monday June 01, 2026 @04:15AM (#48353969)
Yeah, this is basically stochastic dithering applied to numeric floating point quantization instead of image color quantization.

This makes me wonder whether you could apply different dithering approaches to numeric computations. You cannot use diffusion or similar mehods, because you don't have information about neighboring pixels/computations. Using low-discrepancy sequences might work to reduce stochastic noise, but it could also reintroduce bias for some computations.

Re:What it takes to transpose a matrix on Tuesday May 26, 2026 @08:20AM (#48278753)
It's the same topology! Just replace each shuffle/blend with multiplication by a root of unity and addition, and you get FFT!
Re:What it takes to transpose a matrix on Tuesday May 26, 2026 @07:05AM (#48278049)
A good example for this is A + A^T; you can fuse the two operations but you cannot get around the access pattern of matrix transposition.
Re:Minnesota becomes first state to ban prediction markets on Wednesday May 20, 2026 @09:18AM (#48207238)
Making laws more explicit in important cases is valuable because it reduces uncertainty about legal interpretation. Using your example of cellphone use, under distracted driving laws the prosecution would have to prove that the specific case of cellphone use was distracting enough to be a safety hazard. With the more specific ban on cellphones, that is no longer an obstacle.
Thank you for the detailed answers!

I think purity is something the programmer just has to annotate themselves. Any boundary between languages with different type system guarantees will always have this kind of friction - Rust to C/C++ FFI also has to deal with ownership, lifetimes and aliasing manually.

Regarding type classes, monomorphisation indeed seems like a difficult obstacle for polymorphic function. But just translating type classes and impls might not be as difficult? So going from:

    trait Foo {
      fn foo(&self);
    }
    
    impl Foo for Bar {
      fn foo(&self) {...}
    }
to

    class Foo a where
      foo :: a -> IO ()
    
    instance Foo Bar where
      foo :: Bar -> IO ()
      foo self = ...
It's great that this allows passing Rust structs both as ForeignPtr and as native records with marshalling!

Some questions/ideas:

- Is there a way to generate #[hsrs::data_type] bindings for Rust library types, or do you need to create custom wrapper types for them?

- It seems like all #[hsrs::function]s are translated to return IO (since Rust functions can do arbitrary side effects). It would be great if you could (unsafely) mark functions as pure, to get pure Haskell functions without having to wrap them in unsafePerformIO.

- Both Haskell and Rust have HM type systems, so I wonder if you could also translate type classes from Rust to Haskell.

Re:Monad Tutorials Timeline on Thursday April 30, 2026 @06:06AM (#47960342)
Monads got their name from monoids (being a monoid in the category of endofunctors). Monoids are equivalent to one-object categories, so the name uses the greek syllable "mono" for one.
Re:Illegal vs. Unwanted States on Tuesday April 28, 2026 @03:50PM (#47939669)
I've noticed this with UI interfaces before: For example, an IBAN field which actively blocks you from entering more than the expected number of characters. Seems like a good idea - except whoever sent me their account number helpfully included spaces to separate blocks of numbers, so when I copy-paste it the last few digits get cut off. Now I not only have to delete the spaces, but also copy the missing digits again! Just make the field red and block me from submitting until I fix my input!
Re: on Monday March 30, 2026 @10:43AM (#47575016)
Does "Pharma" actually dose medication based on the Eyring equation? I'm not convinced we actually know the value of ΔG. AFAIK, the optimal biological dose is determined via dose-ranging studies during Phase I/II of clinical trials. And drug metabolism rate is measured, not derived from theoretical models.
Re:Waymo 13x safer than human drivers on Friday March 20, 2026 @03:20AM (#47451516)
Road capacity does not increase with speed above 50 km/h on urban roads or 70 km/h on highways. Following distance scales with speed, so more speed can actually mean fewer cars per unit of time.

In theory, braking distance scales quadratically with speed. In practice, people leave less room on highways, because they rely on others driving predictably, but spacing still increases faster than linear.

Re:Hisense TVs add unskippable startup ads before live TV on Tuesday March 10, 2026 @10:19AM (#47323647)
I'm not so sure this is really a free market equilibrium. There are two effects which explain the prevalence of ads even if consumers are willing to pay more for ad-free products:

- Imperfect information, aka Market for Lemons: It can be hard to find out how prevalent ads will be when buying a product. Consumers often make a purchasing decision without knowledge about ads.

- Changing terms after lock-in, aka Enshittification: Manufacturers (like Hisense here) can add advertising to products after consumers have already bought them. Initially, consumers have negotiation power since they can freely choose a product, but later they are locked in and cannot easily react to the manufacturer changing the product to their detriment.

Re:The “JVG algorithm” only wins on tiny numbers on Tuesday March 10, 2026 @06:25AM (#47321350)
The last line of the introduction

> By doing so, we aim to provide a novel paradigm [...]

also made me think of item 19 on your list:

> 10 points for claiming that your work is on the cutting edge of a "paradigm shift".

I'm sad though that you didn't call it the "Baez crackpot index"...

Re:Voith Schneider Propeller on Thursday February 19, 2026 @06:42AM (#47072781)
This reads a lot like an advertisement. The linked page [[Cyclorotor]] is more neutral and has more information on the design and applications outside of marine vessels:

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

It‘s preying on the city‘s desperation to get a cash payout, to get space and utilities worth much more. Facebook abuses its market power to pit city governments against each other, while the cities don‘t have many alternatives.
Re:Are two heads better than one? on Wednesday January 14, 2026 @09:11AM (#46616266)
The saying probably assumes that each chronometer has a certain small probability of malfunctioning, resulting in a significant error (basically a fat-tailed error distribution). With three chronometers, you can use a robust estimator of the true value (consensus value or median). With two, there's no robust estimator and if you use the mean, you have twice the probability of being significantly wrong (though only by half as much).
Thanks for the link, nice to see the informal conventions spelled out like this!
True, although better pruning can massively lower the effective branching ratio compared to pure alpha-beta, making the algorithm benefit more from longer search time again (which is why pruning is so important).
Re:Looking for flagged discussions on HN? See what's active on Friday January 09, 2026 @05:03PM (#46560025)
Users with enough karma can "flag" posts and comments, which a) calls for moderator attention and b) decreases ranking. It's meant for off-topic/inflammatory/low-quality submissions.

Older »