10 Programming Languages Side by Side (JS, Python, Ruby, PHP, GO, Rust, Dart, C#, Java, Ballerina)

How to print text to the console

  • print the value of variables to check that they have the right values
  • print the return values of functions so we can make sure they return the right value
  • be used just to print text to confirm parts of our code are running

Javascript

console.log("Hello World")

Python

print("Hello World")

Ruby

puts "Hello World"

PHP

<?phpecho "Hello World";?>

GO

import fmtfunc main(){
fmt.Println("Hello World")
}

Rust

fn main(){
print!("Hello World");
}

Dart

void main(){
print("Hello, World!");
}

C Sharp

using System;namespace HelloWorldApp {
class HelloWorld {
static void Main(string[] args){
Console.WriteLine("Hello World");
}
}
}

Java

class HelloWorld {
public static void main(String[] args){
System.out.println("Hello, World");
}
}

Ballerina

import ballerina/io;public function main() {
io:println("Hello World");
}

Declaring Variables

Javascript

let number = 5
let str = "Hello"
let bool = true
console.log(number, str, bool)

Python

number = 5
string = "hello"
boolean = True
print(number, string, boolean)

Ruby

num = 5
str = "Hello"
bool = true
puts num, str, bool

PHP

<?php
$num = 5;
$str = "Hello";
$bool = true;
echo $num;
echo $str;
echo $bool;
?>

GO

import fmtfunc main(){
num := 5
str := "Hello"
boolean := true
fmt.Println(num, str, boolean)
}

Rust

fn main(){
let num = 5;
let string = "Hello";
let boolean = true;
print!("{0} - {1} - {2}", num, string, boolean );
}

Dart

void main (){
var number = 5;
var string = "hello";
var boolean = true;
print(number, string, boolean);
}

C Sharp

using System;namespace MyProgramApp {
class MyProgram {
static void Main(string[] args){
int num = 5;
string str = "Hello";
bool boolean = true;
Console.WriteLine(num);
Console.WriteLine(str);
Console.WriteLine(boolean);
}
}
}

Java

class Main {
public static void main(String[] args){
int num = 5;
String str = "Hello";
boolean bool = true;
System.out.println(num);
System.out.println(str);
System.out.println(bool);
}
}

Ballerina

import ballerina/io;public function main(){
int num = 5;
string str = "Hello";
boolean bool = true;
io:println(num);
io:println(str);
io:println(bool);
}

Collection arrays and key/value pairs

  • Arrays/Lists that will be used to store data in an order that is referenced by a zero based index
  • A key/value pair structure by which you can reference different values based on a key.

Javascript

const myArray = [1,2,3,4,5]
const myObject = {name: "Alex Merced", age: 35}
console.log(myArray)
console.log(myObject)

Python

my_list = [1,2,3,4,5]
my_dictionary = {"name": "Alex Merced, "age": 35}
print(my_list)
print(my_dictionary)

Ruby

my_array = [1,2,3,4,5]
my_hash = {name: "Alex Merced", age: 35}
puts my_array
puts my_hash

PHP

<?php$my_array = [1,2,3,4,5];
$my_associative_array = ["name" => "Alex Merced", "age" => 35];
var_dump($my_array);
var_dump($my_associative_array);
?>

GO

import fmtfunc main(){
my_slice := []int{1,2,3,4,5}
my_map := map[string]string{"name":"alex merced", "age":"35"}
fmt.Println(my_slice)
fmt.Println(my_map)
}

Rust

use std::collections::HashMap;fn main(){
let my_array = [1,2,3,4,5];
let mut my_hashmap = HashMap::new();
my_hashmap.insert("name", "Alex Merced");
my_hashmap.insert("age", "35");
println!("{:?}", my_array);
println!("{:?}", my_hashmap);
}

Dart

void main (){
final my_list = [1,2,3,4,5];
final my_map = {"name": "Alex Merced", "age":"35"}
print(my_list);
print(my_map);
}

C Sharp

using System;
using System.Collections;
namespace MyProgramApp {
class MyProgram {
static void Main(string[] args){
int[] my_array = {1,2,3,4,5};
Hashtable my_ht = new Hashtable();
my_ht.Add("name", "Alex Merced");
my_ht.Add("age", "35");
Console.WriteLine(my_array);
Console.WriteLine(my_ht);
}
}
}

Java

import java.util.*;class MyProgram {
public static void main(String[] args){
int[] my_array = {1,2,3,4,5};
Hashtable my_ht = new Hashtable();
my_ht.put("name", "Alex Merced");
my_ht.put("age", "35");
System.out.println(my_array);
System.out.println(my_ht);
}
}

Ballerina

import ballerin/io;public function main(){
int[] my_array = [1, 2, 3, 4, 5];
map<string> my_map = {
"name": "Alex Merced",
"age" : "35"
};
io:println(my_array);
io:println(my_map);
}

Defining Function

  • declare/define the function
  • call/invoke the function

Javascript

function helloWorld(){
console.log("Hello World")
}
helloWorld()

Python

def hello_world():
print("Hello World")
hello_world()

Ruby

def hello_world
puts "Hello World"
end
hello_world

PHP

<?phpfunction helloWorld(){
echo "Hello World";
}
helloWorld();?>

GO

import fmtfunc helloWorld(){
fmt.Println("hello world")
}
func main(){
helloWorld()
}

Rust

fn hello_world(){
println!("Hello World");
}
fn main(){
hello_world();
}

Dart

void hello_world(){
print("Hello World");
}
void main(){
hello_world()
}

C Sharp

using System;namespace MyProgramApp {
class MyProgram {
static void Main(string[] args){
HelloWorld();
}
static void HelloWorld(){
Console.WriteLine("Hello World");
}
}
}

Java

class MyProgram {
public static void main(String[] args){
hello_world();
}
public static void hello_world(){
System.out.println("Hello, World");
}
}

Ballerina

import ballerina/io;function hello_world(){
io:println("Hello World");
}
public function main(){
hello_world();
}

Learning More

--

--

--

Alex Merced is a Developer Advocate for Dremio and host of the Web Dev 101 and Datanation Podcasts.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to Create a Staging site manually (Cpanel Step by step)

How to Create a Staging site manually (Cpanel Step by step)

A very cool portfolio!

Pixel Sorting in Python

Grand Fantasy Integrates Chainlink Sports Data to Power March Madness Contests

Interactive Processing Development with Clojure REPL in IntelliJ IDEA

Flight Centre Hackathon of 2k17

Serverless data sync between Quickbooks Online and Salesforce using Kumologica

Vulnhub- DC 2

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alex Merced Coder

Alex Merced Coder

Alex Merced is a Developer Advocate for Dremio and host of the Web Dev 101 and Datanation Podcasts.

More from Medium

Connect to your MySQL Database using C# & Windows Forms

Introduction to MongoDB

What is the best programming language?

How to Build a Portable Platform Independent Web Server in Java