Hacker News new | ask | show | jobs
by v-erne 1353 days ago
I wonder - why he has not take it a step further and propose to get rid of return type (void) also? It would look even more slick (add optional semicolons and we will get javascript out of this :)).

main() { println("Hello World"); }

I know that this notation is traditionally reserved for constructors but I'm not 100% sure why we cannot differentiate between methods and constructors just by looking at class name?

1 comments

I see very little gain for quite a high price here. It would break the grammar quite a bit, potentially causing even breaking changes, for something that is usually not absent even in languages that do strong type inference.

The proposed changes don’t have these negatives, while still provide benefits.

It's not as bad as it seems because the language already have constructors. So instead of having a peculiar case for constructors, you unify constructors and methods by saying that void does not have to be specified.

And i do not buy your argument that it will break the grammar, the parser of javac consider constructors as methods.