buzz-language / buzz

👨‍🚀 buzz, A small/lightweight statically typed scripting language
https://buzz-lang.dev
MIT License
1.15k stars 31 forks source link

Immutability by default #139

Open giann opened 1 year ago

giann commented 1 year ago

Should things be immutable (and private) by default?

str hello = "hello";
hello = "bye"; | fails

var str hello = "hello";
hello = "bye"; | ok
vexy commented 10 months ago

Hard big YES. Not only that "others" are doing it for years now, but enforcing immutability on a compiler level brings a lot of safety out of the box.

It may eventually lead to questions of "borrowing & ownership" (arrived in Swift 5.9, present in Rust since v1) but that's another subject.

Imho, this should be by default.

giann commented 10 months ago

Enforcing immutability should be relatively straightforward. Implementing this should also pave the way to resolve/implement: