Hacker News new | ask | show | jobs
by lucianbr 786 days ago
How large are the projects you worked on? Usually type safety is more useful and appreciated in large projects, where strict interfaces between modules are more valuable. In small projects, the advantage is for the loosy-goosy, because you can move faster and anyway you have the whole thing in your head, or most of it.

There is a lot of text written and voice recorded over what type safety is good for. It's reasonable to disagree, but to "honestly don't get" what the point of it is seems kinda strange. Like you haven't really looked into it.

3 comments

I think the point isn't really about the value of type safety but rather the value-add of bothering with the whole of typescript (as in the type safety they provide rather than an abstract ideal) versus some other solution.

It's quite annoying IMO. Some of the things it can be infer are reasonably impressive but then that gets balanced out with having to write out a lot of crap that something a bit more HM-like would be able to nail immediately (rather than just "Any!? Fuck you").

That and the refusal to add other value-adds (despite being a compiler in all but name) hobbles the union types and so on.

Could you give me some examples of this unnecessary code? Are you using type inference to its full capabilities? It's only really necessary to declare types at interfaces (function arguments, etc)... Is that what you're referring to?
"Type safety is the property that no primitive operation ever applies to values of the wrong type."

Smalltalk is type safe & not statically checked.

page 263 "Programming Languages: Application and Interpretation"

[pdf] https://cs.brown.edu/~sk/Publications/Books/ProgLangs/2007-0...

It's not really true that type safety is useful for large projects.

It's generally better to do proper micro-services.

Type safety is the inferior way of doing it where you get hit with a double whammy of long compile times and extreme code verbosity.

Network API contracts/documentation are just an attempt of type safety over the untyped network boundary.

Network communications are the most tedious and annoying part of programming for me because of the validation of the request body and checking that it has all the fields needed.

Microservices only increase the amount of documentation needed. I would prefer to lessen the amount of documentation by letting the compiler/code do the work instead.

No, it's forced modularity. It's saying there are hard lines between parts of your program that can't be crossed. This prevents the over time formation of spaghetti code.

It's like British tanks in WW2, your system is composed out of standard parts. Not necessary the best, but standard parts and that's what tends to be important.