2,676 karma · joined Nov 28, 2019 (7y ago) · 1,131 submissions
comment 1y ago · link · parent
Finding the "right" representation for a given set of data is an interesting problem, but most (all) of the time the representation is specified by someone/something else.
In the past I've written a [preprocessor][1] that adds some power to the representation while avoiding general purpose computation. For example,
(buckets
(let ([(regional region (name policy) ...)
((['name name] ['region region] ['lifecycle_policy policy]) ...)])
(regional us-west
(alpha-hourly (delete_after_seconds 345600))
(alpha-daily (delete_after_seconds 2592000))
(alpha-monthly (delete_after_seconds 31536000))
(bravo-hourly (delete_after_seconds 345600))
(bravo-daily (delete_after_seconds 259200))
(bravo-monthly (delete_after_seconds 31536000)))))
Macros, basically. Arithmetic would help there, but that might be too much.comment 1y ago · link · parent
[1]: https://en.cppreference.com/w/cpp/utility/from_chars.html
[2]: https://github.com/gcc-mirror/gcc/blob/461fa63908b5bb1a44f12...
comment 1y ago · link · parent
So three references give three different answers.
You could always use sscanf instead, which tells you how many values were scanned (e.g. zero or one).
[1]: https://en.cppreference.com/w/c/string/byte/atoi.html
[2]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/a...
[3]: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2310.pdf
comment 1y ago · link · parent
For one thing, the example isn't the most compelling, because you can:
const greeting = 'hello'.toUpperCase() + '!!!';
or const greeting = 'HELLO!!!';
That said, there is already: function thrush(initial, ...funcs) {
return funcs.reduce(
(current, func) => func(current),
initial);
}
const greeting = thrush('hello', s => s.toUpperCase(), s => s + '!!!');comment 1y ago · link · parent
But the fingerprint scanner works. The fingerprint scanner works!
Everything else has been fine.
comment 1y ago · link · parent
Text in, text out. The question is how much a sequence of tokens captures what we think a mind is. "It" ceases to exist when we stop giving it a prompt, if "it" even exists. Whether you consider something "AI" says more about what you think a mind is than anything about the software.
comment 1y ago · link · parent
On the other hand, making text unselectable in an app is more annoying. In a browser I can bore through the div soup to find the text element, but in an app it's just a big "fuck you."
Halfway in between is an electron app like Spotify which, as far as I can see, disables text selection.
comment 1y ago · link · parent
Your examples are all programs that predate mobile, even though they are available on mobile (are they local-first on mobile too?).
comment 1y ago · link · parent
Realistically the reason is probably that it's easier to make changes if you assume everything is phoning home to the mother ship for everything.
Also, an unrelated nit: "Why Local-First Apps Haven’t Become Popular?" is not a question. "Why Local-First Apps Haven’t Become Popular" is a noun phrase, and "Why Haven't Local-First Apps Become Popular?" is a question. You wouldn't say "How to ask question?" but instead "How do you ask a question?"
comment 1y ago · link · parent
comment 1y ago · link · parent
I complained, but it wasn't that bad. Mostly I was pointing out that the "premium" line is in disrepair. This is why they're replacing them.
I've ridden plain old Amtrak many times before, and it can be hit or miss but is invariably better than a bus or a plane, in my opinion. Big seats, plenty of room to walk around, a dedicated lounge car, big windows, no TSA.
If the train shows up, that is.
comment 1y ago · link · parent
Some contracts are more difficult to express, though. The worst kind involve sequences of behavior, e.g. "start() must have been called," or "must have been obtained from a previous call to 'allocate()' on the same object."
Even value parameter constraints can be tricky. "The input must be sorted."
I haven't studied type systems, but I like the idea of values picking up attributes as they pass through functions. Imagine a "sort" function that bestows its output with the "sorted" type attribute. But then what happens when you append to that value? Is it still sorted?
At some point it's convenient to be permissive with the parameter's static type and to constrain the caller with a contract.
comment 1y ago · link · parent
The interior of the cars was old and beat up. The tray in front of me didn't work. The bathroom door was borked and there was this persistent hint of a foul smell.
The woman across the isle was bombed and clearly going through something, but before long she fell asleep and when she woke up was docile as a lamb.
I've read that the main advantage of inter-metropolis rail travel is that you enter and exit in the middle of town. This helped for NYC and DC -- I took a short subway ride to Penn Station on the NYC side, and then walked from Union Station to my friend's house on the DC side.
Rail is the most comfortable way to travel by far. If only it were cheaper and faster.
comment 1y ago · link · parent
comment 1y ago · link · parent
It's not about performance, it's about separating concerns: the caller handles the not-a-number case, so the callee doesn't have to.
Then you add optional runtime checking of the contract, preferably in a different build mode (or a different version, e.g. "my-lib1.2-debug"), to get sensible diagnostics quickly in tests and canary deployments. The checks are redundant by definition. Defensive programming.