#!/usr/bin/perl

Mar 11, 2010 13:17

print "Hello World.\n";

- Jux

Leave a comment

kotukawi March 12 2010, 02:34:56 UTC
C#

namespace MyNamespace
{
class MyClass
{
public static void Main(string[] args)
{
Console.Out.WriteLine("Hello world!\n");
}
}
}

Reply

juxtapose_42 March 12 2010, 06:40:26 UTC
Hm. My way seems more... compact.

- Jux

Reply

includedmiddle March 12 2010, 07:08:51 UTC
I see perl has begun to corrupt you already!

http://www.python.org/doc/humor/#python-vs-perl-according-to-yoda

Reply

kotukawi March 12 2010, 09:22:09 UTC
True. One of the interesting... "quirks" of modern languages -- Java and C# primarily -- is that creating more visual forms of text is almost more simple than writing out plain text to the console. For example:

class MyClass
{
public static void Main(string[] args)
{
System.Windows.Forms.MessageBox.Show("Hello world!");
}
}

That would probably be significantly harder to recreate in few lines in Perl. Similarly, there are things in Perl that are easier to do than in C#. Languages are merely tools, and for each task, not all tools are the same. :)

Reply

krizoitz March 12 2010, 08:01:39 UTC
when using WriteLine the \n is going to give you two lines not just one :) You were probably looking for Console.Write(). Out isn't really necessary either.

Reply

kotukawi March 12 2010, 09:18:26 UTC
True. And I was writing dang quickly after a busy day of not using C#. But that doesn't make the example necessarily wrong. :)

That said, I also believe having the namespace declaration to be completely superfluous. Not entirely sure on that point since I haven't written much in the way of C#, but there you go.

Reply

shabubu March 18 2010, 08:47:24 UTC
C# has you using namespaces all the time. It's part of the language framework. Makes things nice in C#. Pain in the butt with C++.

Reply


Leave a comment

Up