33,194 karma · joined Oct 22, 2016 (10y ago) · 12,383 submissions
comment 5h ago · link · parent
But no, people seem to be deliberately creating Metalhead or something equally terrible.
comment 6h ago · link · parent
The existence of Linux made it obvious that the mid-90s yapping, not just from Microsoft but also some Unix vendors, about how the "server" is special and needs entirely different software is bullshit.
Microsoft's plan at that time was that NT is going to be cheaper to make than the then popular server brands but priced similarly. You've budgeted $5000 for a "server" for your business, there are bunch of options and $4000 worth of PC plus a $1000 NT Server OS license fits the budget. You already know Windows, so that's a plus. But a $50 Red Hat CD with the same PC leaves you with $950.
Russinovich helped silence all the people who'd have insisted that you should spend the extra $950 for a "real" server instead of this free Linux thing.
comment 9h ago · link · parent
The natural representation of VecDeque<T,A> would be a thin pointer and three pointer-sized integers, on a modern PC that's 32 bytes.
And sure enough Rust's VecDeque<T,A> is in fact a 32 byte type. But there are indeed layers of abstraction:
VecDeque<T,A> is a WrappedIndex named head, an integer named len and a RawVec<T,A>
RawVec<T,A> is a RawVecInner<A> and a PhantomData<T> marker
The PhantomData is just the idea of T, and evaporates - it doesn't need any space but if you want to get angry about abstractions an evaporating type which makes the compiler work is exasperating.
RawVecInner<A> is that thin pointer, a Cap and the Allocator A. The Global allocator will also evaporate - although some customer allocators might take space here.
Cap, like WrappedIndex is "just" an integer and all the associated code to use that integer properly everywhere and not make clumsy mistakes.
Now, when you use VecDeque you don't care about any of this. It just works properly, and it's no bigger than it would be if it didn't have all this sophisticated machinery inside it, but if you are bothered just by the idea then that's going to drive you away from Rust (or indeed any modern language).
comment 13h ago · link · parent
https://rust.godbolt.org/z/nxnazs7Y6
c and d are both integers. Do you agree?
When you follow this link they'll have arbitrary values so I can't predict what those values will be but I can tell you that they'll be identical because the optimising compiler put both those unused temporary locals in the same spot on the stack.
One and three are booleans which ask whether the pointers to those temporaries are the same, LLVM says they are not even though Rust's policy is that they are. That's not great, but we could choose to imagine that's a Rust bug, except...
Two is another boolean asking whether the integers c and d are the same. LLVM says that those aren't the same either. It has given provenance to integers, that's the bug.
comment 1d ago · link · parent
Well, what I'm doing here is describing the real situation with LLVM. If by "that's not true" you mean "that would be a bug in LLVM" then, uh, yeah, we know that it's a bug in LLVM. The LLVM maintainers know it's a bug in LLVM, have for many years.
> Integers do not have provenance
No, integers shouldn't have provenance. Due to this compiler bug unfortunately we can give integers provenance and blow up the world. Remembering the difference between what is and what should be is important, most especially in Criminal Justice.
So as to not rag specifically on LLVM, here's a ticket with Martin in the comments where somebody blew up GNU's C compiler on essentially the same trick question:
comment 1d ago · link · parent
My favourite example is ColdString, a value the same size as a thin pointer and which could be pointing at some text on the heap - but for smaller texts it is actually inline UTF-8 encoded text, the author originally wrote this to rely on the scary Exposure rules and I asked them if it couldn't be Strict instead and instead of "If you're so smart why don't you do it then?" they just fixed it. Nice. Huge fan of ColdString.
However, there are extant examples where you can just trick LLVM into asserting that two integers a,b are different and then showing that a - b == 0 which proves it was lying, those are by definition miscompilations and they don't rely on Exposure, they're just getting the LLVM optimiser to apply a pointer provenance optimisation to a thing it was just told is not a pointer.
comment 1d ago · link · parent
Here's the Rust documentation: https://doc.rust-lang.org/std/ptr/index.html#strict-provenan...
So in Rust much of this is spelled out today, although of course the LLVM backend still miscompiles some programs (in Rust or indeed in C or C++) because it can be tricked into giving integers provenance even though that's clearly not what anybody wanted. Oops.
However in C, which most of the examples are written in, the status is a bit less clear. Martin Uecker (who can often be found here in HN's comments) and colleagues wrote a document for ISO but that document is not (yet?) part of the ISO C standard itself. Of course in practice compilers like LLVM, GCC and MSVC need to do what the document says instead of making it up as they go, or else this matters very little.
One thing which cannot be in doubt in any of these close-to-the-metal languages today, almost certainly including obscure ones you've maybe taken a shine to like Odin or Hare, is that provenance is a thing, if you're sure you don't have pointer provenance in your languages but you do have actual pointers, check with a stop watch. If your programs in that language are very slow you might be right.
Because that's why this became a thing. Without provenance, pointers strangle many "obvious" optimisations. Add provenance and now these optimisations are available and your programs go much faster. It's a bargain - albeit one you probably never signed up for as a programmer.
comment 1d ago · link · parent
Today if the railway near me were say, blocked by fallen trees, the alternative route needs:
1. A driver with route knowledge for the alternative 2. A guard with the same route knowledge (this is due to "Ding Ding and Away") 3. A train all of which can run on the nearby non-electrified line.
Missing any of those three? Two bad, your service is blocked here, passengers will need to disembark and use a different method to reach their destination, even though that method might be a train.
Electrification would fix (3). Similarly upgrading to a higher ETCS (ETCS level 0 is basically the absence of ETCS and just indicates that the train has manual controls you could use to drive it without ETCS) would fix 1 and 2, modulo exciting Union negotiations.
In the real world parts of a rail network fail, and a single coherent integrated network is best able to cope with this as you work to fix the issue. For HS1 realistically the vast majority of issues make it useless anyway, you can't go via an alternative route if the tunnel is shut for example. But that won't be true for other new lines.
Edited: Throughout s/ECTS/ETCS/g
comment 2d ago · link · parent
comment 2d ago · link · parent
However if politicians make a new railway you achieve almost nothing but there's a fancy opening ceremony and maybe their name goes on a plaque and it's on the TV news that evening. Hooray for them.
comment 2d ago · link · parent
In the US, which produces a whole bunch of natural gas, it is merely more expensive than usual, and so if you're not really tuned in to "normal" I can see you imagining that's cheap - but in the EU it's already at "Russia invades Ukraine" prices.
https://tradingeconomics.com/commodity/eu-natural-gas (check e.g. 10 years to see the longer picture)
In much of Europe (notably the UK, which isn't included in that EU number but is even more affected because it's a major net importer with little inventory) the price of natural gas drives the marginal price of electricity, causing wholesale electricity prices to soar, which then results in retail electricity prices following.
Right now the wholesale price is £220 per MWh. That's 22p per kWh in terms of your retail electricity before any taxes, service charges, network charges or any of the other elements which usually double the final bill.
The right will insist these charges are somehow not caused by the 13GW of gas turbines running on that expensive gas we just mentioned, somehow the price has exploded coincidentally as a result of say solar panels or "windmills". Even their natural audience doesn't really buy this any more, it's so transparently bullshit.
comment 2d ago · link · parent
Seems like just virtue to me. The guy who volunteers every week to pick up garbage from the beach isn't virtue signalling, he's just virtuous. The guy who came once, with a film crew and left once they'd got the shots they wanted - that is virtue signalling. They're both shown in the film, but only one of them actually does the signalled virtuous activity when the cameras aren't rolling.
You could argue that RIIR was conducted as virtue signalling if what we saw was one of those translations smeared in unexplained unsafe blocks, with rats nest logic that no human is going to untangle. But that doesn't seem to be the case here.
comment 2d ago · link · parent
So magically the Rust was just as fast, but much more readable and when a junior (or an LLM) modifies it slightly so that the output container is bigger it won't suddenly segfault due to that scary in-place conversion loop now being a bounds miss, the Rust won't attempt the in-place conversion now that it can't work.
comment 5d ago · link · parent
I don't see it. In Safe Rust we can't write a Data Race so we get SC/DRF because we know we don't have a data race. If we write unsafe Rust we do need to be careful not to break the rules and introduce a data race.
In Java we do not get such a promise at all, just the SC/DRF proof, any of our code might race. However, if we do lose Sequential Consistency we still have defined behaviour, we probably no longer understand how our program behaves (if it's not trivial) but we can say e.g. "I didn't write any code to delete the database" and so conclude it doesn't delete the database.
This doesn't seem like a clean win. I can see valuing either proposition more, but "in every way" I don't get that.
comment 5d ago · link · parent
The Iterator doesn't have bytes in it, we're not idiots, the Iterator is over Rust's char type, a Unicode scalar value (a "character" if you don't know the lingo)
What's delivering value here is division of responsibility. Cutting a problem up into pieces each of which can be tackled by an expert. Uppercasing text, encoding characters as bytes, allocating memory, appending to a buffer, these are all distinct problems which a different expert can solve properly.
In that Ruby code you need to gather maybe a half dozen experts to agree how to write this function. Or, of course, one expert YOLOs the rest of it because every topic we don't know much about is easy, right...
Rust does this division a lot. You as a programmer see String but when your String grows that's not code in String where people who know about Unicode live, that's RawVecInner<A> and that code doesn't even know about characters or strings or any such thing, it just allocates enough space to store data.
comment 5d ago · link · parent
... against str::to_uppercase the Rust function which has a single line of unsafe code, with a two line rationale provided to explain why it's OK to do this. As a subject matter expert I agree with the rationale. LGTM.
Edited: We're talking about uppercase, they're basically mirrors, but we should choose the uppercase function.
comment 5d ago · link · parent
For an example of the latter (LLVM is just nonsense): LLVM still today has a bug found years ago where pointer provenance (a legitimate but hard to think about idea for optimising compilers) accidentally leaks into integers, and so LLVM can end up with two integers a, b which it believes are not equal and yet a - b == 0. Boom.
comment 5d ago · link · parent
If you try to do the same mistake in Rust it does not compile, this function takes an int (obviously shouldn't but that's a different design bug in C not C++) and we have a wchat_t which is not an int, so that does not compile at all. Footgun removed.
When you start trying to figure out how to write the equivalent mistake in Rust properly, you discover that Rust says uppercasing or lowercasing arbitrary Unicode char values gets you an Iterator and you can't convince your compiler that this cannot make the string longer -- because in fact it might make the string longer. The mistake is averted by design.
comment 1w ago · link · parent
But that ISP text message doesn't care why my line went down. I could have guessed that after power was restored and I didn't get a "You are back online" text that meant a problem but I confess to not thinking about it until I returned home and found that although my power was back my Internet was not.
comment 1w ago · link · parent
Last time I called my ISP (last year? the year before? I don't remember) I was wondering when I would get service back. The street had exploded, underground power cable threw a tantrum and tore a big hole in the road, the grid company come out and fixed that but then of course my Internet didn't come back once the lights did.
The person who answered my call:
+ Did not waste my time asking that I restart laptops, routers, etc. the diagnostic lights on the router indicate No signal => not a problem I can fix by rebooting things.
+ Without needing me to re-specify where I live went straight to the identified problem (DSLAM offline) and to the fault report (to last mile provider for a failed DSLAM) and told me that in their experience I should expect a fix on Sunday (it was Friday evening). Which is what happened.
comment 1w ago · link · parent