学习编程语言的第一个程序一般是输出 “Hello World”。 接下来我们来看下26 种不同语言如何输出 “Hello World”:
1. C
#include int main() { printf("Hello, World"); return(0); }
2. C++
#include int main() { std::cout << "Hello World"; return 0; }
3. C#
using System; class Program { public static void Main(string[] args) { Console.WriteLine("Hello, World"); } }
4. Bash
echo "Hello, World"
5. Basic
PRINT "Hello, World"
6. HTML
Hello, World
7. Java
public class Main { public static void main(String[] args) { System.out.println("Hello, World!"); } }
8. Clipper
? "Hello, World"
9. Delphi
program HelloWorld; begin Writeln('Hello, World'); end.
10. CoffeeScript
console.log 'Hello, World'
11. MatLab
disp('Hello, World')
12. Julia
println("Hello, World")
13. JavaScript
document.write('Hello, World');
14. Logo
print [Hello, World]
15. jQuery
$("body").append("Hello, World");
16. Perl 5
print "Hello, World";
17. Pascal
program HelloWorld; begin WriteLn('Hello, World'); end.
18. Objective-C
#import #import int main(void) { NSLog(@"Hello, World"); return 0; }
19. Visual Basic .NET
Module Module1 Sub Main() Console.WriteLine("Hello, World") End Sub End Module
20. R
cat('Hello, World')
21. VBScript
MsgBox "Hello, World"
22. XSLT
Hello, World
23. Processing
void setup(){ println("Hello, World"); }
24. Ruby
puts "Hello, World"
25. Swift
print("Hello, World")
26. Python
print ("Hello, World")