Snipped and backdated from a previous Reddit post of mine.
As /u/x-paste was suggesting in the [Official] Object Orientation Discussion thread about ad-hoc data structures, I still think you can get the niceness and flexibility of just throwing code togeather while still having strong typing.
That or have gradual typing to avoid the messy example I wrote for the otherwise simple
eval() and can just use
any like in TypeScript and don’t bother with being extremely sound and specific.
Or you would still check everything at runtime but be a bit more smart about it like using guards in Elixir (which runs on Erlang):
Either way, I’ve thrown together some general ideas and wanted to see what you guys think. I’m questioning how far you really want to be able to take static typing with type inference. I know from the poll a sizeable amount of people were looking for something functional along with OO.
Dealing with Nominal and Structural Typing
I was thinking about a way to “soundly” deal with having a type system where you could have both nominal and structural typing and be able to use each where appropriate. And likewise, wrote an example of how this would work in some fake syntax:
Structural Type Inference
I when a bit crazy with how powerful the type system can be and what is offered for free with type inference alone.