cabin-lang / cabin

A dead simple, highly performant, extremely safe programming language.
GNU General Public License v3.0
3 stars 0 forks source link

Asynchronous Code / Multithreading #8

Open vi013t opened 3 weeks ago

vi013t commented 3 weeks ago

Currently Cabin has no sense of async code or threading. The reason for this is surprisingly simple: I've never really worked with async code much. It's not that I feel I couldn't make a basic implementation, I'm just not confident it would be very good due to my lack of experience with the subject — It'd be like building a programming language when you've only ever coded in Java: You can definitely make something, but you're missing out on the many proven failures and successes of other attempts, many of which can also expand how you think about the concepts at hand.

As such, I want to do a lot more research on async implementations before committing to one for Cabin. Regardless, it should be considered a core feature that gets done before 1.0.

vi013t commented 2 weeks ago

I think for starters I want asynchronous functions to work how they do in Go; Instead of explicitly declaring a function async at its declaration, any function can be called asynchronously at the call site. I'm thinking of a keyword along the lines of separately to mimic Go's go:

separately call_this_async();

I'm not sure if I love this keyword though. Other options might be... do? concurrently? simultaneously? I think simultaneously is the most accurate word that's also colloquial English, but it's quite long to type. I'll have to think about this.

separately would likely also apply to blocks, by which it would run the whole thing as an async function.

From here, I'm not sure where to go. There has to be a way for these processes to communicate, like Go's channels. I haven't done enough research yet to come up with a good system that's simple and prevents errors like data races.

vi013t commented 2 weeks ago

I'm starting to really like start as a keyword for this too.