How to make "Hello World" in different programming languages.
A lot of them must be compiled before run, short instructions for MacOS below (tested on 10.15.7 / Catalina).
- Assembly (.asm)
nasm -fmacho64 hello.asm
ld -macosx_version_min 10.7.0 -lSystem -o hello hello.o
./hello
- C (.c)
gcc hello.c
./a.out
- C++ (.cpp)
g++ hello.cpp -o hello
./hello
- Cobol (.cbl)
brew instal gnu-cobol
pip3 install OpenCobolIDE --upgrade
(optional)brew install PyQt5
(optional)OpenCobolIDE
- now you have graphic compiler and you can create new cobol file
- best tutorial (in my opinion): https://www.globalnerdy.com/2020/04/15/a-quick-and-dirty-guide-to-installing-a-cobol-compiler-and-ide-on-macos-and-get-a-cobol-book-at-a-discount/
- C# (.cs)
brew install mono
mcs hello.cs
mono hello.exe
- Erlang (.erl)
brew install erlang
erl hello.erl
(to open Erlang console)io:fwrite("Hello from Erlang\n").
- Elixir (.ex)
brew install elixir
elixir hello.ex
- Golang (.go)
go run hello.go
- Haskell (.hs)
brew install ghc
ghc -o hello hello.hs
ghc hello.hs
./hello
- Java (.java)
javac hello.java
java hello
- Kotlin (.kt)
kotlinc hello.kt -d kotlin.jar
java -jar kotlin.jar
- PHP (.php)
php hello.php
- Perl (.pl)
perl hello.pl
- Python (.py)
python hello.py
- Ruby (.rb)
ruby hello.rb
- Rust (.rs)
rustc hello.rs
./hello
- Scala (.sc)
scalac hello.scala
scala hello
- Bash (.sh)
sh hello.sh
- Swift (.swift)
swift
print ("Hello from Swift ")