几乎每个程序员写出来的第一个程序都是“hello world”,Hello World最早是由 Brian Kernighan 创建的。1978年,Brian Kernighan写了一本名叫《C程序设计语言》的编程书,在程序员中广为流传。他在这本书中第一次引用的Hello World程序:
main (){ extrn a,b,c; putchar (a); putchar (b); putchar (c); putchar ('!*n'); } a 'hell'; b 'o, w'; c 'orld';
之后“Hello world”就开始流行起来,并成为了计算机发展历史上一个具有重要意义的里程碑。
最近猿妹在GitHub上发现了一个十分有趣的开源项目,它汇集了500多种编程语言编写的“Hello world”程序。
这个项目名称就叫hello-world,目前已经获得3241个Star,959个Fork(GitHub地址:https://github.com/leachim6/hello-world),下面我们先看几个过过瘾:
Ada:
with Text_IO;procedure Hello_World is begin Text_IO.Put_line("Hello World!"); end Hello_World;
Android:
package com.example.helloworld;import android.app.Activity;import android.os.Bundle;import android.widget.TextView;public class HelloWorld extends Activity{ /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); TextView tv = new TextView(this); tv.setText("Hello, World"); setContentView(tv); }}
Bash:
#!/bin/bashecho "Hello World!"
Basic:
10 REM Hello World in BASIC20 PRINT "Hello World"
C++:
#include // include APIusing namespace std;int main() // the main code portion of a C++ program{ cout <
Caml:
print_endline "Hello world!";;
Delphi:
program HelloWorld;{$APPTYPE CONSOLE}begin WriteLn('Hello World');end.
Dart:
main() { print('Hello, World!');}
Elixir:
#!/usr/bin/env elixirIO.puts "Hello world"
erlang_escript:
#!/usr/bin/env escriptmain(_) -> io:format("Hello World~n").
Factor:
USING: io ;"Hello World" print
Focal:
0.1.0.1 TYPE "HELLO WORLD" , !
Go:
package mainfunc main() { println("Hello, World")}
Groovy:
println "Hello World"
Hack:
Haskell:
module Main wheremain = putStrLn "Hello, World!"
Islisp:
(format (standard-output) "Hello, world!")
Java:
public class Java { public static void main(String[] args){ System.out.println("Hello World"); }}
JavaScript:
console.log("Hello World");
Lisp:
; LISP(DEFUN hello () (PRINT (LIST 'HELLO 'WORLD)))(hello)
感兴趣的想要查看所有语言的“hello world”程序,就自己到GitHub项目页查看吧,最后奉上GitHub地址:https://github.com/leachim6/hello-world
开源最前线(ID:OpenSourceTop)编译
链接:https://github.com/leachim6/hello-world