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

> I don't think languages should be privileged in regard to types.

C++, relatively speaking, is not "privileged" with regard to types, but that lack of privilege is bought with great pain, particularly in exception safety mixing with copy constructors. The lack of semantic guarantees when overriding operators - like assuring the unsuspecting library user that x += y does something similar to x = x + y - can also be a genuine problem. Java evaded the whole thing for quite justifiable reasons, IMO, and C# implements operator overloads in relatively specific ways to avoid some of these problems - and still doesn't let you have copy constructors, assignment operators, or destructors on value types.

By baking in certain assumptions about types into the language, the commonality across all code written in the language is increased, and the costs of documentation and communication at independently developed library boundaries is reduced. There are also other benefits; with baked-in knowledge, the language may support value literals for specific types in the lexer and parser. Doing this in a non-"privileged" way would require macros or compiler plugins, which are themselves undesirable for a whole set of other reasons.




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

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

Search: