Skip to content

Comment on Ask HN: Is it worth it to invest in learning TypeScript?parent

Comments

This is true, especially for experienced coders, it's not very common for you to mix up types. Especially if your code is well written; high cohesion, loose coupling. Loose coupling means that you have simple interfaces which accept simple types (e.g. strings, numbers, raw objects without internal state or methods). Simple interfaces make it easy to figure out what arguments to pass to a function... This means you don't rely so much on a type checker.

What I don't like about statically typed languages is that they seem to encourage developers to define methods which accept complex arguments of type such as 'InputController' or 'Logger' or other complex 'live instances' which makes the function interfaces more complex and encourages violation of the separation of concerns principle.

For example, instead of passing a Logger to a component, why not just make the component an EventEmitter (or similar) and it can emit/trigger an 'error' or 'warning' event on itself when it encounters an error... Then this event can be handled and logged at a higher layer in the code. High cohesion means that components should only concern themselves with one thing; if a component also has to handle its own logging, that's already 2 things... IMO, statically typed languages often encourage such types of tight coupling, low cohesion anti-patterns. Just look at what happened to Java. You need to read 5 pages of documentation to get anything done because the interfaces are so complex and rigid. It almost forces developers into anti-patterns.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.