3 ms·
C, Rust, Go. There are probably many more. But I think you might be overall misinterpreting my original comment. I was responding to someone who said they stil
by kamranjon 4y ago
C, Rust, Go. There are probably many more.
But I think you might be overall misinterpreting my original comment. I was responding to someone who said they still commonly find unpredictable behavior in Javascript that they were unaware of after using it for years. I just responded with something I recently discovered in a similar vein, and you appeared to take it as some sort of statement about Javascript as a language. I really enjoy Javascript, and I was really just highlighting a recent example I ran into that gave me the same feeling conveyed in the original comment I was responding to.
- cxr 4y agoC does not throw an error. C does not even have the infrastructure to throw errors. The closest thing are signals, and it doesn't use those for this issue. Go is similar to C, C#, Java, JS, etc in the sense that if anything is to be done about it then the expectation is for it to be flagged as part of typechecking before runtime. I don't have enough experience with Rust, but I'd be willing to bet that it doesn't do what you're saying, either.
- kamranjon 4y agoC throws a warning, because you need to manually cast to get expected behavior. But it does not behave the same as javascript, try it yourself, you will not get "44" when you add "4" to 4. Go does not support implicit type conversion, so no it does not behave the same as Java or Javascript, and will throw an error. Rust does not allow adding an integer to a string and will also throw an error. I suggest actually trying these things yourself, we are talking about adding an integer to a string, or subtracting an integer from a string. Obviously many languages will throw an error when trying to do this.
- cxr 4y ago> C throws a warning [sic] No, it doesn't. Nor does it throw an error. Once again: C does not even have the infrastructure to throw. Not just when adding numbers and strings, but anything. Ever. In any circumstance. > it does not behave the same as javascript Who said it did? > I suggest actually trying these things yourself Likewise (especially if you're going to be condescending about it). > Obviously many languages will throw an error when trying to do this. That's not obvious. I've asked you for examples, and you've named multiple ones that definitely don't. (And this is not an attempt to be rude, but rather frank: at this point in the discussion you come across as someone who, despite having probably used several handfuls of languages including the ones you mention, has a lot of confidence but only a coarse understanding and/or loose appreciation of the relevant concepts at play—down to confusing the distinction between compile-time vs run-time behavior.)
- kamranjon 4y agoC: "4" + 4 = 8 warning: assignment to ‘char’ from ‘char *’ makes integer from pointer without a cast Go: "4" + 4 invalid operation: "4" + 4 (mismatched types untyped string and untyped int) Rust: "4" + 4 error[E0369]: cannot add `{integer}` to `&str` Listen - you can argue semantics all you want but unless you try these things yourself, we're not going to get anywhere. You asked me for examples of non-dynamic languages that don't behave the same as javascript, I provided them. I feel like maybe you took my suggestion to actually try these things out as condescending, it wasn't, I was trying to be constructive. This is a discussion about what languages allow you to do, compile-time vs run-time is irrelevant, if we get a warning or an error at compile-time vs run-time it makes no difference. The point is that Javascript silently hums along with no warning or error at all when you try to do something that many languages would not allow you to do without at least a warning. You can dig down into a semantic rabbit hole about what "throw" really means but I think you understand what I'm talking about.