News for hackers. Stuff that matters.
Re:Dynamic type systems are not inherently more open by capableweb on Sunday January 19, 2020 @10:17AM (#22091827)
Also, the following part isn't necessarily because of dynamic typing vs static

> what types all the variables are, what expectations are attached to them, what mutation, if any, each method call performs

But more about what the language offers. Clojure for example, goes beyond types with it's abstractions (like seq, that can be applied to strings, lists, maps and so on) and normally stays away from mutation, but when needed, makes it really explicit and easy to find those mutations.

Re:Dynamic type systems are not inherently more open by yakshaving_jgt on Sunday January 19, 2020 @10:30AM (#22091905)
> Clojure for example, goes beyond types with it's abstractions (like seq, that can be applied to strings, lists, maps and so on)

Goes beyond types? Statically-typed languages can have polymorphism.

Re:Dynamic type systems are not inherently more open by roenxi on Sunday January 19, 2020 @04:05PM (#22094064)
Spec is at heart a data modelling system. So for example,

  (s/def ::integer integer?)
is very explicitly not a definition of an "integer" type. It is preparation to model some data x and check that the data will evaluate to true if someone uses the predicate (integer? x). However, this is obviously enough to implement a type system.

But you can also do some very loose things with spec that aren't done in a type system (I speak with a cheerful ignorance of type systems). Eg, I can spec a function so that one argument is smaller than the second. This allows my testing system to automatically generate the correct data to test my function.

So spec can used to implement a type system but also to implement things that aren't type systems.

Re:Dynamic type systems are not inherently more open by candeira on Sunday January 19, 2020 @07:54PM (#22095319)
> But you can also do some very loose things with spec that aren't done in a type system (I speak with a cheerful ignorance of type systems). Eg, I can spec a function so that one argument is smaller than the second. This allows my testing system to automatically generate the correct data to test my function.

Check out dependent type systems. These allow you to define, mindbreakingly enough, types that __depend on the values you assign at runtime__, and functions whose type depends on the values passed as arguments.

Don't ask me how it's done; it's all dark magic to me. All I know is that people who use dependent type systems claim they are very good at certain uses involving incoming streams of unknown data, like parsing binary protocols.

https://en.wikipedia.org/wiki/Dependent_type

Re:Dynamic type systems are not inherently more open by leshow on Sunday January 19, 2020 @12:30PM (#22092597)
Commented elsewhere here but static languages can do this also via ad hoc polymorphism or bounded polymorphism.
Re:Dynamic type systems are not inherently more open by pron on Sunday January 19, 2020 @10:19AM (#22091841)
Java's JML contract system [1] allows you to explicitly state which mutations a method performs as part of its contract.

[1]: https://www.openjml.org/

Re:Dynamic type systems are not inherently more open by fanf2 on Sunday January 19, 2020 @10:32AM (#22091918)
Why is seq “beyond types”? Isn’t it like a Rust Iterator trait?
Re:Dynamic type systems are not inherently more open by hopia on Sunday January 19, 2020 @10:39AM (#22091968)
What do you mean with going beyond types? Is it possible to define some unique compile time constraints on Clojure not related to the type system?
Re:Dynamic type systems are not inherently more open by dllthomas on Sunday January 19, 2020 @01:56PM (#22093152)
When spec was proposed I remember some talk of compile-time checking of some annotations. I don't know whether anything came of that, but in theory it would allow what you're talking about. That has no relation to seq, though, which is the kind of thing supported by many statically typed languages.