Hacker News new | past | comments | ask | show | jobs | submit login

This property is not really part of the type system though.

Also, as mentioned by another commenter below - is a file exists operation async? Sync? Why, why not?




Very simple - in Java, almost any IO operation in blocking. Exceptions are the stuff in the NIO package, thread interruption and signalling, and maybe process termination.


In TypeScript at least, async-ness is encoded in the type system, because async/await is just syntactic sugar for Promise/then/catch.


Well, JS is paired with a single-threaded execution model, so you only have concurrency to worry about. C#, Java has proper multithreading as well, that gives another dimension to the problem.


Kotlin has multithreading, and it also puts `suspend` in the type system.


Some more examples: Rust, Python (with most/all? type checkers), C# all bake this into their type systems.


This is more due to the fact that Kotlin doesn’t control its backend and is designed to work with a language that already includes this model, js.


What if file exists operation MUST be sync?


Then you don’t start it in a virtual thread. Your calls automatically become blocking or not blocking depending on your callsites, which is the proper place to decide that.


So it still has colors?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: