YeenDeer softness blog (programming and electronics)

Ellie the Yeen is a soft YeenDeer that mweeoops and does programming

View on GitHub About Bots Projects Tags

Hello World In Many Languages

Hello world is the most basic program that you tend to try out in a programming language. Here we are going to look at several languages and how to do hello world in them.

Python is quite simple that it just has a print function you can run and print what yo want to print. The signature of the print function is print(*args, sep=' ', end='\n', flush=False) so you can specify if to flush the stream and what separator and what to end each print with. Started with python

print("Hello world")

Ruby is very similar that it has a puts function you call and Ruby has a specialty that you can call functions without having to use parentheses. Started with ruby hello.rb


puts "Hello world"

Yes you can in fact run java like this and run with java even you tend to compile it with javac

class hello {
 public static void main(String[] args) {
  System.out.println("Hello world");

Erlang is a quite unusual language that you use recursion instead of iteration and it tends to be compiled too but you can run this with escript hello.erl


main(_) ->
  io:format("~s~n", ["Hello world"]).

NodeJS allows you to run JavaScript on the command line and you can start it with nodejs hello.js


console.log("Hello world")

Julia is a rather interesting language and you run this with julia hello.jl


println("Hello world");

Perl since why not and run with perl

print "Hello world\n"

PHP requires the start tag in order to run the thing and you run it with php hello.php


echo "Hello world\n";

The script to run all hello world programs is ./

echo -e '\e[31;1mErlang\e[39m'
time escript hello.erl
echo -e '\e[31;1mJulia\e[39m'
time julia hello.jl
echo -e '\e[31;1mJavaScript\e[39m'
time nodejs hello.js
echo -e '\e[31;1mPerl\e[39m'
time perl
echo -e '\e[31;1mPython\e[39m'
time python
echo -e '\e[31;1mRuby\e[39m'
time ruby hello.rb
echo -e '\e[31;1mPHP\e[39m'
time php hello.php
echo -e '\e[31;1mJava\e[39m'
time java

Which gives the output and as you see Java is a bit slow when not compiled


Hello world
escript hello.erl  0.29s user 0.16s system 137% cpu 0.331 total
Hello world
julia hello.jl  0.30s user 0.23s system 102% cpu 0.516 total
Hello world
nodejs hello.js  0.50s user 0.05s system 100% cpu 0.547 total
Hello world
perl  0.00s user 0.01s system 93% cpu 0.007 total
Hello world
python  0.05s user 0.01s system 96% cpu 0.063 total
Hello world
ruby hello.rb  0.20s user 0.05s system 99% cpu 0.248 total
Hello world
php hello.php  0.01s user 0.04s system 98% cpu 0.049 total
Hello world
java  2.03s user 0.19s system 117% cpu 1.887 total


By ellietheyeen 10 December 2023 Permalink Tags: shell