logoalt Hacker News

zahlmantoday at 3:17 AM1 replyview on HN

> the compiler had enough static information to emit a single arraylength bytecode instruction.

I'm skeptical.

If it can prove that the input actually matches the hint, then why does it need the hint?

If it can't, what happens at runtime if the input is something else?

> We replaced a complex chain of method calls with one CPU instruction.

JVM bytecodes and CPU instructions really shouldn't be conflated like that, although I assume this was just being a bit casual with the prose.


Replies

mkmccjrtoday at 3:40 AM

Thank you for this! On the second point, you are absolutely correct; that was sloppy writing on my part. I will correct that in the post.

I'm not certain I understand your first point. When I add the type hint, it's me asserting the type, not the compiler proving anything. If the value at runtime isn't actually a byte array, I would expect a ClassCastException.

But I am new to Clojure, and I may well be mistaken about what the compiler is doing.

show 1 reply