HN Theater @HNTheaterMonth

The best talks and videos of Hacker News.

Hacker News Comments on
Clojure spec Screencast: Leverage

ClojureTV · Youtube · 7 HN points · 1 HN comments
HN Theater has aggregated all Hacker News stories and comments that mention ClojureTV's video "Clojure spec Screencast: Leverage".
Youtube Summary
The new Clojure spec library provides support for data and function specification. In this screencast, Stuart Halloway discusses how spec provides leverage to achieve many returns for a small investment in describing your functions with spec.

spec provides leverage in the following areas:

- Validation
- Conformance
- Destructuring
- Error messages
- Composition
- Example Data Generation
- Assertion
- Documentation
- Generative Testing
- Instrumentation
HN Theater Rankings

Hacker News Stories and Comments

All the comments and stories posted to Hacker News that reference this video.
I worked with Elm for 2 (or maybe 3?) years, and with Clojurescript for another 2. I recently had to decide on which of the two I would use on my next project, and it was definitely not an easy decision. Ultimately, I went with Clojurescript.

Main Clojurescript pro was re-frame[0]. Re-frame makes state handling easy and, especially importantly for performance-sensitive projects, it entirely removes the (rather common) problem of re-renders with the way its subscriptions are handled. This, plus the ability to have your entire stack in a single (amazing) language, were the tipping points to me.

While you can't achieve the same level of compile-time safety in Clojurescript, you can apply "state checks" (with Spec or any custom validation mechanism) any time your state changes. And with re-frame, it is extremely clear when your state changes, therefore you can block any invalid state from being saved and catching it as soon as it happens. Again, not the same kind of safety you have with Elm, but to me it's a good-enough trade-off.

And that's exactly what I do with my code: every time my state changes, I run a validation check on the keys that are about to change. If their value is deemed invalid, an error popup (identical to old Windows XP error popups, because why not) will appear, stating what the invalid state is and what it should be like instead, as well as which event led to this state in the first place. This check is so fast I don't even need to disable it in the production build (but instead of a popup we get a notification that an invalid state error happened).

In fact, there's this (non-mainstream) argument that runtime checks bring even more power over typing: https://www.youtube.com/watch?v=nqY4nUMfus8

TL;DR: Not an easy decision, but the truth is whichever one you pick, it will be a great choice.

[0] - https://github.com/day8/re-frame/

Dec 18, 2016 · 2 points, 0 comments · submitted by tosh
Jul 14, 2016 · 3 points, 0 comments · submitted by gniquil
Jul 13, 2016 · 2 points, 0 comments · submitted by hessammehr
HN Theater is an independent project and is not operated by Y Combinator or any of the video hosting platforms linked to on this site.
~ yaj@
;laksdfhjdhksalkfj more things
yahnd.com ~ Privacy Policy ~
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.