Pozdravljen, svet
Program PozdravljenSvet (tudi ŽivijoSvet) je kratek računalniški program, ki ilustrira uporabo nekega programskega jezika. Programček izpiše na zaslon besedilo »Pozdravljen svet!« (v angleški različici »Hello, world!«).
Program je uporabljen v mnogih (če ne vseh) uvodnih poglavjih knjig o učenju programiranja. Prvič naj bi se pojavil v knjigi The C Programming Language, (Brian Wilson Kernighan in Dennis MacAlistair Ritchie, 1978):
main( ) {
printf("Hello, world!");
}
Primeri v različnih programskih jezikih:
| Ta članek je treba prevesti v slovenščino. |
Črkovni vmesniki (konzola) [uredi]
ABC [uredi]
WRITE "'Pozdravljen svet!'"
Ada [uredi]
with Ada.Text_IO;
procedure Hello is
begin
Ada.Text_IO.Put_Line ("Pozdravljen svet!");
end Hello;
Glejte wikibooks:Programming:Ada:Basic.
AmigaE [uredi]
PROC main()
WriteF('Pozdravljen svet!')
ENDPROC
APL [uredi]
'Pozdravljen svet!'
Zbirnik [uredi]
First successful µP/OS combinations: Intel 8080/Zilog Z80, CP/M, RMAC assembler [uredi]
bdos equ 0005H ; BDOS entry point
start: mvi c,9 ; BDOS function: output string
lxi d,msg$ ; address of msg
call bdos
ret ; return to CCP
msg$: db 'Pozdravljen svet!$'
end start
Accumulator + index register machine: MOS Technology 6502, CBM KERNAL, ca65 assembler [uredi]
MSG: .ASCIIZ "Pozdravljen svet!"
LDX #0
LDA MSG,X ; load initial char
@LP: JSR $FFD2 ; chrout
INX
LDA MSG,X
BNE @LP
RTS
Expanded accumulator machine: Intel x86, DOS, TASM [uredi]
MODEL SMALL
IDEAL
STACK 100H
DATASEG
MSG DB 'Pozdravljen svet!', 13, '$'
CODESEG
MOV AX, @data
MOV DS, AX
MOV DX, OFFSET MSG
MOV AH, 09H ; DOS: output ASCII$ string
INT 21H
MOV AX, 4C00H
INT 21H
END
Expanded accumulator machine: Intel x86, Linux, GAS [uredi]
.data
msg:
.ascii "Pozdravljen svet!\n"
len = . - msg
.text
.global _start
_start:
movl $len,%edx
movl $msg,%ecx
movl $1,%ebx
movl $4,%eax
int $0x80
movl $0,%ebx
movl $1,%eax
int $0x80
General-purpose fictional computer: MIX, MIXAL [uredi]
TERM EQU 19 console device no. (19 = typewriter)
ORIG 1000 start address
START OUT MSG(TERM) output data at address MSG
HLT halt execution
MSG ALF "HELLO"
ALF " WORL"
ALF "D "
END START end of program
General-purpose fictional computer: MMIX, MMIXAL [uredi]
Main GETA $255,string get the address of the string in register 255
TRAP 0,Fputs,StdOut put the string pointed to by register 255 to file StdOut
string BYTE "Pozdravljen svet!",#a,0 string to be printed (#a is newline and 0 terminates the string)
TRAP 0,Halt,0 end process
General-purpose-register CISC: DEC PDP-11, RT-11, MACRO-11 [uredi]
.MCALL .REGDEF,.TTYOUT,.EXIT
.REGDEF
HELLO: MOV #MSG,R1
MOVB (R1),R0
LOOP: .TTYOUT
MOVB +(R1),R0
BNE LOOP
.EXIT
MSG: .ASCIZ /Pozdravljen svet!/
.END HELLO
CISC on advanced multiprocessing OS: DEC VAX, VMS, MACRO-32 [uredi]
.title hello
.psect data, wrt, noexe
chan: .blkw 1
iosb: .blkq 1
term: .ascid "SYS$OUTPUT"
msg: .ascii "Pozdravljen svet!"
len = . - msg
.psect code, nowrt, exe
.entry hello, ^m<>
; Establish a channel for terminal I/O
$assign_s devnam=term, -
chan=chan
blbc r0, end
; Queue the I/O request
$qiow_s chan=chan, -
func=#io$_writevblk, -
iosb=iosb, -
p1=msg, -
p2=#len
; Check the status and the IOSB status
blbc r0, end
movzwl iosb, r0
; Return to operating system
end: ret
.end hello
RISC processor: ARM, RISC OS, BBC BASIC's in-line assembler [uredi]
.program
ADR R0,message
SWI "OS_Write0"
SWI "OS_Exit"
.message
DCS "Pozdravljen svet!"
DCB 0
ALIGN
ali krajša verzija (iz qUE);
SWI"OS_WriteS":EQUS"Pozdravljen svet!":EQUB0:ALIGN:MOVPC,R14
AWK [uredi]
BEGIN { print "Pozdravljen svet!" }
bash [uredi]
Zelo podobno je tudi v ostalih lupinah, potrebno je le ustrezno popraviti pot v prvi vrstici.
#!/usr/local/bin/bash echo "Pozdravljen svet!"
BASIC [uredi]
10 PRINT "Pozdravljen svet!" 20 END
ali
PRINT "Pozdravljen svet!" END
V večini dialektov BASICa ukaz END ni potreben.
TI-BASIC [uredi]
Na kalkulatorji Texas Instruments, serije od TI-80 do TI-86:
:Disp "Pozdravljen svet!" ali :Output(1,1,"Pozdravljen svet!")
Ali preprosto:
:"Pozdravljen svet!"
:hellowld() :Prgm :Disp "Pozdravljen svet!" :EndPrgm
StarOffice/OpenOffice Basic [uredi]
sub main
print "Pozdravljen svet!"
end sub
Visual Basic [uredi]
Za izpis v razhroščevalni konzoli:
Debug.Print "Pozdravljen svet!"
Za izspis kot sporočilo uporabniku:
VBA.Interaction.MsgBox "Pozdravljen svet!"
BCPL [uredi]
GET "LIBHDR"
LET START () BE
$(
WRITES ("Pozdravljen svet!*N")
$)
BLISS [uredi]
%TITLE 'HELLO_WORLD'
MODULE HELLO_WORLD (IDENT='V1.0', MAIN=HELLO_WORLD,
ADDRESSING_MODE (EXTERNAL=GENERAL)) =
BEGIN
LIBRARY 'SYS$LIBRARY:STARLET';
EXTERNAL ROUTINE
LIB$PUT_OUTPUT;
GLOBAL ROUTINE HELLO_WORLD =
BEGIN
LIB$PUT_OUTPUT(%ASCID %STRING('Pozdravljen svet!'))
END;
END
ELUDOM
boo [uredi]
print "Pozdravljen svet!"
Casio fx-7950 [uredi]
Ta program deluje na fx-9750 grafičnih kalkulatorjih in njemu kompatibilnih.
"Pozdravljen svet!"←'
C [uredi]
#include <stdio.h>
int main(void)
{
printf("Pozdravljen svet!\n");
return 0;
}
C# [uredi]
using System;
class HelloWorldApp
{
public static void Main()
{
Console.WriteLine("Pozdravljen svet!");
}
}
C++ [uredi]
#include <iostream>
int main()
{
std::cout << "Pozdravljen svet!" << std::endl;
}
C++, Managed [uredi]
#using <mscorlib.dll>
using namespace System;
int wmain()
{
Console::WriteLine("Pozdravljen svet!");
}
ColdFusion (CFM) [uredi]
<cfoutput> Pozdravljen svet! </cfoutput>
COMAL [uredi]
PRINT "Pozdravljen svet!"
CIL [uredi]
.method public static void Main() cil managed
{
.entrypoint
.maxstack 8
ldstr "Pozdravljen svet!"
call void [mscorlib]System.Console::WriteLine(string)
ret
}
Clean [uredi]
module hello Start = "Pozdravljen svet!"
CLIST [uredi]
PROC 0 WRITE Pozdravljen svet!
COBOL [uredi]
IDENTIFICATION DIVISION. PROGRAM-ID. HELLO-WORLD. ENVIRONMENT DIVISION. DATA DIVISION. PROCEDURE DIVISION. DISPLAY "Pozdravljen svet!". STOP RUN.
Common Lisp [uredi]
(format t "Pozdravljen svet!~%")
ali
(write-line "Pozdravljen svet!")
D [uredi]
import std.stdio;
void main()
{
writefln("Pozdravljen svet!");
}
DCL batch [uredi]
$ write sys$output "Pozdravljen svet!"
Dylan [uredi]
module: hello
format-out("Pozdravljen svet!\n");
Ed and Ex (Ed extended) [uredi]
a Pozdravljen svet! . p
ali tako:
echo -e 'a\nPozdravljen svet!\n.\np'|ed echo -e 'a\nPozdravljen svet!\n.\np'|ex
Eiffel [uredi]
class HELLO_WORLD
creation
make
feature
make is
local
io:BASIC_IO
do
!io
io.put_string("%N Pozdravljen svet!")
end -- make
end -- class HELLO_WORLD
Erlang [uredi]
-module(hello).
-export([hello_world/0]).
hello_world() -> io:fwrite("Pozdravljen svet!\n").
Euphoria [uredi]
puts(1, "Pozdravljen svet!")
F# [uredi]
type data =
{ first: string;
second: string; }
let myData =
{ first="Hello";
second="world"; }
let _ =
print_string myData.first;
print_string " ";
print_string myData.second;
print_newline()
Focus [uredi]
-TYPE Pozdravljen svet!
Forte TOOL [uredi]
begin TOOL HelloWorld;
includes Framework;
HAS PROPERTY IsLibrary = FALSE;
forward Hello;
-- START CLASS DEFINITIONS
class Hello inherits from Framework.Object
has public method Init;
has property
shared=(allow=off, override=on);
transactional=(allow=off, override=on);
monitored=(allow=off, override=on);
distributed=(allow=off, override=on);
end class;
-- END CLASS DEFINITIONS
-- START METHOD DEFINITIONS
------------------------------------------------------------
method Hello.Init
begin
super.Init();
task.Part.LogMgr.PutLine('HelloWorld!');
end method;
-- END METHOD DEFINITIONS
HAS PROPERTY
CompatibilityLevel = 0;
ProjectType = APPLICATION;
Restricted = FALSE;
MultiThreaded = TRUE;
Internal = FALSE;
LibraryName = 'hellowor';
StartingMethod = (class = Hello, method = Init);
end HelloWorld;
Forth [uredi]
." Pozdravljen svet!" CR
FORTRAN [uredi]
PROGRAM HELLO
PRINT *, 'Pozdravljen svet!'
END
Frink [uredi]
println["Pozdravljen svet!"]
Gambas [uredi]
Poglejte tudi GUI kategorijo.
PUBLIC SUB Main()
Print "Pozdravljen svet!"
END
Game Maker [uredi]
V dogodku risanja določenega predmeta:
draw_text(x,y,"Pozdravljen svet!")
Ali da prikaže pogovorno okno s sporočilom:
show_message("Pozdravljen svet!")
Haskell [uredi]
module Main (main) where main = putStrLn "Pozdravljen svet!"
ali
main = putStrLn "Pozdravljen svet!"
Heron [uredi]
program HelloWorld;
functions {
_main() {
print_string("Pozdravljen svet!");
}
}
end
HP-41 & HP-42S [uredi]
(Ročni HP-jevi na RPN temelječi alfanumerični inžinirski kalkulatorji.)
01 LBLTHELLO 02 TPozdravljen svet! 03 PROMPT
HyperTalk (Apple HyperCard's scripting language) [uredi]
put "Pozdravljen svet!"
ali
Answer "Hello, world!"
IDL [uredi]
print,"Pozdravljen svet!"
Inform [uredi]
[ Main;
print "Pozdravljen svet!^";
];
Io [uredi]
"Pozdravljen svet!" print
ali
write("Pozdravljen svet!\n")
Iptscrae [uredi]
ON ENTER {
"Hello, " "World!" & SAY
}
Java [uredi]
Glej tudi GUI sekcijo.
public class Hello {
public static void main(String[] args) {
System.out.println("Pozdravljen svet!");
}
}
JavaScript [uredi]
Izpis v dokument:
document.write("Pozdravljen svet!");
Okno z obvestilom:
alert("Pozdravljen svet!");
JVM [uredi]
(nezbirniški odvod/izhod od javap -c Hello.class)
public class Hello extends java.lang.Object {
public Hello();
public static void main(java.lang.String[]);
}
Method Hello()
0 aload_0
1 invokespecial #1 <Method java.lang.Object()>
4 return
Method void main(java.lang.String[])
0 getstatic #2 <Field java.io.PrintStream out>
3 ldc #3 <String "Pozdravljen svet!">
5 invokevirtual #4 <Method void println(java.lang.String)>
8 return
Kogut [uredi]
WriteLine "Pozdravljen svet!"
Logo [uredi]
print [Pozdravljen svet!]
ali
pr [Pozdravljen svet!]
izključno v mswlogo pa:
messagebox [Hi] [Pozdravljen svet!]
Lua [uredi]
print "Pozdravljen svet!"
M (MUMPS) [uredi]
W "Pozdravljen svet!"
Macsyma, Maxima [uredi]
print("Pozdravljen svet!")$
Maple [uredi]
print("Pozdravljen svet!");
Mathematica [uredi]
Print["Pozdravljen svet!"]
MATLAB [uredi]
disp('Pozdravljen svet!')
Max [uredi]
max v2; #N vpatcher 10 59 610 459; #P message 33 93 63 196617 Pozdravljen svet!; #P newex 33 73 45 196617 loadbang; #P newex 33 111 31 196617 print; #P connect 1 0 2 0; #P connect 2 0 0 0; #P pop;
Modula-2 [uredi]
MODULE Hello;
FROM Terminal2 IMPORT WriteLn; WriteString;
BEGIN
WriteString("Pozdravljen svet!");
WriteLn;
END Hello;
MS-DOS batch [uredi]
| Ta članek je treba prevesti v slovenščino. |
(with the standard command.com interpreter. The @ symbol is optional and prevents the system from repeating the command before executing it. The @ symbol must be omitted on versions of MS-DOS prior to 3.0.)
@echo Pozdravljen svet!
MUF [uredi]
: main
me @ "Pozdravljen svet!" notify
;
Natural [uredi]
WRITE "Pozdravljen svet!" END
Ncurses [uredi]
#include <ncurses.h>
int main()
{
initscr();
printw("Pozdravljen svet!");
refresh();
getch();
endwin();
return 0;
}
Oberon [uredi]
MODULE Hello;
IMPORT Oberon, Texts;
VAR W: Texts.Writer;
PROCEDURE World*;
BEGIN
Texts.WriteString(W, "Pozdravljen svet!");
Texts.WriteLn(W);
Texts.Append(Oberon.Log, W.buf)
END World;
BEGIN
Texts.OpenWriter(W)
END Hello.
Objective C [uredi]
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
NSLog(@"Pozdravljen svet!");
return 0;
}
OCaml [uredi]
print_endline "Pozdravljen svet!"
OPL [uredi]
Glej tudi GUI sekcijo.
PROC hello:
PRINT "Pozdravljen svet!"
ENDP
OPS5 [uredi]
(object-class request
^action)
(startup
(strategy MEA)
(make request ^action hello)
)
(rule hello
(request ^action hello)
-->
(write |Pozdravljen svet!| (crlf))
)
Pascal [uredi]
Program Hello;
begin
WriteLn('Pozdravljen svet!');
end.
Perl [uredi]
print "Pozdravljen svet!\n";
(To je prvi primer knjige Learning Perl.)
PHP [uredi]
<?php echo "Pozdravljen svet!\n"; ?>
ali
<?="Pozdravljen svet!\n" ?>
vendar je to bolj priporočljivo:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title>Pozdravljen svet!</title> </head> <body> <?php echo "Pozdravljen svet!"; ?> </body> </html>
Pike [uredi]
int main() {
write("Pozdravljen svet!\n");
return 0;
}
PL/SQL [uredi]
procedure print_hello_world as
dbms_output.enable(1000000);
dbms_output.put_line("Pozdravljen svet!");
end print_hello_world;
PL/I [uredi]
Test: proc options(main) reorder;
put skip edit('Pozdravljen svet!') (a);
end Test;
POP-11 [uredi]
'Pozdravljen svet!' =>
POV-Ray [uredi]
#include "colors.inc"
camera {
location <3, 1, -10>
look_at <3,0,0>
}
light_source { <500,500,-1000> White }
text {
ttf "timrom.ttf" "Pozdravljen svet!" 1, 0
pigment { White }
}
Processing [uredi]
println("Pozdravljen svet!");
Prolog [uredi]
write('Pozdravljen svet!'),nl.
Python [uredi]
print "Pozdravljen svet!"
REXX, NetRexx, and Object REXX [uredi]
say "Pozdravljen svet!"
RPL [uredi]
Glej tudi GUI sekcijo.
(Na Hewlett-Packard grafičnih kalkulatorjih, serije HP-28, HP-48 in HP-49.)
<<
CLLCD
"Pozdravljen svet!" 1 DISP
0 WAIT
DROP
>>
Ruby [uredi]
Glej tudi GUI sekcijo.
puts "Pozdravljen svet!"
SAS [uredi]
data _null_; put 'Pozdravljen svet!'; run;
Sather [uredi]
class HELLO_WORLD is
main is
#OUT+"Pozdravljen svet!\n";
end;
end;
Scala [uredi]
object HelloWorld with Application {
Console.println("Pozdravljen svet!");
}
Scheme [uredi]
(display "Pozdravljen svet!") (newline)
sed [uredi]
(Opozorilo: potrebuje najmanj eno vrstico vhoda)
sed -ne '1s/.*/Pozdravljen svet!/p'
Seed7 [uredi]
$ include "seed7_05.s7i";
const proc: main is func
begin
writeln("Pozdravljen svet!");
end func;
Self [uredi]
'Pozdravljen svet!' print.
Simula [uredi]
BEGIN
OutText("Pozdravljen svet!");
OutImage;
END
Smalltalk [uredi]
Transcript show: 'Pozdravljen svet!'; cr
SML [uredi]
print "Pozdravljen svet!\n";
SNOBOL [uredi]
OUTPUT = "Pozdravljen svet!"
END
SPARK [uredi]
with Spark_IO;
--# inherit Spark_IO;
--# main_program;
procedure Hello_World
--# global in out Spark_IO.Outputs;
--# derives Spark_IO.Outputs from Spark_IO.Outputs;
is
begin
Spark_IO.Put_Line (Spark_IO.Standard_Output, "Pozdravljen svet!", 0);
end Hello_World;
SPITBOL [uredi]
OUTPUT = "Pozdravljen svet!"
END
SQL [uredi]
CREATE TABLE `message` (`text` char(15));
INSERT INTO `message` (`text`) VALUES ('Pozdravljen svet!');
SELECT `text` FROM `message`;
DROP TABLE `message`;
ali (Oracleov dialekt)
SELECT 'Pozdravljen svet!' FROM dual;
| Ta članek je treba prevesti v slovenščino. |
ali (for Oracle's PL/SQL proprietary procedural language)
BEGIN
DBMS_OUTPUT.ENABLE(1000000);
DBMS_OUTPUT.PUT_LINE('Pozdravljen svet!, from PL/SQL');
END;
ali (MySQL in PostgreSQL dialekt)
SELECT 'Pozdravljen svet!';
ali (T-SQL dialekt)
PRINT 'Pozdravljen svet!'
ali (KB-SQL dialekt)
select Null from DATA_DICTIONARY.SQL_QUERY FOOTER or HEADER or DETAIL or FINAL event write "Pozdravljen svet!"
STARLET [uredi]
RACINE: HELLO_WORLD.
NOTIONS:
HELLO_WORLD : ecrire("Pozdravljen svet!").
TACL [uredi]
#OUTPUT Pozdravljen svet!
Tcl (Tool command language) [uredi]
Glej tudi GUI sekcijo.
puts "Pozdravljen svet!"
Turing [uredi]
put "Pozdravljen svet!"
TSQL [uredi]
Declare @Output varchar(16) Set @Output='Pozdravljen svet!' Select @Output
ali preprostejši način:
Select 'Pozdravljen svet!' Print 'Pozdravljen svet!'
UNIX-style shell [uredi]
echo 'Pozdravljen svet!'
ali
printf 'Pozdravljen svet!\n'
| Ta članek je treba prevesti v slovenščino. |
or for a curses interface:
dialog --msgbox "Pozdravljen svet!" 0 0
Grafični vmesniki (GUI) [uredi]
ActionScript (Macromedia Flash MX) [uredi]
trace ("Pozdravljen svet!")
AppleScript [uredi]
display dialog "Pozdravljen svet!"
Or to have the OS synthesize it and literally say "Pozdravljen svet!" (with no comma, as that would cause the synthesizer to pause)
say "Pozdravljen svet!"
Cocoa ali GNUStep (v objektivnem C-ju) [uredi]
#import <Cocoa/Cocoa.h>
@interface hello : NSObject {
}
@end
@implementation hello
-(void)awakeFromNib
{
NSBeep(); // we don't need this but it's conventional to beep
// when you show an alert
NSRunAlertPanel(@"Message from your Computer", @"Pozdravljen svet!", @"Hi!",
nil, nil);
}
@end
Delphi, Kylix [uredi]
ShowMessage("Pozdravljen svet!");
FLTK2 (v C++) [uredi]
#include <fltk/Window.h>
#include <fltk/Widget.h>
#include <fltk/run.h>
using namespace fltk;
int main(int argc, char **argv)
{
Window *window = new Window(300, 180);
window->begin();
Widget *box = new Widget(20, 40, 260, 100, "Pozdravljen svet!");
box->box(UP_BOX);
box->labelfont(HELVETICA_BOLD_ITALIC);
box->labelsize(36);
box->labeltype(SHADOW_LABEL);
window->end();
window->show(argc, argv);
return run();
}
Gambas [uredi]
Glej tudi TUI sekcijo.
PUBLIC SUB Main()
Message.Info("Pozdravljen svet!")
END
GTK toolkit (v C++) [uredi]
#include <iostream>
#include <gtkmm/main.h>
#include <gtkmm/button.h>
#include <gtkmm/window.h>
using namespace std;
class HelloWorld : public Gtk::Window {
public:
HelloWorld();
virtual ~HelloWorld();
protected:
Gtk::Button m_button;
virtual void on_button_clicked();
};
HelloWorld::HelloWorld()
: m_button("Pozdravljen svet!") {
set_border_width(10);
m_button.signal_clicked().connect(SigC::slot(*this,
&HelloWorld::on_button_clicked));
add(m_button);
m_button.show();
}
HelloWorld::~HelloWorld() {}
void HelloWorld::on_button_clicked() {
cout << "Pozdravljen svet!" << endl;
}
int main (int argc, char *argv[]) {
Gtk::Main kit(argc, argv);
HelloWorld helloworld;
Gtk::Main::run(helloworld);
return 0;
}
GTK# (v C#) [uredi]
using Gtk;
using GtkSharp;
using System;
class Hello {
static void Main()
{
Application.Init ();
Window window = new Window ("helloworld");
window.Show();
Application.Run ();
}
}
GTK 2.x (v Euphoria) [uredi]
include gtk2/wrapper.e Info(NULL,"Hello","Pozdravljen svet!")
Java [uredi]
Glej tudi TUI sekcija.
import javax.swing.JOptionPane;
public class Hello {
public static void main(String[] args) {
JOptionPane.showMessageDialog(null, "Pozdravljen svet!");
}
}
Java applet [uredi]
Programčki, napisani v Javi, delujejo tudi v HTML datotekah.
<HTML> <HEAD> <TITLE>Pozdravljen svet!</TITLE> </HEAD> <BODY> Program Pozdravljen svet! pravi: <APPLET CODE="HelloWorld.class" WIDTH=600 HEIGHT=100></APPLET> </BODY> </HTML>
import java.applet.*;
import java.awt.*;
public class HelloWorld extends Applet {
public void paint(Graphics g) {
g.drawString("Pozdravljen svet!", 100, 50);
}
}
JavaScript and JScript [uredi]
- JavaScript (an implementation of ECMAScript) is a client-side scripting language used in HTML files. The following code can be placed in any HTML file:
<script type="text/javascript"><!--
function helloWorld()
{
alert("Pozdravljen svet!");
}
//--></script>
<a href="#" onclick="helloWorld(); return false;">Pozdravljen svet! Example</a>
- An easier method uses JavaScript implicitly, directly calling the reserved alert function. Cut and paste the following line inside the <body> .... </body> HTML tags.
<a href="#" onclick="alert('Pozdravljen svet!'); return false;">Pozdravljen svet! Example
</a>
- An even easier method involves using popular browsers' support for the virtual 'javascript' protocol to execute JavaScript code. Enter the following as an Internet address (usually by pasting into the address box):
javascript:alert('Pozdravljen svet!');
- There is an almost infinite number of ways to do it:
javascript:document.write('Pozdravljen svet!\n');
OPL [uredi]
See also TUI section.
(On Psion Series 3 and later compatible PDAs.)
PROC guihello:
ALERT("Pozdravljen svet!","","Exit")
ENDP
ali
PROC hello:
dINIT "Naslov okna"
dTEXT "","Pozdravljen svet!"
dBUTTONS "OK",13
DIALOG
ENDP
Ogrodje Qt (v C++) [uredi]
#include <qapplication.h>
#include <qpushbutton.h>
#include <qwidget.h>
#include <iostream>
class HelloWorld : public QWidget
{
Q_OBJECT
public:
HelloWorld();
virtual ~HelloWorld();
public slots:
void handleButtonClicked();
QPushButton *mPushButton;
};
HelloWorld::HelloWorld() :
QWidget(),
mPushButton(new QPushButton("Pozdravljen svet!", this))
{
connect(mPushButton, SIGNAL(clicked()), this, SLOT(handleButtonClicked()));
}
HelloWorld::~HelloWorld() {}
void HelloWorld::handleButtonClicked()
{
std::cout << "Pozdravljen svet!" << std::endl;
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
HelloWorld helloWorld;
app.setMainWidget(&helloWorld);
helloWorld.show();
return app.exec();
}
REALbasic [uredi]
MsgBox "Pozdravljen svet!"
RPL [uredi]
Glej tudi TUI sekcijo.
(Na Hewlett-Packard grafičnih kalkulatorjih serije HP-48G in HP-49G.)
<< "Pozdravljen svet!" MSGBOX >>
RTML [uredi]
Hello () TEXT "Pozdravljen svet!"
SWT [uredi]
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Label;
public class SWTHello {
public static void main (String [] args) {
Display display = new Display ();
final Shell shell = new Shell(display);
RowLayout layout = new RowLayout();
layout.justify = true;
layout.pack = true;
shell.setLayout(layout);
shell.setText("Pozdravljen svet!");
Label label = new Label(shell, SWT.CENTER);
label.setText("Pozdravljen svet!");
shell.pack();
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
}
Tcl/Tk [uredi]
Glej tudi TUI kategorijo.
label .l -text "Pozdravljen svet!" pack .l
Visual Basic vključuje VBA [uredi]
Sub Main()
MsgBox "Pozdravljen svet!"
End Sub
Windows API (v C) [uredi]
#include <windows.h>
LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
char szClassName[] = "MainWnd";
HINSTANCE hInstance;
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
int nCmdShow)
{
HWND hwnd;
MSG msg;
WNDCLASSEX wincl;
hInstance = hInst;
wincl.cbSize = sizeof(WNDCLASSEX);
wincl.cbClsExtra = 0;
wincl.cbWndExtra = 0;
wincl.style = 0;
wincl.hInstance = hInstance;
wincl.lpszClassName = szClassName;
wincl.lpszMenuName = NULL; //No menu
wincl.lpfnWndProc = WindowProcedure;
wincl.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); //Color of the window
wincl.hIcon = LoadIcon(NULL, IDI_APPLICATION); //EXE icon
wincl.hIconSm = LoadIcon(NULL, IDI_APPLICATION); //Small program icon
wincl.hCursor = LoadCursor(NULL, IDC_ARROW); //Cursor
if (!RegisterClassEx(&wincl))
return 0;
hwnd = CreateWindowEx(0, //No extended window styles
szClassName, //Class name
"", //Window caption
WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX,
CW_USEDEFAULT, CW_USEDEFAULT, //Let Windows decide the left and top
//positions of the window
120, 50, //Width and height of the window,
NULL, NULL, hInstance, NULL);
//Make the window visible on the screen
ShowWindow(hwnd, nCmdShow);
//Run the message loop
while (GetMessage(&msg, NULL, 0, 0)>0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hdc;
switch (message)
{
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
TextOut(hdc, 15, 3, "Pozdravljen svet!", 13);
EndPaint(hwnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, message, wParam, lParam);
}
return 0;
}
Ali zelo preprosto:
#include <windows.h>
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
int nCmdShow)
{
MessageBox(NULL, "Pozdravljen svet!", "", MB_OK);
return 0;
}
Windows Script Host [uredi]
WScript.Echo "Pozdravljen svet!"
Ruby with WxWidgets [uredi]
Glej tudi TUI sekcija.
require 'wxruby'
class HelloWorldApp < Wx::App
def on_init
ourFrame = Wx::Frame.new(nil, -1, "Pozdravljen svet!").show
ourDialogBox = Wx::MessageDialog.new(ourFrame, "Pozdravljen svet!", "Information:", \
Wx::OK|Wx::ICON_INFORMATION).show_modal
end
end
HelloWorldApp.new.main_loop
XUL [uredi]
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <box align="center" pack="center" flex="1"> <description>Pozdravljen svet!</description> </box> </window>
Document formats [uredi]
ASCII [uredi]
The following sequence of characters, expressed in hexadecimal notation (with carriage return and newline characters at end of sequence):
48 65 6C 6C 6F 2C 20 77 6F 72 6C 64 21 0D 0A
The following sequence of characters, expressed as binary numbers (with cr/nl as above, and the same ordering of bytes):
00--07: 01001000 01100101 01101100 01101100 01101111 00101100 00100000 01110111
08--0F: 01101111 01110010 01101100 01100100 00100001 00001101 00001010 DONTCARE*
(* The DONTCARE marker fills in for byte #0F, i.e. #15, which comes after our string.)
LaTeX [uredi]
\documentclass{article}
\begin{document}
Pozdravljen svet!
\end{document}
XHTML 1.1 [uredi]
(UTF-8 kodiranje.)
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="sl"> <head> <title>Pozdravljen svet!</title> </head> <body> <p>Pozdravljen svet!</p> </body> </html>
Označevalni jeziki [uredi]
HTML [uredi]
(preprosto)
<html> <body> <h1>Pozdravljen svet!<p> </body> </html>
Elementa <html> in <body> nista potrebna za hitra testiranja, za <h1> je priporočljivo, da se zaključi z </h1>, tako tudi <p>, ni pa potrebno. Lahko uporabite tudi naslednje:
<pre>Pozdravljen svet!</pre>
ali pa ga preprosto napišite brez elementov.
HTML 4.01 Strict [uredi]
(polno)
(UTF-8 kodiranje.)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Pozdravljen svet!</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body> <p>Pozdravljen svet!</p> </body> </html>
XSL 1.0 [uredi]
(UTF-8 kodiranje.)
<?xml version="1.0" encoding="utf-8">
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="utf-8"
doctype-system="http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-strict.dtd"
doctype-pubilc="-//W3C//DTD XHTML 1.0 Strict//EN"/>
<xsl:template match="/">
<html>
<head>
<title>Pozdravljen svet!</title>
</head>
<body>
Pozdravljen svet!
</body>
</html>
</xsl:template>
</xsl:stylesheet>
PostScript [uredi]
/Courier findfont 24 scalefont setfont 100 100 moveto (Pozdravljen svet!) show showpage
RTF [uredi]
{\rtf1\ansi\deff0
{\fonttbl {\f0 Courier New;}}
\f0\fs20 Pozdravljen svet!
}
TeX [uredi]
\font\HW=cmr10 scaled 3000
\leftline{\HW Pozdravljen svet!}
\bye
Zunanje povezave [uredi]
- Projekt ACM "Pozdravljen svet!"
- "Kako ljudje napišejo programsko kodo za "Pozdravljen svet!", temelječ na njihovi starosti in zaposlitvi" – Izvzeto iz GNU kolekcije humorja
- Zbirka "Pozdravljen svet!" programov
- Še ena kolekcija "Pozdravljen svet!" programčkov
- Več, kot 1000 programov v različnih programskih jezikih