Behind Python: The Languages That Power AI

📅 2026-06-16
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
This study addresses the challenge of selecting programming languages that balance performance and efficiency for implementing AI algorithms in resource-constrained environments or when standard AI libraries are unavailable. For the first time, five representative AI algorithms—k-means, k-NN, MLP, genetic algorithm, and Mamdani fuzzy inference—are implemented from scratch in Python, C, C++, Rust, Go, and Julia, with strict equivalence in algorithmic logic. Using identical pseudorandom seeds, native language features, and precise timing and memory monitoring, the work conducts a fine-grained, reproducible cross-language evaluation. Results show that C and C++ deliver the best performance, Rust is only 9% slower, while Julia and Go are 3.3× and 5.0× slower, respectively, and Python is up to 315× slower. Memory usage reveals a fixed overhead of 224 MiB for Julia, whereas C, C++, and Rust all remain below 6 MiB; notably, performance rankings vary significantly across algorithm types.
📝 Abstract
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.
Problem

Research questions and friction points this paper is trying to address.

programming language selection
AI implementation
performance evaluation
resource-constrained systems
algorithm implementation
Innovation

Methods, ideas, or system contributions that make the work stand out.

empirical evaluation
programming language comparison
AI system implementation
performance benchmarking
memory footprint
J
Juan P. Licona-Luque
Tecnológico de Monterrey, Monterrey, Nuevo León, Mexico
B
Beatriz A. Bosques-Palomo
Tecnológico de Monterrey, Monterrey, Nuevo León, Mexico
N
Nezih Nieto-Gutiérrez
Tecnológico de Monterrey, Monterrey, Nuevo León, Mexico
G
Gustavo de los Ríos-Alatorre
Tecnológico de Monterrey, Monterrey, Nuevo León, Mexico
L
Luis A. Muñoz-Ubando
Tecnológico de Monterrey, Monterrey, Nuevo León, Mexico