惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

RisingIce

2024年终总结 | RisingIce 使用大模型总结B站视频 | RisingIce 使用Vercel搭建Umami统计 | RisingIce 部署Twikoo评论系统 | RisingIce Vercel域名被墙的问题 | RisingIce 修改anzhiyu主题的TianliGPT插件为其他大模型API | RisingIce Ubuntu挂载群晖共享文件夹与Comfyui模型迁移 | RisingIce 记一次conda环境激活却不起作用的问题及解决方法 | RisingIce 《程序员的README》- 随笔 | RisingIce
Hello Word的由来 | RisingIce
871996643@qq.com (RisingIce) · 2023-12-10 · via RisingIce

一、前言

还记得大一刚学编程的时候,学的第一门语言是C语言,print出的第一行代码是Hello World。现在想起来记忆已经有些模糊,只记得当时配置好环境之后,跟着老师一个字母一个字母的输入进去,点击运行之后,cmd窗口弹出,第一行就是Hello World,当时忙于惊叹于计算机编程之神奇带给我的冲击,并没有细想为什么是Hello World,老师也没有过多解释。今天周末闲来无事,就去翻找了一下Wiki以及其他资料,在此做一个总结报告记录一下。

二、Hello World 的由来

Hello World 最早可追溯至1973Brian Kernighan 撰写的一份内部的技术文件《A Tutorial Introduction to the Language B》中的一个示例程序:

bash

main( ) {
    extern a, b, c;
    putchar(a); putchar(b); putchar(c); putchar('!*n');
}
 
a 'hell';
b 'o, w';
c 'orld';

但让其广为流传的是1978年由Brian Kernighan 和C 语言之父 - Dennis M. Ritchie 合著的C程序设计语言,它是第一部介绍C语言编程方法的书籍,书中用"hello,world"为示例开始讲解程序设计:

在示例中,main( )函数定义了程序开始执行的位置。其主体由一条语句组成,即对printf函数的调用,意思是“打印格式化”(print formatted)。这个函数将使程序输出以参数传递给它的任何内容,在本例中是字符串hello, world。

▲布莱恩·柯尼汉在1978年用C语言手写的hello,world程序以及他个人的亲笔签名,图片来源于wiki

随着这部经典著作的大卖,"hello, world"也流行起来,逐渐成为具有特定象征意义的文化符号。

e40d54c637b88d0a5417fe82ad21a3a5.jpege40d54c637b88d0a5417fe82ad21a3a5.jpeg

▲年轻时的布莱恩·柯尼汉,图片来源网络

但是非常遗憾的是,当 Forbes India 杂志在2011年采访他的时候,他自己对这段传奇故事中一些记忆已经有点儿模糊了。当他被问及关于“hello,world”的准确来历时,他是回答时说:

我只记得,我好像看过一幅漫画,讲述一枚鸡蛋和一只小鸡的故事,在那副漫画中,小鸡说了一句 ‘Hello World’

三、目前一些流行语言的Hello World

Java

java

class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, world!");
    }
}

Python

Python

print("Hello, World!")

C#

c#

using System;

class Program {
    static void Main(string[] args) {
        Console.WriteLine("Hello, World!");
    }
}

C++

c++

#include <iostream>

int main() {
    std::cout << "Hello, World!" << std::endl;
    return 0;
}

Ruby

ruby

puts "Hello, World!"

Go

go

package main

import "fmt"

func main() {
    fmt.Println("Hello, World!")
}

Kotlin

kotlin

fun main() {
    println("Hello, World!")
}

Rust

rust

fn main() {
    println!("Hello, World!");
}

PHP

php

<?php
echo "Hello, World!";
?>

TypeScript

typescript

console.log("Hello, World!");

Scala

scala

object HelloWorld {
  def main(args: Array[String]): Unit = {
    println("Hello, World!")
  }
}

Erlang

erlang

io:format("Hello, World!~n").