Fork me on GitHub
#cljs-dev
<
2018-09-23
>
mfikes20:09:59

Interesting view regarding type inference and compiler perf: The primary purpose of types (hinted or inferred) in ClojureScript is so that the compiler can leverage types to generate optimal code. While static type checking during dev is of secondary interest, a fundamental problem is that, as you add stronger type inference, you end up with compiled code that needs to be invalidated because types changed due to dynamic re-definition at the REPL. (This is similar to how premature static arity dispatch is a bad thing in the REPL and :static-fns is disabled.) Many of the type inference tickets currently in flight are proving difficult to pull off without harming compilation performance (at least a little). So... perhaps thinking of it as a knob that you turn on, akin to :advanced, would put us down a path where the cost of type inference isn't that critical, and we could afford to consider somewhat more expensive inference algorithms that we would otherwise object to.

4
john21:09:48

Or do you have a branch somewhere with a diff on github?

mfikes21:09:49

@john All of the diff is in the -5 patch.

john21:09:05

Just spitballing here, but we go so far as to make a new knob for type inference, I wonder how much Ambrose work and spec could also play into that knob...

john21:09:05

or if, in the other direction, this new stuff could be libified... Seems pretty deep in the guts of things though.

mfikes21:09:08

Ahh, interesting. Cook up some ways to control various aspects

:type-inference {:internal 11, :spec :core-preds, :typed-clojure some-lib/fn}

mfikes22:09:29

^ Seems complicated, maybe a simpler way to convey intent

john22:09:55

And, perhaps some ability to leverage existing specs to populate the hierarchy?