Giới thiệu về Hello World , Hello World là gì ?
Hello World hay còn gọi là 'Xin chào thế giới' được xem là bài học vỡ lòng của mọi ngôn ngữ lập trình. Tui chắc chắn với các ông rằng bất kể khi nào các ông học một ngôn ngữ lập trình nào đó. Hello World luôn là (đa số là) bài học đầu tiên mà các ông được dạy
Và bài tui viết dưới đây là một bài funy, tổng hợp tất cả (không phải hết nhưng cũng kha khá) chương trình Hello World trong các ngôn ngữ lập trình(hoặc tương tự hoặc đang cãi nhau có phải là ngôn ngữ lập trình hay không. ví dụ HTML) phổ biến hiện nay
Hello World ! Start !
Python 3.x
print('Hello World')Python 2x
print 'Hello World'HTML 😃
Hello WorldJavaScript
document.write('Hello World')Rust
fn main() {
println!("Hello, world!");
}C
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}Java
class HelloWorldApp {
public static void main(String[] args) {
System.out.println("Hello World!"); // Prints the string to the console.
}
}Matlab
classdef hello
methods
function greet(this)
disp('Hello, World')
end
end
endPowerShell
Write-Host "Hello, World!"Logo
TO HELLO
PRINT [Hello world]
ENDMachine code
b8 21 0a 00 00 #moving "!\n" into eax
a3 0c 10 00 06 #moving eax into first memory location
b8 6f 72 6c 64 #moving "orld" into eax
a3 08 10 00 06 #moving eax into next memory location
b8 6f 2c 20 57 #moving "o, W" into eax
a3 04 10 00 06 #moving eax into next memory location
b8 48 65 6c 6c #moving "Hell" into eax
a3 00 10 00 06 #moving eax into next memory location
b9 00 10 00 06 #moving pointer to start of memory location into ecx
ba 10 00 00 00 #moving string size into edx
bb 01 00 00 00 #moving "stdout" number to ebx
b8 04 00 00 00 #moving "print out" syscall number to eax
cd 80 #calling the linux kernel to execute our print to stdout
b8 01 00 00 00 #moving "sys_exit" call number to eax
cd 80 #executing it via linux sys_callC#
using System;
using System.Collections.Generic;using System.Linq;
using System.Text;using System.Threading.Tasks;
namespace ConsoleApp1{
class Program {
static void Main(string[] args) {
Console.WriteLine("Hello, world!");
Console.ReadLine();
} }}Basic
10 PRINT "Hello, World!"
20 ENDC++
#include <iostream>
int main() {
std::cout << "Hello World!";
return 0;
}Perl
#!/usr/bin/perluse strict;
use warnings;
print("Hello World\n");Ruby
puts 'hello world'PHP
echo 'Hello World'Haskell
putStrLn "Hello World"Go
package mainimport "fmt"func
main() {
fmt.Println("hello world")
}Bash
#!/bin/bash
STR="Hello World!"
echo $STRDelphi
procedure TForm1.ShowAMessage;
begin
ShowMessage('Hello World!');
end;AutoIT
#include MsgBox($MB_OK, "Tutorial", "Hello World!") Erlang
-module(hello).
-export([hello_world/0]).
hello_world() -> io:fwrite("hello, world\n").Pascal
write('Hello World')Lua
print("Hello World")Scala
object HelloWorld extends App {
println("Hello, World!")
}Scheme
(let ((hello0 (lambda() (display "Hello world") (newline))))
(hello0))Smalltalk
Transcript show: 'Hello World!'.Elixir
IO.puts "Hello World!" OK ! Tạm thời là như vậy.