几乎每个程序员写出来的第一个程序都是“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 isbeginText_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. */@Overridepublic 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 << "Hello World" << endl; //print Hello World on the screenreturn 0; // conventional}
Caml:
print_endline "Hello world!";;
Delphi:
program HelloWorld;{$APPTYPE CONSOLE}beginWriteLn('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:
echo 'Hello World';
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
“ 另外想要成为一个优秀的、有能力程序员的话,其实作为一个开发者或者编程学习者,有一个学习的氛围跟一个交流圈子特别重要!这里我要推荐一个C语言 c++交流Q群,7-4-1-8-1-8-6-5-2,不管你是大牛还是小白,大家都一起成长进步。