Hello World in 10 Popular Programming Languages – Complete Beginner Guide
Hello World Programs in Multiple Languages
Absolutely! Let’s go step by step for each language. I’ll give you the simplest “Hello, World!” example and explain how to write and run it.
1. JavaScript
Code (hello.js):
console.log("Hello, World!");
Steps to run:
- Install Node.js.
- Save the code in a file named
hello.js. - Open terminal and run:
node hello.js
- Output:
Hello, World!
2. Python
Code (hello.py):
print("Hello, World!")
Steps to run:
- Install Python.
- Save the file as
hello.py. - Run in terminal:
python hello.py
- Output:
Hello, World!
3. TypeScript
Code (hello.ts):
console.log("Hello, World!");
Steps to run:
- Install Node.js and TypeScript:
npm install -g typescript
- Save the file as
hello.ts. - Compile to JavaScript:
tsc hello.ts
- Run the compiled JS file:
node hello.js
- Output:
Hello, World!
4. SQL
Example using SQLite (hello.sql):
SELECT 'Hello, World!' AS greeting;
Steps to run:
- Install SQLite or use any SQL client.
- Save as
hello.sql. - Run in terminal:
sqlite3 :memory: < hello.sql
- Output:
greeting ---------- Hello, World!
5. Java
Code (HelloWorld.java):
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
Steps to run:
- Install Java JDK.
- Save as
HelloWorld.java. - Compile:
javac HelloWorld.java
- Run:
java HelloWorld
- Output:
Hello, World!
6. C#
Code (HelloWorld.cs):
using System;
class HelloWorld {
static void Main() {
Console.WriteLine("Hello, World!");
}
}
Steps to run:
- Install .NET SDK.
- Save as
HelloWorld.cs. - Compile and run:
dotnet run HelloWorld.cs
- Output:
Hello, World!
7. C++
Code (hello.cpp):
#include <iostream>
using namespace std;
int main() {
cout << "Hello, World!" << endl;
return 0;
}
Steps to run:
- Install a C++ compiler like
g++. - Save as
hello.cpp. - Compile:
g++ hello.cpp -o hello
- Run:
./hello
- Output:
Hello, World!
8. Go
Code (hello.go):
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}
Steps to run:
- Install Go.
- Save as
hello.go. - Run:
go run hello.go
- Output:
Hello, World!
9. Rust
Code (main.rs):
fn main() {
println!("Hello, World!");
}
Steps to run:
- Install Rust.
- Save as
main.rs. - Run:
rustc main.rs ./main
- Output:
Hello, World!
10. Bash
Code (hello.sh):
#!/bin/bash echo "Hello, World!"
Steps to run:
- Save as
hello.sh. - Make it executable:
chmod +x hello.sh
- Run:
./hello.sh
- Output:
Hello, World!
Comments
Post a Comment