Readit News logoReadit News
bkolobara commented on Unexpected productivity boost of Rust   lubeno.dev/blog/rusts-pro... · Posted by u/bkolobara
dvt · 21 hours ago
Using sync locks in an async environment is a code smell, so the Rust code is bad right off the bat. Just stick with async locks and take the tiny performance hit unless you know exactly what you're doing.
bkolobara · an hour ago
I didn't need to hold the lock across the .await point and in that case the official docs recommend a regular lock.
bkolobara commented on Unexpected productivity boost of Rust   lubeno.dev/blog/rusts-pro... · Posted by u/bkolobara
phplovesong · 6 hours ago
This boils down to "dev found out that a static typesystem is usefull".

Its always funny when i see these kinds of posts.

bkolobara · 6 hours ago
My intention with the blog was to show that Rust's lifetime tracking and trait system allow you to catch much more complicated issues than just "one type doesn't match another" errors.

That's the main reason why I chose to compare it with TypeScript, that is also a statically typed language, but just can't catch some issues that Rust can.

bkolobara commented on Unexpected productivity boost of Rust   lubeno.dev/blog/rusts-pro... · Posted by u/bkolobara
johnfn · 7 hours ago
I'm not as familiar with Rust, but isn't there still a gap? For instance, if we modified window.set_href to have move semantics, wouldn't this still work (i.e. not produce an error)?

    let win = window.set_href("/foo")
    win.set_href("/bar")
You might say "why would you ever do that" but my point is that if it's really the lack of move semantics that cause this problem (not the deferred update), then you should never be able to cause an issue if you get the types correct. And if you do have deferred updates, maybe you do want to do something after set_href, like send analytics in a finally() block.

In fact, Typescript does have a way to solve this problem - just make `setHref` return never[1]! Then subsequent calls to `setHref`, or in fact anything else at all, will be an error. If I understand correctly, this is similar to how `!` works in Rust.

So maybe TS is not so bad after all :)

[1]: https://www.typescriptlang.org/play/?ssl=9&ssc=1&pln=9&pc=2#...

bkolobara · 6 hours ago
Your Rust example would not work, because `window.set_href("/foo")` would not return anything (it would return the unit type "()" aka void). And you can't call `set_href()` again on "()". This is a common pattern in Rust, allow certain functions to only be called once on specific objects.

I really like your TypeScript solution! This actually perfectly solves the issue. I just wish that this was the ONLY way to actually do it, so I would not have experience the issue in the first place.

bkolobara commented on Unexpected productivity boost of Rust   lubeno.dev/blog/rusts-pro... · Posted by u/bkolobara
johnfn · 9 hours ago
I think Rust is awesome and I agree with that part of the article.

What I disagree with is that it's the fault of Typescript that the href assignment bug is not caught. I don't think that has anything to do with Typescript. The bug is that it's counter-intuitive that setting href defers the location switch until later. You could imagine the same bug in Rust if Rust had a `set_href` function that also deferred the work:

    set_href('/foo');

    if (some_condition) {
        set_href('/bar');
    }
Of course, Rust would never do this, because this is poor library design: it doesn't make sense to take action in a setter, and it doesn't make sense that assigning to href doesn't immediately navigate you to the next page. Of course, Rust would never have such a dumb library design. Perhaps I'm splitting hairs, but that's not Rust vs TypeScript - it's Rust's standard library vs the Web Platform API. To which I would totally agree that Rust would never do something so silly.

bkolobara · 8 hours ago
Thanks! I should have clarified a bit better that example.

The point I was trying to make is that Rust's ownership model would allow you to design an api where calling `window.set_href('/foo')` would take ownership of `window`. So you would not be able to call it twice. This possibility doesn't exist at all in TypeScript, because it doesn't track lifetimes.

Of course, TypeScript can't do anything here either way. Even if it had knowledge of lifetimes, the JavaScript API already existed before and it would not be possible to introduce an ownership model on top of it, because there are just too many global variables and APIs.

I wanted more to demonstrate how Rust's whole set of features neatly fits together and that it would be hard to get the same guarantees with "just types".

bkolobara commented on Unexpected productivity boost of Rust   lubeno.dev/blog/rusts-pro... · Posted by u/bkolobara
Spivak · a day ago
How do you encode the locking issue in the type system, it seems magical? Can you just never hold any locks when calling await, is it smart enough to know that this scheduler might move work between threads?
bkolobara · a day ago
Yes, if you use a scheduler that doesn't move work between threads, it will not require the task to be Send, and the example code would compile.

Rust can use that type information and lifetimes to figure out when it's safe and when not.

bkolobara commented on Code review can be better   tigerbeetle.com/blog/2025... · Posted by u/sealeck
bkolobara · 7 days ago
I have been working on the PR implementation for lubeno[1] and have been thinking a lot about the code review process.

A big issue is that every team has a slightly different workflow, with different rules and requirements. The way GitHub is structured is a result of how the GitHub team works. They built the best tool for themselves with their "just keep appending commits to a PR" workflow.

Either you need to have enough flexibility so that the tool can be adapted to everyone's existing workflow. Or you need to be opinionated about your workflow (GitHub) and force everyone to match it in some way. And in most cases this works very well, because people just want you to tell them the best way of doing things and not spend time figuring out what the best workflow would look like.

[1]: https://lubeno.dev

bkolobara commented on OpenAI's new GPT-5 models announced early by GitHub   theverge.com/news/752091/... · Posted by u/bkolobara
bkolobara · 21 days ago
The actual announcement (now deleted on GitHub's blog): https://archive.is/IoMEg
bkolobara commented on I gave the AI arms and legs then it rejected me   grell.dev/blog/ai_rejecti... · Posted by u/serhack_
bkolobara · 22 days ago
> Unfortunately they thanked me for my application but said the team doesn't have the capacity to review additional applications.

It seems like they didn't even look at his application.

u/bkolobara

KarmaCake day1165July 3, 2011
About
building flawless.dev
View Original