So I was wondering what my opinion is about that.
I don't like it a lot, as now it seems like calling a constructor looks similar to calling a method.
The only difference that's visible is that the constructor begins with a capital, and then only if you properly follow the coding style guidelines.
I noticed that where Java prefers clarity of purpose, Kotlin prefers brevity (and sacrifices clarity for this).
In Java the "new" keyword does a lot of heavy lifting, that is not part of the constructor. The constructor merely sets the internal structure of an object-to-be to appropriate values. The responsibility of actually making the object, registering it in de Heap, doing the pointer bits, is indicated by the new keyword.
What are your opinions?
References
- Reddit - Is keyword new redundant?
- https://www.reddit.com/r/java/comments/1n0m7cg/is_keyword_new_redundant/
- Kotlin Documentation - Classes
- https://kotlinlang.org/docs/classes.html
No comments:
Post a Comment