HNHacker News
TopNewBestAskShowJobs

Diggsey

2,827 karma · joined October 6, 2014

submissionscomments
Diggsey··on UK electric car drivers should be charged per mile, say campaigners
> 65% of the public believe it is fair for electric car drivers to be taxed, but at a lower rate than petrol and diesel drivers

Electric cars still use roads, which still need to be maintained. There's no "extrapolation of logic" required, because the tax on the most fuel efficient cars already dwarfs that which would be paid by electric cars.

Diggsey··on Good refactoring vs. bad refactoring
> Putting aside the mis-application of "pattern" (which _should_ be used with respect to a specific design problem, per the Gang of Four)

This is not in any way a mis-application of the word "pattern". There is no exhaustive list of all design patterns. A design pattern is any pattern that is used throughout a codebase in order to leverage an existing concept rather than invent a new one each time. The pattern need not exist outside the codebase.

> Consistency increases legibility, but only to a certain point.

It's the opposite: inconsistency decreases legibility, and there is no limit. More inconsistency is always worse, but it may be traded off in small amounts for other benefits.

Take your example of experimenting with new solutions: in this case you are introducing inconsistency in exchange for learning whether the new solution is an improvement. However, once you have learned that, the inconsistency is simply debt. A decision should be made to either apply the solution everywhere, or roll back to the original solution. This is precisely the point the author is making by saying "consider refactoring the entire codebase to use this new pattern".

This refactoring or removal doesn't need to happen overnight, but it needs to happen before too many more experiments are committed to. Instead what often happens is that this debt is simply never paid, and the codebase fills with a history of failed experiments, and the entire thing becomes an unworkable mess.

Diggsey··on CrowdStrike's Falcon Sensor also linked to Linux kernel panics and crashes
Microsoft don't own the kernel in that sense: anyone can write kernel drivers for windows... While there are some things that the kernel can do to protect against a bad driver, it's not a security boundary, so ultimately bad code can cause crashes.

AIUI, Microsoft actually has good tooling for validating drivers before they are deployed, but it requires that you actually run the validation...

Diggsey··on Let's blame the dev who pressed "Deploy"
As someone who works in this space, I can tell you: it's because big companies buy Cyber Security Insurance, and the insurance forms have a checkbox along the lines of "do you run Endpoint Security Software on all devices connected to your network", and if you check the box you save millions of dollars on the insurance (no exageration here). Similarly, if you sell software services to enterprises, the buyers send out similar due diligence forms which require you as a vendor to attest that you run Endpoint Security Software on all devices, or else you won't make the sale. This propagates down the whole supply chain, with the instigator being the Cyber Security insurance costs, regulation or simply perceived competence depending on the situation.

So it's not necessarily government regulation per se, but a combination of things:

1. It's much safer (in terms of personal liability) for the decision makers at large companies to follow "standard industry practices" (however ridiculous they are). For example, no-one will get fired outside of Crowd Strike for this incident precisely because everyone was affected. "How could we have foreseen this when noone else did?"

2. The Cyber Security Insurance provider may not cover this kind of incident given there was no breach and so as far as they are concerned installing something like Crowd Strike is always profitable.

3. The insurance provider has no way to effectively evaluate the security posture of the enterprise they are insuring, so rely on basic indicators such as this checkbox, which completely eliminates any nuance and leads to worse outcomes (but not to the insurance provider!)

4. "Bad checkboxes" propagate down the supply chain the same way that "good checkboxes" do (eg. there are generally sections on these due diligence questionnaires about modern slavery regulation, and that's something you really want to propagate down the supply chain!)

Overall I would say the main cause of this issue is simply "big organisation problems". At a certain scale it seems to become impossible for everyone within the organization to commicate effectively and to make correct, nuanced decisions. This leads to the people at the top seeing these huge (and potentially real) risks to the business because of their lack of information. The person ultimately in charge of security can't scale to understand every piece of software, and so ends up having to make organisation-wide decisions with next to no information. The entire thing is a house of cards that noone can let fall down because it's simply too big to fail.

Making these large organisations work effectively is a very hard problem, but I think any solution must involve mechanisms to allow parts of the business to fail withing taking everything down. Allowing more decisions to be taken locally, but also the responsibilities and repercussions of those decisions to be felt locally.

Diggsey··on Why CockroachDB doesn't use EvalPlanQual
You always need app-level retries for SERIALIZABLE isolation level. You don't need any explicit locking - the database should handle that for you (and in the case of PostgreSQL, locking is not the only tool it uses for avoiding serialization anomalies).

The strategy I use is to keep transactions as small as possible, and have retry functionality built into the transaction abstraction, so the buesiness logic doesn't really need to worry about it. I also explicitly use read-only transactions where possible.

Diggsey··on Dear Paul Graham, there is no cookie banner law
> No, people cannot escape responsibility by saying "the law made me be belligerent toward my users".

Correction: people should not be able to escape responsibility by saying this.

The problem is that right now people do escape responsibility for saying this because the EU is not properly enforcing these new laws.

Introducing a law and then not enforcing it has consequences, and those consequences should have been foreseen. Either the law is unenforceable due to practical constraints, in which case it's a bad law, or the EU is failing to enforce it due to inability.

Hopefully the EU starts putting more focus on enforcing its existing laws rather than creating new ones.

Diggsey··on C++ Safety, in Context
> 30% to 50% of Rust crates use unsafe code

This is particularly misleading for two reasons:

1) There are a lot of `-sys` crates which link to C libraries, so the "unsafe" code in these crates comes from the binding to C rather than some limitation of Rust. Often there are 100% safe Rust alternatives to these C libraries as well.

2) Of the remaining crates which use "unsafe", the unsafe code is often contained to a tiny percentage of the code, so if we're looking at the overall amount of unsafe code, you're going from 100%, to a fraction of a percent.

Diggsey··on Bug in reader/writer locks in Windows API
I think part of the reason is that there's a very similar code pattern which is user error, and avoiding that pattern tends to avoid this pattern as well.

The similar case occurs when you have: - 1+ threads holding a shared lock (Readers) - 1+ threads waiting to acquire an exclusive lock (Pending Writers) - 1+ threads trying to acquire the shared lock (Pending Readers) - 1+ Reader is waiting on a Pending Reader

In this case the Pending Readers will be unable to acquire the shared lock even though it is still in "read mode" because in a fair RW lock Pending Writers are prioritised above Pending Readers so as not to starve the writer side of the lock.

Diggsey··on What's new in the Postgres 16 query planner
But when is it going to be able to use indexes to speed up `IS NOT DISTINCT FROM` queries? ;)
Diggsey··on Memory leak proof every C program
This doesn't make sense even as a joke, since that's not what it means to leak memory.

Memory being "reachable" is a property used by garbage collectors to determine what can be safely freed, but reachable memory can still be a memory leak. (Which is why languages with GC can still suffer from memory leaks...)

Diggsey··on The memory remains: Permanent memory with systemd and a Rust allocator
Not really - you have to completely change your data model to avoid pointers which won't save correctly (eg. using a byte array for name in the article) compared to just slapping `#[derive(Serialize, Deserialize)]` on your structs. Not to mention all the extra unsafe code.
Diggsey··on Advent of Code 2023 is nigh
> Re-using the existing code where possible is the fundamentally right approach to the problem.

Reusing code does not make something "fundamentally right approach". An implementation that actually does what the problem asks is a "fundamentally right approach". If you can reuse existing code in that implementation then that's a bonus.

The problem is very clearly specified, so if you choose to implement something else hoping that it's "close enough" then that's on you...

Diggsey··on Sentry Relicense Again (FSL)
Why do you think the MIT license is "revokable"? It's not - the version that was MIT licensed can always be used under that license.
Diggsey··on Scandinavian spy drama: An intelligence chief who came under state surveillance
This is a guardian article, not BBC. Maybe the link was changed?
Diggsey··on Othello Is Solved?
Now that Othello is solved, there exist a set of rules a player can follow to guarantee a win or draw every game. It's possible (if unlikely) that a computer could sufficiently compress those rules to be memorizable (and then applicable) by a human.
Diggsey··on An implementation of the NTFS filesystem in a Rust crate
I would expect writing to be much harder on all file-systems. There's only one way to read the data, but there could be any number of strategies for deciding where to write new data.
Diggsey··on Don't use DISTINCT as a "join-fixer"
You're overthinking it - the optimization is absolutely possible as you've described. The reason databases haven't done is not some question of design philosophy, it's simply that nobody bothered to implement it.

> I know that I would be deeply surprised if I found a database doing it, and not in a good way.

SQL engines do way more surprising optimizations than this. SQL is a "4th gen" language after all, meaning it's absolutely within the spirit that the database engine does whatever it wants to get the result.

Diggsey··on Don't use DISTINCT as a "join-fixer"
Nobody actually answered your question helpfully, so here goes:

When you write `SELECT DISCTINCT a, b` you are asking for every unique pair (a, b) in the result. Specifically, the same value of `a` could appear multiple times in the result paired with different values of `b`.

The only way to implement that "generally" is to visit all of the rows in the result-set, and skip over duplicates using a hash table of "already seen" pairs, or by sorting the result. The problem is that this intermediate result-set is much bigger than we really want.

As a human, we look at this and think "Oh, but `a` is the primary key (in this case CustomerID) and `b` is a column in the same table (CustomerName) so we only need to be distinct over `a`, which means the query optimizer should be able to "push down" the DISTINCT clause into the scan of the joined tables". The problem is that the query optimizer has not been endowed with this kind of knowledge about the specific relationship between `a` and `b`, and so cannot do this optimization. In principle, a query optimizer could implement this kind of optimization though.

At this level you really start getting into the nitty gritty of what optimizations a particular database has implemented though: the solution presented in the article may be the best way to write this for SQL Server, but this "correlated subquery" form could be catastrophically slow in other database engines...

Diggsey··on Bentham's Mugging (2022)
Well the ten pounds still exists either way. You'd have to argue that there's more utility in Bentham owning the £10 than the mugger owning the £10, and that the difference in utility between them is greater than the utility of a finger.

I imagine you could define utility that way, but presumably the mugger could increase the cost (two fingers? an arm?) until the argument works. Also, if you do definite a utility function like that (say, "there is more utility in this £10 being mine rather than yours than the utility of your arm") then that's a pretty questionable morality.

Diggsey··on Fiber in C++: Understanding the Basics
Userspace != Application-managed

On Windows, many things exist in user-space that are managed by the OS. This is in contrast to linux where the Linux kernel is its own thing with its own stable API.

Fibers are an OS-level concept that exists in user-space.

Diggsey··on An INI Critique of TOML (2021)
Because for a long time if you wanted to build a website with no money and no experience those were your only options!

JavaScript and HTML for obvious reasons. PHP because if you didn't have your own server, you couldn't run anything else (while there were free hosting providers that would host your PHP scripts).

Nowadays there are tons more options.

Diggsey··on UK air traffic control meltdown
Software has bugs, that's not really the damning part... The damning part is that in four hours and two levels of support teams, there was noone who actually knew anything about how the system worked who could remove the problematic flight plan so that the rest of the system could continue operating!

What exactly is the point of these support teams when they can't fix the most basic failure mode (a single bad input...)

Diggsey··on More than you've ever wanted to know about errors in Rust (2022)
> However in Rust, panics cannot be recovered from, there is no way to incept a panic in the current thread.

You definitely can: https://doc.rust-lang.org/std/panic/fn.catch_unwind.html

Diggsey··on In 1961 a Gallup poll showed only 33% of Americans in favor of moon landing
The research was a side effect of a very well defined goal, which was achievable albeit extremely hard. Investing in achieving a goal (with the research being a side benefit) is different from just investing in research because it changes the motivations of the researchers (from "how do we get our next research grant" to "how do we solve this problem").

That's not to say you shouldn't invest in abstract research with no obvious goal at all, but probably you should consider it a much higher risk investment and not fund all your research that way...

There's also the fact that money now is more valuable that money later even if you adjust for inflation (one of the reason countries run a deficit) so the expected return should be much higher than $1 to be worth investing in.

Next, there's the fact that investment is finite, so the expected return has to be higher than the expected return you would get elsewhere.

Finally there's the fact that as you invest more, the effects of all three of those factors increase, so it has diminishing returns.

Diggsey··on PostgreSQL reconsiders its process-based model
It's not just CPU - memory usage is also higher. In particular, idle connections still consume signficant memory, and this is why PostgreSQL has so much lower connection limits than eg. MySQL. Pooling can help in some cases, but pooling also breaks some important PostgreSQL features (like prepared statements...) since poolers generally can't preserve session state. Other features (eg. notify) are just incompatible with pooling. And pooling cannot help with connections that are idle but inside a transaction.

That said, many of these things are solvable without a full switch to a threaded model (eg. by having pooling built-in and session-state-aware).

Diggsey··on If a PR Says “Artificial Intelligence,” There’s a Good Chance It’s Meaningless
It's missing generality. It can't do basic maths, or even follow instructions. It can't make valid moves in a game. It can only do what it was trained to do: make a good guess at what word should come next.

I don't mean to down-play how impressive models like GPT-4 are - they are very impressive and have great utility.

The problem is we are talking about PR, and when you throw around words like "artificial intelligence" it misleads everyone who is not intimately familiar with the limitations of such models.

> Personally I believe it's possible to have intelligence without sentience/self-awareness

The general public doesn't make that distinction when you throw around terms like artificial intelligence. They hear artificial intelligence and imagine "thinking machines".

No doubt people will say this is just moving the goalposts - that whatever these models achieve it will never be "AI", but that's demonstrably false. The concept of AI has existed in film and other media in the same form since forever, and it's pretty clear if you put those representations side by side with what we actually have today, that we are not even close yet.

For some reason "advances in machine learning" just isn't hip enough to get funding, so "AI" gets thrown around instead.

Diggsey··on Ways to shoot yourself in the foot with Postgres
I asked this specific question before on the PostgreSQL IRC, and was told that it simply wasn't implemented. There's no huge technical blocker to it being done, it's just a bit awkward to make it work the way the code is structured AIUI.
Diggsey··on Custom Allocators in Rust
You can already do custom allocation in Rust. These efforts are about bringing support for custom allocators to the types in `std` so that you can combine use of a normal `Vec` with a custom allocator, instead of needing to definte your own `Vec` (or at least pull one in from a 3rd party crate).
Diggsey··on Custom Allocators in Rust
Neither, I was disagreeing with the comparison to Go and generics.

Generics in Go don't add anything beyond what generics already do in other languages, so the challenge with bringing generics to Go is "how do we adapt the language to support a feature that already exists in other languages and is generally well understood". Bringing generics to a language that wasn't designed with them in mind has often resulted in a sub-optimal implementation (eg. Java vs C#).

On the other hand, "safe custom allocators" are not a feature that any language (to my knowledge) has solved. It's not as though this was an oversight in Rust's initial design: using a custom allocator in an unsafe context has always been possible in Rust, and it's too early to say whether bringing this feature into the language later will result in a similarly sub-optimal design: in order to be sub-optimal there would have to exist some better solution out there, and there currently doesn't.

Diggsey··on Custom Allocators in Rust
I think most of the challenges are around making custom allocators safe without harming the ergonomics, which Zig hasn't solved.

If Rust was content to have use of custom allocators be unsafe it would be trivial to add them (since you could just add new variants of allocating methods that take an allocator as a parameter).

← PreviousPage 3 of 16Next →