Hacker News new | past | comments | ask | show | jobs | submit login

Posts like yours demonstrate that you're arguing fervently about asm.js without having used it. One obvious error:

My guess is that you meant that asm.js has a bunch of properties that are statically verifiable, and it validates conformance at compile time. That is great, but not really the same as "no undefined behavior". At a glance, asm.js has undefined behavior. For example: "As JavaScript functions, they produce the undefined value, but asm.js code is not allowed to make use of this value"

'Not allowed to make use of this value' means that the asm.js application will not get AOT compiled if it tries to use the value, because it's not a valid asm.js application. So the behavior isn't 'undefined', it doesn't work. The AOT compiler rejects it and it runs as regular JS, in which case the behavior is 'defined' in that it works the way all other regular JS does.

asm.js is specced and there's a verifier; if you pass the verifier your code should behave predictably in an AOT-compiling runtime. The runtime isn't producing code that does dynamic type checks at runtime or other sorts of nondeterministic behavior.

It's certainly possible that some undefined behavior slipped into the spec somewhere, but I definitely haven't seen any actual examples where they specced it and the Firefox implementation generates undefined behavior on purpose. That would be insane. asm.js delivers the same safety guarantees as regular JS; you can't do that with undefined behavior ala C.

Ultimately if you have concerns about the safety of asm.js or the presence of undefined behavior, you should test it and report bugs. I've tested asm.js some and played around with it and have not found any reason to be concerned.




"Posts like yours demonstrate that you're arguing fervently about asm.js without having used it. One obvious error: "

Sorry, but no. Also, I was addressing points made about LLVM IR, and the asm.js specification, as well as it's suitability as a compiler IR. I've used asm.js, i've read and understood the current optimizing compiler implementation, as well as the published roadmaps and mailing lists.

I don't appreciate the unrelated attack, it was completely unwarranted and unnecessary. The fact that I don't agree with you does not mean "I haven't used it".

" So the behavior isn't 'undefined', it doesn't work."

You completely misunderstand undefined behavior.

The behavior is undefined, it is simply verified at compile time that the program does not perform it. That does not make it less undefined, it makes the program "statically checked" as opposed to "dynamically checked" or "not checked at all" (like most C, though it's worth pointing out it's entirely legal for a C compiler to reject code producing undefined behavior, it's only required to accept implementation defined behavior).

Exactly as I said, C programs (or others) that exhibit undefined behavior are in fact noncomforming, in exactly the same way that the asm.js program would be noncomforming. The only difference is when and whether checking and rejection of nonconforming behavior is performed.

If you are going to argue about language specifications, and make claims about them, you need to be precise.

pcwalton likely meant to make the claim that asm.js itself is safer because it has no undefined behavior at runtime, as it rejects programs that may exhibit undefined behavior at compile time (or something similar), which is at least possible to be true, though i would have a lot of trouble believing it without some formal proof (the spec offers none). It is incredibly hard to actually come up with things like this that are completely statically decidable and still useful.

Your definition of behavior that does not meet the spec as "defined" because "it works the way it all regular JS normally does" is a hilarious new definition of 'defined behavior'.

Also, would you like to refute any other point I have made about how pcwalton has completely misrepresented a lot about LLVM IR?


DannyBee, it is you who are demonstrating considerable misunderstanding here (and in other posts here).

To respond to your comments in this post, the asm.js validator is not checking for undefined behavior. In fact, it has nothing to do with undefined behavior whatsoever. It also has nothing to do with decidability. It is merely determining which execution strategy to use. And, behaving according to a spec is actually a pretty ordinary definition of "defined behavior".

You have misunderstood how asm.js works, you have misunderstood other people's comments, and you have mischaractarized LLVM in other posts here. I know you're capable of much higher-quality discussion than this. Please take a moment to reflect.


"To respond to your comments in this post, the asm.js validator is not checking for undefined behavior."

So let's start simple:

asm.js's validator does in fact, statically try to decide asm.js spec conformance. That means it is checking for undefined behavior, since it is checking whether the program meets the language specification, and the language spec disallows various undefined behavior. I'm not sure how you could characterize it as anything else, when the spec itself says this is what it does:

"This sublanguage effectively describes a safe virtual machine for memory-unsafe languages like C or C++. A combination of static and dynamic validation allows JavaScript engines to employ an ahead-of-time (AOT) optimizing compilation strategy for valid asm.js code."

Note: it says it uses static and dynamic checking to validate spec conformance. It also claims it is safe. Such claims and static program validation of any sufficiently complex language, like asm.js, involves decidability issues and issues about undefined behavior. Period. If you disbelieve this, all I can suggest is delving into the field of program validation and static analysis. I completely understand the cases it cannot validate fall back to normal javascript engine execution, but that actually changes exactly nothing about what the validation is doing, the language specification, undefined behavior, whether it has fundamental limitations, etc.

"You have misunderstood how asm.js works, you have misunderstood other people's comments, and you have mischaractarized LLVM in other posts here. "

I disagree that I have done anything of the sort. Starting from the last, I have not mischaracterized LLVM in any way.

What I see here is a discussion with people who are trying to make very imprecise comments about very precise technical specifications and definitions, and then argue about them. I feel like i'm trying to argue physics with a bunch of chemists. It's not that they aren't smart, it's that they are abusing terminology and trying to make nonsense out of very well understood issues in the field.

In fact, i don't believe anyone working in the compiler field (even on asm.js) would disagree with anything i've said, because as far as I can tell, they understand these are all issues, and try to stay away from ridiculous claims about competitors.

pcwalton originally made some very direct claims about LLVM's IR, and asm.js. I have pointed out they are directly false. That is not mischaracterizing LLVM, or asm.js. It is in fact, a response to such mischaracterizations. Out of kindness, I did not originally point out that a very trivial reading of any paper on LLVM, it's bitcode, or the IR, would have shown that his claims are false, and instead responded directly. The very first LLVM paper ever written even covers exactly the claim he makes about portability, platform independence, and specificity. He would not have had to look very far on the website to find a refutation.

I actually have no real love for either (they are both a set of engineering tradeoffs). I just cannot stand to see one side or the other pretend that the other side is completely horrible, and that they have chosen "the one true path". I am also not going to watch one side or the other make claims that are simply false in an attempt to support that path.

In any case, i'm not going to argue about it anymore here, as it is a mild exercise in futility. You are welcome to believe what you like about asm.js and LLVM, and their relative merits.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: