RSS

Hello world!

18 Dec

So the default title for the first post on a WordPress blog is fittingly, “Hello world!”  Seeing as how this blog is going to center on my programming-related projects and adventures, why not start it off by looking at how this classic programming greeting varies over four languages I know (okay, my correct relationship with Java would be “familiar,” but we’re not doing anything too tough):

C:  printf(“Hello world!\n”);

// <– that means comment in these languages

// \n is the escape character for a newline

C++: cout << “Hello world!” << endl;

// cout is standard output to command line; you can use it by including the “iostream” header file

// << is normally the bitwise operator, but it is overloaded for use in the iostream family.

// The function header looks something like this:    ostream&  operator<<(char * input)

Objective-C: NSLog(“%@”, “Hello world!”);

// % indicates a format, the @ indicates a string

Java: System.out.println(“Hello world!”);

// the “ln” gives you a newline

Advertisements
 
Leave a comment

Posted by on December 18, 2011 in General, Programming

 

Tags: , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: