4 ms·
Wow, I like the selling points: * Strong modular system and built in testing. * Global state is not allowed. * There's no null and everything is automaticall
by didip 8y ago
Wow, I like the selling points:
* Strong modular system and built in testing.
* Global state is not allowed.
* There's no null and everything is automatically initialized to empty values. No more null reference crashes.
* Variables are immutable by default and functions are partially pure: function arguments are always immutable, only method's receiver can be changed.
* Thread safety and guaranteed absence of data races. You no longer have to constantly ask yourself: "Is this thread safe?" Everything is! No perfomance costs either. For example, if you are using a hash map in a concurrent function, a thread safe hash map is used automatically. Otherwise a faster single thread hash map is used.
* Strict automatic code formatting. It goes further than gofmt and even has a set of rules for empty lines to ensure truly one coding style.
Especially eye catching is the 2 mode of every data structure. Switch to thread-safe if there are concurrent access.
- duncan-donuts 8y agoFor no null is he saying that everything is just initialized to a default value (int=0, str=“”, etc)? I’m thrown off by, “everything is initialized to empty values” because I don’t see how empty and null are different.
- eridius 8y agoThe difference is all values are valid. In C, you can't know that a `char *` is safe to dereference.
- dkersten 8y agoGarbage but valid values are, in my opinion, much harder errors to catch because they can silently corrupt data, than a simple crash/null pointer exception. I'm not a fan of null (option types seem better -- which V does say it has), but defaulting to an "empty" value isn't the answer IMHO as it makes it much harder to debug by obscuring that there's a problem at all. You may not realise that the 0 is actually an "empty" and not a valid 0 until you realise all of your calculations are wrong, months later.
- amedvednikov 8y agoRight, the only syntax for variable declaration is a := val, so you are forced to initialize variables.