This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-09-21
Channels
- # announcements (12)
- # architecture (26)
- # beginners (165)
- # biff (19)
- # calva (25)
- # circleci (2)
- # clj-kondo (25)
- # clojure (70)
- # clojure-dev (17)
- # clojure-europe (37)
- # clojure-nl (1)
- # clojure-norway (22)
- # clojure-spec (10)
- # clojure-sweden (1)
- # clojure-uk (24)
- # clojurescript (10)
- # clr (9)
- # cursive (17)
- # data-science (2)
- # datahike (1)
- # deps-new (1)
- # dev-tooling (3)
- # emacs (3)
- # events (7)
- # helix (10)
- # honeysql (1)
- # hugsql (3)
- # humbleui (3)
- # hyperfiddle (30)
- # introduce-yourself (3)
- # jobs (1)
- # malli (4)
- # music (1)
- # off-topic (3)
- # pathom (3)
- # polylith (6)
- # portal (7)
- # re-frame (16)
- # reitit (3)
- # releases (3)
- # remote-jobs (1)
- # shadow-cljs (23)
- # xtdb (14)
(One of those "just curious" questions 🙂)
Is there an intrinsic reason why spec (1) is slower than Malli? It's relatively common to hear that it's not performant enough to be used in something like a web handler. However it doesn't sound too crazy to implement some sort of drop-in replacement for a few key functions like conform
.
One would still use the regular spec/def
for definitions - the custom checker could simply read the original registry.
Never had a significantly slow spec such that it matters for web app... For data generation yes, it can be slow and can be fixed by tweaking generators. Is there an example?
'That matters' is the tricky part... for many webapps a 1ms delay doesn't appear to matter, but if you are trying to serve thousands of requests per second, it becomes the bottleneck
We use conform
heavily in our main REST API at work and it's "fast enough". I guess if you have an app where Spec's performance matters and Malli satisfies while Spec does not, then use Malli?
We've never seen Spec as a bottleneck. JDBC stuff, yes. Elastic Search stuff, yes. Spec, never.
I once participated in a project where we used, roughly speaking, spec for code (fdefs and the like), and malli for data. Wasn't bad, I might even enjoy exercising all those skills on a good day, but it doesn't seem ideal. I'm a spec1 fan and would rather use it everywhere... but its performance is theoretically inferior. Again, you can say the same about e.g. Rails or Python web servers. In reality CPU is rarely the bottleneck, as you hint... but some of us enjoy squeezing the last drop of performance. Knowing it can do fast coercion, validation, etc can help in the occasional team-wide decision making processes.
Reflecting a bit, a later project used Malli in a more advanced way. I had the impression that you could go as far as building "your own spec1" but in Malli terms. Would seem a clearer path than hacking on spec1, as it is a stalled project.
w.r.t conform
vs decode/encode
in malli a lot more optimization work is done at 'compile time' (in the sense of constructing a chain of lambda functions to arrive at a a parser)
e.g. in malli , it's possible your decoder/conform compiles to an identity function