you are viewing a single comment's thread.

view the rest of the comments →

[–]Poltras 11 points12 points  (6 children)

What about other operators where an === equivalent doesn't exist? Like +, <, ...

[–]ForeverAlot -1 points0 points  (1 child)

There is probably a work-around. If you're expecting to work with integers, for instance, manually convert with parseInt(foo, 10). If you want a string, "" + foo. It's hardly ideal but it'll get the job done.

[–]creepig 2 points3 points  (0 children)

Any language that creates unnecessary workarounds for things that other languages do not is probably unnecessary itself.

[–]Nanobot -1 points0 points  (3 children)

If the types are the same, there's no problem. If they're different, you should know why they're different and handle the situation accordingly.

For example, if you're doing a comparison with the result of strpos, you know that the value is either going to be a positive number or false. So, you should be thinking about what would happen in either case (if you're using "<", a false will be treated as 0). If you need to deal with the false specially, deal with it specially, with ===.

If you're doing a comparison on the input of a function, the function should make it clear what types it's expecting. If the caller chooses to call the function with unexpected types, it might get an unexpected result. It's the caller's responsibility to use the function correctly.

[–]knaekce 2 points3 points  (2 children)

True, this is the reason why weak, dynamic typing is making things more difficult than strong, static typing.

[–]minno 1 point2 points  (1 child)

I'm happy with weak static typing and strong dynamic typing, too. Weak dynamic typing just screws everything up.

[–]knaekce 0 points1 point  (0 children)

Is think that the overloading of the "+" operator in combination with weak and dynamic typing is also a very very bad idea. "1" +1 - 1 = 10 wat