Hello World Python3, Bash, C, C++, Go, Lua, Ruby, Java – Programming Languages on Ubuntu 18.04

Hello world! All programs start with a hello world. It tests that your environment is working, so that you can run your code.
This is how you install and run the most important languages on Linux: Python 3, Bash, C, C++, Go, Lua, Ruby and Java.

Tested on Ubuntu 18.04 LTS (Xubuntu). All languages installed with apt-get, from default repositories.

Python 3

$ cat hellotero.py
print("Hello Tero")
$ python3 hellotero.py
Hello Tero

Bash

$ cat hellotero.sh
echo "Hello Tero"
$ bash hellotero.sh
Hello Tero

C

$ cat hellotero.c
#include <stdio.h>
int main()
{
 printf("Hello Tero\n");
}
$ gcc hellotero.c -o helloteroc
$ ./helloteroc
Hello Tero

C++ (cpp)

$ cat hellotero.cc
#include <iostream>
int main()
{
 std::cout << "Hello Tero\n";
}
$ g++ hellotero.cc -o helloterocc
$ ./helloterocc
Hello Tero

Java

$ cat HelloTero.java   # filename must match class name
public class HelloTero
{
 public static void main(String[] args)
 {
 System.out.println("Hello Tero");
 }
}
$ javac HelloTero.java
$ java HelloTero   # do not write .class here
Hello Tero

Go

$ sudo apt-get -y install golang-go
$ cat hellotero.go
package main
import "fmt"
func main() {
 fmt.Printf("Hello Tero\n")
}
$ go build -o helloterogo hellotero.go
$ ./helloterogo
Hello Tero

Ruby

$ cat hellotero.rb
print ("Hello Tero\n")
$ ruby hellotero.rb
Hello Tero

Lua

$ cat hellotero.lua
print("Hello Tero")
$ lua hellotero.lua
Hello Tero
Posted in Uncategorized | Tagged , , , , , , , , , , , , , | Comments Off on Hello World Python3, Bash, C, C++, Go, Lua, Ruby, Java – Programming Languages on Ubuntu 18.04

Comments are closed.