HNHacker News
TopNewBestAskShowJobs

OskarS

8,399 karma · joined September 4, 2016

submissionscomments
OskarS··on Reference count, don't garbage collect
> Almost everyone that actually uses reference counting uses more like 2-4 bits.

Here is an incomplete list of languages which use 8 bytes for their reference count on 64-bit computers:

1. Rust, in Rc<T> and Arc<T>

2. C++, in std::shared_ptr<T>

3. Objective-C, in NSObject's retainCount

4. Swift, because of Objective-C

5. Python, where reference count is Py_ssize_t

These were literally the first languages i thought of, they all use 64-bit types. I would argue since reference counting is much rarer than GC, these make up the bulk of reference counting use in the real world. "Almost everyone", huh? It's a bit rich accusing the author of being "almost incoherent" and then say this.

> Reference counting can have arbitrarily long pauses as well.

Deallocating can take arbitrarily long, but deallocation does not stop-the-world. It stops the current thread, which is a huge difference. Malloc can take arbitrarily long as well, it's not like it's wait-free.

In addition, the GC pauses in regular programming languages are frequently orders of magnitude longer than deallocation. You would have to deallocate an enormous tree of object at the root for this to be an issue. And GCs have to do that as well, in addition to their regular stop-the-world pauses. This argument is just irrelevant.

> The blog states that atomic writes are "basically free", but that ignores the fact that in multi-threaded code, atomic writes can actually be fairly expensive since each one requires communication between every thread (This is why python still has a GIL)

First off, this is not why Python has a GIL, but lets leave that aside.

Atomic writes are more expensive than non-atomic ones, but they are not slow operations in the grand scheme of things. If you properly implement acquire-release semantics, they are not even that slow under high contention. Compare this to a GC which literally STOPS ALL THREADS, it's nothing.

> you still need a GC anyway to deal with objects that get too many references.

This is just silly. In languages which has both reference counting and traditional garbage collection (e.g. Python), they do it to avoid reference cycles, not because objects get "too many references". That is a ridiculous statement.

In fact! I just realized we do have data for which is more performant: this article describes how Instagram turned of GC for Python and just relied on reference counting. They gained 10% increase in performance:

https://instagram-engineering.com/dismissing-python-garbage-...

I think it's still an open question if reference counting is always faster than GC, but I do not believe you have the technical expertise to evaluate such a claim. Your comment is four paragraphs long and riddled with factual errors. If you want to be convincing, show data that is better than that Instagram case study.

OskarS··on Rumor: Google Stadia May Be Getting Shut Down
Yeah, but they don't have to make it worse! If they do the right thing here and transfer the licenses somehow, it's way more likely that whatever their next thing is is going to go down smoother. If they don't do the right thing here, they're never going to be able to launch anything like it ever again. That must carry some weight. You'd hope, at least.
OskarS··on Reference count, don't garbage collect
> Its actually usually slower than both manual memory management and GC

[citation needed]

You and the blog post are arguing opposite things, and neither of you have shown any evidence. I get that you're arguing that reference counted objects are bigger (to store the reference count) and/or might use double indirection (depending on implementation), which are both bad for caches. It's not a bad argument. But the counter-argument that the blog posts makes is persuasive as well: it's expensive running a GC that scans the heap looking for loose objects, and reference counting does not need to do that. GC is also "stop-the-world" as well unpredictable and jittery in a way reference counting is not.

My instinct is that reference counting is actually faster (which matches my personal experience), but really, this is not an argument you can solve by arguing in the abstract, you need actual data and benchmarks.

OskarS··on Rumor: Google Stadia May Be Getting Shut Down
Played Cyberpunk on Stadia as well, mostly just to try the service out. Not a bad experience, honestly. Stadia had the technical stuff pretty nailed from day 1. It was just the business model that was out of whack.
OskarS··on Rumor: Google Stadia May Be Getting Shut Down
My guess is that they're gonna. Google is starting to get a reputation for this, and this would be an ESPECIALLY egregious example. Nobody would ever buy a digital good from them again if they didn't do some version of this (lots of people are skittish about it already, but this would make it so much worse).

I don't think it's "trivial" though. They probably have to do some negotiation with both Steam as well as each individual publisher of games on the service.

OskarS··on Why the Windows Registry sucks technically (2010)
> Second, I dare you to run "ls /etc" and claim it's not a mess...

In principle, sure. But in practice, using /etc to edit configuration data is not that hard, and every Linux user does it all the time. Different software uses different configuration formats, sure (though it's worth nothing that NixOS is doing really clever things to solve that problem), but it's really not that hard or scary.

Manually editing the registry though... That way lies madness. It's much scarier and it's much more fragile.

OskarS··on Standard Ebooks
What about texts where there are more or less “canonical” illustrations? Like, for an edition of Bleak House by Charles Dickens, it’s just not the same without the sketches by “Phiz” that were present in the original publication. Same with John Tenniels illustrations of Alice in Wonderland.

Amazing project by the way. Can’t believe I just heard about it today, will dig into your catalogue with excitement!

OskarS··on Performance comparison: counting words in Python, C/C++, Awk, Rust, and more
> But IMHO AWK takes the crown here. :)

Agreed! AWK is still the king of this stuff. For tasks like this, I kinda think AWK is nigh-unbeatable: so simple to write, so obvious what's going on (even if you've never seen any AWK program before, you're probably going to be able to figure out what's going on there), and decently performant.

AWK is the bee's knees.

OskarS··on Magnus Carlsen to give up World Championship title
By Chinook, actually. The computer science Jonathan Schaeffer became obsessed with solving checkers, because it was the only way to prove that Chinook could've beaten Tinsley in a fair game (as Tinsley passed away before Chinook could defeat him on the board).
OskarS··on Magnus Carlsen to give up World Championship title
I love this story so much. This The Atlantic article telling the full tale is a favorite of mine [1]

It's hard to overstate how incredibly dominant Tinsley was. In his entire career, he never lost a match, and only ever lost 7 games (two to Chinook). That is out of maybe tens of thousands of games. He was a mathematician by training and taught at a historically black university. He was also deeply religious and a lay minister at a black church. He famously described the difference between chess and checkers like this: “Chess is like looking out over a vast open ocean; checkers is like looking into a bottomless well.”

I could just quote the entire article, but I'll just leave it at this passage:

> The two men sat in his office and began the matches, Schaeffer moving for Chinook and entering changes in the game into the system. The first nine games were all draws. In the tenth game, Chinook was cruising along, searching 16 to 17 moves deep into the future. And it made a move where it thought it had a small advantage. “Tinsley immediately said, ‘You’re gonna regret that.’” Schaeffer said. “And at the time, I was thinking, what the heck does he know, what could possibly go wrong?” But, in fact, from that point forward, Tinsley began to pull ahead...

> The computer scientist became fixated on that moment. After the match, he ran simulations to examine what had gone wrong. And he discovered that, in fact, from that move to the end of the game, if both sides played perfectly, he would lose every time. But what he discovered next blew his mind. To see that, a computer or a human would have to look 64 moves ahead.

Tinsley was simply one of the most remarkable human minds of the 20th century. I'm happy he finally got a challenger that was worthy of him (as no other humans could even come close), but it also seems fitting that he was never officially defeated in a real checkers match. Rest in peace.

[1]: https://www.theatlantic.com/technology/archive/2017/07/mario...

OskarS··on How efficient can cat(1) be?
How would you suggest the kernel would accomplish that feat? If the user calls read() on a file descriptor, what can the kernel do except... you know... actually read from it and copy the data to user space?
OskarS··on Iceland’s forest and bush cover has increased sixfold since 1990
> long before the plantations (even BCE)

Iceland wasn't settled by humans until the Viking age, in the 9th century CE. Are you claiming it was deforested a millennia earlier than that?

Edit: I'm an idiot, I misread your comment. Apologies!

OskarS··on I just finished reading a book and took lots of notes. Now what?
Reading the question I was in disbelief: what a miserable way to experience literature (even non-fiction). Just read the book! Enjoy it! What possible goal could be fulfilled by this kind of incessant note-taking?

Really brilliant people, the kind of people that can take different ideas from different sources and synthesize them into new things, they don’t read books in this way. They just read them. If they do take notes, it’s to check something with some other source or if it’s something they want to remember. They don’t make “120 notes about the most interesting ideas” or whatever. That just sounds like some kind of obsessive dedication to a note-taking system, not a way to actually learn anything, let alone as a good way to experience culture.

OskarS··on Gamedevs not baking in monetization are “fucking idiots”, says Unity CEO
I don't think the full context does him any favors. The way he talks of gamedevs that are not engaging in predatory behaviour ("beautiful and pure, brilliant people") is incredibly condescending. Like, "yes children, once you grow up you'll realize how foolish your idealism has been and you'll stuff your game full of gems you can overpay for!". These are his customers he's talking about. And later talking about "compulsion loops"... just, no.

Unity used to be famous for being the game engine of choice for creative indies. Games like Hollow Knight, Return of the Obra Dinn, or Ori and the Blind Forest. It seems to me very clear that Riccitello has no understanding of the value of tools for making games like that. He sees Unity as a way of pumping out endless shitty Candy Crush clones stuffed with predatory microtransactions.

EDIT: by the way, for the full context, this is the question he's answering:

> "Implementing monetisation earlier in the process and conversation is certainly an angle that has seen pushback from some developers."

The pushback the question is referring to is developers being disappointed in the ironSource merger. He's literally being asked about Unity focusing too much on microtransactions and ad technology, and in his answer to the question he refers to his critics (which, again, are his customers!) as "fucking idiots".

This guy should not be in charge of Unity.

OskarS··on Tell HN: We are trying to get tail calls into the WebAssembly standard
I don't mean to minimize anybody's work, I'm genuinely curious about why it can't be done. Like, what's stopping me from making a compiler that optimizes tail calls?

For instance: the C and C++ standards have very strict rules for how to handle floating point math, and compilers aren't allowed to deviate from that according to the standard. Which turns off all sorts of cool optimizations you can do. But of course, all modern compilers implement some version of "-ffast-math" which turns off those rules and allows for the optimizations. It's no longer standard C/C++, but that doesn't mean that switch can't exist. The compiler is a computer program, it can output anything it wants, regardless of what the standard says. Nobody is going to go to jail because you turned on -ffast-math. The code will still run just fine.

So, my question is, why can't you write a compiler with an option that's like "I don't particularly care that .stack changes, do the tail call optimization". A -ffast-math, but for tail calls. Is there a technical reason why you can't do this?

OskarS··on Tell HN: We are trying to get tail calls into the WebAssembly standard
I don't quite get your point here. Suppose I write a compiler to compile Scheme to WASM. I would have write it so that it does proper tail calls, otherwise it wouldn't be Scheme. What's stopping me? Would the browsers not run the code? Like, yeah, it would change .stack, but who cares?

Same thing applies, I think, to any other language compiled to WASM. C/C++ compilers regularly inline huge amounts of the code when optimizations are turned on, as well as do tail-call optimization. I haven't tried, but I would assume that they do that for WASM just as they do for x86 or ARM or whatever other build target I choose. As long as my users are ok with this (and they presumably are, otherwise they wouldn't turn optimizations), what's the problem, exactly?

OskarS··on GCC Rust Approved by GCC Steering Committee
I think having some diversity in the Rust compiler space is an excellent idea. The rustc monoculture is really bad in the long-term, having multiple compilers allows for creating a much more robust standard (so that implementation bugs doesn't get "baked in" to the language) and benchmarking compile times as well as resulting binaries (in addition to many other benefits).

You're right that GCC Rust will probably be behind rustc for a while, but the sooner you start, the sooner it'll get there. The language isn't gonna "settle down" in that way any time soon, might as well just get going as soon as possible.

OskarS··on Unity employees ‘mad and stressed out’ amidst unexpected layoffs
Ever heard of fucking Spotify?
OskarS··on Electric fan car shatters the Goodwood hill climb record
They've actually radically redesigned the aerodynamics of the cars this year to address this exact problem (using ground effect instead of relying so much on wings for downforce). It's had it's own issues (there have been real problems with the cars bouncing on track), but it does seem like it's worked, they can follow much closer for much longer now.

DRS is still there though. The basic argument for it is that it makes races more exciting by encouraging overtakes even more (though there is a lot of debate about that).

OskarS··on WebAssembly and C++
> You're only wasting virtual address space, not actual RAM.

Fair enough, that's true.

> And of course the WASM runtime already needs to trap for invalid addresses (eg, -1 right out the gate). How would trapping the first few pages be any more expensive than any other unmapped range?

Memory locations are presumably all unsigned, so -1 is not an issue. The thing I'm saying is that you're turning a test that was `if (addr < LIMIT)` into `if (addr != 0 && addr < LIMIT)`, which is not nothing. And it's on EVERY memory access.

Thinking about it, there's no way you could rely on the MMU to be the ONLY memory check obviously. Like, the JIT can't translate a reference to `x = memory[ptr]` into just a `mov x, [BASE + ptr]`, because it could reference non-WASM memory, which is obviously a security no-no (unless it could statically guarantee `ptr < LIMIT`). You need some kind of runtime check in addition for security and stability, you can't get around it. Given that, I think I agree with you, might as well just do it. It's, like, two or three extra instructions or something? But I would not say that it's free.

OskarS··on WebAssembly and C++
My guess is probably that it's performance issue. You would have to do a `if (addr == 0) trap()` branch on EVERY memory access in the WASM runtime, which is not free. I guess it would still has to do some kind of bounds check to see that you're not overflowing your allotted buffer, but I could imagine that adding that kind of null-check to every memory access is not something you just get for free.

The other option would maybe be to make the entire first page of memory non-readable, and then have the MMU execute the trap for you (this is how real OSes does this null check, right?), but then you're wasting 4kb in every WASM runtime. Doesn't seem ideal.

I agree with you, this is a real shame, and it's going to lead to a LOT of bugs that would have been discovered otherwise. But I can see the reasoning why you wouldn't do this in WASM.

OskarS··on Adding Modules to C in 10 Lines of Code [pdf]
> Just use your allocators with malloc/free, that is what i do (you do the same in zig, allocators)

If you do that, is it RAII like C++/Rust? Objects get destructed at end of scope, and members get destructed recursively? Or do you have to manually call `free()` on everything? (which, granted, is significantly easier in languages with `defer` mechanisms)

OskarS··on Adding Modules to C in 10 Lines of Code [pdf]
C doesn't have "private" functions in that way, what it has is "static" functions, and this is indeed the biggest limitation of doing this kind of amalgamated build.

If you mark a function as static, it means that has internal linkage and is only visible inside the translation unit was defined and no symbol is exported for linking. This is not the default: if you just define a function with some name, that symbol is in general visible to all other translation units that gets linked together by the linker (though with no type information attached, just the name of the symbol. Making sure the type information is correct is the purpose of header files).

That means you can have any number of functions marked static in different translation units with the same name, and it's fine, they don't see each other. If you're doing an amalgamated build like this, that no longer works: all symbols have to have globally unique names.

In addition, of course, you don't get the "separation" that "static" provides. You can't call a static function across a translation unit boundary, but since this just one big translation unit, anything goes: all functions can call all other functions, even if they shouldn't.

OskarS··on Modern HDDs have gotten somewhat better
It's absurd to claim they're doing this for any other reason beyond deceptive marketing. It's like an advertising version of a dark pattern: a decision which has a sheen of reasonableness, but is clearly designed to deceive and exploit your customers.

Nowhere else in the computer is the base-10 version standard, and it shouldn't be. The sentence "a 32-bit CPU register can address up to 4 gigabyte of memory" is clearly reasonable, the sentence "a 32-bit CPU register can address up to 4.29497... gigabytes of memory" is not. It's not just ram though: all basic data types (bytes, ints, floats, pointers, SIMD registers, whatever) are sized to powers of 2, having a storage unit that is not is insanity. Or, to bring it back to hard drives: what's the max file size of a file stored on a FAT32 filesystem again?

It's just bad and deceptive, and hard drive manufactures should not be allowed to play these kinds of games. You should stop carrying the water for their shitty practices.

OskarS··on Advancing the state of the art for std:unordered_map implementations
I can totally see the line of reasoning that ended up with this decision. It was the wrong decision, but I absolutely can see how smart and competent people could've arrived there, or missed the reasons why (for instance) promising pointer stability was a bad idea. I've seen that Facebook/Meta talk as well, but they didn't have that data in 2003. Hindsight is 20/20.
OskarS··on Advancing the state of the art for std:unordered_map implementations
The fact that the STL api leaks these kind of implementation details is such a shame. Multiplied globally over all users of unordered_map, the amount of CPU time that has been wasted because of that decision boggles the mind. Has to be one of the biggest library design blunders in the history of the industry (up there with C strings being null-terminated). They should just add a new map to the standard with a better API.
OskarS··on Shortsightedness has become an epidemic
Yeah, I hadn’t heard about this ”daylight” thing either. I’ve been nearsighted since I was a kid, and back then people said I got it because I read to much, focusing on things too close to my face. I thought that was a pretty fair trade-off, since I liked reading, and didn’t particularly mind wearing glasses.

This sunlight thing makes a lot of sense though. I kept hearing proposals during the pandemic about holding classes outside if the weather allowed for it. Might not be such a terrible idea in climates where it’s suitable.

OskarS··on Using the mold linker for fun and 3x-8x link time speedups
I’m guessing a linker like this is also a VERY extreme case when it comes to mmap’ing a huge number of files. For most software, it’s just not that big of an issue.
OskarS··on Apple Music is the most buggy and annoying software I use
I’ve had similar issues with HomePod when it comes to other apps (e.g. playing podcasts from Overcast using AirPlay), but the Apple Music integration has never been a problem, that has always just worked. Siri sometimes gets confused about what you’re asking (as with all these systems), but it’s less than I expected and at an acceptible rate for me.
OskarS··on Apple Music is the most buggy and annoying software I use
The integration with HomePod is very nice, I can just go ”Hey Siri, play Tom Waits” or whatever. Maybe that works with Spotify, I dunno, but the integration with Apple Music is obviously seamless, it just works.
← PreviousPage 13 of 34Next →