
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.
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-instr()function for the rest of the file.textorwordis safer. - In TypeScript, the
// @ts-ignoreis covering for a setting.String.prototype.includescomes from ES2015; if the compiler targets an older version it complains. Setting"target": "ES2015"(or newer) intsconfig.jsonremoves 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 frompython/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.tssits next to the.jsit 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.
