Skip to content

Marhc/hellozine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 

Repository files navigation

Hellozine

A collection of different ways to write "Hello World!".

Echo on Bash

echo Hello World!

Echo with parameter expansion on Bash

echo "Hello $(echo World)!"

name='World'
echo "Hello $name!"

message='Hello @!'
echo "${message/@/World}"

Printf on Bash

printf 'Hello %s!\n' World

Echo on Powershell

echo 'Hello World!'

Write-Host on Powershell

Write-Host Hello World!

Echo or Write-Host with interpolation on Powershell

echo ('Hello {0}!' -f 'World')
Write-Host ('Hello {0}!' -f 'World')

$name = 'World'
echo "Hello $name!"

Print on Python

print('Hello World!')

Print with string interpolation on Python

print('Hello %s!' % 'World')

Print with format method on Python

print('Hello {0}!'.format('World'))

Print with f-strings on Python

print(f'Hello { "World" }!')
print(f"Hello { 'World' }!")

Echo, print, printf and print_r on PHP

<?php
  echo "Hello World!\n";
  print("Hello World!\n");
  printf("Hello World!\n");
  print_r("Hello World!\n");

Printf and echo with string interpolation on PHP

<?php
  printf("Hello %s!\n", "World");

  $name = 'World';
  echo "Hello $name!\n";

Console.log on Javascript

console.log('Hello World!');

Console.log with string interpolation on Javascript

console.log('Hello %s!', 'World');

Console.log with Template literals on Javascript

const message = 'World';
console.log(`Hello ${ message }!`);

Alert on Javascript (Browser only)

alert('Hello World!');

Document.write on Javascript (Browser only)

document.write("Hello World!");

CSS

body::before {
  content: "Hello World!";
}

SQL

SELECT 'Hello World!';

HTML

<!DOCTYPE html>
<html>
<head>
  <title>Hello World!</title>
</head>
<body>
  <p>Hello World!</p>
</body>
</html>

JSON

{
  "message": "Hello World!"
}

XML

<xml>
  <message>Hello World!</message>
</xml>

YAML

---
message: Hello World!

Markdown

Hello World!

TOML

[message]
text = "Hello World!"

CSV

message
Hello World!

jQuery

<!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>

SASS

@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

SCSS

$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;
}

Java

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

R

cat("Hello World!")

Cobol

        IDENTIFICATION DIVISION.
        PROGRAM-ID. HELLOWORLD.
        PROCEDURE DIVISION.
          DISPLAY 'Hello World!'.
        STOP RUN.

VBScript

MsgBox "Hello World!"

VB.NET

Module HelloWorld
    Sub Main()
        Console.WriteLine("Hello World!")
    End Sub
End Module

VBA

Sub HelloWorld()
    MsgBox "Hello World!"
End Sub

Swift

print("Hello World!")

Kotlin

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

Dart

void main() {
  print("Hello World!");
}

Express.js

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}`);
});

Flask

from flask import Flask

app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello World!'

if __name__ == '__main__':
    app.run()

FastAPI

from fastapi import FastAPI

app = FastAPI()

@app.get("/")
def hello_world():
    return "Hello World!"

Django

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}")

Laravel

Route::get('/', function () {
    return 'Hello World!';
});

.NET Core Web API

using Microsoft.AspNetCore.Mvc;

namespace HelloWorld.Controllers
{
    [ApiController]
    [Route("[controller]")]
    public class HelloWorldController : ControllerBase
    {
        [HttpGet]
        public ActionResult<string> Get()
        {
            return "Hello World!";
        }
    }
}

C#

using System;

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

String interpolation on C#

using System;

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

Dockerfile

FROM alpine:latest

CMD ["echo", "Hello World!"]

Docker CLI

docker run hello-world
docker run --rm alpine:latest echo Hello World!

Functional Component on React

import React from 'react';

function HelloWorld() {
  return <h1>Hello World!</h1>;
}

export default HelloWorld;

Class Component on React

import React from 'react';

class HelloWorld extends React.Component {
  render() {
    return (
      <div>
        <h1>Hello World!</h1>
      </div>
    );
  }
}

export default HelloWorld;

Vue

<template>
  <div>
    <h1>{{ greeting }}</h1>
  </div>
</template>

<script>
export default {
  data() {
    return {
      greeting: 'Hello World!'
    };
  }
};
</script>

Svelte

<script>
  let greeting = 'Hello World!';
</script>

<main>
  <h1>{greeting}</h1>
</main>

Angular

import { Component } from '@angular/core';

@Component({
  selector: 'app-hello-world',
  template: '<h1>{{ greeting }}</h1>'
})
export class HelloWorldComponent {
  greeting: string = 'Hello World!';
}

Preact

import { h, render } from 'preact';

const App = () => <h1>Hello World!</h1>;

render(<App />, document.body);

Next

export default function Home() {
  return (
    <div>
      <h1>Hello World!</h1>
    </div>
  );
}

Micronaut

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!";
    }
}

RESTEasy

@Path("/")
public class HelloWorldResource {

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String sayHello() {
        return "Hello World!";
    }
}

Spring Boot

@RestController
public class HelloWorldController {

    @GetMapping("/hello")
    public String hello() {
        return "Hello World!";
    }
}

TailwindCSS

<!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>

Styled-Components

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;

Bootstrap

<!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>

LESS (Leaner Style Sheets)

@message: "Hello World!";
@color: red;

.hello-world {
  color: @color;
  content: @message;
}

Emotion CSS

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;

Stylus CSS

hello-world
  text-align center
  font-size 24px
  color #333

div
  .hello-world
    Hello World!

Lit

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);

JSS ("Javascript Style Sheets" or "CSS-in-JS")

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'));

React Native

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>
  );
}

Flutter

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),
          ),
        ),
      ),
    );
  }
}

Go

package main

import "fmt"

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

About

A collection of different ways to write "Hello World!".

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published