Everything2
Near Matches
Ignore Exact
Full Text
Everything2

Hello World

created by CmdrTaco

(idea) by Jargon (1.8 y) (print)   ?   (I like it!) Thu Jul 19 2001 at 10:19:34

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.


(idea) by dabcanboulet (1.5 d) (print)   ?   (I like it!) Fri Oct 04 2002 at 18:41:10

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.

*
* enter supervisor state
*
    %%% left as an exercise for the reader %%%
*
* 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.


(thing) by Nene (2.5 y) (print)   ?   (I like it!) 1 C! Sat Jun 21 2003 at 8:03:42

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.


(thing) by jclast (8.4 mon) (print)   ?   (I like it!) 2 C!s Thu Feb 17 2005 at 4:30:01

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)


(thing) by Sylvar (1.1 wk) (print)   ?   (I like it!) 1 C! Wed Dec 19 2007 at 2:28:08

"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

printable version
chaos

Brainfuck Inefficient hello world programs Hello, wall! Fictitious programming language
compile C++ Daria Morgendorffer windowing system
First date kissing hex How do I find the G-Spot? 1999
What goes on at Fondue parties Transmeta crack whore X
BOFH e Orbital Noosphere
The dot in .com Frank Zappa Phish Mozilla
No more writeups are being accepted for this node. Because. If you feel you have something to add to this node, post it on your Scratch Pad and contact an editor.
  Epicenter
Login
Password

password reminder
register

Everything2 Help

Cool Staff Picks
Just another sprinkling of indeterminacy
Barbed wire
Women's suffrage
Funerals should be a celebration
Math is not a social construct
woodchipper
Useful Latin phrases
Willow pattern
John Lee Hooker
1793
Slaughterhouse tour, or Why I'm no longer a lawyer
You use chopsticks very well
Tea tree oil
Grenada
New Writeups
Meezzio
Gotlandssnus(thing)
argv
Astral Plane(idea)
Madara
One Winged Angel(fiction)
Tom Rook
Talk is cheap(poetry)
shaogo
Adelle Davis(person)
Aerobe
race car g sfjsgsd(poetry)
Binah
Dream Log: July 5, 2008(dream)
StrawberryFrog
Forgotten things in space(idea)
antigravpussy
velvet revolution fairy tale(idea)
Heitah
Nerve agent VX(thing)
Pavlovna
shite(idea)
wonton
Days and nights come together in a slow falling down(fiction)
Pavlovna
wee(idea)
katherine
root log: July 2008(log)
Madara
There’s nothing like a trail of blood to find your way back home(fiction)
This page courtesy of The Everything Development Company