Hello worldプログラムの一覧

出典: 謎の百科事典もどき『エンペディア(Enpedia)』
ナビゲーションに移動 検索に移動
Wikipedia-logo.pngウィキペディアの生真面目なユーザーたちが「Hello worldプログラムの一覧」の項目を作っていたんですけどねぇ…。

ここではHello, world!を表示するプログラムの一覧を示す。

JavaScript[編集]

console.log("Hello, world!");

Python 2.x[編集]

print "Hello, world!"

Python 3.x[編集]

print("Hello, world!")

PHP[編集]

<?php
echo("Hello, world!");
?>

Lua[編集]

print("Hello, world!")

Ruby[編集]

print "Hello, world!" # 改行なし
puts "Hello, world!" # 改行付き

Perl[編集]

print "Hello, world!"; # 改行なし
print "Hello, world!\n"; # 改行付き
say "Hello, world!"; # 改行付き, 5.10以降で利用可能

Raku(元 Perl 6)[編集]

どちらでも。(Raku/Perlのモットー:TMTOWTDI)

say 'Hello, world!';
'Hello, world!'.say;

C言語[編集]

#include <stdio.h>
int main(void){
    puts("Hello, world!");
}

C++[編集]

#include <iostream>

int main()
{
  std::cout << "Hello, world!" << std::endl;
  return 0;
}

PSP(C++形式)[編集]

#include <pspkernel.h>
#include <pspdebug.h>

PSP_MODULE_INFO("HELLOWORLD",0,1,1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER);
int flag = 0;

int exit_callback(int arg1,int arg2,void *common)
{
	flag = 1;
	return 0;
}

int CallbackThread(SceSize args,void *argp)
{
	int exitc = sceKernelCreateCallback("Exit Callback",exit_callback,NULL);
	sceKernelRegisterExitCallback(exitc);
	sceKernelSleepThreadCB();
	return 0;
}

int Init(void)
{
	int eid = 0;
	eid = sceKernelCreateThread("update_thread",CallbackThread,0x11,0xFA0,0,0);
	if(eid >= 0)
		sceKernelStartThread(eid,0,0);
	return eid;
}

int main(int argc,char *argv[])
{
	Init();
	pspDebugScreenInit();
	while(!flag)
	{
		pspDebugScreenSetXY(0,0);
		pspDebugScreenPrintf("Hello, world!\n");
	}
	sceKernelExitGame();
	return 0;
}

D[編集]

import std.stdio;

void main()
{
    writeln("Hello, world!");
}

Rust[編集]

fn main() {
  print!("Hello, world!")
}

V言語[編集]

print('Hello, world!')

Go[編集]

package main

import "fmt"

func main() {
  fmt.Println("Hello, world!")
}

Dart[編集]

main() {
  print('Hello, world!');
}

Erlang[編集]

-module(hello_world).
-compile(export_all).

hello() ->
    io:format("Hello, world!~n").

Java[編集]

public class Main {
    public static void main(String[] args) {
        System.out.println("Hello, world!");
    }
}

Kotlin[編集]

fun main(args: Array<String>) {
  println("Hello, world!")
}

Scala[編集]

object Application extends App {
  println("Hello, world!")
}

Groovy[編集]

println "Hello, world!"

上記のコードをHelloWorld.groovyファイルに保存した場合、クラスファイルの内容は下記と同等となる。

class HelloWorld {
    public HelloWorld() {
        println "Hello, world!"
    }
    public static void main(String[] args) {
        new HelloWorld()
    }
}

Objective-C[編集]

Xcodeで"Create a New Xcode Project"→"macOS"→"Command Line Tool"でプロジェクトを作成すると生成されるコード(コメントは削除している)。

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        NSLog(@"Hello, World!");
    }
    return 0;
}

Swift[編集]

print("Hello, world!")

C♯[編集]

Visual Studioで「コンソール プロジェクト」を新規作成すると生成されるコード。

using System;
 
namespace HelloWorld
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }
}

Visual Basic(VB.net)[編集]

Visual Studioで「コンソール プロジェクト」を新規作成すると生成されるコード。

Imports System

Module Program
	Sub Main(args As String())
		Console.WriteLine("Hello World!")
	End Sub
End Module

F♯[編集]

Visual Studioで「コンソール プロジェクト」を新規作成すると生成されるコード(コメントは削除している)を一部改変したもの。

[<EntryPoint>]
let main argv =
    printfn "Hello, world!"
    0

Julia[編集]

print("Hello, world!")

Common Lisp[編集]

(format t "Hello, world!~%")

Scheme[編集]

(display "Hello, world!\n")

Clojure[編集]

(println "Hello, world!")

Haskell[編集]

main = putStrLn "Hello, world!"

Frege[編集]

module Main where
main _ = println "Hello, world!"

Smalltalk[編集]

Transcript show: 'Hello, world!'

Pascal[編集]

program HelloWorld;
begin
  writeln('Hello, world!');
end.

データベース言語[編集]

SQL[編集]

厳密には、SQLは単独ではプログラミング言語ではなく問い合わせ言語だが、一般的には次のような方法が「Hello worldプログラム」に該当すると考えられている。

標準SQLに該当するもの(VALUESコンストラクタ)

VALUES('Hello, world!');

標準SQLではないが、一部のRDBMSで使用可能なもの

SELECT 'Hello, world!';

ORACLEデータベースの場合(DUAL仮想表)

SELECT 'Hello, world!' FROM DUAL;

マークアップ言語[編集]

HTML[編集]

<!DOCTYPE html>
<html lang="ja">
  <head>
    <title>HTMLでの"Hello, world!"</title>
  </head>
  <body>
    <p>Hello, world!</p>
  </body>
</html>

CSS[編集]

X mark.pngIt's JOKE!この節は全力で不真面目に書かれています。 寛容な心でお読み下さい。
<style>div::before{content: "Hello, world!"}</style><div></div>
<!DOCTYPE html>
<html lang="ja">
  <head>
    <title>CSSでの"Hello, world!"</title>
    <style>
#word {
    background: transparent;
    width: 10px;
    height: 10px;
      
    box-shadow:
    /* H */
    30px  10px #181010,
    30px  20px #181010,
    30px  30px #181010,
    30px  40px #181010,
    30px  50px #181010,
    30px  60px #181010,
    30px  70px #181010,
    30px  80px #181010,
    30px  90px #181010,
    30px 100px #181010,
    30px 110px #181010,
    40px  60px #181010,
    50px  60px #181010,
    60px  60px #181010,
    70px  10px #181010,
    70px  20px #181010,
    70px  30px #181010,
    70px  40px #181010,
    70px  50px #181010,
    70px  60px #181010,
    70px  70px #181010,
    70px  80px #181010,
    70px  90px #181010,
    70px 100px #181010,
    70px 110px #181010,

    /* e */
    110px  80px #181010,
    120px  80px #181010,
    130px  80px #181010,
    140px  80px #181010,
    140px  70px #181010,
    140px  60px #181010,
    130px  50px #181010,
    120px  50px #181010,
    110px  50px #181010,
    100px  60px #181010,
    100px  70px #181010,
    100px  80px #181010,
    100px  90px #181010,
    100px 100px #181010,
    110px 110px #181010,
    120px 110px #181010,
    130px 110px #181010,
    140px 100px #181010,

    /* l */
    200px  10px #181010,
    200px  20px #181010,
    200px  30px #181010,
    200px  40px #181010,
    200px  50px #181010,
    200px  60px #181010,
    200px  70px #181010,
    200px  80px #181010,
    200px  90px #181010,
    200px 100px #181010,
    200px 110px #181010,

    /* l */
    270px  10px #181010,
    270px  20px #181010,
    270px  30px #181010,
    270px  40px #181010,
    270px  50px #181010,
    270px  60px #181010,
    270px  70px #181010,
    270px  80px #181010,
    270px  90px #181010,
    270px 100px #181010,
    270px 110px #181010,

    /* o */
    330px  60px #181010,
    330px  70px #181010,
    330px  80px #181010,
    330px  80px #181010,
    330px  90px #181010,
    330px 100px #181010,
    340px 110px #181010,
    350px 110px #181010,
    360px 110px #181010,
    370px 100px #181010,
    370px  90px #181010,
    370px  80px #181010,
    370px  70px #181010,
    370px  60px #181010,
    360px  50px #181010,
    350px  50px #181010,
    340px  50px #181010,

    /* , */
    430px  90px #181010,
    420px  90px #181010,
    420px 100px #181010,
    430px 100px #181010,
    430px 110px #181010,
    420px 120px #181010,

    /* w */
    550px  50px #181010,
    550px  60px #181010,
    550px  70px #181010,
    550px  80px #181010,
    560px  90px #181010,
    560px 100px #181010,
    560px 110px #181010,
    570px  80px #181010,
    570px  70px #181010,
    570px  60px #181010,
    570px  50px #181010,
    580px  90px #181010,
    580px 100px #181010,
    580px 110px #181010,
    590px  80px #181010,
    590px  70px #181010,
    590px  60px #181010,
    590px  50px #181010,

    /* o */
    630px  60px #181010,
    630px  70px #181010,
    630px  80px #181010,
    630px  80px #181010,
    630px  90px #181010,
    630px 100px #181010,
    640px 110px #181010,
    650px 110px #181010,
    660px 110px #181010,
    670px 100px #181010,
    670px  90px #181010,
    670px  80px #181010,
    670px  70px #181010,
    670px  60px #181010,
    660px  50px #181010,
    650px  50px #181010,
    640px  50px #181010,

    /* r */
    710px  50px #181010,
    710px  60px #181010,
    710px  70px #181010,
    710px  80px #181010,
    710px  90px #181010,
    710px 100px #181010,
    710px 110px #181010,
    720px  60px #181010,
    730px  50px #181010,
    740px  50px #181010,

    /* l */
    800px  10px #181010,
    800px  20px #181010,
    800px  30px #181010,
    800px  40px #181010,
    800px  50px #181010,
    800px  60px #181010,
    800px  70px #181010,
    800px  80px #181010,
    800px  90px #181010,
    800px 100px #181010,
    800px 110px #181010,

    /* d */
    890px  60px #181010,
    880px  50px #181010,
    870px  50px #181010,
    860px  60px #181010,
    860px  70px #181010,
    860px  80px #181010,
    860px  90px #181010,
    860px 100px #181010,
    870px 110px #181010,
    880px 110px #181010,
    890px 100px #181010,
    900px  10px #181010,
    900px  20px #181010,
    900px  30px #181010,
    900px  40px #181010,
    900px  50px #181010,
    900px  60px #181010,
    900px  70px #181010,
    900px  80px #181010,
    900px  90px #181010,
    900px 100px #181010,
    900px 110px #181010,

    /* ! */
    950px  10px #181010,
    950px  20px #181010,
    950px  30px #181010,
    950px  40px #181010,
    950px  50px #181010,
    950px  60px #181010,
    950px  70px #181010,
    950px 100px #181010,
    950px 110px #181010;
}
    </style>
  </head>
  <body>
    <div id="word"></div>
  </body>
</html>

SVG[編集]

<svg xmlns="http://www.w3.org/2000/svg">
  <text y="20">Hello, world!</text>
</svg>

LaTeX[編集]

\documentclass{article}
\begin{document}
Hello, world!
\end{document}