News for hackers. Stuff that matters.
Re:Faster than C? Parsing binary data in JavaScript. by CJefferson on Monday October 08, 2012 @06:19PM (#4628986)
This is true, but a high-level language can avoid having to even make that check, making it "faster than C", in at least some sense of the phrase.
Re:Faster than C? Parsing binary data in JavaScript. by goggles99 on Tuesday October 09, 2012 @03:38PM (#4633538)
If it does not "make that check"... then how does it know? (It does check)
Re:Faster than C? Parsing binary data in JavaScript. by CJefferson on Wednesday October 10, 2012 @06:49AM (#4635780)
A Javascript JIT doesn't have to make the check, because it can simply decide that all memory blocks, and all copies, occur on word boundaries.

One of the problems with optimising C is that you have to assume (in simple terms, obviously the full story is more complicated) whenever a user's function is called, then all of memory might have changed. Even if you have a pointer to a const int, maybe in another part of the code there is another pointer to that int which isn't const, so you have to assume it might have changed.

In a language with different semantics, the optimisers can have a much easier job seeing what is going on, and know what can effect what else. This is the reason that Fortran compilers can often be seen beating C compilers.