Hacker News new | ask | show | jobs
by nicobn 3704 days ago
The point that was made is that multiple (static) classes cannot be declared in the same file, which is 100% false. I'm not arguing that C# is functionally equivalent to Java. There was no mention of "compilation unit" or "partial classes", which are a completely different subject.

It doesn't matter whether the additional classes defined in the file are top level or not, they're still classes that can be used independently.

1 comments

You are being disingenuous. "File" is layman-speak for "compilation unit", so it is not a "completely different subject". You cannot declare multiple top-level types in a single compilation unit in Java. Yes, you can create static types within another type. However, those are not top-level types; they are scoped within the type they are declared in.

Let's just put it this way. Would a Java programmer, by way of normal operation, implement a project with a few Java files, each of which contains a type with several static types internal to it, and where those internal static types are in fact the main types of the program? If they wouldn't, then there is no equivalency, because this is something you see in C# code bases all the time.