hello, wall! = H = hex

hello world interj.

1. The canonical minimal test message in the C/Unix universe. 2. Any of the minimal programs that emit this message. Traditionally, the first program a C coder is supposed to write in a new environment is one that just prints "hello, world" to standard output (and indeed it is the first example program in K&R). Environments that generate an unreasonably large executable for this trivial test or which require a hairy compiler-linker invocation to generate it are considered to lose (see X). 3. Greeting uttered by a hacker making an entrance or requesting information from anyone present. "Hello, world! Is the LAN back up yet?"

--The Jargon File version 4.3.1, ed. ESR, autonoded by rescdsk.

Hello world written in IBM System/370 assembler language using the SIOF (start I/O fast release) instruction complete with associated channel program. Output will appear on the IBM 1403 line printer that you've (naturally) got connected to channel 0 at the usual address (i.e. 00E).

In order to avoid a bunch of extraneous details (that I don't remember anymore), we'll assume that the system is currently running in BC (Basic Control) mode.

EXAMPLE CSECT
*
* enter supervisor state
*
    %%% left as an exercise for the reader %%%
*
* establish a base register
*
        BALR  12,0
        USING *,12
*
* disable I/O interrupts (save the old mask)
*
        STNSM SYSMASK,0
*
* start the operation
*
        LA    2,CPROGRAM          Get the address of our first CCW
        ST    2,72                set the CAW to point at it
*                                 (EQU statements are for wimps!)
        SIOF  X'00E'              bang!
        BNZ   OOPS                Did it work?
*
* restore the system mask and continue
*
        SSM   SYSMASK
         .
         .
         .
*
* Something went wrong.  Just sit and stare at our navel.
* Someone will eventually notice that we need help!
*
OOPS    B     OOPS
*
* Our channel program
* (longer than it needs to be if memory serves)
*
* Sends "Hello World!" to a 1403 line printer

CPROGRAM DS 0D           Force double-word alignment

* first CCW - skip to the top of the next page
* (does anyone remember if "Skip to channel 0" will take data as well?)

        DC    X'83'      Skip to channel 0 (assumes 1403 line printer)
        DC    AL3(0)     no data
        DC    X'60'      Command Chaining and Suppress Length Indication
        DC    X'00'      unused (always set to 0)
        DC    AL2(0)     no length

* second CCW - send the message text
        DC    X'09'      Write text and then advance to next line
        DC    AL3(HELLO) address of the data
        DC    X'20'      Suppress Length Indication
        DC    X'00'      unused (always set to 0)
        DC    AL2(LHELLO) length of message
*
* Our "Hello world!" message
*
HELLO   DC    C'Hello world!'
LHELLO  EQU   *-HELLO
*
* Somewhere to save the system mask
* (not re-entrant but you can't have everything)
*
SYSMASK DS    X
*
* Done
*
        END
Unfortunately, I wasn't able to convince anyone to lend me their mainframe so that I could test the program although I'm pretty sure that it would work.

Yes, I know - BC mode is also for wimps.

Here's hello world in C++ as a newbie to the language might write it (after a few unsuccessful tries, naturally):

#include <iostream>
using namespace std;

int main()
{
    cout << "Hello World!" << endl;
    return 0;
}

Looks nice, doesn't it? However, like all pieces of code, it can be improved.

#include <iostream>

int main()
{
    std::cout << "Hello World!" << std::endl;
}

We hardly need to include the entire std namespace when we're only using cout and endl, now do we? The return call is also redundant. Having now optimized our code, let's try and make it as short as possible by removing all unneeded whitespace:

#include<iostream>
int main(){std::cout<<"Hello World!"<<std::endl;}

Finally, let's obfuscate our Hello World.

#include<iostream>
int main(){char*hw=".!dlroW olleH";hw+=12;while(*hw!=46)std::cout<<*hw--;}

As you can no doubt see, our "obfuscation" consists simply of re-writing the program to output Hello World using a pointer which iterates backwards, and eliminating all the whitespace. Surely, we can do better by violating a few rules:

#include<cstdio>
main(/*p!*/){{char*hw=".!dl"/*extern"C"*/"roW"
/**/" ol""leH";hw+=12;while(*/*<<\int*/hw!=46)
{putc(*/*/*co/*ut*/hw--,&_iob[1]);};}}//>;^)*/

Beautiful. Believe it or not, the above still compiles and runs without a hitch using Microsoft's C++ compiler and linker. Now for something completely different: Hello World in C#:

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

Shortening and obfuscating this is left as an exercise to the reader.

As we computer programmers set out learning new languages, we almost always start with 'Hello, World!'. I know I do. It gives you that warm fuzzy feeling that only a freshly compiled program can, and it's the first step to becoming an <insert language here> ninja. Although important (superstitiously for some of us) as 'Hello, World!' is, it doesn't do much; it's one and only purpose is to print the string 'Hello, World!' to the screen (or your default output device of choice).

Some of these languages are repeats (and I'm sure some are covered in other nodes as well), but they serve to show just how similar (or how different) the 'Hello, World!' program can look from language to language. The C version, for example, is perfectly valid C++ code (compiles with both gcc and g++ anyway). Also, these versions are by no means optimized. They are either as I wrote them when I was learning the language or a reasonable facsimile thereof.

So here it is, 'Hello, World!' in every language I know (or once used and had that superstitious first program lying around taking up disk space) unless otherwise noted:

  • BASIC
    10 REM Hello, World in BASIC
    20 print "Hello, World!"
     
  • Brainfuck
    >+++++++++[<++++++++>-]<.[-]
    >++++++++++[<++++++++++>-]<+.[-]
    >+++++++++++[<++++++++++>-]<--..[-]
    >+++++++++++[<++++++++++>-]<+.[-]
    >+++++++[<++++++>-]<++.[-]
    >++++++[<+++++>-]<++.[-]
    >++++++++++[<+++++++++>-]<---.[-]
    >+++++++++++[<++++++++++>-]<+.[-]
    >+++++++++++[<++++++++++>-]<++++.[-]
    >+++++++++++[<++++++++++>-]<--.[-]
    >++++++++++[<++++++++++>-]<.[-]
    +++++++++++++.---.-
     
  • C
    /* Hello, World! in C */
    #include <stdio.h>
    int main() {
        printf("Hello, World!\n");
        return 0;
    }
     
  • C++
    // Hello, World! in C++
    #include <iostream>
    using namespace std;
    int main() {
        cout<<"Hello, World"<<endl;
        return 0;
    }
     
  • C# 1
    // Hello, World! in C#
    using System;
    namespace Hello {
        public class HelloWorld {
            static void Main() {
                Console.WriteLine("Hello, World!");
            }
        }
    }
    
     
  • COBOL
    000100 IDENTIFICATION DIVISION.
    000200 PROGRAM-ID. hello.
    000300 ENVIRONMENT DIVISION.
    000400 DATA DAVISION.
    000500 PROCEDURE DIVISION.
    000600*Hello, World! in COBOL
    000700    DISPLAY "Hello, World!".
    000800    STOP RUN
     
  • DCL
    $! Hello, World! in DCL
    $  WRITE SYS$OUTPUT "Hello, World!"
     
  • DOS batch
    REM Hello, World! in DOS batch
    @echo off
    echo Hello, World!
    echo on
     
  • FORTRAN66
    c     Hello, World in FORTRAN66
          PROGRAM HELLO_WORLD
          WRITE (*,100)
      100 FORMAT (13HHello, World!)
          END
     
  • FORTRAN77
    c     Hello, World in FORTRAN77
          PROGRAM HELLO_WORLD
          PRINT *,'Hello World'
          END
     
  • HTML
    <!-- Hello, World! in HTML -->
    <HTML>
      <HEAD>
        <TITLE>
          Hello, World!
        </TITLE>
      </HEAD>
      <BODY>
        Hello, World!
      </BODY>
    </HTML>
     
  • Java
    // Hello, World in Java
    class hello_world {
        public static void main(String args[]) {
            System.out.println("Hello, World!");
        }
    }
     
  • JavaScript
    <!-- Hello, World! in JavaScript (in HTML) -->
    <HTML>
      <HEAD>
        <TITLE>
          Hello, World!
        </TITLE>
      </HEAD>
      <BODY>
        <SCRIPT LANGUAGE="JavaScript">
          document.write("Hello, World!")
        </SCRIPT>
      </BODY>
    </HTML>
     
  • make
    # Hello, World! in make
    default:
        echo Hello, World!
     
  • O'Caml 2
    (* Hello, World! in O'Caml *)
    print_string "Hello, World!\n"
     
  • Pascal 1
    (* Hello, World! in Pascal *)
    program HelloWorld(input, output);
    begin
        writeln('Hello, World!')
    end.
     
  • Perl
    #!/usr/bin/perl
    # Hello, World! in Perl
    print "Hello, World!\n";
     
  • PHP 2
    #!/usr/bin/php -q 
    <?php
    // Hello, World! in PHP
    echo "Hello, World!\n";
    ?>
     
  • PHP (in HTML)
    <!-- Hello, World in PHP (in HTML) -->
    <HTML>
      <HEAD>
        <TITLE>
          Hello, World!
        </TITLE>
      </HEAD>
      <BODY>
        <?echo("Hello, World!");>
      </BODY>
    </HTML>
     
  • Python
    #!/usr/bin/python
    # Hello, World! in Python
    print "Hello, World!"
     
  • QBASIC
    ' Hello, World! in QBASIC
    PRINT "Hello, World!"
     
  • Unix shell 2
    #!/bin/sh
    # Hello, World! in Unix shell
    echo "Hello, World!"
     
  • VBScript (in HTML)
    <!-- Hello, World in VBScript (in HTML) -->
    <HTML>
      <HEAD>
        <TITLE>
          Hello, World!
        </TITLE>
      </HEAD>
      <BODY>
        <script language="vbscript">
          document.write("Hello, World!")
        </script>
      </BODY>
    </HTML>
     

1 - C# and Pascal programs were inspired by StrawberryFrog's writuep on both languages.
2 - O'Caml, PHP, and Unix shell programs were all given to me via a /msg (if you'd like credit, please /msg me)

"Hello World" in LOLcode:

HAI
  I HAS A GREETZ ITZ "HELLO"
  I HAS A WURLD ITZ "WORLD"
  VISIBLE GREETZ N " " N WURLD
  BTW we could have done this in one line (VISIBLE "HELLO WORLD")
KTHXBYE

Log in or register to write something here or to contact authors.