Better HN
topnewbestaskshowjobs
Log inSign up

codeflo

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

Submissions

comment 6y ago · link · parent

There are not all that many ways this could happen, though. I think you can only enter the square of the opposing king with a pawn. With all other pieces, you’d have to threaten the square first, which would be check. You could promote a pawn into the king and create a queen on its square.

The other way would be if the king itself moves. If the king moves onto a square with an opposing rook and a queen, and decides to capture the rook, the king is trapped until the queen moves. In this scenario, the queen must have moved there in the last turn, putting the king in check. Maybe that’s a new way to get a stalemate.

comment 6y ago · link · parent

You limit the generality of the function by passing it more than it needs. If your function doesn’t care about the shared_ptr itself, then you should only be passing a const ref to the value (which you get by dereferencing the shared_ptr at the call site). That way, your function works with values in shared_ptrs, unique_ptrs, values on the stack, manually managed pointers etc., without you doing any extra work.

comment 6y ago · link · parent

I wouldn’t call it dangerous, just meaningless. A lot of the discussion in this thread dives deeply into the technicalities of Unicode. All of that is correct, but a bit besides the point IMO.

I think the real issue is that “reversing text” is fundamentally an operation that only makes sense in Western alphabets — the complexities of Unicode just reflect that. This is a bit hard to fathom for people who grew up with such an alphabet (this includes me), where there’s a rich tradition of games based on shuffling letters. It’s not just reversing; my understanding is that you can’t meaningfully define the concept of an anagram in many writing systems.

comment 6y ago · link · parent

No experience is universal, so I'm curious in what industry you encounter Win32. Or do you mean WinForms? I often work with industrial manufacturing companies in Europe, with a mindset about as far from that of Silicon Valley startups as you can imagine. You usually won't find Electron there. Many "legacy" projects are in WinForms. But for newer stuff, I see lots of WPF and Qt projects, both of which don't use native controls.

comment 6y ago · link · parent

You probably mean Win16/Win32, not WinForms. But it only survives in the sense that it’s still there, not in the sense that it’s still useful. How many applications created in the last five years use Win32 for anything but creating a top-level window (usually via Chromium/Electron)?

comment 6y ago · link · parent

I agree with you. However, making a great single-page app takes a lot of experience and work, a bit less so with current frameworks, but still. A lot of in-house SPAs are truly terrible, with bad performance and broken navigation, you wish the developers wouldn’t have bothered. Multi-page apps might be a bit harder to screw up as badly.

So maybe the user experience hierarchy goes something like: great SPA > MPA > average SPA?

This would mean there’s still a place for MPAs, at least with certain budget constraints.

comment 6y ago · link · parent

I’ve had this discussion as well, and I fully agree. In my experience, this kind of thing exists purely to sneak in the more programmer friendly JSON in corporate environments that have otherwise “standardized on XML”. You wouldn’t get away with pure JSON, but you can argue for a hybrid approach.

comment 6y ago · link · parent

I’m interested in this as well. As opposed to CPUs from 15 years ago, the 3990X has 256 MB L3 cache and around 100 GB/s of memory bandwidth, which should help a bit. What kinds of workloads can we expect to be bandwidth-botllenecked still?

comment 6y ago · link · parent

The prefix/postfix change is a red herring, that doesn't do anything (since the expression result isn't used). Which means that the security fix is interspersed with code style changes. Maybe there's a reason to do this here, but it's often not considered good practice because it makes it harder to review the code.

AFAICT, the only real changes are in (new) line 411, resetting the cp variable after the loop, and line 416, ignoring write errors. The former is probably the relevant one.

comment 6y ago · link · parent

It’s often considered bad practice to pass around raw values for that very reason. Introduce a (minimal) abstraction, that is, give the thing you’re passing through those layers a name. Then you can change the endpoints at will and still get static checking (as a plus, you can‘t accidentally pass the wrong bool, or mix up the tuple order).

I agree with the GP‘s point that static typing forces you to do that kind of design work earlier.

(Edit: You raise a good point, though. I think a lot of people run into this kind of problem with static typing.)

comment 6y ago · link · parent

Sure, but the point of a standard is usually to make implementations interchangeable.

comment 6y ago · link · parent

I’m not convinced CL is more useful for real world usage. People sometimes fall into the trap of thinking that more features are always better. With programming languages, that’s rarely true, because even features you don’t use cost you something — in terms of training new programmers, and every time your dealing with other people’s code. (And note here that in real-world projects, most of the code you have to modify and debug isn’t yours!)

Of course it’s possible to go too far the other way, and R5RS leaves too many questions unanswered. But in my opinion, simplicity is also an important feature, not just academically, but in practice.

comment 6y ago · link · parent

I’m a bit torn on this. I have most of my experience in the .NET ecosystem, where dependencies are a lot more manageable. However, if something breaks, you’re screwed a lot harder, because it’s not so easy to replace a large library, and there are very likely fewer well-maintained alternatives than there would be on NPM.

In total, I find it hard to deny how productive the NPM ecosystem can be, despite my philosophical objections to the way the community is run. Am I crazy here?

comment 6y ago · link · parent

If they are our direct ancestors, then we are surrounded by artifacts built by their descendants, are we not? That's like being confused that no one builds antique vases anymore.

comment 6y ago · link · parent

Do "vanish" and "appear" have another meaning that I'm not aware of? To me, they imply two discontinuities. But if they are our direct ancestors, they simply gradually became us. Or rather, we still are them.

comment 6y ago · link · parent

"Homo erectus, one of modern humans’ direct ancestors, was a wandering bunch. [...] But about 400,000 years ago, Homo erectus essentially vanished."

So are they our direct ancestors, or have they vanished? Both can't be true.

comment 6y ago · link · parent

The way most people explain this is completely backwards. Monads don't actually solve the I/O problem. So forget about monads and just consider how to mathematically model I/O.

Take something like getStrLn (which reads a line from STDIN). What is "getStrLn", as a mathematical object? It's not a string, rather, it's some kind of "I/O operation" that when executed, returns a string. Haskell calls such an object an "IO String". Similarly, the expression (putStrLn "foo") is an I/O operation that when executed, doesn't return anything. Haskell calls this an "IO ()".

Once you develop an intuition of I/O operations, you can see how you might want to combine atomic I/O operations into larger and larger I/O operation, feeding the output from one as input into the other. Or how you could treat a plain Int as an "empty" I/O operation that when executed, simply returns the Int. And how your entire program, its "main" entry point, can be modeled simply as one large I/O operation.

You can do all of that, and write every possible kind of I/O code in Haskell, without ever learning about monads.

What are monads for, then? They generalize the structure of this approach, with its (>>=) and return operators, and apply it to other cases that don't have anything to do with I/O. But this step is completely optional! This is very similar to how the idea of a mathematical "field" generalizes the arithmetic operators (+, -, *, /) and applies them to objects that don't look anything like the rational numbers. You don't have to learn about fields to successfully use rational numbers. And we would never dream of explaining the abstract idea of fields to people before we introduce them to rational numbers. Yet almost every I/O tutorial in Haskell begins with a half-baked explanation of monads.

comment 7y ago · link · parent

Very interesting link, thanks. Obviously your use case goes way beyond running a standard Docker installation. It sounds like you really want the kernel to schedule containers instead of processes -- which it doesn't really do by default, hence my comment. Perhaps it shouldn't be surprising, that you're able to get these clear performance gains from a highly optimized special-purpose scheduler. Still, I was a bit surprised. :)

However, that's at the OS level. What can realistically be done at the hardware level? It must be possible in theory to design a CPU that's better at this kind of context switching, but I don't know if a new "computer company" really wants to go there.

comment 7y ago · link · parent

That seems to be the common theory, but what does that even mean? There's nothing all that special about running containers at the hardware level, they are really just groups of processes that the kernel manages a certain way.

comment 7y ago · link · parent

IIRC correctly, unlike HDDs, (audio) CD players change their rotation speed to match the data density, because they need the data at a constant bit rate. So it wouldn’t matter whether the data starts inside or outside. I think your argument about physical robustness is very plausible.

Additionally, starting from the inside allowed for physically smaller disc formats without any special software support: https://en.m.wikipedia.org/wiki/Mini_CD

I don’t know for sure if that possibility was part of the original design. But it must have been introduced somewhat early, given that every CD player tray I’ve ever seen has that extra ridge to hold the smaller discs in place.

comment 7y ago · link · parent

Given that I have the highest voted reply and several people asked, I've written a rundown here: https://news.ycombinator.com/item?id=21345820

Yes, the response is technically correct. But...

comment 7y ago · link · parent

Given that others also asked, I'll give a rundown of the discussion:

The context of the discussion was cpuguy83's suggestion that compared to AMD, Intel has been "suffering from shortcuts leading to Spectre/Meltdown and the performance regressions due to patching those".

cpuguy83's comment was very concise, so let me elaborate that the distinction between Spectre and Meltdown is essential here. Both are security flaws in CPUs that were published at the same time. Spectre is an industry-wide problem that also hit AMD, but "Meltdown" is the result of an Intel-specific implementation choice that I think one might fairly describe as a "shortcut". (Even IshKebab later agrees: https://news.ycombinator.com/item?id=21342048) Meltdown was also more immediately dangerous, and the software workarounds that were necessary to mitigate it in existing CPUs cost a lot of performance.

Given this context, I'll quote the relevant item from cpuguy83 again and then IshKebab's reply:

> cpuguy83: Intel [... has been ...] suffering from shortcuts leading to Spectre/Meltdown and the performance regressions due to patching those.

> IshKebab: AMD chips suffer from Spectre too (which is the hard to fix issue). They didn't really take any fewer "shortcuts" than Intel. And they weren't "shortcuts".

Note how IshKebab carefully ignores the Meltdown part of cpuguy83's comment to be able to claim that Intel hasn't been doing any worse than AMD, and that there were no shortcuts. For Spectre in the stricter sense, that's technically true. It's not true in the context of the entire Spectre/Meltdown event, which was cpuguy83's argument.

comment 7y ago · link · parent

That’s highly misleading, and the very careful way that you worded your reply tells me that you know this. Why the obfuscation?

comment 7y ago · link · parent

std::move's implementation not quite as elegant, though (this is from the GCC source):

  template<typename _Tp>
    constexpr typename std::remove_reference<_Tp>::type&&
    move(_Tp&& __t) noexcept
    { return static_cast<typename std::remove_reference<_Tp>::type&&>(__t); }

comment 7y ago · link · parent

Interesting, I don’t remember this proof (maybe I learned it, but it’s been a couple of years since university). Do you remember the “stop condition”? At some point the algorithm would have to “give up” and declare the problem unsatisfiable.

comment 7y ago · link · parent

Can you give a reference, or a hint on where to read more? This sounds really interesting, but Google has failed me.

comment 7y ago · link · parent

> I always understood di­ffizil to be the correct translation of the word difficult.

I think that’s misleading or even wrong. Source: native speaker.

First, it’s a very rare word that would definitely stand out, even in an already formal conversation. More importantly, “diffizil” is mostly reserved for problems that require a lot of fine motor skills or finesse. It would be wrong to say that lifting some large boulder is “diffizil”, for example, except as a joke. You might use it for repairing a watch or a complicated negotiation (“eine diffizile Angelegenheit”), however.

comment 7y ago · link · parent

To make a different audio analogy: When they graph the input vs. the optimized control values, it looks a lot like the ringing artifacts of a low-pass filter. A low-pass filter removes high frequencies from an input signal. Since there are physical limits on how fast limbs can oscillate, maybe that’s part of what makes it look more natural.

comment 7y ago · link · parent

Thanks for the summary.

> First check the remainder modulo 10, modulo 9 and modulo 24.

This makes zero sense already. First, 9=3 x 3, so checking for 3 is sufficient. (Checking for 9 might be easier in decimal, but why the hell would you do cryptography in decimal?) Then there’s the 24=2 x 2 x 2 x 3. Again, why not just use 6, but even worse, there’s no new factor here that’s not already covered by 10 and 9.

(And as you mentioned, even if this works, much better primality Tests are readily available.)

(Off-topic: Is there a good way to indicate multiplication on HN? I can’t figure out how to escape asterisks, and Unicode symbols seem to be simply filtered out, which is a bit crazy in 2019.)

1
414243
51