Differences between version 23 and revision by previous author of HelloWorld.
Other diffs: Previous Major Revision, Previous Revision, or view the Annotated Edit History
Newer page: | version 23 | Last edited on Wednesday, April 4, 2007 8:32:59 am | by AristotlePagaltzis | Revert |
Older page: | version 22 | Last edited on Tuesday, April 3, 2007 11:37:27 pm | by SpiroHarvey | Revert |
@@ -1,100 +1,121 @@
-This is the default introductory program to a new ProgrammingLanguage. It simply prints the text string "
Hello World\n"
.
+This is the default introductory program to a new ProgrammingLanguage. It simply prints the text “
Hello World” and a newline
.
HelloWorld is not really meant as a sample program, though. What you learn from creating a Hello World program is how to use the language tools: it's a first exercise in entering, compiling and running a program on a paticular system, and it might make you go find the documentation on the I/O library in some cases. In many very high level languages, it looks exactly the same.
As a demonstration of the feel of a language, PPR:WardNumber is a much better problem. [99 Bottles of Beer on the Wall | http://99-bottles-of-beer.ls-la.net/] can also be adequate.
-Some examples of HelloWorld in different [
ProgrammingLanguage]
s:
+Some examples of HelloWorld in different ProgrammingLanguage~
s:
-[BASIC]
- PRINT "Hello World\n"
+[BASIC]::
+ <verbatim>
+
PRINT "Hello World\n"
+ </verbatim>
-[C]
- #include <stdio.h>
- int main(int argc, char **argv) {
-
printf("Hello World\n");%%%
-
return ;
- }
+[C]::
+ <verbatim>
+
#include <stdio.h>
+
int main(int argc, char **argv) {
+
printf("Hello World\n");
+
return ;
+
}
+ </verbatim>
-[C++]
- #include <iostream>
- int main (int argc, char *argv[]) {
-
std::cout << "Hello World" << std::endl;%%%
-
return ;
- }
+[C++]::
+ <verbatim>
+
#include <iostream>
+
int main (int argc, char *argv[]) {
+
std::cout << "Hello World" << std::endl;
+
return ;
+
}
+ </verbatim>
-[COBOL]
-
-
''I'm not sure how much of this is serious or facetious...''
- 000100 IDENTIFICATION DIVISION.%%%
- 000200 PROGRAM-ID. HELLOWORLD.%%%
- 000300 DATE-WRITTEN. 02/05/96 21:04.%%%
- 000400* AUTHOR BRIAN COLLINS%%%
- 000500 ENVIRONMENT DIVISION.%%%
- 000600 CONFIGURATION SECTION.%%%
- 000700 SOURCE-COMPUTER. RM-COBOL.%%%
- 000800 OBJECT-COMPUTER. RM-COBOL.%%%
- 000900%%%
- 001000 DATA DIVISION.%%%
- 001100 FILE SECTION.%%%
- 001200
- 100000 PROCEDURE DIVISION.%%%
- 100100%%%
- 100200 MAIN-LOGIC SECTION.%%%
- 100300 BEGIN.%%%
- 100400 DISPLAY " " LINE 1 POSITION 1 ERASE EOS.%%%
- 100500 DISPLAY "HELLO, WORLD." LINE 15 POSITION 10.%%%
- 100600 STOP RUN.%%%
- 100700 MAIN-LOGIC-EXIT.%%%
- 100800 EXIT.%%%
+[COBOL]::
+
''I'm not sure how much of this is serious or facetious...''
+ <verbatim>
+
000100 IDENTIFICATION DIVISION.
+
000200 PROGRAM-ID. HELLOWORLD.
+
000300 DATE-WRITTEN. 02/05/96 21:04.
+
000400* AUTHOR BRIAN COLLINS
+
000500 ENVIRONMENT DIVISION.
+
000600 CONFIGURATION SECTION.
+
000700 SOURCE-COMPUTER. RM-COBOL.
+
000800 OBJECT-COMPUTER. RM-COBOL.
+
000900
+
001000 DATA DIVISION.
+
001100 FILE SECTION.
+
001200
+
100000 PROCEDURE DIVISION.
+
100100
+
100200 MAIN-LOGIC SECTION.
+
100300 BEGIN.
+
100400 DISPLAY " " LINE 1 POSITION 1 ERASE EOS.
+
100500 DISPLAY "HELLO, WORLD." LINE 15 POSITION 10.
+
100600 STOP RUN.
+
100700 MAIN-LOGIC-EXIT.
+
100800 EXIT.
+ </verbatim>
[Java]
- public class HelloWorld
-
{
-
public static void main(String[] args)
-
{
-
System.out.println("Hello World");
+ <verbatim>
+
public class HelloWorld {
+
public static void main(String[] args) {
+
System.out.println("Hello World");
+ }
}
- }
+ </verbatim>
+
+[Linux] [x86] AssemblyLanguage::
+
<verbatim>
+ .data
+ .align 4
+ message::
+ .string "Hello World\n"
+ message_len = . - message
+
+ .text
+ .align 4
+ .globl _start
+ _start::
+ movl $0x4, %eax
+ movl $0x1, %ebx
+ movl $message, %ecx
+ movl $message_len, %edx
+ int $0x80
+ movl $0x1, %eax
+ xorl %ebx, %ebx
+ int $0x80
+ </verbatim>
-Linux x86 AssemblyLanguage
- .data%%%
- .align 4%%%
- message:%%%
- .string
"Hello World\n
"%%%
- message_len = . - message%%%
+[Perl]::
+ <verbatim>
+ print join('', pack(
"V4
", (0x6c6c6548,0x6f77206f,0xa646c72)));
+ </verbatim>
-
.text%%%
- .align 4%%%
- .globl _start%%%
- _start
:%%%
- movl $0x4, %eax%%%
- movl $0x1, %ebx%%%
- movl $message, %ecx%%%
- movl $message_len, %edx%%%
- int $0x80%%%
- movl $0x1, %eax%%%
- xorl %ebx, %ebx%%%
- int $0x80%%%
+ ''Sorry, someone is being facetious
. Of course, it's
:''
-[Perl]:
- print join('', pack("V4", (0x6c6c6548,0x6f77206f,0xa646c72)));
-''Sorry, someone is being facetious. Of course, it's:''
- print "Hello World\n";
+ <verbatim>
+
print "Hello World\n";
+ </verbatim>
-[Python]:
- print "Hello World"
+[Python]:
:
+ <verbatim>
+
print "Hello World"
+ </verbatim>
-UserRPL (for the HP48 Calculator):
- << "Hello World" MSGBOX >>
+__
UserRPL__
(for the HP48 Calculator):
:
+ <verbatim>
+
<< "Hello World" MSGBOX >>
+ </verbatim
>
-[PHP]:
- <?php%%%
- echo ("Hello World\n") ;%%%
- ?>%%%
+[PHP]:
:
+ <verbatim>
+
<?php
+
echo("Hello World\n");
+
?>
+ </verbatim>
And the list could go on and on.
See also:
-* [Hello, World Page! | http://www2.latech.edu/~acm/HelloWorld.shtml], a very comprehensive collection of HelloWorld programs in many [
ProgrammingLanguage]
s
+* [Hello, World Page! | http://www2.latech.edu/~acm/HelloWorld.shtml], a very comprehensive collection of HelloWorld programs in many ProgrammingLanguage~
s
* PolyGlot