Programmiersprachen
-
C
#include <stdio.h> #include <string.h> void call(char* name) { printf("Hello World, and hello %s\n", name); } int main() { call("Hans"); return 0; }
-
C++
#include <iostream> #include <string> using namespace std; class HelloWorld { public: static void call(string name) { cout << "Hello World, and hello " << name << endl; } }; int main() { HelloWorld::call("Hans"); return 0; }
-
Common Lisp
(defun call (name) (format t "Hello World, and hello ~a~%" name)) (call "Hans")
Ausführung:
sbcl --script <dateiname>
-
D
module helloworld; import std.stdio; void call(string name) { writeln("Hello World, and hello ", name); } void main (string[] args) { call("Hans"); }
-
Elixir
defmodule HelloWorld do def call(name) do IO.puts("Hello World, and hello #{name}") end end
Aufruf aus Elixir-Shell:
HelloWorld.call("Hans")
-
Erlang
-module(hw). -export([call/1]). call(Name) -> io:format("Hello World, and hello ~p~n", [Name]).
Aufruf aus Erlang-Shell:
hw:call("Hans")
-
Go
package main import "fmt" func main() { call("Hans") } func call(name string) { fmt.Printf("Hello world, and hello %s\n", name) }
Mit
go run dateiname.go
ausführen. -
Haskell
module HelloWorld where call :: String -> IO () call name = putStrLn $ "Hello World, and hello " ++ name
Aufruf aus GHCi:
HelloWorld.call "Hans"
-
Java
class HelloWorld { public static void call(String name) { System.out.println("Hello World, and hello " + name); } public static void main(String[] args) { HelloWorld.call("Hans"); } }
-
Javascript
exports.call = function(name) { console.log("Hello World, and hello " + name); }
Aufruf aus node.js:
call("Hans");
-
PHP
<?php class HelloWorld { public static function call($name) { echo "Hello World, and hello " . $name; } } HelloWorld::call("Hans"); ?>
-
Python
# Der Modulname entspricht dem Dateinamen ohne die Endung # Modulname: helloworld # Dateiname: helloworld.py class HelloWorld: @staticmethod def call(name): print('Hello World, and hello ' + name) HelloWorld.call('Hans')
- Aufruf aus der Shell:
python helloworld.py
- Aufruf aus der interaktiven Shell:
import helloworld
- Aufruf aus der Shell:
-
Ruby
module HelloWorld def self.call(name) puts "Hello World, and hello #{name}" end end HelloWorld.call("Hans")
-
Rust
mod hello_word { pub fn call(name: &str) { println!("Hello World, and hello {}!", name); } } fn main() { hello_word::call("Hans"); }
Mit
rustc dateiname.rs
kompilieren und dann mit./dateiname
ausführen. -
Scala
// Bei einzeiligen Methoden können die {} weggelassen werden // class = object object HelloWorld { def main(args: Array[(String)]) { HelloWorld.call("Hans") } def call(name: String) = println("Hello World, and hello " + name) }
- Kompiliert mit
scalac HelloWorld.scala
, ausgeführt mitscala HelloWorld
- Kompiliert mit
-
Scheme
(define (call name) (display (string-append "Hello World, and hello " name "!")) (newline)) (call "Hans")
Ausführung (Beispiel):
csi <Dateiname>.scm
-
Vala
class HelloWorld { static void main() { HelloWorld.call("Hans"); } static void call(string name) { print("Hello World, and hello " + name + "\n"); } }