Category: Uncategorized

  • Hello world in different computer languages

    We will write Hello world in different computer languages:

    • PHP
    • Python
    • C
    • Java

    Hello world in different computer languages will be implemented using Termux Linux emulator on an android smart phone.

    PHP

    PHP is server side programing language. There are many well known applications have been written using PHP such Meta’s Facebook, WordPress, Drupal, SugarCRM, Joomla, etc. Very popular language for Web development.

    Check out the version of PHP on your device.

    ~ $ pkg show php
    Package: php
    Version: 8.1.3-2
    Maintainer: @termux
    Installed-Size: 52.6 MB
    Depends: freetype, libandroid-glob, libandroid-support, libbz2, libcrypt, libcurl, libgd, libgmp, libiconv, liblzma, libresolv-wrapper, libsqlite, libxml2, libxslt, libzip, oniguruma, openssl, pcre2, readline, zlib, libicu, libffi, tidy, zstd
    Conflicts: php-mysql, php-dev
    Replaces: php-mysql, php-dev
    Homepage: https://php.net
    Download-Size: 8450 kB
    APT-Manual-Installed: yes
    APT-Sources: https://dl.kcubeterm.com/termux-main stable/main aarch64 Packages
    Description: Server-side, HTML-embedded scripting language

    Hello world in PHP language

    <?php
    echo "Hello world\n";
    ?>

    You do not need to compile PHP or Python program. Just run it from the command line.

    PHP code must start with <?php tag and end with ?>

    ~ $ php hello.php
    Hello world
    ~ $

    Hello world in Python language

    print("Hello world")

    Save your file with suffix .py. Run using python hello.py

    ~ $ python hello.py
    Hello wirld
    ~ $ more hello.py
    print("Hello world")
    ~ $

    Check python on your device

    ~ $ pkg show python
    Package: python
    Version: 3.10.4
    Maintainer: @termux
    Installed-Size: 50.0 MB
    Provides: python3
    Depends: gdbm, libandroid-posix-semaphore, libandroid-support, libbz2, libcrypt, libexpat, libffi, liblzma, libsqlite, ncurses, ncurses-ui-libs, openssl, readline, zlib
    Recommends: clang, make, pkg-config
    Suggests: python-tkinter
    Breaks: python2 (<= 2.7.15), python-dev
    Replaces: python-dev
    Homepage: https://python.org/
    Download-Size: 8948 kB
    APT-Manual-Installed: yes
    APT-Sources: https://dl.kcubeterm.com/termux-main stable/main aarch64 Packages
    Description: Python 3 programming language intended to enable clear programs
    ~ $ python
    Python 3.10.4 (main, Mar 25 2022, 15:08:58) [Clang 12.0.8 (https://android.googlesource.com/toolchain/llvm-project c935d99d7 on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> exit
    Use exit() or Ctrl-D (i.e. EOF) to exit

    Hello world in C language

    C language is a general purpose system programming language and it’s one of the oldest programming language. You have compile your codes using a compiler and create executable binary file to run the program.

    See implementation of checking if number is a prime or not at https://broadoakdata.uk/hello-c-termux/

    ~ $ more hello.c                   #include <stdio.h>                 int main(){                          printf("Hello world\n");           return 0;                        }
    ~ $ gcc hello.c -o hello
    ~ $ ./hello
    Hello world

    Hello world in Java language

    Java is an object oriented language by design. You also need to compile your code into byte codes using Java compiler. The bytes codes will sun on any systems which support Java.

    ~ $ more hello.java                class hello{
        public static void main(String args[]){       System.out.println("Hello Java");                                    }                              }
    ~ $ javac hello.java
    ~ $ java hello
    Hello Java