Okay, adding #swift Automatic Reference Counting (ARC), which is thread safe, to what my dream #programmingLanguage should have. Compared to Swift, #nim their preferred implementation, ORC, doesn’t leak memory when dealing with reference cycles. Although I don’t know if #nimlang their implementation it thread safe, as well.
Maybe my theoretical #languageDesign should warn, but leak upon reference cycles. It seems to make the implementation easier.
References:
Nim
- https://nim-lang.org/docs/mm.html
Swift
- https://docs.swift.org/swift-book/documentation/the-swift-programming-language/automaticreferencecounting/
- https://clang.llvm.org/docs/AutomaticReferenceCounting.html
Rust leaking on memory cycles
- https://doc.rust-lang.org/book/ch15-06-reference-cycles.html
- https://doc.rust-lang.org/std/sync/struct.Arc.html
Maybe the compiler can detect if a variable is shared between threads and use atomic operations by default. If not, it’s just like #golang where it is up to the programmer
@rollbrettklauen It's one of the most interesting benefits of the #rust memory model and ownership rules. The compiler can ensure at compile time lots of interesting properties for mutexes, like "one writer, many readers" rule. I think there is a good potential for having some limited Rust-like ownership even in a language with a different memory model.
@orsinium yeah Rust‘s ownership model is definitely interesting, but makes programming in Rust really difficult as well. Whereas Swift is beginner friendly and ensures thread safety as well. I want software written my language to be editable by a junior software dev
Very true! Performance is important but you have to balance how important it is for your use case.
Sometimes all you need is a fast enough language that can be easily adopted by your team.