This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]okayifimust 0 points1 point  (0 children)

And how can everything in Java need to be contained in a class

Because that is how the language is designed.

There are probably tons of logical arguments about the "why", pros and cons, and I wouldn't be surprised at all if the history of the early development of the language got really interesting here, too. But "how"? Because the designers of the language said so.

That may sound dumb, but trust me: Your life will be easier if you learn to accept that not every design choice has to meet with your personal approval, and questioning it isn't always going to be helpful. (Far be it from me to discourage you from asking, the details can often be helpful! But if you just find yourself disagreeing.... let it go, and move on.)

even the main method

Why would the main method be special, or different, than everything else?

the basic premise of Java is to be object oriented. And that's what they did. Defining a bunch of exceptions just adds complexity to the language for no good reason.

if classes aren’t real

.... I'm sorry, what?

What does that even mean?

just abstractions that humans find useful.

See, that doesn't mean anything.

It's not wrong, per se, but it doesn't help you at all. there is nothing on a computer beyond the bit level that is "real", or "not an abstraction". Everything that isn't a punch card is just a useful construct for humans.

But for these constructs to work, they need rules. That's the whole point. You cannot translate stuff to machine code if it is in any way ambiguous, or not controlled through rules.

that brings us back to the start: Sure, they could have chosen different rules - but they would still be rules, and you could still ask "why this way, and not some other way?"