by dkarapetyan · 9y ago · 0 comments
Guess I can also solve all pointer aliasing problems by just adding "if p != q {...}".
Note: I'm one of these compiler writers. In fact, i'm one of the compiler writers who wrote the current aliasing implementations for the two major compilers everyone uses, among other things. If you are going to disagree, please be concrete. I'm stating that good enough aliasing algorithms exist to do what you want, and where you can't, you can do runtime checks.
People who truly care about performance hand the compiler the whole program, and want it to do a great job. It can and will. Your counter argument is what, exactly.
That because people spend time getting type systems right, this must be false?
If so, that's just silly. People spend time on getting type systems right to make it easier to reason about for people. Not because it's impossible at the compiler level. But because they'd rather not have to do it if they can avoid it. That doesn't mean it can't be done, and isn't done.
Seems like all I need to do is bone up on alias analysis, JITing, and inlining and I'm good to go.
In the meantime, i'll just point out, you can have the nicest type system in the world. It still has to translate into concrete aliasing info about pointers that is usable by both high and lower levels, and is queryable in O(1) time, without taking up a ton of space. Otherwise, it's just sitting there making guarantees no one can use.
"Seems like all I need to do is bone up on alias analysis, JITing, and inlining and I'm good to go."
For most code, yes, actually, that's probably just about right.
Instead you made a bunch of disparaging remarks, trivialized large swaths of CS theory, and failed to see the actual point of my comment in connecting type annotations as mechanically verifiable invariants/assumptions that can be used in optimization pipelines.
Yeah.
> I wonder then why all these compiler writers spend so much time on getting the type system right if all they need to do is just add some if statements then add a JIT.
Because (1) JIT has a latency hit users like to avoid, and (2) you still have to solve the same problem during JIT time, it doesn't magically go away.