On Saturday, 11 February 2023 at 02:18:48 UTC, thebluepandabear
wrote:
What attracts me to D, is the inability to program outside of
a class in C#. I think they are trying to find ways to make
this happen, but I wouldn't hold my breath.
programming outside of a class is overrated though in my
opinion. i've never seen a usecase for it in an object oriented
language. Of course Kotlin can do this, which is good, but you
can just create utility classes (i.e. `static class` in C#,
`final class` in Java with a private ctor, or Kotlin `object`.)
Yes, it's overrated, I agree, especially with C# static classes.
still... in Swift, you can do hello world, just like this:
print("Hello World!");
Of course in C# dotnet 5, you can use top-level statements now:
using System;
Console.WriteLine("Hello World!");
(but that's just syntactic sugar .. the class, main etc. is
actually generated behind the scenes.) I don't use top-level
statements though, as find them completely pointless (and
annoying) in C#.
The shortest syntax in D, for hello workd - as far as I know, is:
import std.stdio;
void main()
{
writeln("Hello World!");
}