9,664 karma · joined Jun 14, 2010 (16y ago) · 1,504 submissions
comment 4y ago · link · parent
I also agree that panic and crash is usually the correct response to a logic error.
However, I think library functions like Regex::new shouldn’t decide for me what I do or don’t consider a logic error — how should the library know where that string comes from? They also shouldn’t be effectively required to offer two overloads for every function just to enable both decisions: there’s already a very clean way to put that decisions into the hands of the library user, Result.unwrap() vs. Result?.
Now, about unwrap vs. expect: Since the author and I agree that panics should be reserved for logic errors, the expect() argument is effectively only a debugging aid. Should that be required? I’m torn. Often, which one I personally use reflects my confidence in getting the invariant correct and never hitting the panic in production. That can be risky. A particular team in a particular context might therefore adopt a convention to always use expect instead of unwrap, that’s fine. But I don’t think it’s unreasonable that the language offers a choice here, and in similar places, like the no-parameter variant of panic!().
comment 4y ago · link · parent
For example, why was the triangle area formula only memorized and not demonstrated to them? I thought this should be standard everywhere in the world? Maybe they just don’t remember, it happens early (age 11-12 for me IIRC).
Similarly, and this is from two decades ago at this point, some basics of gene expression and cell differentiation were covered in my later biology classes, including some of the evolutionary steps. Details are of course fuzzy now. But I clearly remember that learning we share so many genes and so much cell chemistry with even basic bacteria threw me into a bit of an existential crisis when I was 17 — making me question what if anything is so special about humans.
When they were students, some people were simply unwilling to follow any train of thought that was unlikely to be test-relevant. The author almost admits as much: “Someone probably told me that every cell in my body has the same DNA. But no one shook me by the shoulders, saying how crazy that was.” That’s a perfectly fine way to approach school, I’m not judging. But then maybe don’t complain that you didn’t learn anything?
comment 4y ago · link · parent
comment 4y ago · link · parent
Because I have a hard time recognizing the noses as anything but face wounds in some of the shots, and I wonder why the colors were chosen this way. Characters don't stand out from the background very much, which again, is an intentional choice of colors. And the animations seem to happen mostly via rotations and stretches in the 2D plane, which makes everything look flat. (I think that's also what gives the "flash game" vibes that another commenter described.)
Is this supposed to look like it's made out of paper cutouts (in the style of other games with a "hand-crafted" look, like Paper Mario or Kirby's Wooly World)? That's my best guess, but I'm grasping at straws.
comment 4y ago · link · parent
I hope Clang on x86_64 is common enough for you to make my point. In this example, Clang reasons (backwards in time) that the if couldn't have been taken and dereferences whatever was in p, instead of dereferencing null: https://gcc.godbolt.org/z/zjhY1W67Y
comment 4y ago · link · parent
I've found a simple example. Code order and compiler options are very finicky with this sort of thing, but as of posting this, clang optimizes away the null dereference here entirely: https://gcc.godbolt.org/z/zjhY1W67Y
(Edit: Simplified example even a bit more.)
comment 4y ago · link · parent
For anyone who’s wondering, I’m referencing “UB” here (which is short for Undefined Behavior, but don’t be confused by the English language meaning, it’s a precise technical term in the spec). Skipping the details, there’s a surprising (and growing) amount of situations where a null pointer access leads to silent incorrect code execution instead of a crash already, with standard compilers and CPUs. C++ programmers need to deal with that on any platform. As I’m sure the author is aware, what the WASM compilers do here is well within the spec.
comment 4y ago · link · parent
Since power demand isn’t entirely predictable, flexibility is rewarded in these markets. For example, if there’s a downward spike in demand that causes an imbalance, you can earn extra money by either having a power plant that can ramp down very quickly, or by being a consumer that can ramp up very quickly.
I wouldn’t be surprised if mining rigs participated in these spot markets. In theory, they should be able to adjust their power consumption within seconds.
BTW, it’s been theorized that overnight charging of electric cars could do the same thing and dynamically adjust the charging speed based on spot prices.
comment 4y ago · link · parent
It supposedly solves the N*M problem (so it’s an interface?), but it can’t be statically typed (so the interface has to be implicit?), and success stories are HTML5 and the x86 ABI (so it does require explicit specification after all, and huge amounts of it? Just look at the size of that Intel ABI book…), but also, it must be plaintext (so not like x86 at all?).
I’m not trying to be mean because maybe there’s something there that I miss, but frankly, I don’t get it, at least not yet.
comment 4y ago · link · parent
(BTW, this is exactly the kind of argument people made in defense of left-pad, which in my view completely validates my analogy.)
comment 4y ago · link · parent
Very few programs ran on non-x86 back then anyway. Some people used to argue that writing assembly is more portable than using OS functions. I’m not saying I fully agree with that view, but it’s a discussion one can reasonably have.
comment 4y ago · link · parent
Let’s say you really only cared about the sign of the result — freeing a resource when a refcount reaches 0 is a plausible use-case for that. But instead of using a single CPU instruction, you decide to link in a Windows function, because it’s easy, and why not pay for the overhead of a dynamically linked function call when CPUs are so fast?
And the joke is, when users upgraded to Windows 98, your program became a lot slower, because without asking you, the API was augmented to emulate a CPU feature you don’t need.
If this isn’t essentially 1995’s left-pad, I don’t know what would qualify.
comment 4y ago · link · parent
comment 4y ago · link · parent
Here’s what you might be missing: Even on a single processor machine, if you have multiple threads and a preemptive (!) multitasking OS like Windows 95, any locking protocol can be interrupted mid-sequence. A second OS thread (yes, they existed) may be scheduled and observe an inconsistent state. Or it may perform an update on its own and leave the first state in an inconsistent state when it resumes.
And yes, this kind of stuff actually happened.
comment 4y ago · link · parent
comment 4y ago · link · parent
I’m also not against selling software on principle. Downgrading a free piece of software into a demo with an auto-update feels shady, however.
[0] https://marketplace.visualstudio.com/items?itemName=eamodio....
comment 4y ago · link · parent
People may not fully realize this, but the problem with the “just standardize TypeScript” suggestions is that TypeScript is a fast moving target. This is actually well argued in the proposal: lots of meaningful innovation is still happening in that space with more precise checks, which also means that small incompatibilities happen from version to version. That’s okay if we’re talking about dev tooling that a team can choose to upgrade at their own pace. It would be really bad to have browser upgrades affect the functionality of existing websites.
comment 4y ago · link · parent
For resources like memory, where it’s merely a question of performance, I would agree. But some resources have correctness implications. Files, for example, you often want to close deterministically. It’s simply a terrible experience if a user can’t save because a file handle from a previous operation still lingers in a GC queue somewhere.
That’s also the reason why language features like try-with-resources were added in the first place.
comment 4y ago · link · parent
Here's one important difference: Destructors work in standard data structures. If for whatever reason you want to build a map<string, list<fstream>>, and the map goes out of scope, all files are correctly closed. (Rust's drop semantics work the same way.) That's a lot more work in Java or C#.
comment 4y ago · link · parent
comment 4y ago · link · parent
2. The violence on the vulnerable is inflicted by the sanctioned regime, not the sanctioners. As another commenter noted, these regimes effectively hold their population hostage. They could feed their population, they just prefer to pour everything into the military.
3. In your example, are the residents following the orders of those burglars?