tnowacki
Joined 8 years ago
Joined 8 years ago
> but can't an object be considered immutable when all its fields are immutable and all its member functions (but the constructor perhaps) are pure?
How exactly do you expect to track this accurately without integrating it into the type system? It's not an issue of whether or not the field itself is assignable, but whether or not the type that it points to is mutable. This becomes much more difficult to determine when generics are involved. This sort of type level knowledge for generics would make it hard to staple onto an existing type system. Even if you did, you would likely end up with a lot of code duplication as you would need two forms of types, immutable and mutable, e.g. `ImmVector` and `MutVector`, `ImmMap` and `MutMap`, `ImmMyObject` and `MutMyObject`, etc. To make this more ergonomic, Skip has a mode based mutability model, where the mutability is determined not at the class declaration, but rather at the type annotation/object instantiation. So we would then have `Vector` and `mutable Vector`, two modes of the same class.
You can read more here: http://skiplang.com/blog/2018/04/10/understanding-mutability...
If you want an overview of language features/design. I'd start with the docs: http://skiplang.com/docs/hello_world.html
We had a specification in the works, but it fell horribly out of date. I wasn't sure that we kept it around
Other non deterministic computation, like randomness or time is outright banned in the tracked environment. (There is an opt-in 'untracked' modifier if you want to write code outside of the reactive environment).
For other tricky behavior, like mutability/mutations on an object, the type system tracks the mutability mode of any object. Only objects that are fully immutable ('frozen' in the language) can be memoized inputs/outputs to a function.
As far as results, we saw some great numbers for the effectiveness of the recomputation. The language is self hosted. And the type checker is currently incremental. On my machine the initial type checking of the compiler itself is in the ballpark of ~40s. Changing a file and getting new type errors returns in <0.5s
https://www.youtube.com/watch?v=QMFLcmsjOBg
In the video, they mention that the models we have for FTL (by bending spacetime) wouldn't generate ripples in this way. We could however detect ripples from a really massive ship accelerating really really quickly.