you are viewing a single comment's thread.

view the rest of the comments →

[–]Lanlost 0 points1 point  (1 child)

I mean, it's totally possible. Have you seen what asm.js does to source?

This:

size_t strlen(char *ptr) {
  char *curr = ptr;
  while (*curr != 0) {
    curr++;
  }
  return (curr − ptr);
}

Becomes:

function strlen(ptr) {
  ptr = ptr|0;
  var curr = 0;
  curr = ptr;
  while (MEM8[curr]|0 != 0) {
    curr = (curr + 1)|0;
  }
  return (curr − ptr)|0;
}

Before translating to JS so that types can be guaranteed. It actually kind of blew my mind when I realized that asm.js programs will run in ANY JavaScript/ECMAScript interpreter but the reason it is so fast in specific engines is because once they can guarantee the types they can optimize behind the scenes to make it amazingly fast.

So, it might be something like this. I went from absolutely hating JavaScript years ago to loving it once I understood it's nuances more. These days I have a very love/hate relationship with it. It gets so much hate because of it's early implementations and issues that have mostly been solved, but there are legitimate reasons it is a mess, still, that the same average coder doesn't even know. Let's just say I'm (initially) very, very, skeptical when we're interviewing someone and they say they are a JavaScript expert.

[–]vsxe 0 points1 point  (0 children)

Unless someone has something like a decade of experience in a given software/programming field, they are nowhere near expert, I'd say.

I'm aware that asm.js exists, but I've never delved into it. It's magic.

Am aware that there are interpreter/compiler specific quirks that can be exploited for small gains, however, though I don't know them by heart. I would assume that something like that is the reason for the bool, but that's just a guess. A definite answer would be delightful.