Skip to main content

Code Comparison

See how 26 languages express the same programming concepts.
Click tabs to switch features.

← Back to Beauty Index Read the methodology → Score justifications →

Filter languages (0/26)
Beautiful
Handsome
Practical
Workhorses

Variable Declaration

Basic variable syntax, type annotations, and initialization patterns.

name = "Python"
count: int = 0
languages: list[str] = ["Python", "Ruby"]
x, y = 10, 20
count += 1
PI: float = 3.14159
name = "Ruby"
count = 0
languages = ["Ruby", "Python"]
x, y = 10, 20
count += 1
MAX_SIZE = 1024
@instance_var = "hello"
name = "Elixir"
age = 12
{status, message} = {:ok, "Connected"}
[head | tail] = [1, 2, 3, 4]
%{name: lang} = %{name: "Elixir", year: 2011}
let name = "Rust";
let mut count: i32 = 0;
let (x, y) = (10, 20);
count += 1;
const MAX_SIZE: usize = 1024;
let inferred = vec![1, 2, 3];
greeting :: String
greeting = "Hello, World!"
add :: Int -> Int -> Int
add x y = x + y
result :: Int
result = add 3 7
(def name "Clojure")
(def languages ["Clojure" "Java"])
(let [count 0
x 10
y 20
total (+ x y)]
(println name total))
F#
let name = "F#"
let mutable count = 0
let languages = ["F#"; "C#"; "OCaml"]
count <- count + 1
let x, y = 10, 20
let pi : float = 3.14159
let name = "Gleam"
let count: Int = 0
let languages = ["Gleam", "Erlang"]
let #(x, y) = #(10, 20)
let result = count + x + y
val name = "Kotlin"
var count: Int = 0
val languages = listOf("Kotlin", "Java", "Scala")
count += 1
val (x, y) = Pair(10, 20)
val nullable: String? = null
let name = "Swift"
var count: Int = 0
let languages = ["Swift", "Objective-C"]
count += 1
let optional: String? = nil
let (x, y) = (10, 20)
(defvar *name* "Lisp")
(defparameter *count* 0)
(let ((x 10)
(y 20)
(langs '("Lisp" "Scheme")))
(+ x y (length langs)))
let name = "OCaml"
let count = ref 0
let languages = ["OCaml"; "Haskell"]
let () = count := !count + 1
let x, y = 10, 20
let (pi : float) = 3.14159
Go
name := "Go"
var count int = 0
languages := []string{"Go", "C"}
count++
var (
x = 10
y = 20
)
const MaxSize = 1024
name = "Julia"
count::Int = 0
languages = ["Julia", "Python"]
count += 1
x, y = 10, 20
const MAX_SIZE = 1024
val name = "Scala"
var count: Int = 0
val languages = List("Scala", "Java")
count += 1
val (x, y) = (10, 20)
lazy val expensive = computeResult()
Zig
const name = "Zig";
var count: i32 = 0;
const languages = [_][]const u8{ "Zig", "C" };
count += 1;
const x: u32 = 10;
const y: u32 = 20;
const name: string = "TypeScript";
let count = 0;
const languages: string[] = ["TS", "JS"];
count += 1;
const [x, y] = [10, 20];
const { age, ...rest } = { age: 30, name: "TS" };
C
char *name = "C";
int count = 0;
const char *languages[] = {"C", "C++"};
count++;
int x = 10, y = 20;
#define MAX_SIZE 1024
Lua
local name = "Lua"
local count = 0
local languages = {"Lua", "C"}
count = count + 1
local x, y = 10, 20
-- No constants in Lua
final name = 'Dart';
var count = 0;
final languages = <String>['Dart', 'Flutter'];
count++;
const maxSize = 1024;
String? nullable;
late final String deferred;
C#
var name = "C#";
int count = 0;
var languages = new List<string> { "C#", "F#" };
count++;
var (x, y) = (10, 20);
const int MaxSize = 1024;
R
name <- "R"
count <- 0L
languages <- c("R", "Python")
count <- count + 1L
x <- 10; y <- 20
MAX_SIZE <- 1024L
String name = "Java";
int count = 0;
var languages = List.of("Java", "Kotlin");
count++;
final int MAX_SIZE = 1024;
var x = 10;
var y = 20;
const name = "JavaScript";
let count = 0;
const languages = ["JS", "TS"];
count++;
const [x, y] = [10, 20];
const { age, ...rest } = { age: 30, name: "JS" };
C++
auto name = std::string("C++");
int count = 0;
auto languages = std::vector<std::string>{"C++", "C"};
count++;
auto [x, y] = std::pair(10, 20);
constexpr int MAX_SIZE = 1024;
PHP
$name = 'PHP';
$count = 0;
$languages = ['PHP', 'Python'];
$count++;
[$x, $y] = [10, 20];
define('MAX_SIZE', 1024);
const VERSION = '8.3';

Feature Support Matrix

Quick reference showing which languages support each feature.

Language Variable Declaration If/Else Loops Functions Structs Pattern Matching Error Handling String Interpolation List Operations Signature Idiom
C Beauty Index profile
C# Beauty Index profile
C++ Beauty Index profile
Clojure Beauty Index profile
Dart Beauty Index profile
Elixir Beauty Index profile
F# Beauty Index profile
Gleam Beauty Index profile
Go Beauty Index profile
Haskell Beauty Index profile
Java Beauty Index profile
JavaScript Beauty Index profile
Julia Beauty Index profile
Kotlin Beauty Index profile
Lisp Beauty Index profile
Lua Beauty Index profile
OCaml Beauty Index profile
PHP Beauty Index profile
Python Beauty Index profile
R Beauty Index profile
Ruby Beauty Index profile
Rust Beauty Index profile
Scala Beauty Index profile
Swift Beauty Index profile
TypeScript Beauty Index profile
Zig Beauty Index profile