[Paper Review] There is no fast lunch: an examination of the running speed of evolutionary algorithms in several languages
This paper benchmarks the execution speed of evolutionary algorithm operations—specifically bit-flip mutation—across four popular programming languages: Lua, JavaScript (Node.js), Python, and Scala, using both string and vector representations. It finds that interpreted languages like Python and JavaScript can outperform compiled languages like Scala across various problem sizes, challenging the assumption that compiled languages are universally faster for scientific computing tasks.
It is quite usual when an evolutionary algorithm tool or library uses a language other than C, C++, Java or Matlab that a reviewer or the audience questions its usefulness based on the speed of those other languages, purportedly slower than the aforementioned ones. Despite speed being not everything needed to design a useful evolutionary algorithm application, in this paper we will measure the speed for several very basic evolutionary algorithm operations in several languages which use different virtual machines and approaches, and prove that, in fact, there is no big difference in speed between interpreted and compiled languages, and that in some cases, interpreted languages such as JavaScript or Python can be faster than compiled languages such as Scala, making them worthy of use for evolutionary algorithm experimentation.
Motivation & Objective
- To challenge the common assumption that compiled languages (e.g., C++, Java, Scala) are inherently faster than interpreted languages (e.g., Python, JavaScript, Perl) for evolutionary algorithm (EA) implementations.
- To evaluate the performance of widely used programming languages in executing the core mutation operator in EAs, a frequently called but often overlooked operation.
- To assess whether language choice significantly impacts runtime performance across different chromosome sizes and data representations (bitstrings vs. boolean vectors).
- To provide empirical evidence for researchers choosing programming languages based on both performance and development efficiency, especially in scientific computing contexts.
Proposed method
- Benchmarking the bit-flip mutation operation on binary strings of varying lengths (from 8 to 65,536 bits) across four languages: Lua, JavaScript (Node.js), Python, and Scala.
- Implementing mutation using two data representations: bitstrings (strings of '0' and '1') and vector-based representations (e.g., Vector[Boolean] in Scala, arrays in other languages).
- Using a consistent, minimal implementation across languages to isolate performance differences to language and runtime characteristics, avoiding algorithmic or library-level optimizations.
- Measuring execution time for 10,000 mutation operations per test case and recording results in CSV format for statistical analysis.
- Visualizing performance trends using R and ggplot2 to identify patterns, plateaus, and performance degradation across sizes.
- Analyzing results across multiple problem sizes to assess scalability and identify language-specific performance characteristics.
Experimental results
Research questions
- RQ1Does the choice of programming language significantly affect the runtime of the mutation operator in evolutionary algorithms?
- RQ2Are interpreted languages like Python, JavaScript, or Lua slower than compiled languages like Scala for basic EA operations?
- RQ3How do different data representations (bitstrings vs. boolean vectors) impact performance across languages?
- RQ4Does performance vary non-linearly with chromosome size, and are there size-dependent plateaus or inflection points in execution time?
- RQ5Can interpreted languages outperform compiled languages in real-world EA workloads, particularly when considering development speed and ecosystem support?
Key findings
- Lua demonstrated the fastest performance for small chromosome sizes (up to 128 bits), outperforming all other languages in this range.
- Python and JavaScript (Node.js) showed remarkably consistent performance across a wide range of sizes, with execution time largely independent of string size up to 1,024 bits.
- For larger chromosome sizes (>1,024 bits), Python and JavaScript maintained strong performance, with Python being the fastest overall in the largest size range.
- Scala, despite being a compiled language targeting the JVM, was outperformed by interpreted languages like Python and JavaScript for most problem sizes, particularly beyond 128 bits.
- The performance gap between languages was not consistent across sizes, with some languages (e.g., Lua) showing performance plateaus, suggesting efficient string handling in their runtime implementations.
- The choice of data representation (bitstring vs. vector) had measurable but diminishing effects on performance as size increased, with bitstrings generally being faster in interpreted languages.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.