The article builds a strawman. It's not the types that fail, but the type system and its misuse. > This is like pretending really hard No, that's not pretending — static typing is literally about theorem proving, type theory being equivalent with math logic. This is the famous Curry-Howard isomorphism, types corresponding to propositions. Of course, you can have situations in which your type system cannot describe th…
Did you read the whole thing? This is exactly the point the author is trying to make. Look, you both arrive at the same conclusion even: > Or you change the game and just use PureScript. Or ReasonML, or Elm, or even ClojureScript. > If you want to see actual dynamic typing and how it can shine, use ClojureScript. If you want to see actual static typing and how it can kick ass, use PureScript.
Fear, trust and JavaScript: When types and functional programming fail
31–40 of 210 posts
Re: Fear, trust and JavaScript: When types and functional programming fail
#32Earlier quoted context omitted.
How would static typing help you if it's two different applications like the post you reply to is talking about?
You can insert whatever level of validation you need at the untyped interface between the two... just as you would with dynamically typed languages.
Re: Fear, trust and JavaScript: When types and functional programming fail
#33Earlier quoted context omitted.
How would static typing help you if it's two different applications like the post you reply to is talking about?
You try to parse the received data into a predefined data type, if this fails you are forced by the type system to handle the failure scenario, if it parses correctly you now have a 100% valid data structure you can work with in the rest of your codebase, no defensive checks necessary.
Re: Fear, trust and JavaScript: When types and functional programming fail
#34Broken promises in Javascript? ... unsurprising ... Here is an imaginary article that I would read: "New web platform runs entirely in webassembly generated by well-typed languages". Subtitle: "When hand-written Javascript is detected, continuous integration activates subdermal shock-collar that each of the developers is contractually obliged to have".
Re: Fear, trust and JavaScript: When types and functional programming fail
#35> in various cases the types are wrong and the compiler doesn’t care It's disturbing how often I encounter this in TypeScript. Or its inverse: the types are correct and the compiler is wrong. Or a third common problem: the types for a library are incorrect. The unsoundness of TypeScript is not merely theoretical. The compiler is frequently just wrong. For that reason, I am mystified by the amount of enthusiasm for Ty…
Re: Fear, trust and JavaScript: When types and functional programming fail
#36Re: Fear, trust and JavaScript: When types and functional programming fail
#37Earlier quoted context omitted.
I did Objective-C work for a decade under such conditions. It's never enough to have tests and code reviews. Static typing is strictly better.
I worked on a 150k LOC pure JS codebase for almost two years and my experience is different - if tests aren't enough then they're either not written well enough or there isn't enough of them.
Re: Fear, trust and JavaScript: When types and functional programming fail
#38The thing to realize is that at the end of the day, all you are doing is reducing bugs, and while your type system (IMO) really can help reduce bugs, it will never catch all bugs. There is still value in a function declaring that its argument is of type User (and not defensively checking it) even if it is theoretically possible, in the presence of a bug, though unlikely, that the argument is not really a User. The function has said what its precondition is, and (assuming you are validating any data that comes over the network or from an untyped source), this precondition will in practice be checked 99% of the time. If a bug happens to line up with a hole in the type system, you’ll just have to debug and fix it.