News for hackers. Stuff that matters.
Re:Java 22 Released by HackerThemAll on Tuesday March 19, 2024 @03:36PM (#39759448)
C#'s got even better version of this feature since Nov 2021. Hello world is just a true one-liner.

https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals...

Re:Java 22 Released by masfoobar on Wednesday March 20, 2024 @06:22AM (#39764654)
I really disliked this the first time I saw it. I was like "WTF is this?"

I can only think the reason why they did this was to compete with python, as our scripting languages that do not require a main/Main entry point.

Personally, it just feels wrong for compiled-based languages.

I think they could improve on C# with their namespace. Rather, for example, a typical C# file looking like:-

  using EFG;
  namespace ABC
  {
    public class XYZ
    {
     
    }
  }
They could just :-

  using EFG;
  using namespace ABC;
  public class XYZ
  {
    
  }
Pretty much taken from the C++ way.. but it saves on space availability.
Re:Java 22 Released by neonsunset on Wednesday March 20, 2024 @06:34AM (#39764727)
The second option is what C# defaults to since a few versions ago.
Re:Java 22 Released by masfoobar on Wednesday March 20, 2024 @06:39AM (#39764759)
Correct -- was added since .net 6, I believe.
Re:Java 22 Released by sfn42 on Wednesday March 20, 2024 @06:31AM (#39764706)
Namespace declarations have been a thing in C# for a while
Re:Java 22 Released by masfoobar on Wednesday March 20, 2024 @06:40AM (#39764773)
Yep. Point is it should have been added since Framework 4.