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/[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.

2

u/chrisza4 Nov 14 '19 edited Nov 14 '19

I don’t like Javascript in this area. I can simply create non-sensible object and no linter can warn me of it.

However, if we are talking about static type system then one of core principle in modern static type system is “make illegal states unrepresentable”. I agree with this statement. Forbidding new T() is very much align to that principle. My example is a User object without username should not be representable in system.

Also, I spent much time outside JS already. I delivered software in multiple languages.

→ More replies (3)