如果你学过编程,我猜你写的第一个程序一定是“Hello World”。如果你没学过编程,我打赌你将来学的时候,动手写的第一个程序也一定是“Hello World”。哈哈哈,今天uncle心血来潮,整理了15种语言版本的“Hello World”,等读完这篇文章,你也可以对外装X:我精通15种语言……的“Hello World”!
1 Java
public class HelloWorld {
public static void main(String []args) {
System.out.println("Hello World!");
}
}
2 C
#include "stdio.h"
int main(void) {
printf("Hello World!");
return 0;
}
3 C++
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!";
return 0;
}
4 Python
print("Hello World!")
5 C#
using System;
namespace HelloWorldApplication
{
class HelloWorld
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
Console.ReadKey();
}
}
}
6 Objective-C
#import <stdio.h>
int main(void)
{
printf("%s\n", "Hello World!");
return 0;
}
7 Swift
print("Hello World!")
8 PHP
<?php
echo 'Hello World!';
?>
9 JavaScript
console.log("Hello World!");
10 HTML
<!DOCTYPE html>
<html>
<body> Hello World!</body>
</html>
11 Ruby
puts "Hello World!";
12 GO
package main
import "fmt"
func main() {
fmt.Println("Hello World!")
}
13 VBScript
MsgBox "Hello World!"
14 SQL
select 'Hello World!';
15 Shell
echo "Hello World!"
看完了上面15种高级编程语言的“Hello World”程序,是不是觉得也不过如此呀,只不过有些简练,有些繁琐罢了。下面放出远古编程语言汇编的“Hello World”程序,缅怀一下上一代程序员大佬,此致敬礼!
.data # section declaration
msg:
.ascii "Hello, world!\n" # our dear string
len = . - msg # length of our dear string
.text # section declaration
# we must export the entry point to the ELF linker or
.global _start # loader. They conventionally recognize _start as their
# entry point. Use ld -e foo to override the default.
_start:
# write our string to stdout
movl $len,%edx # third argument: message length
movl $msg,%ecx # second argument: pointer to message to write
movl $1,%ebx # first argument: file handle (stdout)
movl $4,%eax # system call number (sys_write)
int $0x80 # call kernel
# and exit
movl $0,%ebx # first argument: exit code
movl $1,%eax # system call number (sys_exit)
int $0x80 # call kernel
最后
在这里还是要推荐下我自己建的Python开发学习群:246410170,群里都是学Python开发的,如果你想学或者正在学习Python ,欢迎你加入,大家都是软件开发党,不定期分享干货/源码分享(只有Python软件开发相关的),包括我自己整理的一份2021最新的Python进阶资料和高级开发教程,欢迎进阶中和进想深入Python的小伙伴!