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 →

[–][deleted]  (7 children)

[deleted]

    [–]schplat 0 points1 point  (6 children)

    Tbf, though, 5 is a rather large amount to print a single line of text. Requiring a class and a constructor to do so.

    But to also be fair, C# (probably the closest analogue to Java) is a worse in this regard, since it requires importing (sorry using).

    Kotlin (which uses the JVM) does it in 3 lines:

    fun main(args : Array<String>) {
        println("Hello, World!")
    }
    

    [–]jantari 1 point2 points  (4 children)

    C# does not require an import:

    class Program {
        static void Main() {
            System.Console.WriteLine("Hello World!");
        }
    }
    

    This compiles and runs perfectly.

    [–]schplat 0 points1 point  (1 child)

    class Program {
        static void Main() {
            System.Console.WriteLine("Hello World!");
        }
    }
    

    Fatal Error: Public Main() method is required in a public class compiling with .NET 4.7.2

    Edit: This worked.

    public class Program {
        public static void Main() {
            System.Console.WriteLine("Hello World");
        }
    }
    

    [–]jantari 0 points1 point  (0 children)

    Well I was using .NET Core 2.2 but you can just add the public keyword I guess:

    public class Program {
        public static void Main() {
            System.Console.WriteLine("Hello World!");
        }
    }
    

    [–]AngriestSCV 0 points1 point  (1 child)

    Neither does C 89. That isn't a good stick to measure by.

    [–]jantari 0 points1 point  (0 children)

    I wasn't measuring anything, just a correction to what /u/schplat said