4 ms·
Yes! With this release clojure.spec is ready to go (tm). It adds a ton to Clojure(script), including better error messages (yes!), data-structure shape declara
by escherize 9y ago
Yes! With this release clojure.spec is ready to go (tm).
It adds a ton to Clojure(script), including better error messages (yes!), data-structure shape declarations, generation of data, writing quickcheck (generative) tests for a function by just describing the args and return values of functions, and more.
- karma_fountain 9y agoYes, but I'm confused. The website still says specs still in alpha so whats the deal? Is the spec api now stable?
- tensor 9y agoSpec is still alpha as far as I'm aware. They decided to break spec off into it's own library because it was holding up the release of 1.9.
- puredanger 9y agoThe API is still subject to change (alpha) but those changes are not expected to be dramatic at this point.
- roenxi 9y agoI'm looking forward to hearing a long-form rational of the :args :ret :fn function instrumenting decisions, and seeing if the devs see it as an easy choice or up for debate. It feels really uncomfortable declaring a full spec for a function & instrumenting it, then getting feedback if the args don't conform to spec but Clojure being A-OK if the return value doesn't. I understand well that in theory the functioning of a function can be fully checked in a proactive test framework, but the process for testing return values is way clunkier and less fun than testing argument values. It just seems weird that the function has a spec, the function doesn't conform and Clojure doesn't seem to be bothered. I can see it will only be a matter of days until I have Orchestra installed for all my projects.
- int_19h 9y agoI'm not familiar with Spec, but what you're describing sounds like enforcing preconditions but not postconditions by default, which is what most DbC frameworks (or languages with intrinsic support) normally do. The idea being that most of the time, you're running library code, and you want to validate what you're passing in, but you trust it to do the right thing for any input that is valid.
- coinme 9y agoThat’s fine, and makes sense, but without hacks, it is not possible to turn on ret checking in your tests that are not generative tests - so no post condition checks in the rest of your test suite. I believe this is a missed opportunity to find bugs.
- bpicolo 9y agoWhy are all the relevant changes for a point release alpha? Why do you reckon this isn’t 1.9-alpha?
- puredanger 9y agoThere are also many changes in the language itself (see https://github.com/clojure/clojure/blob/master/changes.md https://github.com/clojure/clojure/blob/master/changes.md), none of which are alpha. The things that are really the new big drivers are pieces that are not inside the language (other than a few spec integration points). Those things are significant pieces of work that are imminently usable now, but not quite final yet. In the interest of getting this work into more hands, we made a new release of the language with those parts marked as alpha. The modularized spec allows us to continue releasing new versions (and for you to use them) with Clojure 1.9.0. Eventually spec will leave alpha and we will consider that a finalized part of the language. Similarly, tools.deps is still evolving as we work on it but the tools should remain fairly stable.
- WalterGR 9y agobetter error messages (yes!) What are some good examples of this?
- puredanger 9y agoAt the moment, most of the things that are spec'ed in the box are the gnarly macro "languages" like destructuring, defn, ns, etc. These spec'ed macros do catch a far more complete set of error messages than the macro did with custom error handling. However, those error messages are in many case more challenging to read than before. This is an area of ongoing research - the reasons for the complexity are varied. In general, specs for core functions are much simpler and provide much better errors, but we have not focused on adding those yet. This is why some of this stuff is still alpha!
- misterbowfinger 9y agoDo you have an idea of how far along clojure.spec is for a stable, non-alpha/beta release? clojure.spec is by far the most interesting and compelling reason for me to check out Clojure. I would also love for it to apply to ClojureScript as well, although I understand that's a separate project.
- simongray 9y agoSpec is also available for ClojueScript: http://cljs.github.io/api/cljs.spec.alpha/ http://cljs.github.io/api/cljs.spec.alpha/
- puredanger 9y agoYou should try it now - the API has been out and stable for over a year. While it may change slightly, there is no reason not to use it now. https://clojure.org/guides/spec https://clojure.org/guides/spec The ClojureScript version of spec is largely API-compatible as well so the same specs should work in both.