DEV Community

Discussion on: const 📦, seal 🤐, freeze ❄️ & immutability 🤓 in JS

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

I have a wishlist for JavaScript around this subject.

I have always wanted the ability to temporarily toggle mutability.

I would love to see the removal of the const assignment from the language altogether and make everything immutable by default, making let the new const and var the new let.

Anything immutable should be deeply immutable by default not just the reference to them.

I realize that would make this post redundant, but the fact that it's actually hard to do immutable JavaScript (compared to say, Rust Lang) and you have to explain it, meaning it's complex, there is something wrong with the implementation of es6. That's just my opinion. Anyway great post 😁.

Collapse
 
juancarlospaco profile image
Juan Carlos

You can do that using Nim (is immutable by default):
github.com/nim-lang/Nim/wiki/Nim-f...

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

Nim, I hear good things... But I am already proficient with typescript and I am currently learning rust, do you think Nim is going to stick around. I personally can understand why Nim was invented, what are its goals?

Thread Thread
 
juancarlospaco profile image
Juan Carlos

For Frontend only?, is kinda explained on the link,
better types than TypeScript, immutable by default,
powerful meta-programming, fullstack with 1 lang,
for Frontend is kinda like Svelte but with TypeScript and a whole Backend ecosystem, JS/WASM/WebGL you name it.

For Backend, easy syntax like Python or Ruby, is fast as C.

For DevOps, it can run interpreted cross-platform.

If you are doing Rust+TypeScript you are mixing 2 very different worlds,
I do everything with 1 lang.

Different from Rust, Nim is self-supporting Rust is not,
Nim can produce Hardened Binaries yet Rust can not,
has new memory management strategy that works kinda similar to Rust,
you can "import" a C/C++/ObjC/JS lib no need to re-write,
Nim also has an LLVM backend like Rust too,
Nim uses a lot less lines of code (expected from a C++ alternative),
not trolling Rust just explaining diff :)

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

Ooo that does look good. I wouldn't want to give up rust though, it's really a great language.