Ask HN: Why don't we see more “bolt-on” type systems?
It's been shown that type systems can reduce certain classes of programming errors. It would seem that even in a weakly-typed language there would be at least some situations where type checking would be worth the additional effort.
Since every programming language is Turing complete, there's no reason you can't write a strongly typed DSL within any language, like:
defineType("Badger")
defineType("SharpThingies")
typeHasAttribute("Badger", "claws", "SharpThingies")
honey = stronglyTyped("Badger")
claws = stronglyTyped("SharpThingies")
setAttribute(honey, "claws", claws)
... but I rarely hear about anything like this. Does it just turn out badly? Is it just that the only people who care about types already switched to other languages? Is it that the benefits of strong typing only really pay out when you use it 100% of the time? Do you need access to the AST or some other compiler representation to make it fast?
2 comments
[ 72.6 ms ] story [ 52.8 ms ] threadThat being said, I may come back to it in another year -- it's still in pretty active development.
Your example is really describing a class; you could drop all the typing and it would still be a great question.
[0]: https://metacpan.org/pod/distribution/Moose/lib/Moose/Manual...