feat: Add support for numerous new programming languages and update the popular language list.

This commit is contained in:
n.tolstov 2025-11-30 22:03:05 +03:00
parent ac3ce38444
commit dcedf491df
2 changed files with 68 additions and 20 deletions

View File

@ -12,8 +12,8 @@ class LanguageResponse(BaseModel):
name: str
# Popular languages to show at the top
POPULAR_LANGUAGE_IDS = [71, 54, 62, 63, 50, 51, 52, 60, 68, 78] # Python, C++, Java, JS, C, C#, etc.
# Popular languages to show at the top (synced with LANGUAGE_MAP in judge.py)
POPULAR_LANGUAGE_IDS = [71, 54, 50, 62, 63, 73, 60, 78, 51, 74] # Python, C++, C, Java, JS, Rust, Go, Kotlin, C#, TS
@router.get("/", response_model=list[LanguageResponse])

View File

@ -2,31 +2,53 @@ import httpx
from app.config import settings
# Mapping Judge0 language_id to Piston language name and version
# Updated with latest available versions in Piston
# Mapping language_id to Piston language name and version
# Synced with languages installed in entrypoint.sh
LANGUAGE_MAP = {
# Python
71: ("python", "3.12.0"), # Python 3.12 LTS
70: ("python", "3.12.0"), # Python 2 -> redirect to Python 3
# Core languages
71: ("python", "3.12.0"),
50: ("c", "10.2.0"),
54: ("c++", "10.2.0"),
62: ("java", "15.0.2"),
63: ("javascript", "20.11.1"),
# C/C++
50: ("c", "10.2.0"), # C (GCC 10.2.0)
54: ("c++", "10.2.0"), # C++ (GCC 10.2.0)
# Systems programming
60: ("go", "1.16.2"),
73: ("rust", "1.68.2"),
# Java
62: ("java", "15.0.2"), # Java (OpenJDK 15.0.2)
# JVM languages
78: ("kotlin", "1.8.20"),
81: ("scala", "3.2.2"),
# JavaScript/Node.js
63: ("javascript", "20.11.1"), # Node.js 20.11.1
# .NET
51: ("csharp", "5.0.201"),
# Go
60: ("go", "1.16.2"), # Go 1.16.2
# Scripting
72: ("ruby", "3.0.1"),
85: ("perl", "5.36.0"),
68: ("php", "8.2.3"),
64: ("lua", "5.4.4"),
# Rust
73: ("rust", "1.68.2"), # Rust 1.68.2
# Functional
61: ("haskell", "9.0.1"),
65: ("ocaml", "4.12.0"),
90: ("elixir", "1.11.3"),
86: ("clojure", "1.10.3"),
95: ("racket", "8.3.0"),
# Kotlin
78: ("kotlin", "1.8.20"), # Kotlin 1.8.20
# Other
67: ("pascal", "3.2.2"),
59: ("fortran", "10.2.0"),
83: ("swift", "5.3.3"),
74: ("typescript", "5.0.3"),
91: ("nim", "1.6.2"),
96: ("zig", "0.10.1"),
56: ("d", "10.2.0"),
69: ("prolog", "8.2.4"),
# Low-level
45: ("nasm", "2.15.5"),
46: ("bash", "5.1.0"),
}
@ -87,6 +109,27 @@ class JudgeService:
"go": "Go",
"rust": "Rust",
"kotlin": "Kotlin",
"scala": "Scala",
"csharp": "C#",
"ruby": "Ruby",
"perl": "Perl",
"php": "PHP",
"lua": "Lua",
"haskell": "Haskell",
"ocaml": "OCaml",
"elixir": "Elixir",
"clojure": "Clojure",
"racket": "Racket",
"pascal": "Pascal",
"fortran": "Fortran",
"swift": "Swift",
"typescript": "TypeScript",
"nim": "Nim",
"zig": "Zig",
"d": "D",
"prolog": "Prolog",
"nasm": "Assembly (NASM)",
"bash": "Bash",
}
display_name = name_map.get(piston_lang, piston_lang.title())
@ -137,6 +180,11 @@ class JudgeService:
ext_map = {
"python": "py", "c": "c", "c++": "cpp", "java": "java",
"javascript": "js", "go": "go", "rust": "rs", "kotlin": "kt",
"scala": "scala", "csharp": "cs", "ruby": "rb", "perl": "pl",
"php": "php", "lua": "lua", "haskell": "hs", "ocaml": "ml",
"elixir": "exs", "clojure": "clj", "racket": "rkt", "pascal": "pas",
"fortran": "f90", "swift": "swift", "typescript": "ts", "nim": "nim",
"zig": "zig", "d": "d", "prolog": "pl", "nasm": "asm", "bash": "sh",
}
ext = ext_map.get(language, "txt")
filename = f"main.{ext}"