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

For procedural code, async is fine. I still hate writing anything resembling a higher-order function (a function that takes or returns a function) in async Rust. The type constraints become longer than the code, and I can never seem to remember what I need to pin, unpin or box.

comment 4y ago · link · parent

The “initial scan” scenario also happens after git operations like pull, checkout etc. When working in a team where you pull and push often, it’s a real quality of life improvement if the IDE adapts quickly, so I wouldn’t dismiss that completely.

Async is also okay (not perfect) for CPU parallelism, with tokio::spawn etc., which I think is important for fast incremental compilation once everything is in RAM. To pick an example, let’s say you change the type of a widely used function, now you have to typecheck the entire project again.

If I were to design a language server, my hope would be to achieve both good IO interleaving and good CPU parallelism with a single async based design.

comment 4y ago · link · parent

If all of this was planned (and I’m not saying it is), that would have been very clever. It would work like this:

1. You “accidentally forget” to disable the feature in hardware. Given how competitive the market is, motherboard manufacturers can be relied upon to enable it in their “1337 OVERCLOCKZ” mode. No conspiracy is needed.

2. You “tolerate” this practice just long enough to win the critical initial wave of reviews and benchmarks. Interested buyers will look at those charts for years to come.

3. And when you finally do turn the feature off to protect the market for your server chips, you can plausibly claim that you had explicitly forbidden using this configuration from the very beginning. None of this is your fault.

.

Edit/Addendum: Just to clarify my actual opinion, of course an honest mistake is more likely, at least for step 1. Very few “evil schemes” exist in reality because people aren’t all that clever (and all that evil). But the possibility is interesting to speculate on.

comment 4y ago · link · parent

Thanks, that’s a great correction/clarification.

comment 4y ago · link · parent

I didn’t downvote, in fact, I’m a bit amused because the reason I used quotes is exactly because I’m not using any official definition! There’s no consensus definition of “native”, and I’m using “should” purely in the colloquial sense of “something I’d like to see”.

comment 4y ago · link · parent

It is. I haven’t checked the complete source code. What I know for sure is that a program using Rust’s std still requires the C runtime to link and run, and from that perspective, it doesn’t really matter if some or even many parts of the std don’t actually use it.

comment 4y ago · link · parent

As a believer in removing unnecessary layers of abstraction, this looks interesting. Is there a technical reason Rustix doesn’t support Windows, or is that just not a priority at the moment?

(For a bit of background info: It might seem counterintuitive, but on Windows, a “native” application “should” actually call the programming language agnostic Kernel32.dll functions directly. At least that’s the documented, stable way of doing things. Instead, Rust’s std currently goes through libc, which is also fine, but on Windows is an abstraction built on top of the Windows APIs, and is historically a lot less stable. This can cause code bloat and distribution hassles.

This is a bit different from Linux, where the abstractions are layered the other way round: the OS (POSIX) spec mostly assumes an existing libc. As a result, on Linux, going libc-less is a bit harder in my limited experience — though certainly possible if you know what you’re doing.)

comment 4y ago · link · parent

Unfortunately, they’ll get away with it as long as the company value goes up. As long as investors make money, who told whom what is irrelevant.

comment 4y ago · link · parent

Isn’t Al Capone’s tax evasion conviction usually mentioned as a bit of a joke? I don’t see how anyone can cite it as an example of the system working perfectly fine.

Ignoring for a moment that this was in a very different era, to me, there are only two possible conclusions from this:

(a) The conviction was legitimate. This means that if only he had been a bit more thorough about laundering his money, he’d have gotten away with organized murder.

(b) The conviction was ultimately politically motivated, because it became a public embarrassment that he couldn’t be convicted of anything. But if the state really wants to get rid of someone, a prosecutor will find a way, so they did.

And I seriously don’t know which possibility is more frightening.

comment 4y ago · link · parent

It’s a large topic, but the most important goal is to minimize the amount of code that’s transitively included in headers.

That can mean avoiding templates, or (if you’re willing to do the work) using explicit instantiations in one source file only.

Use the PImpl pattern so that users of a class don’t need to know the declarations of its private members.

And whenever reasonable, design your method signatures so that objects are passed by pointer/reference — this means you can work with forward declarations instead of always having to include the full class declaration.

Do all of that only where reasonable. Small headers usually don’t matter much, and avoiding dependencies on headers that users are likely to include anyway (like <string>) doesn’t win anything either.

comment 4y ago · link · parent

That matches my experience as well. It takes a nontrivial amount of discipline, but it’s possible to structure a C++ project for fast builds. In theory, having a module system that isn’t based on text substitution should give Rust an advantage, but on the minus side, the crate structure gives you fewer knobs to optimize.

comment 4y ago · link · parent

I agree, and even as someone who holds Rust in high regard, I’m becoming increasingly frustrated by this. There doesn’t seem to be one clear root of this problem.

Some of it is the language not being designed with ease of compilation in mind, unlike let’s say, to pick an extreme example, Go. Some of it is the tooling and default settings, especially around incremental compilation, linkers etc. People are working on this, but it takes time.

But unfortunately, a lot of the problem is with the ecosystem, as hinted at in the article. There seems to be no limit to the amount of code bloat and compile time complexity that people are willing to accept to win some microbenchmarks. This includes some very popular crates with lots of dependents, like Tokio.

In the C++ world, the popular “boost” library has a similar problem, and I know shops that avoid it, or large parts of it, simply because the compile times would be unbearable. I really hope that parts of the Rust community start to make similar decisions.

comment 4y ago · link · parent

Are we looking at a different version of the page? I see descriptions and definitions, but no proof.

comment 4y ago · link · parent

But you don’t start with a point belonging to the triangle, that’s the whole idea!

comment 4y ago · link · parent

I'm sorry, but that gives me "draw the rest of the fucking owl" vibes. You're basically restating the algorithm's definition -- it's the rest of the proof that contains the interesting steps.

Edit: In my view, to show that this draws the Sierpinsky triangle, one would need to show that (1) we only draw points that are in the Sierpinski triangle and (2) we draw all the points of the Sierpinski triangle.

(1) is clearly false (we start with a random point), but the claim is of course only that we draw an “approximation”. What that means exactly would need to be defined. I assume a rigorous argument would involve 2D probability densities. Given that, (2) isn’t obvious to me as well, what’s the argument that all the parts of the Sierpinski shape correspond to areas with high probability density?

comment 4y ago · link · parent

I don’t think we actually disagree, see my last paragraph.

comment 4y ago · link · parent

Not the OP, but off the top of my head, we have:

* str and String, which are the ones we just call “strings”

* CStr and CString, for interop with libraries that work with null-terminated strings

* OsStr and OsString, for interop with system libraries that expect non-UTF-8 encodings

* Path and PathBuf, which are also just strings

* [u8] and Vec<u8>, which are encoding-neutral binary strings (&[u8] is the type of b"Hello world") and are useful for interop with e.g. C++’s std::string

That’s 10.

(For non-Rust people who are curious: In these pairs, the first one is the type of a view of a string that’s stored elsewhere, and the second is the type that actually owns the string data. All of these 10 have their uses, but outside of interfacing with non-Rust libraries, you mostly work with str/String and Path/PathBuf.)

comment 4y ago · link · parent

That’s an evil problem to have. Let’s say you derive two references to a GC’d object (this can easily happen accidentally in a graph-like data structure) and pass them both as parameters to a function. I’ve looked at disassembled Rust code before. Given how aggressively the compiler optimizes based on the guarantees around & and &mut, I’d be surprised if this system compiles any non-toy programs correctly at all.

comment 4y ago · link · parent

I absolutely agree. There’s prior art in that direction. It’s more or less abandoned now, but Microsoft developed an extension to C++ that integrated the .NET runtime with it’s garbage collector called C++/CLI. The way it worked is that in addition to C++’s native pointers and references (Foo* and Foo&), you had a new kind of garbage collected reference, written Foo^. There were some annoying limitations that a GC built directly for this use case might have solved better, but mostly, this worked really well.

And I think Rust would be a much better target language for such a system than C++ was. For example, one of the interesting problems was that the .NET GC is compacting — it will move objects around to improve cache locality and simplify the allocation algorithm. To interact with ordinary C++ code, you need native pointers into GC’d objects. But it was only safe to take such a pointer while you told the GC to temporarily “pin” the object in memory, otherwise, your pointer could be randomly invalidated. Forgetting that step was a very evil source of nondeterministic memory bugs. It’s not hard to see how the borrow checker would help there.

comment 4y ago · link · parent

It’s been a while, but didn’t the program knob in those machines turn in discrete steps? If so, then that system was — to be pedantic — a mechanical digital computer, not an analog one.

comment 4y ago · link · parent

Supposedly, one application of analog computing is simulating systems governed by differential equations.

The discrete time step in a typical numerical simulation introduces some artifacts, often seen as an error at high frequencies. In an analog computer, you set up a system of differential equations by using integration components that you plug back into the system to literally form a feedback loop. Because such a setup is physical, it can simulate the target system without any temporal artifacts.

The CCC hosted a great (English language) talk on this that really blew my mind: https://media.ccc.de/v/saal_mp7_og_-_2013-07-07_14:00_-_anal...

comment 4y ago · link · parent

“Only”.

comment 4y ago · link · parent

Look more carefully, the estimation according to Wikipedia is 10^80, which is roughly 2^266.

(BTW, when converting 10^x to 2^x, times 3 is what I use for very rough back of the envelope estimations. Times 10/3 is actually almost precise, as log2(10) = 3.32…)

comment 4y ago · link · parent

Boyajian’s star is 1470 lightyears away according to Wikipedia. As a sci-fi concept: Imagine we detect an expanding civilization at this distance, and they travel at a significant fraction of c. We have a few millennia, at most, what do we do?

comment 4y ago · link · parent

I personally don’t get bored when a tool is “too simple”, but when it forces me to do things by hand that the machine should be able to do. Like manually specializing a generic concept. I didn’t become a programmer out of love for repetitive tasks!

comment 4y ago · link · parent

Even though I personally much prefer Unix environments, I've done a lot of work in Microsoft's tech stacks and WPF in particular.

WPF is nice, but it's not developed much anymore and lacks basic features that people have come to accept (great touch support, smooth scrolling). And the successor technologies are all a mess, driven by Microsoft's internal politics more than by any coherent strategy. I tuned into a few streams of Microsoft's developer conference last year, and no fewer than three different UI libraries, developed by three competing divisions, where announced as "the future of app development on Windows". I can guarantee that only 0-1 of those will survive, so good luck betting on the right one.

The only real recommendation I can give is to do as Microsoft does, not as they say. So while they tell everyone to use UWP, WinUI, MAUI or whatever, all of their own new apps are written in Electron. Decide what that means for yourself.

comment 4y ago · link · parent

Laws that require software companies to implement a user choice should really contain some wording against dark patterns. EU lawmakers could have been warned: A similar thing happened back when Microsoft was forced to give users in the EU a choice of browsers, when they created the most confusing dialog possible and hoped that users would just click OK to Internet Explorer out of desperation.

For me personally, when those data protection laws where implemented, seeing the extent of the market for user tracking was a shock to me. The respect that I lost for actually quite a lot of companies as a consequence has informed some purchasing decisions. And I don’t think anybody would mind those banners if the opt-out option you want to click is reachable with a single, easily visible button.

Edit: Responses suggest that the GDPR already contains something to that effect. Glad to know. If that’s true, then I guess it’s time for court cases to sort this out.

comment 4y ago · link · parent

Exactly, straight lines on a texture should obey perspective (think rows of bricks on a wall). I think this wasn't as widely understood back then, but notably, id software already got it right a few years earlier in the original Wolfenstein.

Great link. The artifacts are especially apparent when the walls are near the camera, for example at this timestamp: https://www.youtube.com/watch?v=VutzIK3DqZE&t=398s And note that here, the seemingly flat walls are already heavily subdivided into smaller polygons to lessen the impact of the problem. (Why they wouldn't then make use of those additional polygons to include more geometry details for free is beyond me, however.)

comment 4y ago · link · parent

In early 3D hardware, the Z buffer was a bit more special cased than it is now, where you quite literally allocate a texture. In either case, the interesting (and expensive to emulate in software) part is of course using the depth buffer to perform depth testing, that is, rejecting pixels that would be hidden.

comment 4y ago · link · parent

Fake/real is not the most precise terminology, but I think it gets the important point across, so I’ll use it.

In a "real 3D" rasterizer, you interpolate the depth coordinate for each individual pixel. You need this value to perform two steps in the pixel pipeline that are required to get the correct look: First, you use the depth coordinate the perform depth testing (reject pixels that should be hidden). Then, you use it to perform a perspective correct texture lookup (make straight lines on the texture obey the laws of perspective).

If you throw out the depth coordinate anywhere earlier in the pipeline, as the PS1 did, you can’t do either of those things, so you get artifacts where objects flicker and warp when rotating. The rasterizer really needs to be "3D aware" right until writing out the final pixel values.

Note that both artifacts can be lessened, to some degree at least, with workarounds. For depth testing, you simply sort the polygons (which doesn’t work in every case, as triangles can overlap in cycles). And for the texture lookup problem, you subdivide the polygons (this helps because the vertex calculations are perspective correct, but it's expensive and you'd need infinite subdivision to fully solve the problem).

As an aside, the PS1 had another issue where the rasterizer didn’t support subpixel precision, which also leads to artifacts. But IMO that’s mostly unrelated to the 3D coordinate problems — 2D games need that as well to get smooth movement.

1
323334
51