Skip to content

oceanmallik/polyglotCalculator

Repository files navigation

5-Language Polyglot Calculator

This project seamlessly links Python, C, C#, and Rust through a master C++ orchestrator.

📦 Prerequisites

Before building the project, ensure you have the required compilers and SDKs installed for all 5 languages.

This is the linux guide. For windows version, scroll down a bit.

C / C++:

For Ubuntu / Debian Linux:

sudo apt update
sudo apt install build-essential

For Fedora / RHEL / Bazzite:

sudo dnf install gcc gcc-c++

Python:

For Ubuntu / Debian Linux:

sudo apt install python3 python3-dev

For Fedora / RHEL / Bazzite:

sudo dnf install python3 python3-devel

Rust:

The Rust compiler and Cargo package manager. (It is recommended to use rustup).

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

C# (.NET 10):

The .NET 10 SDK (required for Native AOT compilation). Please follow the Official Microsoft Documentation to install the .NET 10 SDK for your specific Linux distribution.

Note

This project currently supports Linux on both ARM64 (Apple Silicon VMs, Raspberry Pi) and standard x64 (Intel/AMD) architectures. Run the commands below based on your system.

For Linux

⚙️ Automated Build

The easiest way to compile the entire project is to use the included build script. It will automatically detect your system architecture and compile all 5 languages.

1. Make the script executable and Run the build script (only needed once)

chmod +x build.sh
./build.sh

2. Run the Polyglot Calculator

./main

🛠️ Manual Compilation Steps

If you prefer to compile each language manually, follow these steps based on your a

1. Compile the C Library (Subtraction)

gcc -shared -o subtraction.so -fPIC subtraction.c

2. Compile the C# Executable (Multiplication - .NET 10)

For ARM64 Linux:

dotnet publish CSharpMath/CSharpMath.csproj -c Release -r linux-arm64
cp CSharpMath/bin/Release/net10.0/linux-arm64/publish/multiplication .

For x64 Linux (Standard Intel/AMD):

dotnet publish CSharpMath/CSharpMath.csproj -c Release -r linux-x64
cp CSharpMath/bin/Release/net10.0/linux-x64/publish/multiplication .

3. Compile the Rust Library (Division)

cd division
cargo build --release
cd ..
cp division/target/release/libdivision.so .

4. Compile the C++ Orchestrator (The Brain)

g++ calculator.cpp subtraction.so libdivision.so -o main -Wl,-rpath,. $(python3-config --cflags --embed --libs)

5. Run the Project

./main

For Windows

⚙️ Automated Build

1. Run the build script (Bypasses local execution policy for this script only)

powershell.exe -ExecutionPolicy Bypass -File .\build.ps1

2. Run the Polyglot Calculator

.\main.exe

About

Making a simple terminal based app that works using multiple languages. (polyglot programming) [Only rust code is fully AI generated, cause I don't know how to code on RUST]

Topics

Resources

Stars

Watchers

Forks

Contributors