Better HN
topnewbestaskshowjobs
Log inSign up

codeflo

9,664 karma · joined Jun 14, 2010 (16y ago) · 1,504 submissions

Submissions

comment 4y ago · link · parent

> In contrast, evolutionary theory puts humans (or hominins) last, just as does the biblical story of Genesis. Yet in all instances, the position confers on Homo sapiens a unique status, thereby separating us from the rest of the animal kingdom.

Ha ha ha, no. That’s a wild misunderstanding of evolutionary theory, that humans are somehow “more evolved” than other current species. Modern apes are our siblings, not our ancestors. And nothing fundamental “separates” us from other animals: we’re yet another species, granted with some unique features that we ourselves consider very important.

comment 4y ago · link · parent

The author even implies in a footnote that switch statements are unusable. I mean, we probably all had painful experience with the “gotcha”, and I appreciate efforts towards safer designs. But I mean, let’s not be ridiculous. It works fine.

comment 4y ago · link · parent

Some language features aren’t aimed at toy examples, and if that’s the scope of your thinking, you won’t see the point.

For example, I like how the catch block is just a single function call to handleErrorSomehow — which would be totally fine for an example, if it weren’t for the fact that the author makes a special note of how convenient it is that the Promise variant reduces to just .catch(handleErrorSomehow). Suuuper-realistic.

I should probably admit that I also didn’t completely see the point of async/await — this was years ago in C# — until I first had a chance to use it inside a complex loop of some kind. I think it’s a good exercise to try manually desugaring such an example. It really makes you appreciate what the compiler’s doing for you in these cases.

comment 4y ago · link · parent

It's unfortunately a very human tendency to shift baselines, to judge each individual step only relative to the last one, without considering the situation in the absolute.

This applies in much lower stakes environments as well: the workplace, relationships. It's surprising how reliably someone's attitude can flip from "if ever X, I'll quit" to "X isn't that much worse than X-1, this isn't worth making a fuss about" if the change happens slowly enough.

comment 4y ago · link · parent

Also, users are sometimes simply ordered, by their bosses or IT, not to press buttons in ways that are known to break the software. This is sometimes considered cheaper than fixing bugs, or at the very least, mitigates the problem until the next scheduled deployment window. It’s a very different world.

comment 4y ago · link · parent

Yeah, I hadn't thought this fully through when posting, and was almost right more by accident than anything. To further show your point, if you actually take the (real) limit, you get lim t->0 (x^t-1)/t = ln(x) using L'Hopital's rule, so ln(x) = (x^ε-1)/ε makes some sense in that regard.

comment 4y ago · link · parent

I think this article does a good job of highlighting the difference between simulations and ML-based approaches. The latter are faster, but have limitations outside of their training parameters. As with everything in ML, broader training data to cover those cases probably helps. Though I would guess some of the problems could be inherent, that there fundamentally is no computational shortcut to this problem, whether you use a neural network or not.

comment 4y ago · link · parent

If you want to make a statement like that, then logarithms might not be the zeroth power, but the epsilonth power, where ε is an “infinitesimal”.

Bear with me here, I know infinitesimal math isn’t a fully coherent thing. But there’s a reason why Newton used it, it sometimes works surprisingly well to make intuitive analogies. Maybe there’s a way to make it work here.

For example: The function ln(x) grows strictly slower than x^a for any positive real a, but faster than x^0. Hence, it’s x^ε, where 0 < ε < a for any positive real a.

comment 4y ago · link · parent

You do realize that most charities sell some things, right?

comment 4y ago · link · parent

That’s right, the keyword enables additional operations, namely those that can’t be checked — which one might even call “unchecked operations” to justify the keyword.

My problem with the word “unsafe” is that many people seem to think unsafe code blocks necessarily have security issues. Hence the bullying of library authors even in cases where the authors did their homework.

Anything about the mechanics of the implementation is a second-order detail compared to that, as far as I’m concerned.

comment 4y ago · link · parent

If it weren't for the source, the cringy Matrix references and sensationalist writing would have made me dismiss this without much thought. The Wikipedia article on Eurodollars and some others make all of this sound a lot more mundane.

So I'm confused. Does anyone know, or have a better source, whether there's actual cause for concern?

comment 4y ago · link · parent

I don't think comparing a service like S4 to a non-existing disk is fair. Especially in enterprise software, I often get the requirement that the data is reliably written. I can easily point an auditor to the S4 service contract and SLAs to prove we fulfill this. A bespoke arrangement of floppy drives and shredders might pass if the auditor's having a good day. But removing the disks entirely? That will never fly.

comment 4y ago · link · parent

“List of things named after members of the Bernoulli family”: https://en.m.wikipedia.org/wiki/List_of_things_named_after_m...

comment 4y ago · link · parent

I guess the name stuck because naming even more things after the Bernoullis would just be too confusing.

comment 4y ago · link · parent

Oh for the love of God, don’t introduce confusingly named variants of widely known licenses. If a new license is really needed — fine, if lawyers think that’s necessary, it probably is — but don’t name it that. No one will bother to check whether MIT and MIT-7BZ3/2 are slightly incompatible.

comment 4y ago · link · parent

It’s funny that no amount of (Rust-like) compile time or (Java-like) runtime checks would have prevented this — every line of code is working as intended. The parallels to the recent Log4J vulnerability are evident.

If you happen to think, as I do, that we need safe(r) languages to have any hope of creating secure systems, then problems like these are a striking reminder that memory safety alone isn’t sufficient to achieve security.

comment 4y ago · link · parent

The article, and the comments praising this approach, don’t do a great job of explaining how any of this is substantively different from running the likes of yarn install --frozen-lockfile, or cargo build --frozen.

Here’s the thing: You can argue about being secure by default and encouraging better CI practices. I’d fully agree it isn’t great that one has to know a somewhat obscure flag to get a secure CI build in those environments.

But claiming in what I perceive to be in parts a somewhat grandiose tone to have reinvented the wheel, when you’re just describing a standard approach, can make you sound uninformed.

comment 4y ago · link · parent

These random/urandom blocking/nonblocking discussions have been going on for at least a decade at this point, maybe even longer. I get that RNG algorithms are hard. What’s surprising to me is that it seems so hard to even figure out the desired interface of such a basic thing in the kernel. Security in entropy-starved environments seems to be very hard to square with backwards compatibility.

comment 4y ago · link · parent

Let’s say I give you a box with two lights to show its state, one green and one red. Currently, the red light is on. The red light will also be on tomorrow. In fact, people who have observed this box for years have only ever seen it show red.

You might argue that this box is simply hard-wired to show red, but then I explain: No, your impression is wrong. I’ve built this box, and I’ve taken every possible measure to make it show green.

How credible am I?

And would you be more inclined to believe me more if I told you about my intrinsic love for the color green, and how I wired up the green light first, and how I have an entire committee of experts that has to sign off every design change to this box to ensure sufficient greenness? While it still shows, and only ever will, show the red light?

comment 4y ago · link · parent

As you hint at in your last paragraph, it’s probably hard to come up with a blog-sized example for any programming technique. If 10-15 lines were really the extent our scope, we probably wouldn’t need anything more advanced than assembler. Some amount of imagination is necessary to consider whether an idea is useful in production code, so we all have different examples in mind.

Personally, I’ve had cases where three or four places had to be kept in sync, and the list was changing frequently enough that something like this became useful.

Even then, it’s still a judgement call whether code generation or (if available) macros are worth the complexity. The decision might also heavily depend on the experience of the team.

comment 4y ago · link · parent

It’s not that simple. Also, the article isn’t about binaries at all, but about code generation at build time.

comment 4y ago · link · parent

Thanks for the link, that seems very useful. I recently had to work around this by transforming a list (a, b, c, d) into something like 1+1+1+1+0 to get a count. What this RFC proposes looks so much less painful.

comment 4y ago · link · parent

Generating code is a powerful tool that I think everyone should have in their toolbox — use it wisely of course, but don’t avoid it on principle.

This describes an interesting approach that I hadn’t seen. I personally wouldn’t have considered putting the result in the same file because I usually like to gitignore any and all generated code, mostly to reduce phantom merge conflicts. However, some colleagues have the opinion that those conflicts are trivially resolved by rebuilding and thus don’t matter, and having diffs of the generated code show up in pull requests adds value.

What do others think, check in generated code or put it in gitignore?

comment 4y ago · link · parent

What’s the main use case? I guess build scripts?

comment 4y ago · link · parent

My story is less interesting, but I also remember quitting Facebook when it started to taunt me with photos of a past relationship that I wasn’t completely over yet at the time.

Stuff like that has to be common. Did the “growth hacking” cynics who design these features not realize the harm they cause, or is the generated “engagement” still worth it in aggregate despite a few lost users?

comment 4y ago · link · parent

I can totally believe that. What you’re describing has an uncanny resemblance to academic software engineering research: many of the published insights scale up all the way to one semester student projects — in other words, are completely useless in the real world.

comment 4y ago · link · parent

Such a one-off Haskell interpreter might even get away without or with less rigorous type checking.

comment 4y ago · link · parent

Oh, that’s a good example. I’ll argue that you should try to use primitives (strings/numbers) as keys in those cases. But if you can’t, then you’re right that identity is critically important.

comment 4y ago · link · parent

Two thoughts.

One, you don’t rely on a semantic guarantee if you use useMemo for derived state. Avoiding rerendering counts as an optimization as far as the React docs are concerned (your program works if there’s an extra render), and this is in fact exactly what it was intended for. The docs you linked seem to agree: Regardless of whether an offscreen component keeps or doesn’t keep its useMemo, the code is correct and there’s at most one extra render.

Second, while I agree with the verbosity complaint, I personally make a point to use useMemo as coarsely as possible. It’s often completely fine to compute all derived state in a single big lambda that returns one big (immediately destructured) object. It’s only when you have multiple pieces of derived state that update individually and are also all expensive to compute that you actually need fine-grained useMemo calls. And in this case, you can always think about extracting sone of that logic into a helper function/hook.

It’s not perfect, but I think it’s possible to avoid a lot of the pain most of the time.

1
272829
51