3 ms·
> Plain wrong, types are semantically equal in both languages (they are weak). Nope. Try evaluating (+ 1 "1") in Clojure as well as Clojurescript. One is weak
by darksaints 6y ago
> Plain wrong, types are semantically equal in both languages (they are weak).
Nope. Try evaluating (+ 1 "1") in Clojure as well as Clojurescript.
One is weak...it doesn't throw an error, might throw a warning because the compiler can plainly see that it is wrong, but you'll get no warnings when it is out of scope or evaluated at runtime.
The other is strongly typed, because it will actually throw an error, knowing that adding a string and a number is nonsense. While it would be better if this was caught at compile time, catching it at runtime is waaaaay better than not catching it at all.
The languages are actually different languages, because their type semantics are different. And you might want to figure such things out, as well as the far reaching implications, before you go around telling people they're wrong on the internet about a language that is laying in the mud like a crocodile, waiting for the perfect time to bite you in the ass.
- kolme 6y ago> And you might want to figure such things out, [...] before you go around telling people they're wrong on the internet Apply it to yourself my friend, you are wrong again. What you are talking about here is implicit type coercion, which doesn't have much to do with strong vs weak types. Also in your example you do get a warning, so it doesn't seem to be a problem?
- darksaints 6y agoImplicit type coercion is exactly the difference between strong and weak types. FFS. https://www.educative.io/edpresso/statically-v-dynamically-v-strongly-v-weakly-typed-languages https://www.educative.io/edpresso/statically-v-dynamically-v... And if you really do not believe that to be a problem because the compiler warned you about it, I bid you the best of luck. You're gonna need it. There are dozens of ways that bug can sneak its way past the compiler where you won't get a warning because the compiler only does local type inference.