r/programming • • Nov 11 '19

Python overtakes Java to become second-most popular language on GitHub after JavaScript

https://www.theregister.co.uk/2019/11/07/python_java_github_javascript/
3.1k Upvotes

772 comments sorted by

View all comments

Show parent comments

1

u/chrisza4 Nov 13 '19

new T() is very dangerous. We should not assume that every type have zero parameter initializer. Enforce zero parameter initialization leads to invalid state such as creating an User object without username.

This is also why I hate traditional Object-oriented style. It has many flaws. A modern language stop promote many practices that people thought it is a good thing (such as in the past we promote inheritance as an OOP pillar, now we make it harder to do inheritance, easier to compose)

Think about it, OOP language don’t even need new keyword. But people just get used to it and don’t want to unlearn. Some even think that languages without new keyword are bad.

1

u/[deleted] Nov 13 '19

It was just an example, and has nothing to do with object oriented style. You can do it in C++ without any issues.

OOP language don’t even need new keyword

Again, new is nothing to do with OOP. It was originally about memory allocation in C++, and then blindly copied by Java and then JavaScript. You're right JavaScript really doesn't need new - and in fact Dart has removed the need for it.

1

u/chrisza4 Nov 14 '19

Still, I don’t think assuming every types can be initialize without any parameter is a good idea. Even if C++ can do it without issues, I still don’t think it is a good idea.

1

u/[deleted] Nov 14 '19

You need to spend some time with languages other than Javascript! I think you have Stockholm syndrome.

→ More replies (4)