Better HN
topnewbestaskshowjobs
Log inSign up

MathMonkeyMan

2,676 karma · joined Nov 28, 2019 (7y ago) · 1,131 submissions

Submissions

comment 1y ago · link · parent

> The specific problems in the example could be solved by changing how the data is represented.

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.

[1]: https://github.com/dgoffredo/llama

comment 1y ago · link · parent

This is why I stopped watching American presidential "debates." If I wanted that kind of entertainment, I'd listen to a rap battle.

comment 1y ago · link · parent

If your use case can have C++, then [std::from_chars][1] is ideal. Here's gcc's [implementation][2]; a lot of it seems to be handling different bases.

[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

Unspecified, really? cppreference's [C documentation][1] says that it returns zero. The [OpenGroup][2] documentation doesn't specify a return value when the conversion can't be performed. This recent [draft][3] of the ISO standard for C says that if the value cannot be represented (does that mean over/underflow, bad parse, both, neither?), then it's undefined behavior.

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

Neat, but I think that functions already do what we need.

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

I just upgraded my recently bought X1 Carbon Gen 12 from Ubuntu 22.04 LTS to Ubuntu 24.04 LTS. And now the sound stutters occasionally :( My guess is it's something with Pipewire replacing PulseAudio, where some apps now use a PulseAudio shim on top of Pipewire. Or maybe drivers I dunno.

But the fingerprint scanner works. The fingerprint scanner works!

Everything else has been fine.

comment 1y ago · link · parent

How many times can you say "genocide" in an article about Amazon?

comment 1y ago · link · parent

It doesn't understand anything. Yet if you prompt it with a question about what it understands, its output is consistent with something that understands.

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

Lacto fermentations like 2-3% salt by total mass. So if you ate nothing but pickles and drank water, you might have around a 2% salt diet.

Then again I wonder about pizza, hotdogs, and potato chips. They're crazy salty, but don't underestimate how salty 3% really is.

comment 1y ago · link · parent

The trick is defining "their own people."

comment 1y ago · link · parent

The trick is not to show anybody the prototype, especially your manager.

comment 1y ago · link · parent

The two days before you received the package was two days. QED.

comment 1y ago · link · parent

Hey, things have improved. Once in a while still I find a website that intercepts right click with an alert box: "This website's content is COPYRIGHTED!"

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

Maybe the distinction is in that word "app." We started calling programs "apps" when smart phones came out. Smart phones are remote-first, and it makes sense (or it did) as long as you think of a phone as your terminal into... something.

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

The free software evangelist in me says "because local-first gives more to the user of the software," which will tend not to happen when the user is not in control of the software.

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

Socially awkward dog prefers not to dog.

comment 1y ago · link · parent

The only context in which I heard it mentioned is the idea of trying to date the earth by its temperature. Assume it was a hot molten mess in the past and has been cooling down ever since. Factor in the rate at which it would radiate heat and all of the energy coming from the sun and... you conclude that the planet is very young. Because you didn't account for radioactive material within the planet, keeping it warm.

comment 1y ago · link · parent

That gives you an idea of how much I enjoy buses and airports.

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

All other things being equal, yes. Static types work well for constraints on function parameters. "Parse, don't validate" and all that.

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

I took the Acela from NYC to DC to visit a friend. It was expensive, but I wanted to try it.

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

He stole the gun, so it was robbery. I feel like an armed robbery is one where you bring a weapon, which makes the robbery more dangerous. This guy was looking for cash and found a gun, so "armed robbery." The comment above claiming that the charge is justified does make sense, but I disagree with it. I'm also not a lawyer.

comment 1y ago · link · parent

I know of a guy who got nailed with "armed robbery" because he stole a gun from the glove compartment of an unoccupied car that he had broken into. All a prosecutor wants to do is screw somebody as hard as possible and win the case.

comment 1y ago · link · parent

"J. Robot Choppenheimer" is what earned my upvote.

If this knife works as well as the pitchman says, that's amazing. Just don't touch the edge.

I've gotten into the habit of using one of those slatted knife sharpeners before every use of my knife. It works well enough.

comment 1y ago · link · parent

This is what undefined behavior is for. You specify a contract for your function, and then the implementation of the function assumes that the contract is satisfied. It does not check, and does not try to diagnose errors.

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.

comment 1y ago · link · parent

The mole got me.

comment 1y ago · link · parent

GotchaScript

comment 1y ago · link · parent

ee-see-ehm-ay-skript? It's ECK-mah-script.

comment 1y ago · link · parent

Ants are descended from a wasp-like ancestor.

comment 1y ago · link · parent

That was xslt, which is part of the xml toolset but not specific to libxml2.
1
678
38