Hello World Examples in 12 Popular Programming Languages
This article showcases the correct "Hello World" syntax for twelve widely used programming languages, providing clear code snippets and brief explanations to help beginners understand the fundamental first program across Java, C, Python, C++, C#, Visual Basic .NET, JavaScript, PHP, Objective‑C, SQL, Ruby, and MATLAB.
As a programmer, the first program you usually write is the classic "Hello World". This article presents the proper "Hello World" implementation for twelve popular programming languages, based on rankings from GitHub and Tiobe, and includes the source code for each example.
1. Java
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. Python
print('Hello World')4. C++
#include <iostream>
using namespace std;
int main() {
cout << "\nHello World" << endl;
return 0;
}5. C#
using System;
namespace helloWorld {
class HelloWorld {
static void Main(string[] args) {
Console.WriteLine("Hello World!");
}
}
}6. Visual Basic .NET
Module HelloWorld
Sub Main()
System.Console.WriteLine("Hello world!")
End Sub
End Module7. JavaScript
console.log("Hello World");8. PHP
<?php
// In PHP, we use echo to print text
echo "Hello World";
// If you want to print in browser's console, we use print_r
print_r("Hello World");
// To also show variable data types, use var_dump
$stringVar = 'hello world';
var_dump($stringVar);
?>9. Objective‑C
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSLog(@"Hello World!");
}
return 0;
}10. SQL
SELECT 'Hello World';
PRINT 'Hello World';11. Ruby
puts 'Hello World'12. MATLAB
fprintf(1, 'Hello, world!');
quitAll example code is taken from the open‑source repository https://github.com/blackbird71SR/Hello-World . Readers are encouraged to contribute additional languages to the collection.
Python Programming Learning Circle
A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.