version 23, including all changes.
.
Rev |
Author |
# |
Line |
23 |
AristotlePagaltzis |
1 |
This is the default introductory program to a new ProgrammingLanguage. It simply prints the text “Hello World” and a newline. |
15 |
CraigBox |
2 |
|
21 |
AristotlePagaltzis |
3 |
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. |
20 |
AristotlePagaltzis |
4 |
|
|
|
5 |
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. |
|
|
6 |
|
23 |
AristotlePagaltzis |
7 |
Some examples of HelloWorld in different ProgrammingLanguage~s: |
15 |
CraigBox |
8 |
|
23 |
AristotlePagaltzis |
9 |
[BASIC]:: |
|
|
10 |
<verbatim> |
|
|
11 |
PRINT "Hello World\n" |
|
|
12 |
</verbatim> |
15 |
CraigBox |
13 |
|
23 |
AristotlePagaltzis |
14 |
[C]:: |
|
|
15 |
<verbatim> |
|
|
16 |
#include <stdio.h> |
|
|
17 |
int main(int argc, char **argv) { |
|
|
18 |
printf("Hello World\n"); |
|
|
19 |
return 0; |
|
|
20 |
} |
|
|
21 |
</verbatim> |
15 |
CraigBox |
22 |
|
23 |
AristotlePagaltzis |
23 |
[C++]:: |
|
|
24 |
<verbatim> |
|
|
25 |
#include <iostream> |
|
|
26 |
int main (int argc, char *argv[]) { |
|
|
27 |
std::cout << "Hello World" << std::endl; |
|
|
28 |
return 0; |
|
|
29 |
} |
|
|
30 |
</verbatim> |
15 |
CraigBox |
31 |
|
23 |
AristotlePagaltzis |
32 |
[COBOL]:: |
|
|
33 |
''I'm not sure how much of this is serious or facetious...'' |
|
|
34 |
<verbatim> |
|
|
35 |
000100 IDENTIFICATION DIVISION. |
|
|
36 |
000200 PROGRAM-ID. HELLOWORLD. |
|
|
37 |
000300 DATE-WRITTEN. 02/05/96 21:04. |
|
|
38 |
000400* AUTHOR BRIAN COLLINS |
|
|
39 |
000500 ENVIRONMENT DIVISION. |
|
|
40 |
000600 CONFIGURATION SECTION. |
|
|
41 |
000700 SOURCE-COMPUTER. RM-COBOL. |
|
|
42 |
000800 OBJECT-COMPUTER. RM-COBOL. |
|
|
43 |
000900 |
|
|
44 |
001000 DATA DIVISION. |
|
|
45 |
001100 FILE SECTION. |
|
|
46 |
001200 |
|
|
47 |
100000 PROCEDURE DIVISION. |
|
|
48 |
100100 |
|
|
49 |
100200 MAIN-LOGIC SECTION. |
|
|
50 |
100300 BEGIN. |
|
|
51 |
100400 DISPLAY " " LINE 1 POSITION 1 ERASE EOS. |
|
|
52 |
100500 DISPLAY "HELLO, WORLD." LINE 15 POSITION 10. |
|
|
53 |
100600 STOP RUN. |
|
|
54 |
100700 MAIN-LOGIC-EXIT. |
|
|
55 |
100800 EXIT. |
|
|
56 |
</verbatim> |
18 |
DavidHallett |
57 |
|
|
|
58 |
[Java] |
23 |
AristotlePagaltzis |
59 |
<verbatim> |
|
|
60 |
public class HelloWorld { |
|
|
61 |
public static void main(String[] args) { |
|
|
62 |
System.out.println("Hello World"); |
|
|
63 |
} |
18 |
DavidHallett |
64 |
} |
23 |
AristotlePagaltzis |
65 |
</verbatim> |
|
|
66 |
|
|
|
67 |
[Linux] [x86] AssemblyLanguage:: |
|
|
68 |
<verbatim> |
|
|
69 |
.data |
|
|
70 |
.align 4 |
|
|
71 |
message:: |
|
|
72 |
.string "Hello World\n" |
|
|
73 |
message_len = . - message |
|
|
74 |
|
|
|
75 |
.text |
|
|
76 |
.align 4 |
|
|
77 |
.globl _start |
|
|
78 |
_start:: |
|
|
79 |
movl $0x4, %eax |
|
|
80 |
movl $0x1, %ebx |
|
|
81 |
movl $message, %ecx |
|
|
82 |
movl $message_len, %edx |
|
|
83 |
int $0x80 |
|
|
84 |
movl $0x1, %eax |
|
|
85 |
xorl %ebx, %ebx |
|
|
86 |
int $0x80 |
|
|
87 |
</verbatim> |
15 |
CraigBox |
88 |
|
23 |
AristotlePagaltzis |
89 |
[Perl]:: |
|
|
90 |
<verbatim> |
|
|
91 |
print join('', pack("V4", (0x6c6c6548,0x6f77206f,0xa646c72))); |
|
|
92 |
</verbatim> |
15 |
CraigBox |
93 |
|
23 |
AristotlePagaltzis |
94 |
''Sorry, someone is being facetious. Of course, it's:'' |
15 |
CraigBox |
95 |
|
23 |
AristotlePagaltzis |
96 |
<verbatim> |
|
|
97 |
print "Hello World\n"; |
|
|
98 |
</verbatim> |
15 |
CraigBox |
99 |
|
23 |
AristotlePagaltzis |
100 |
[Python]:: |
|
|
101 |
<verbatim> |
|
|
102 |
print "Hello World" |
|
|
103 |
</verbatim> |
15 |
CraigBox |
104 |
|
23 |
AristotlePagaltzis |
105 |
__UserRPL__ (for the HP48 Calculator):: |
|
|
106 |
<verbatim> |
|
|
107 |
<< "Hello World" MSGBOX >> |
|
|
108 |
</verbatim> |
19 |
ReneBartosh |
109 |
|
23 |
AristotlePagaltzis |
110 |
[PHP]:: |
|
|
111 |
<verbatim> |
|
|
112 |
<?php |
|
|
113 |
echo("Hello World\n"); |
|
|
114 |
?> |
|
|
115 |
</verbatim> |
15 |
CraigBox |
116 |
|
20 |
AristotlePagaltzis |
117 |
And the list could go on and on. |
15 |
CraigBox |
118 |
|
20 |
AristotlePagaltzis |
119 |
See also: |
23 |
AristotlePagaltzis |
120 |
* [Hello, World Page! | http://www2.latech.edu/~acm/HelloWorld.shtml], a very comprehensive collection of HelloWorld programs in many ProgrammingLanguage~s |
20 |
AristotlePagaltzis |
121 |
* PolyGlot |