Skip to content

Comment on The Wake Programming Languageparent

Comments

I think that whether the semantics of the language make sense to a particular person isn't really the criterion for type-safety. The language does define what should happen in the case of the expression ([]+{}), so no violation of the type system occurs and the behaviour of the program is well defined.

More examples of js insanity here (1:20):

https://www.destroyallsoftware.com/talks/wat

How about {} + [], is that deliberately zero, and why is addition not commutative in this case if it is allowed? Or {} + {}?

I think most people would infer type safety to mean that attempts to coerce types which are meaningless result in an error, not meaningless output, like the result of "string" - 1, or {} + "string" or {} + []. Otherwise your type system isn't going to stop you doing something insane by mistake, and is therefore not adding any safety.

{} + "string" or similar just shouldn't be allowed, and in most languages (let alone type safe ones), it is not.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.