
Ask HN: Why don't we see more “bolt-on” type systems? - erikpukinskis
It&#x27;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.<p>Since every programming language is Turing complete, there&#x27;s no reason you can&#x27;t write a strongly typed DSL within any language, like:<p><pre><code>    defineType(&quot;Badger&quot;)
    defineType(&quot;SharpThingies&quot;)
    typeHasAttribute(&quot;Badger&quot;, &quot;claws&quot;, &quot;SharpThingies&quot;)
    honey = stronglyTyped(&quot;Badger&quot;)
    claws = stronglyTyped(&quot;SharpThingies&quot;)
    setAttribute(honey, &quot;claws&quot;, claws)
</code></pre>
... 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?
======
falsedan
Generally, your language has to expose a meta-object protocol like this
itself. Perl5's Moose[0] did it without this, thanks to Perl5's extreme
flexibility & easy ability to run code at the compile stage.

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...](https://metacpan.org/pod/distribution/Moose/lib/Moose/Manual/Attributes.pod)

------
mattbillenstein
It's kinda clunky -- I tried out mypy recently for a smallish Python code-base
and there are just a bunch of rough edges in that system. After some time with
it, I thought my time would be better spent writing solid unit tests than
fighting the type checker.

That being said, I may come back to it in another year -- it's still in pretty
active development.

