Fork me on GitHub
#cljs-dev
<
2018-11-06
>
didibus03:11:01

@dnolen Does that exclude @mfikes prototype then? I guess I'm not sure what numerics cover. I'm talking about warning on primitive type mismatch only. Once you implement it for arithmetic functions like +, -, etc. I don't see why you'd go out of the way to prevent using it for other functions?

mfikes03:11:56

@didibus FWIW, the bottom half of that gist explains my motivation for that exploration: It is not to infer parameter types for the purpose of type checking, but instead for optimal code generation. In short,

(defn xyzzy [x] 
 (subs x (dec (count x))))
can be compiled down to
function cljs$user$xyzzy(x){
return x.substring(x.length - 1);
}

didibus04:11:43

Yes, I know. And that's awesome. But type checking is a spectrum. For example, ClojureScript performs less of it than Clojure. Such as (+ 1 "1") not being checked at runtime. Now, ClojureScript has some type checking done at compile time, where it will warn on possible type mismatch. Your branch takes it even further. So, I'm very much on the pro dynamic side of the spectrum. I don't want to be limited by my type system, or have to switch to a type based paradigm. I'm onboard with using datastructures for data modeling, and not being forced to declare anything extra about my code just so it lets me run it. But, if I'm already forced to define type hints for performance, and the machinery is there to also warn me of potential bugs in my code, then why not? Similarly for inference, why not warn me of strange things that are most likely bugs? I understand the: because it would take a lot of work and it's not the priority argument. What I'm unsure I understand is if there are other reasons and what those would be?

mfikes04:11:36

Yeah, even though the changes in that branch were not motivated by a desire to warn on the kind of type mismatch your example illustrates, it does indeed do that type check. Why? My only rationale is: Once you’ve inferred parameter types and also inferred argument types, why not type check? 😀

mfikes04:11:25

To be honest though, the fact that the compiler today doesn’t generate optimal code for xyzzy is really what is driving me.

mfikes04:11:04

(The optimized variant runs about 4 times faster in :none mode.)

didibus04:11:12

> Once you’ve inferred parameter types and also inferred argument types, why not type check? Yes, sorry, erm, what I meant was: Why not, not type check? If the machinery is there. I felt like @dnolen was aluring to some other reasons why it would be restricted to numerics and maybe even simply performance without even type mismatch warnings.

rarous04:11:23

@didibus ClojureScript already has type checking (thanks to GCC), if you want less bugs, you can use it https://github.com/clojure/clojurescript/wiki/Compile-Time-Type-Checking.

richiardiandrea05:11:28

Wow that looks pretty dated. Is it still working as advertised?

rarous18:11:27

sure, GCC uses doc comments for type declarations

didibus04:11:19

@rarous Hum, that's good to know. That said, I'm not really looking for static type checking. I'm looking for something that can warn me of potential bugs, without me being required to change anything in my source code. So, something that can infer types, or leverage my existing type hints, which I have to include currently because of performance reasons. @mfikes’s branch is really promising in that regard. That's also why I don't buy the argument that Spec is better suited to this. Spec is additional work on my part. Though I wouldn't mind automatic inference from my existing Specs which could also warn of potential inferred Spec mismatches 😛

dnolen11:11:57

@didibus Clojure doesn't really do that much out of numerics - it falls out of JVM stuff

dnolen11:11:38

anyways, while appreciate the enthusiasm in this area - I've already stated what we're interested in for the time being

dnolen11:11:07

type hints are not for type checking - no amount of discussion is going to change this - this is exactly Clojure's own stance

mkvlr14:11:16

fwiw our tests pass with cljs 1.10.439

👍 4
borkdude16:11:02

our build got 8 seconds faster 🙂

dnolen17:11:45

@borkdude what were they before?

borkdude17:11:27

@dnolen

339: Elapsed time: 77.649 sec
439: Elapsed time: 71.927 sec

dnolen17:11:47

@borkdude for the advanced build?

dnolen17:11:53

not going to be a huge change there

dnolen17:11:59

oh ok - interesting

borkdude17:11:30

we use boot, not cljs.main, does that matter?

dnolen17:11:09

I don't think it should, but unsure

borkdude17:11:15

parallel, I’ll try

mfikes17:11:39

I have a project, where switching from 1.10.339 to 1.10.439 and also enabling :parallel-build dropped it from 21.5 s to 9.1 s.

borkdude17:11:16

I had parallel-build enabled a while back, but I disabled it when I was looking for a weird error

mfikes17:11:16

(To measure this stuff, be sure to blow away ~/.cljs and also do a clean build in your project, and use :compiler-stats true.)

borkdude17:11:36

with boot there’s nothing to clean afaik

dnolen17:11:42

right to ignore other aspects of tooling time

dnolen17:11:05

it seems pretty common for some tooling setups to take more than 10 seconds

borkdude17:11:17

ok, turning that on

borkdude17:11:56

Output with 439:

Compile sources, elapsed time: 21441.956571 msecs
Compile sources, elapsed time: 1103.507717 msecs
Elapsed time: 60.640 sec

borkdude17:11:19

now with 339:

borkdude17:11:54

Compile sources, elapsed time: 25784.826339 msecs
Compile sources, elapsed time: 1536.513698 msecs
Elapsed time: 66.553 sec

dnolen18:11:42

@borkdude thanks, yeah some projects will definitely have more modest gains

borkdude18:11:02

I’m ok with every release that’s not slower 🙂