from Hacker News

Show HN: js.spec, a JavaScript implementation of clojure.spec

by prayerslayer on 11/29/16, 10:57 PM with 24 comments

  • by moxious on 11/30/16, 12:03 AM

    I think of dynamic typing in a language as a big pro and a big con at the same time, but it's one of the things that makes a language like JavaScript or closure what it is.

    I love typing systems too, there are compelling advantages...and disadvantages.

    I guess sometimes what seems strange is attempts to bolt type systems on to fundamentally dynamic languages, like adding two extra wheels to a motorcycle, extra fairing, and then calling it a car.

    I don't fault anyone for wanting a car. But if you wanted a car, why not start off with a statically typed language? Why bolt this stuff on really in contravention to what the dynamic languages are trying to be?

    Perhaps this is JavaScript fatigue in a new guise? If everything has to be JavaScript (for whatever reason) then having no static typing ever may be hard to live with?

    Am I missing something or does the motorcycle with two extra wheels seem destined to be clunkier and less flexible than a proper car?

  • by rattray on 11/30/16, 1:08 AM

    Seems cool.

    Also worth checking out: tcomb[0] which can let you use your Flow types at runtime for eg; pattern matching.

    [0] https://github.com/gcanti/tcomb

  • by dwwoelfel on 11/29/16, 11:56 PM

    Have you used js.spec or clojure.spec in production? Has it helped you catch bugs that you would have otherwise missed? How does the runtime-only limitation work out in practice?

    I know that flow has prevented me from checking in bugs, because I've tried to push up code with e.g. misspelled property names and the pre-push hook stopped me.