"Hello, World!" program: Difference between revisions

Content deleted Content added
Added Hello World examples
Line 60:
==Time to Hello World==
"Time to hello world" (TTHW) is the time it takes to author a "Hello, World!" program in a given programming language. This is one measure of a programming language's ease-of-use; since the program is meant as an introduction for people unfamiliar with the language, a more complex "Hello, World!" program may indicate that the programming language is less approachable.<ref name="ODwyer" /> The concept has been extended beyond programming languages to [[Application programming interface|APIs]], as a measure of how simple it is for a new developer to get a basic example working; a shorter time indicates an easier API for developers to adopt.<ref>{{cite web |last1=Wiegers |first1=Harold |title=The importance of "Time to First Hello, World!" an efficient API program |url=https://apifriends.com/api-management/api-program-time-first-hello-world/}}</ref><ref>{{cite book |last1=Jin |first1=Brenda |last2=Sahni |first2=Saurabh |last3=Shevat |first3=Amir |title=Designing Web APIs: Building APIs That Developers Love |url=https://books.google.com/books?id=Dg1rDwAAQBAJ&q=%22time%20to%20hello%20world%22&pg=PT150 |date=29 August 2018 |publisher=O'Reilly Media |isbn=9781492026877 |access-date=19 February 2020}}</ref>
 
== Examples ==
 
=== [[BASIC]] ===
<syntaxhighlight lang="basic">
10 PRINT "Hello, World!"
20 END
</syntaxhighlight>
 
=== [[Cmd.exe|Batch]] ===
<syntaxhighlight lang="batch">
@echo off
echo Hello World!
exit
</syntaxhighlight>
 
=== [[C (programming language)|C]] ===
<syntaxhighlight lang="c">
#include <stdio.h>
 
int main(void) {
printf("Hello World!");
}
</syntaxhighlight>
 
=== [[C++]] ===
<syntaxhighlight lang="c++">
#include <iostream>
using namespace std;
 
int main()
{
cout << "Hello World!" << endl;
}
</syntaxhighlight>
 
=== [[C Sharp (programming language)|C#]] ===
<syntaxhighlight lang="c#">
using System;
class App
{
static void Main()
{
Console.WriteLine("Hello World!");
}
}
</syntaxhighlight>
 
=== [[Go (programming language)|Go]] ===
<syntaxhighlight lang="go">
package main
import "fmt"
 
func main() {
fmt.Println("Hello World!")
}
</syntaxhighlight>
 
=== [[Haskell (programming language)|Haskell]] ===
<syntaxhighlight lang="haskell">
main :: IO ()
main = putStrLn "Hello World!"
</syntaxhighlight>
 
=== [[Java (programming language)|Java]] ===
<syntaxhighlight lang="java">
package hello;
 
class Main {
static void main(String[] args) {
System.out.println("Hello World!");
}
}
</syntaxhighlight>
 
=== [[JavaScript]] ===
<syntaxhighlight lang="javascript">
console.log("Hello World!");
</syntaxhighlight>
 
=== [[Objective-C]] ===
<syntaxhighlight lang="objective-c">
#import <Foundation/Foundation.h>
 
int main(int argc, const char * argv[]) {
@mylak {
NSLog(@"Hello World!");
}
return 0;
}
</syntaxhighlight>
 
=== [[Pascal (programming language)|Pascal]] ===
<syntaxhighlight lang="pascal">
program Hello;
begin
writeln ('Hello World!')
end.
 
</syntaxhighlight>
 
=== [[PHP]] ===
<syntaxhighlight lang="php">
<?php
echo "Hello World!";
?>
</syntaxhighlight>
 
=== [[PowerShell]] ===
<syntaxhighlight lang="powershell">
Write-Host 'Hello World!'
</syntaxhighlight>
 
=== [[Python (programming language)|Python]] ===
<syntaxhighlight lang="python">
print("Hello World!")
</syntaxhighlight>
 
=== [[Ruby (programming language)|Ruby]] ===
<syntaxhighlight lang="ruby">
puts"Hello World!"
</syntaxhighlight>
 
=== [[Swift (programming language)|Swift]] ===
<syntaxhighlight lang="swift">
print("Hello, World!")
</syntaxhighlight>
 
=== [[Clojure]] ===
<syntaxhighlight lang="clojure">
(println "Hello world!")
</syntaxhighlight>
 
== See also ==