David R. MacIver

I guess I toot now.

David R. MacIver boosted:
2025-05-23

Two different approaches to debugging a software problem:

The Sudoku approach: stare at the limited set of clues you have, and think harder and harder about them until you find a way to deduce something useful.

The Minesweeper approach: don't even try to figure out the solution from only the clues you have right now. Instead, focus on finding a way to acquire another clue, and then using that to get another, and so on. Eventually you've collected so many clues that the answer is obvious.

Sometimes the Sudoku approach is necessary, because you've got all the clues you're ever going to get. But I think my new motto is "Never Sudoku a problem when you can Minesweeper it."

David R. MacIverDRMacIver
2025-05-13

@Patricia This is good knowledge because that book has been sitting on my shelves staring at me waiting for me to read it for a while.

David R. MacIverDRMacIver
2025-05-10

@norootcause Yours, or quoting someone?

David R. MacIver boosted:
Lorin Hochstein :verified:norootcause@hachyderm.io
2025-05-10

Liked this line: an ounce of practice beats a pound of theory, but a pound of practice needs an ounce of theory

David R. MacIverDRMacIver
2025-04-24

@fanf @chrisamaphone Honestly I don't remember why I hated it quite as much as I did. I found it smug and condescending and generally full of facile advice. There must have been more to it than that, but I've forgotten all the details.

David R. MacIverDRMacIver
2025-04-24

@chrisamaphone Thinking further back I also read all of Atlas Shrugged (I skipped the speech though), because I was bored and there wasn't much internet back then.

David R. MacIverDRMacIver
2025-04-24

@chrisamaphone Oh I also hate read all of "Finite and Infinite Games" because I wanted to find out if it got better after the number of people I'd heard praise it.

It didn't.

David R. MacIverDRMacIver
2025-04-24

@chrisamaphone it was partly because I thought it would be funny, partly because I didn't want to pass it on in case someone else read it

David R. MacIverDRMacIver
2025-04-24

@chrisamaphone I read the Tao of Pooh and then burned my copy

David R. MacIverDRMacIver
2025-04-13
David R. MacIverDRMacIver
2025-04-13
David R. MacIverDRMacIver
2025-04-07

@cfbolz Custom dunder methods is sortof how it works in Scala. There's a special `unapply` method that returns an Option of a tuple, and `match(x) { case Foo(a, b, c) }` matches when Foo.unapply(x) gives you a three-tuple matching a, b, c.

(I think. Some details might be wrong, and syntax probably is. I haven't written Scala in > a decade)

David R. MacIverDRMacIver
2025-04-07

@ltratt @cfbolz I find it mildly useful even in fairly basic cases, but I think the only case where it really shines is when you want to nest patterns.

But e.g. here's some code I wrote recently that uses it and I'm not going to claim you couldn't express this without pattern matching (you could, easily) but I do think the pattern matching version is a bit cleaner.

David R. MacIverDRMacIver
2025-04-07

@Edent I really hate how hard it is to find out who is linking to my stuff these days.

David R. MacIverDRMacIver
2025-04-07

Wrote this up in slightly more detail: notebook.drmaciver.com/posts/2

David R. MacIverDRMacIver
2025-04-07

@tintvrtkovic yeah for sure. Misleading notation on my part given that sorry!

David R. MacIverDRMacIver
2025-04-07

@tintvrtkovic No, it works with arbitrary matchers. e.g. `object(some_field=1)` matches if the field is present and its value is 1.

I think my notation is confusing you. `some_matcher` is just meant as a standin for an arbitrary match expression, and you're interpreting it as a variable literally named `some_matcher`

David R. MacIverDRMacIver
2025-04-07

@tintvrtkovic Yup. It works like any other Python pattern match. Crucially though, it won't match if the object being matched doesn't have some_field.

David R. MacIverDRMacIver
2025-04-07

Hey did you know that Python has arbitrary structural pattern matching?

```
match x:
case object(some_field=some_matcher):
...
```

This will match a value iff it is an instance of object and has the field some_field, whose value matches some_matcher.

David R. MacIverDRMacIver
2025-04-01

@jcoglan I think password resets have always meant that your email is de facto a credential, so this isn't actually much worse for security reasons, but I still hate it. Adds a tonne of friction for no good reason.

Client Info

Server: https://mastodon.social
Version: 2025.04
Repository: https://github.com/cyevgeniy/lmst