A collection of different ways to write "Hello World!".
echo Hello World!
echo "Hello $(echo World)!"
name='World'
echo "Hello $name!"
message='Hello @!'
echo "${message/@/World}"
printf 'Hello %s!\n' World
echo 'Hello World!'
Write-Host Hello World!
echo ('Hello {0}!' -f 'World')
Write-Host ('Hello {0}!' -f 'World')
$name = 'World'
echo "Hello $name!"
print('Hello World!')
print('Hello %s!' % 'World')
print('Hello {0}!'.format('World'))
print(f'Hello { "World" }!')
print(f"Hello { 'World' }!")
<?php
echo "Hello World!\n";
print("Hello World!\n");
printf("Hello World!\n");
print_r("Hello World!\n");
<?php
printf("Hello %s!\n", "World");
$name = 'World';
echo "Hello $name!\n";
console.log('Hello World!');
console.log('Hello %s!', 'World');
const message = 'World';
console.log(`Hello ${ message }!`);
alert('Hello World!');
document.write("Hello World!");
body::before {
content: "Hello World!";
}
SELECT 'Hello World!';
<!DOCTYPE html>
<html>
<head>
<title>Hello World!</title>
</head>
<body>
<p>Hello World!</p>
</body>
</html>
{
"message": "Hello World!"
}
<xml>
<message>Hello World!</message>
</xml>
---
message: Hello World!
Hello World!
[message]
text = "Hello World!"
message
Hello World!
<!DOCTYPE html>
<html>
<head>
<title>Hello World!</title>
</head>
<body>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function() {
$("body").append("<p>Hello World!</p>");
});
</script>
</body>
</html>
@import 'compass/reset'
$primary-color: #ff0000
body
background-color: $primary-color
color: white
text-align: center
font-size: 24px
padding-top: 100px
&:before
content: 'Hello World!'
display: block
$greeting: "Hello World!";
body:before {
content: $greeting;
display: block;
text-align: center;
font-size: 24px;
font-weight: bold;
padding: 20px;
background-color: #f7f7f7;
border: 1px solid #ccc;
margin: 20px auto;
width: 200px;
}
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
cat("Hello World!")
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLOWORLD.
PROCEDURE DIVISION.
DISPLAY 'Hello World!'.
STOP RUN.
MsgBox "Hello World!"
Module HelloWorld
Sub Main()
Console.WriteLine("Hello World!")
End Sub
End Module
Sub HelloWorld()
MsgBox "Hello World!"
End Sub
print("Hello World!")
fun main() {
println("Hello World!")
}
void main() {
print("Hello World!");
}
const express = require('express');
const app = express();
const port = 3000;
app.get('/', (_, res) => {
res.send('Hello World!');
});
app.listen(port, () => {
console.log(`Server listening on port ${port}`);
});
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World!'
if __name__ == '__main__':
app.run()
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def hello_world():
return "Hello World!"
from django.http import HttpResponse
from django.urls import path
from django.conf import settings
from django.conf.urls.static import static
from django.core.wsgi import get_wsgi_application
from django.core.management import execute_from_command_line
from django.core.exceptions import ImproperlyConfigured
from django.core.validators import validate_email
class HelloWorldView:
def __init__(self):
self.response = HttpResponse("Hello World!")
def __call__(self, request):
return self.response
urlpatterns = [
path('', HelloWorldView()),
]
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
application = get_wsgi_application()
if __name__ == '__main__':
try:
validate_email(settings.DEFAULT_FROM_EMAIL)
execute_from_command_line()
except ImproperlyConfigured as e:
print(f"Error: {e}")
Route::get('/', function () {
return 'Hello World!';
});
using Microsoft.AspNetCore.Mvc;
namespace HelloWorld.Controllers
{
[ApiController]
[Route("[controller]")]
public class HelloWorldController : ControllerBase
{
[HttpGet]
public ActionResult<string> Get()
{
return "Hello World!";
}
}
}
using System;
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
using System;
class Program
{
static void Main(string[] args)
{
String name = "World";
Console.WriteLine($"Hello { name }!");
Console.WriteLine("Hello {0}!", "World");
}
}
FROM alpine:latest
CMD ["echo", "Hello World!"]
docker run hello-world
docker run --rm alpine:latest echo Hello World!
import React from 'react';
function HelloWorld() {
return <h1>Hello World!</h1>;
}
export default HelloWorld;
import React from 'react';
class HelloWorld extends React.Component {
render() {
return (
<div>
<h1>Hello World!</h1>
</div>
);
}
}
export default HelloWorld;
<template>
<div>
<h1>{{ greeting }}</h1>
</div>
</template>
<script>
export default {
data() {
return {
greeting: 'Hello World!'
};
}
};
</script>
<script>
let greeting = 'Hello World!';
</script>
<main>
<h1>{greeting}</h1>
</main>
import { Component } from '@angular/core';
@Component({
selector: 'app-hello-world',
template: '<h1>{{ greeting }}</h1>'
})
export class HelloWorldComponent {
greeting: string = 'Hello World!';
}
import { h, render } from 'preact';
const App = () => <h1>Hello World!</h1>;
render(<App />, document.body);
export default function Home() {
return (
<div>
<h1>Hello World!</h1>
</div>
);
}
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Get;
import io.micronaut.http.annotation.Produces;
@Controller("/hello")
public class HelloWorldController {
@Get("/")
@Produces(MediaType.TEXT_PLAIN)
public String hello() {
return "Hello World!";
}
}
@Path("/")
public class HelloWorldResource {
@GET
@Produces(MediaType.TEXT_PLAIN)
public String sayHello() {
return "Hello World!";
}
}
@RestController
public class HelloWorldController {
@GetMapping("/hello")
public String hello() {
return "Hello World!";
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
<title>Hello World!</title>
</head>
<body>
<div class="flex justify-center items-center h-screen">
<h1 class="text-4xl text-blue-500 font-bold">Hello World!</h1>
</div>
</body>
</html>
import React from 'react';
import styled from 'styled-components';
const Greeting = styled.h1`
color: #ff00ff;
font-size: 24px;
font-weight: bold;
`;
const HelloWorld = () => {
return <Greeting>Hello World!</Greeting>;
};
export default HelloWorld;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<title>Hello World!</title>
</head>
<body>
<div class="container">
<h1>Hello World!</h1>
</div>
</body>
</html>
@message: "Hello World!";
@color: red;
.hello-world {
color: @color;
content: @message;
}
import React from 'react';
import { css } from '@emotion/react';
const HelloWorld = () => {
const helloWorldStyles = css`
text-align: center;
font-size: 24px;
color: #333;
`;
return (
<div css={helloWorldStyles}>
Hello World!
</div>
);
};
export default HelloWorld;
hello-world
text-align center
font-size 24px
color #333
div
.hello-world
Hello World!
import { html, css, LitElement } from 'lit';
class HelloWorld extends LitElement {
static styles = css`
:host {
display: block;
text-align: center;
font-size: 24px;
color: #333;
}
`;
render() {
return html`
<div>
Hello World!
</div>
`;
}
}
customElements.define('hello-world', HelloWorld);
import React from 'react';
import ReactDOM from 'react-dom';
const styles = {
helloWorld: {
fontSize: '20px',
color: 'red',
},
};
const HelloWorld = () => {
return (
<div className={styles.helloWorld}>
Hello World!
</div>
);
};
ReactDOM.render(<HelloWorld />, document.getElementById('root'));
import React from 'react';
import { Text, View } from 'react-native';
export default function App() {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Text>Hello World!</Text>
</View>
);
}
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Hello World!'),
),
body: Center(
child: Text(
'Hello World!',
style: TextStyle(fontSize: 24),
),
),
),
);
}
}
package main
import "fmt"
func main() {
fmt.Println("Hello World!")
}