i used to dislike static typing in principle because i felt it would restrict me. look what i can do without static types, i might have said, and constructed a variadic higher-order function (which some type systems cannot express)
i think this thought process was ... partially valid ,,
type systems do restrict what one can do. however, ideally, the result of this restriction is in general just increased explicitness. examples of when this goes well:
- in haskell you have no i/o. just kidding, you use monads, which is a little weird, but in the end all it's really doing is requiring to make your use of i/o very explicit
- in many languages you have no
null. just kidding, you haveOption/Maybe/whatever, which is likenullbut callsites are forced to be explicit about their handling of it - say you want a class whose fields have a fixed type--say
Int-- but unknown names. in javascript this is simple; just use an object. in most typed languages this is impossible. just kidding -- you give your class one field,fields, with typeMap String Int. you are forced to make explicit that you don't know the field names
etc etc. in these cases static typing looks like its getting in the way but it really isn't; it's just forcing us to write better code. this is the ideal outcome
sometimes tho the type system really does get in the way. for instance, to avoid having to write our own lenses for every haskell ADT we need to bring in huge tools like TemplateHaskell and/or Generic. there is no analogous difficulty in python, because class metaprogramming is just writing plain functions
