Loading
October 26, 2026

AmirHesamTech

Raspberry Pi, homelab, Linux and automation — projects and practical guides

The same tasks in Java, Python, JavaScript and TypeScript

Learning a second programming language is mostly discovering that you already know the ideas. A loop is a loop; only the syntax changes. My Multi_Language_Project on GitHub makes that visible: the same small problems solved in Java, Python, JavaScript and TypeScript, in one repository, so you can open two files side by side and see exactly where they differ.

  • Nine tasks — from swapping two variables to finding a median — solved in several languages.
  • Theory files per language: printing, loops, collections, classes, exceptions and the things each language does its own way.
  • Independent folders. You only need the language you’re working in installed.

Run it

git clone https://github.com/amirh3sam/Multi_Language_Project.git
cd Multi_Language_Project

python python/tasks/median_number.py                          # Python
node src/JavaScript/tasks/MedianNumber.js                      # JavaScript
npx tsc src/TypeScript/MedianNumber.ts && node src/TypeScript/MedianNumber.js   # TypeScript

For Java, open the project in IntelliJ IDEA and run any class with a main method.

The tasks

Task Java Python JavaScript TypeScript
Swap two variables ✓ ✓ ✓ —
Combine two words ✓ ✓ ✓ —
Reverse something ✓ ✓ — ✓
Remove duplicates ✓ ✓ ✓ ✓
Merge two arrays ✓ ✓ ✓ —
Frequency of a word ✓ ✓ ✓ —
Median of a list ✓ ✓ ✓ ✓
Remove the last comma ✓ ✓ — —
A small calculator ✓ ✓ ✓ —

One task, four languages: remove duplicate characters

This is the one that exists in all four, so it’s the best place to start. The goal: keep the first time each character appears and drop the repeats. All four versions use the same idea — walk through the string and only add a character if the result doesn’t contain it yet.

Advertisement

Java (src/Java/tasks/RemoveDuplicate.java):

String str = "xxxcccddddssswwewrsawer";
String result = "";
for (int i = 0; i < str.length(); i++) {
    if (result.contains(str.charAt(i) + "")) {
        continue;
    }
    result += str.charAt(i);
}
System.out.println(result);   // xcdswera

Python (python/tasks/remove_duplicate.py):

str = "aaassddffrree"
result = ""
for i in range(0, len(str)):
    if str[i] not in result:
        result += str[i]
print(result)   # asdfre

JavaScript (src/JavaScript/tasks/RemovedDuplicate.js):

let str = "aaaassssdderfff";
let result = "";
for (let i = 0; i < str.length; i++) {
    if (result.includes(str.charAt(i))) {
        continue;
    }
    result += str.charAt(i);
}
console.log(result);   // asderf

TypeScript (src/TypeScript/RemoveDuplicate.ts):

const str: string = "aaaassssdderfff";
let result: string = "";
for (let i = 0; i < str.length; i++) {
    // @ts-ignore
    if (result.includes(str[i])) {
        continue;
    }
    result += str[i];
}
console.log(result);   // asderf

What the comparison teaches

Java Python JavaScript TypeScript
“Does it contain?” contains() (needs a String, hence + "") the in operator includes() includes()
Getting a character charAt(i) str[i] charAt(i) or str[i] str[i]
Types Declared Inferred at run time Inferred at run time Declared, then removed when compiled
Blocks Braces Indentation Braces Braces

Two details worth fixing when you write this yourself:

  • In Python, don’t call a variable str. It hides the built-in str() function for the rest of the file. text or word is safer.
  • In TypeScript, the // @ts-ignore is covering for a setting. String.prototype.includes comes from ES2015; if the compiler targets an older version it complains. Setting "target": "ES2015" (or newer) in tsconfig.json removes the error properly instead of silencing it.

And if you want a shorter answer once the loop makes sense: Python’s "".join(dict.fromkeys(text)) and JavaScript’s [...new Set(text)].join("") both keep the first occurrence of each character in order.

What’s in each language folder

  • Java (src/Java): 25 theory files and 16 tasks — printing, primitives and casting, strings, operators, conditionals, loops, arrays, methods, classes, and the four pillars of object orientation in their own files.
  • Python (python): 30 theory files and 9 tasks — the widest coverage, including the four built-in collections one at a time and reading files from python/files.
  • JavaScript (src/JavaScript): 16 theory files and 7 tasks — the basics, then arrow functions, callbacks and promises, best read in that order.
  • TypeScript (src/TypeScript): 7 files focused on arrays. Each .ts sits next to the .js it compiles to, so you can see what TypeScript produces once the types are stripped away.

Setting up IntelliJ IDEA for all four

Language What to set
Java File → Project Structure → Project: choose a JDK, version 11 or newer
Python Install Python, add it under Project Structure → SDKs, and enable the Python plugin
JavaScript / TypeScript Install Node.js, then set it under Settings → Languages & Frameworks → Node.js

Frequently asked questions

Do I need all four languages installed?

No. Each folder stands alone — install only the one you’re using.

The Python file examples can’t find their files.

They use relative paths, so run them from the top of the repository: python python/theory/file_handlings.py.

Which language should I start with?

The one you already know best. The value is in comparing, so start where you’re comfortable and then open the same task in the language you’re learning. If Java is your path into test automation, the Java Stream API examples are a good next step.

Clone it and compare for yourself: Multi_Language_Project on GitHub.

Advertisement

65 Posts

SDET and QA engineer. I build Raspberry Pi servers, a Proxmox homelab and automations, and share how on TikTok and Instagram (@techwithamirh3sam).

View All Posts

You Missed

REWARDS 🔰 LV1 0🪙 ❯
🔰
Recruit
Guest Operative
Level1
XP0 / 100
💬 Need help?
coins0
Streak0 days · best 0
📋 Daily missions
↻ Resets daily at midnight
Rank ladder
How to earn
✓ Welcome bonus for joining — +200 🪙 & +100 XP (one-time)
✓ Daily check-in (streak bonus) — +20 XP & +12–24 🪙 (more 🪙 the longer your streak)
✓ Spin the daily wheel — +10 to +150 🪙 (free, once a day)
✓ Daily missions — check-in +15 🪙/+10 XP · daily spin +15 🪙/+10 XP
✓ Finish ALL daily missions — +30 🪙 & +20 XP bonus
✓ Level up — +25 🪙 every new level
✓ Achievements — first sign-in +50 🪙 · Lv5 +75 · Lv10 +150 · Lv25 +300 · 7-day streak +100 · 30-day +250 · collector +100 · subscriber +50
✓ Complete your profile (name, bio, photo) — up to +55 XP (one-time)
✓ Subscribe to the newsletter — +250 🪙 (one-time)
Coins and XP are just for fun: they have no cash value and can't be exchanged for money or prizes. You never earn them for viewing or clicking ads, or for how many pages or articles you open.
🛒 Token Shop0 🪙
🛍️ Shop0items
🎒 Inventory0items

🎡 Daily Spin

One free spin every day — pure bonus coins!
🪙
💬Need help?