Search papers, labs, and topics across Lattice.
This paper empirically evaluates the performance of various programming languages鈥擯ython, C, C++, Rust, Go, and Julia鈥攚hen implementing five key algorithms in AI, including k-means and MLP with backpropagation. The study reveals that while C and C++ lead in performance, Rust lags slightly, and Julia and Go exhibit significant slowdowns, particularly under varying workloads. Importantly, the findings highlight that the choice of language can drastically impact performance and memory usage, providing actionable insights for developers faced with algorithm implementation challenges in resource-constrained environments.
Performance rankings among programming languages for AI algorithms can shift dramatically based on workload characteristics, revealing critical insights for developers.
Python dominates AI development, yet the numerical work behind frameworks like PyTorch and NumPy is executed in C, C++, or Rust. When a developer must implement an algorithm without such libraries -- because none exists, the target is resource-constrained, or a new system is being built -- which language should they choose? This paper answers that question empirically. Five algorithms covering data mining (k-means), machine learning (k-NN), neural networks (MLP with backpropagation), computational intelligence (genetic algorithm), and fuzzy systems (Mamdani inference) are implemented from scratch in Python, C, C++, Rust, Go, and Julia. All implementations share a common pseudo-random generator, consume identical inputs, and produce bit-identical outputs, so every measured difference reflects the language rather than the computation. Three performance tiers emerge: C and C++ are effectively tied; Rust trails them by 9% (geometric mean); Julia runs 3.3x slower than C and Go 5.0x; Python sits at 315x. Memory tells a different story -- Julia's JIT runtime carries a fixed ~224 MiB footprint regardless of workload, while C, C++, and Rust stay below 6 MiB. Crucially, rankings are not stable: Go's slowdown swings from 2.6x on k-NN to 8.0x on k-means, showing that workload characteristics can shift a language's position by a full tier. The results provide concrete, per-workload guidance for choosing an implementation language in AI systems.