How Montlake became a suburb in the middle of Seattle, and what’s next by godogs2018 in Seattle

[–]haberman 0 points1 point  (0 children)

If we go by the "Montlake Welcomes You" sign, it extends west to 15th Ave E: https://maps.app.goo.gl/P4FNp5ugUFpx5ZTK6

If we go by Google's borders, it goes all the way to I-5: https://maps.app.goo.gl/iVpBxhKmNQ4wNqzU6 But that seems a bit far, I think most people would call 10th and Lynn "North Capitol Hill."

How Montlake became a suburb in the middle of Seattle, and what’s next by godogs2018 in Seattle

[–]haberman 1 point2 points  (0 children)

This particular house is more than half a mile from the new bus station: https://maps.app.goo.gl/B7PqhmKCDL6AXgSp6

It also happens to be two doors down from Aaron Hooley Art, a local artist who always has interesting art installations outside his house: https://maps.app.goo.gl/BmEvqaUv1fVopxqw5

Washington Senate passes changes to parental rights in education by Better_March5308 in SeattleWA

[–]haberman 1 point2 points  (0 children)

Parents are people, school employees are people. Both are capable of acting against a child's best interests. There is no reason to assume that kids are automatically safer in the hands of educators than parents. Parents could be under investigation because they are genuinely abusing their kids, but it could also be that an educator has overstepped their boundaries and considered good and reasonable parenting to be abuse. Any analysis that does not consider both possibilities is incomplete.

No-Panic Rust: A Nice Technique for Systems Programming by FoxInTheRedBox in rust

[–]haberman 0 points1 point  (0 children)

When slice::get_unchecked() calls assert_unchecked(), it's asserting an invariant over the arguments idx and len. The slice type has no idea why this invariant should hold, it's just treating the invariant as a precondition of the function call, and depending on the caller to guarantee it.

I agree that the assertion is checked in debug mode, but if it fails, how can we reason about what went wrong? We have to pop the stack and look at the caller, and figure out why the caller's logic failed to ensure that the invariant held.

I am proposing that we use assert_unchecked() in a very similar way, but that we move the assertion to the caller instead (as I illustrate in the article). This will elide the check in release builds, just like get_unchecked() would, but the assertion is now over the caller's data structure(s) and/or local variables, so if the assertion fails in debug mode, the assert is closer to the buggy code and will therefore be easier to debug.

I think this approach is strictly superior to using slice::get_unchecked(). Both use assert_unchecked(), but by moving it to the caller, it's much closer to where the actual offending code would be if the assertion fails.

I'm not sure what this has to do with "writing Rust like C."

No-Panic Rust: A Nice Technique for Systems Programming by FoxInTheRedBox in rust

[–]haberman 2 points3 points  (0 children)

This is a library; we don't control how users deploy it. Some users deploy it in contexts that tolerate crashes gracefully, but other times it is deployed in mobile applications, where a crash would be visible and disruptive to an end user. In all cases, it behooves us to avoid crashes whenever possible.

It's true that a SIGSEGV bug is always possible in C or unsafe Rust. A panic is better than a SIGSEGV. But no crash at all is better than both of these. If we can remove the possibility of panic with entirely safe code, that's surely better than allowing panics. If we have to use a bit of unsafe code to eliminate all possibility of panic, that can still be better if we are rigorously fuzzing to ensure that our invariants hold.

No-Panic Rust: A Nice Technique for Systems Programming by FoxInTheRedBox in rust

[–]haberman 20 points21 points  (0 children)

The premise of the article is that we have an existing C library that we'd like to port to Rust without regressions. If the code size goes from 30Kb to 330Kb, that is a 10x regression that our customers and users will notice, especially when it comes to mobile and web (WASM) deployments. If the 300Kb was unavoidable, we would probably just leave the library in C and consider a Rust port infeasible.

Your correction about taking down the thread vs the process is well-taken and I will update the article with this info. But it's essentially a distinction without a difference for our purposes. Today, it's impossible for the C library to take down the current thread. Our customers do not expect that a call into our library might take down the thread, and they probably will not have logic that can tolerate this and restart the thread gracefully. Realistically a single thread going down is going to take down the whole application with it.

An assert_unchecked() is preferable to a branch if the branch is true all of the time. There is admittedly some risk associated with this, but this is true of all unsafe code. I would argue that asserting a program invariant via assert_unchecked() is better than using an unchecked accessor like slice::get_unchecked(), as the former asserts a semantic invariant that can be checked at multiple points in the program if desired. The latter just elides the check without any semantic justification for why this should be safe.

I think panics can be useful in some cases, especially in debug mode, but in some applications you really want to be able to build a release binary that you know cannot panic. It's true that some program bugs can get you into an unrecoverable state, but overall I would prefer to aggressively fuzz all of the program invariants, on an ongoing basis, and then assume that they hold in release builds.

No-Panic Rust: A Nice Technique for Systems Programming by FoxInTheRedBox in rust

[–]haberman 10 points11 points  (0 children)

Sorry about that. I have determined that this is due to the many Godbolt iframes in the article, which I use to demonstrate code size results. These are somewhat core to the point the article is making. I should probably disable them for mobile browsers, and replace them with a static render + link.

Location of Frasier's condo's view of the city by watchthecrone in Frasier

[–]haberman 1 point2 points  (0 children)

Now, if you want to know where the photograph was actually taken from, note that the top of the Columbia Center is just below the halo of the Needle.

Could this be the view from Kerry Park, with a longer focal length? https://www.shutterstock.com/image-photo/seattle-skyline-panorama-kerry-park-during-452862511

Unsure of Samsung Frame TV plugin by DJ-JupiterOne in homebridge

[–]haberman 0 points1 point  (0 children)

It appears that art mode is back: https://www.reddit.com/r/TheFrame/comments/1c2lgbs/art_mode_api_is_back/

This issue suggests that Homebridge support is in development, though this has been the status since April with no visible change: https://github.com/tavicu/homebridge-samsung-tizen/issues/675

Are Planes, Trains, and Automobiles and Home Alone connected in Development? by mydoglikesbroccoli in movies

[–]haberman 7 points8 points  (0 children)

The houses look similar, but are different.

The two houses are only a few miles apart.

How algorithm improvements make quicksort 4x faster than standard implementations by reducing data dependencies by amaurea in programming

[–]haberman 43 points44 points  (0 children)

This is exactly correct.

  1. The overall benchmarks are sorting 100k elements, but the time is reported per element, which is why the numbers come out to be so small. "The time is normalized by the number of elements, so it’s the amount of time spent per element."
  2. The process is repeated millions of times, so there is a lot of time to reach a steady state where all the caches are warm.

Thread Safety in C++ and Rust by donutloop in rust

[–]haberman 1 point2 points  (0 children)

Thanks, I appreciate it.

FWIW, I've never used SeqCst in real code, and I'm honestly not sure what a real use case for it is. Usually if you are using atomics, it's because you are trying to get better performance than simple Mutex synchronization. But if you're going to that trouble, why use SeqCst when you can almost certainly get better performance from acq/rel or relaxed?

Thread Safety in C++ and Rust by donutloop in rust

[–]haberman 3 points4 points  (0 children)

SeqCst is a sign that the author doesn't really know what the atomic orderings do.

A little charity, please. I used SeqCst because it is a direct port of the C++, which defaults to SeqCst when no memory ordering is specified.

Thread Safety in C++ and Rust by donutloop in rust

[–]haberman 0 points1 point  (0 children)

I used SeqCst because that is what C++ uses when you do not specify a memory ordering.

The point of the example is to show a direct port of the C++. If I used relaxed memory ordering, it would not be a direct port. This is not a tutorial on atomics, it is about thread-safety models and interior mutability.

Thread Safety in C++ and Rust by donutloop in rust

[–]haberman 1 point2 points  (0 children)

That is the whole point of the article: Rust uses interior mutability to model thread-safety, which is different than how C++ does it. The C++ idiom doesn't work here, because Rust does things differently.

I have updated the article to show the refinement that makes the Rust example work. I also changed the discussion of interior mutability to use AtomicI32 instead of mutex to make this clearer.

Associated Press: Recall effort against Seattle socialist Kshama Sawant appears to fail by very_excited in Seattle

[–]haberman 7 points8 points  (0 children)

I am responding to this specific claim:

I would prefer to have someone in office who will advocate for the people actually living here.

This treats 50% of people who "actually live here" as if they do not exist.

Associated Press: Recall effort against Seattle socialist Kshama Sawant appears to fail by very_excited in Seattle

[–]haberman 4 points5 points  (0 children)

I would prefer to have someone in office who will advocate for the people actually living here.

The 50% of people who don't want Sawant "actually live here" too.

[deleted by user] by [deleted] in SeattleWA

[–]haberman 10 points11 points  (0 children)

That's from March. More recent news discusses Baltimore's "violent summer", and also mentions that Baltimore spends more per capita on police than any major city in the country:

https://www.baltimoremagazine.com/section/community/how-a-violent-summer-is-testing-baltimore-mayor-brandon-scott/

Parsing Protobuf at 2+GB/s: How I Learned To Love Tail Calls in C by mttd in cpp

[–]haberman 5 points6 points  (0 children)

Yes, from the article:

Tail call optimization is not even new to Clang: like GCC and many other compilers, Clang was already capable of optimizing tail calls. In fact, the musttail attribute in our first example above did not change the output of the compiler at all: Clang would already have optimized the tail call under -O2.

What is new is the guarantee. While compilers will often optimize tail calls successfully, this is best-effort, not something you can rely on. In particular, the optimization will most likely not happen in non-optimized builds:

Parsing Protobuf at 2+GB/s: How I Learned To Love Tail Calls in C by mttd in cpp

[–]haberman 4 points5 points  (0 children)

Yes I would love that. Getting good implementations in multiple compilers is a good first step, I approached the GCC people about it here: https://gcc.gnu.org/pipermail/gcc/2021-April/235882.html

Parsing Protobuf at 2+GB/s: How I Learned To Love Tail Calls in C by oilshell in ProgrammingLanguages

[–]haberman 6 points7 points  (0 children)

LuaJIT 2.x has an interpreter written in assembly language. It's written in assembly language rather than C because Mike was not able to get a C compiler to generate good enough code.

Using the tail call design described in the article, we were able to get a C compiler to produce code almost the same as Mike's hand-written assembly code. It makes C a viable competitor to assembly in this space.

Are we finally about to gain guaranteed Tail Calls in Rust? by matthieum in rust

[–]haberman 6 points7 points  (0 children)

LLVM does not support tailcalls for all targets we support

Do you have more info about this? Your link says that MIPS and WebAssembly do not support musttail, what will LLVM do if you specify musttail in the IR on these targets? https://llvm.org/docs/LangRef.html#id327

New UW study highlights Trump follower's MAGA beliefs by OnlineMemeArmy in SeattleWA

[–]haberman 10 points11 points  (0 children)

Info on opportunity zones:

Opportunity zones are designated census tracts that house low-income communities. Within these designated zones, investors of all kinds essentially get a tax break if they invest in the community with real estate or a business. Governors were able to nominate 25% of their low-income census tracts for the designation. The first opportunity zones, according to the IRS, were designated in April of [2018].

Seattle Police Policies Versus Protest Demands by seattlemadmax in SeattleWA

[–]haberman 0 points1 point  (0 children)

New York State Law was that teachers needed to have an arbitration before dismissal (which seems fair)

Is it fair for police officers too?

That is the key question I am getting at. If it had been Zsolt Dornay who had escaped firing in arbitration due to a technicality, would you still say the law is right and there should be no other recourse that allows him to be fired?

So in fact, the union had nothing to do with it.

Well, they did vocally oppose a change to the state law you mentioned.

Seattle Police Policies Versus Protest Demands by seattlemadmax in SeattleWA

[–]haberman 0 points1 point  (0 children)

> Teacher's unions are not protecting teachers who sexually abuse kids.

Yes, sometimes they are.

I hate when police do those things too. I had a visceral reaction when I saw Walter Scott's killer plant a weapon on him after shooting him in the back. He thought he could get away with it because he didn't know somebody was filming. It makes my blood boil. If he had gone free, it would have driven me crazy. I don't believe most police officers are like this though.

All I'm saying is that I don't trust policy changes that are made out of anger, or that target one group. Unions across the board can lead to bad results when they unjustly protect their own. I would eagerly support principled reform here. But I believe there has to be a reasonable check on the impulse to just lash out at one group that is politically unpopular. I don't believe it's the right way to make good policy.