Hello World Category

"Hello, World!" in Pascal

How to do "Hello, World!" in Pascal.

(* hello-world.p *)
program HelloWorld;
begin
    WriteLn('Hello, World!');
end.

Pascal was one of the first computer languages I learned, back in the late 1980s and early 1990s. The Borland Turbo Pascal compiler was really fast, and I once actually took a university course in Computer Science, where we wrote code in Pascal on Macintosh computers. This was in 1996. A few years later, I had the opportunity to try Delphi 8 (Octane), which among other things had an immensly superior "Intellisense" solution.

For more "Hello, World!" examples, go to the Hello World category.

Posted by Anders Tornblad on Category Hello World Labels
Tweet this

"Hello, World!" in Brainfuck

How to do "Hello, World!" in Brainfuck.

[ hello-world.bf ]
--------[>+>++++
+>-->-->--->++++
>------<<<<<<<--
-----]>.>---.>--
--..>-.>++++.>.>
+++++++.<<<.+++.
<.<-.>>>>+.

This is what legacy code feels like sometimes!

For more "Hello, World!" examples, go to the Hello World category.

Posted by Anders Tornblad on Category Hello World Labels
Tweet this

"Hello, World!" in ZX Spectrum machine code

How to do "Hello, World!" in ZX Spectrum machine code.

; hello-world.z80
CHAN_OPEN   equ  5633
PRINT       equ  8252

            org  32512

            ld   a, 2                ; 3E 02
            call CHAN_OPEN           ; CD 01 16
            ld   de, text            ; 11 0E 7F
            ld   bc, textend-text    ; 01 0E 00
            jp   PRINT               ; C3 3C 20

text        defb 'Hello, World!'     ; 48 65 6C 6C 6F 2C 20 57
                                     ; 6F 72 6C 64 21
            defb 13                  ; 0D

textend     equ  $

This piece of code calls two subroutines in the original ZX Spectrum ROM. First it calls CHAN-OPEN which sets the current output channel to number 2 (normal screen output), and then it calls PRINT, which prints a string of characters to the selected channel. To print this on a ZX Printer, simply select channel 3 instead.

For more "Hello, World!" examples, go to the Hello World category.

Posted by Anders Tornblad on Category Hello World Labels
Tweet this

"Hello, World!" in CSS

How to do "Hello, World!" in CSS.

/* hello-world.css */
html::before {
    content: 'Hello, World!'
}

This is a very unorthodox use of CSS. Combined with an empty valid HTML document, this will produce an output in any browser. I made a pen for you.

For more "Hello, World!" examples, go to the Hello World category.

Posted by Anders Tornblad on Category Hello World Labels
Tweet this

"Hello, World!" in HTML

How to do "Hello, World!" in HTML5.

<!-- hello-world.html -->
<!doctype html>
<title>Hello, World!</title>
<p>Hello, World!

Most of the structure of an HTML document, including the html, head and body elements, can be left out without invalidating the document. Also, most block-level elements are self-closing. For instance, the segment <p>Hello<div>World is perfectly equivalent to <p>Hello</p><div>World</div>, which can sometimes be unintuitive, especially in combination with CSS or the querySelector function.

For more "Hello, World!" examples, go to the Hello World category.

Posted by Anders Tornblad on Category Hello World Labels
Tweet this

"Hello, World!" in JavaScript

How to do "Hello, World!" in JavaScript.

// hello-world.js
'use strict';
console.log('Hello, World!')

JavaScript has really matured over the last years. Though it started out as a browser-only language, giving grey hairs to web developers everywhere, it is now a competent language in its own right. Combined with initiatives such as node.js, it performs on par with most other system languages. The code above works in your browser (printing to the developer console) as well as in node.js (printing to your terminal output). And yes, you should always go for strict mode.

For more "Hello, World!" examples, go to the Hello World category.

Posted by Anders Tornblad on Category Hello World Labels
Tweet this

"Hello, World!" in PHP

How to do "Hello, World!" in PHP.

// hello-world.php
<?php
echo 'Hello, World!';
?>

Even though PHP is mostly used for adding server-side functionality to web pages, PHP is actually a self-containing language that can be run on a lot of different platforms, both in a web server and completely stand-alone. When PHP is run inside a web server, the echo function renders output to the response of an HTTP request. When PHP is run from the command line, it prints to the console.

For more "Hello, World!" examples, go to the Hello World category.

Posted by Anders Tornblad on Category Hello World Labels
Tweet this

"Hello, World!" in Java

How to do "Hello, World!" in Java.

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

I have never really gotten into the Java world. I wrote some Java code in Notepad back in the 1990s and liked the language, but then I had the misfortune of having to use Eclipse at work a few times, and hated the whole experience, from installation to debugging.

For more "Hello, World!" examples, go to the Hello World category.

Posted by Anders Tornblad on Category Hello World Labels
Tweet this

"Hello, World!" in C sharp

How to do "Hello, World!" in C#.

// hello-world.cs
class HelloWorld
{
    static void Main()
    {
        System.Console.WriteLine("Hello, World!");
    }
}

For writing desktop and server applications, C# has been my language of choice for over ten years now, both for work and for side projects. I really like PHP too, but I don't think it can measure up to the maturity of C#, even though PHP7 looks really nice. The size of the .NET Framework and all the open source NuGet packages available really help focusing on what to do, instead of how to do it.

For more "Hello, World!" examples, go to the Hello World category.

Posted by Anders Tornblad on Category Hello World Labels
Tweet this

"Hello, World!" in C plus plus

How to do "Hello, World!" in C++.

// hello-world.cpp
#include <iostream>

int main() {
    std::cout << "Hello, World!" << std::endl;
    return 0;
}

About ten years after the birth of the C language, object oriented paradigms were added to form the C++ language. The latest version of the C++ standard is called C++14.

For more "Hello, World!" examples, go to the Hello World category.

Posted by Anders Tornblad on Category Hello World Labels
Tweet this

"Hello, World!" in C

How to do "Hello, World!" in C.

// hello-world.c
#include <stdio.h>

int main()
{
    puts("Hello, World!");
    return 0;
}

The C language is mother and grandmother of a whole range of modern languages, like C++, PHP, C#, Java, Objective C, Swift, JavaScript and others. Development of the language is continuing, and the latest version, from December of 2011, is called C11. C is still in heavy use, mostly for embedded systems, realtime applications and operating systems on small devices.

For more "Hello, World!" examples, go to the Hello World category.

Posted by Anders Tornblad on Category Hello World Labels
Tweet this