<?xml version='1.0' encoding='UTF-8'?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
  <id>https://hansspaans.nl</id>
  <title>Hans Spaans</title>
  <updated>2026-05-30T08:35:03.205782+00:00</updated>
  <link href="https://hansspaans.nl"/>
  <link href="https://hansspaans.nl/blog/atom.xml" rel="self"/>
  <generator uri="https://ablog.readthedocs.io/" version="0.11.13">ABlog</generator>
  <entry>
    <id>https://hansspaans.nl/blog/2025/one-billion-nested-loop-iterations.html</id>
    <title>One billion nested loop iterations</title>
    <updated>2025-09-09T10:00:00+00:00</updated>
    <author>
      <name>Editor</name>
    </author>
    <content type="html">&lt;section id="one-billion-nested-loop-iterations"&gt;

&lt;p&gt;A few days ago I was &lt;a class="reference external" href="https://www.linkedin.com/feed/update/urn:li:activity:7370840117663674370/"&gt;reading a post on LinkedIn&lt;/a&gt; about a performance comparison between Python and other languages. The author made a benchmark with a nested loop of one billion iterations in both languages and concluded that C and Rust was much faster than Python. As I was curious about this claim, I decided to replicate the benchmark myself and see if I could achieve similar results and how much of this post was true.&lt;/p&gt;
&lt;div class="admonition note"&gt;
&lt;p class="admonition-title"&gt;Note&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;This benchmark is mostly done for fun and educational purposes on GitHub Codespaces.&lt;/strong&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;As no code was provided in the post, all the code had to be created from scratch. The benchmark consists of a nested loop where the outer loop runs 100,000 times and the inner loop runs 10,000 times, resulting in a total of 1 billion iterations (10^5 * 10^4 = 10^9). A counter variable is incremented in each iteration to ensure that the loops are not optimized away by the compiler or interpreter. And generating the source code for different languages was an ideal task for &lt;a class="reference external" href="https://gemini.google.com/app"&gt;Google Gemini&lt;/a&gt; with some hints from &lt;a class="reference external" href="https://github.com/features/copilot"&gt;GitHub Copilot&lt;/a&gt;.&lt;/p&gt;
&lt;div class="admonition warning"&gt;
&lt;p class="admonition-title"&gt;Warning&lt;/p&gt;
&lt;p&gt;The following code snippets are for educational purposes only and may not represent best practices for performance benchmarking or to have the most efficient code in each language.&lt;/p&gt;
&lt;/div&gt;
&lt;section id="python-benchmark"&gt;
&lt;h2&gt;Python Benchmark&lt;/h2&gt;
&lt;p&gt;Here is the Python code I used for the benchmark:&lt;/p&gt;
&lt;div class="literal-block-wrapper docutils container" id="id1"&gt;
&lt;div class="code-block-caption"&gt;&lt;span class="caption-text"&gt;Python code for one billion nested loop iterations&lt;/span&gt;&lt;/div&gt;
&lt;div class="highlight-python notranslate"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;time&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;nested_loop_counter&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="sd"&gt;&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;
&lt;span class="sd"&gt;    Performs 1 billion nested loop iterations and measures the execution time.&lt;/span&gt;

&lt;span class="sd"&gt;    The outer loop runs 100,000 times and the inner loop runs 10,000 times,&lt;/span&gt;
&lt;span class="sd"&gt;    resulting in a total of 1,000,000,000 iterations (10^5 * 10^4 = 10^9).&lt;/span&gt;
&lt;span class="sd"&gt;    &amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Starting the nested loop counter...&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;start_time&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="c1"&gt;# Initialize a counter variable&lt;/span&gt;
    &lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;

    &lt;span class="c1"&gt;# Outer loop runs 100,000 times&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100000&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="c1"&gt;# Inner loop runs 10,000 times&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10000&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

    &lt;span class="n"&gt;end_time&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="c1"&gt;# Calculate the total execution time&lt;/span&gt;
    &lt;span class="n"&gt;elapsed_time&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;end_time&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;start_time&lt;/span&gt;

    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;--- Execution Finished ---&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Total iterations: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Time taken: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;elapsed_time&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;.2f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; seconds&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;------------------------&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Run the program&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="vm"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;__main__&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;nested_loop_counter&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The results of the Python benchmark were as follows:&lt;/p&gt;
&lt;div class="literal-block-wrapper docutils container" id="id2"&gt;
&lt;div class="code-block-caption"&gt;&lt;span class="caption-text"&gt;Python benchmark execution output&lt;/span&gt;&lt;/div&gt;
&lt;div class="highlight-console notranslate"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;$ &lt;/span&gt;python3&lt;span class="w"&gt; &lt;/span&gt;onebillion.py
&lt;span class="go"&gt;Starting the nested loop counter...&lt;/span&gt;

&lt;span class="go"&gt;--- Execution Finished ---&lt;/span&gt;
&lt;span class="go"&gt;Total iterations: 1000000000&lt;/span&gt;
&lt;span class="go"&gt;Time taken: 22.81 seconds&lt;/span&gt;
&lt;span class="go"&gt;------------------------&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;And with 22.81 seconds, Python was indeed not the fastest language for this benchmark. As a comparison, I also ran the code with PyPy, which is an alternative implementation of Python that often provides better performance for long-running tasks. The results with PyPy were significantly better:&lt;/p&gt;
&lt;div class="literal-block-wrapper docutils container" id="id3"&gt;
&lt;div class="code-block-caption"&gt;&lt;span class="caption-text"&gt;PyPy benchmark execution output&lt;/span&gt;&lt;/div&gt;
&lt;div class="highlight-console notranslate"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;$ &lt;/span&gt;pypy3&lt;span class="w"&gt; &lt;/span&gt;onebillion.py
&lt;span class="go"&gt;Starting the nested loop counter...&lt;/span&gt;

&lt;span class="go"&gt;--- Execution Finished ---&lt;/span&gt;
&lt;span class="go"&gt;Total iterations: 1000000000&lt;/span&gt;
&lt;span class="go"&gt;Time taken: 0.51 seconds&lt;/span&gt;
&lt;span class="go"&gt;------------------------&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/section&gt;
&lt;section id="java-benchmark"&gt;
&lt;h2&gt;Java Benchmark&lt;/h2&gt;
&lt;p&gt;Here is the equivalent Java code for the benchmark:&lt;/p&gt;
&lt;div class="literal-block-wrapper docutils container" id="id4"&gt;
&lt;div class="code-block-caption"&gt;&lt;span class="caption-text"&gt;Java code for one billion nested loop iterations&lt;/span&gt;&lt;/div&gt;
&lt;div class="highlight-java notranslate"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;java.lang.System&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;public&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;nested_loop_counter&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kd"&gt;public&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;static&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kt"&gt;void&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;

&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="c1"&gt;// Use &amp;#39;long&amp;#39; for the counter and loop variables to ensure they can&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="c1"&gt;// handle a very large number of iterations without overflowing.&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="kt"&gt;long&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="n"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Starting the nested loop counter...&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="c1"&gt;// Start the timer using nanoseconds for high precision&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="kt"&gt;long&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;startTime&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;nanoTime&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="c1"&gt;// The outer loop runs 100,000 times&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;long&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;100000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="c1"&gt;// The inner loop runs 10,000 times&lt;/span&gt;
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;long&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;10000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;                &lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="c1"&gt;// Stop the timer&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="kt"&gt;long&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;endTime&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;nanoTime&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="c1"&gt;// Calculate the elapsed time in seconds&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="kt"&gt;double&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;elapsedTimeInSeconds&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;endTime&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;startTime&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;1_000_000_000.0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="n"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;\n--- Execution Finished ---&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="n"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Total iterations: &amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="n"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Time taken: %.2f seconds\n&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;elapsedTimeInSeconds&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="n"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;------------------------&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Luckily, modern Java development environments and build tools allow developers to compile their code more easily for development purposes. The results of the Java benchmark were as follows:&lt;/p&gt;
&lt;div class="literal-block-wrapper docutils container" id="id5"&gt;
&lt;div class="code-block-caption"&gt;&lt;span class="caption-text"&gt;Output of Java benchmark for one billion nested loop iterations&lt;/span&gt;&lt;/div&gt;
&lt;div class="highlight-console notranslate"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;$ &lt;/span&gt;java&lt;span class="w"&gt; &lt;/span&gt;onebillion.java
&lt;span class="go"&gt;Starting the nested loop counter...&lt;/span&gt;

&lt;span class="go"&gt;--- Execution Finished ---&lt;/span&gt;
&lt;span class="go"&gt;Total iterations: 1000000000&lt;/span&gt;
&lt;span class="go"&gt;Time taken: 0.23 seconds&lt;/span&gt;
&lt;span class="go"&gt;------------------------&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The results show that Java is indeed faster than Python for this benchmark, completing the task in just 0.23 seconds. Overall quite impressive to see how much the JVM has improved over the years.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="golang-benchmark"&gt;
&lt;h2&gt;Golang Benchmark&lt;/h2&gt;
&lt;p&gt;Here is the equivalent Go code for the benchmark:&lt;/p&gt;
&lt;div class="literal-block-wrapper docutils container" id="id6"&gt;
&lt;div class="code-block-caption"&gt;&lt;span class="caption-text"&gt;Go code for one billion nested loop iterations&lt;/span&gt;&lt;/div&gt;
&lt;div class="highlight-go notranslate"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="kn"&gt;package&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;main&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="s"&gt;&amp;quot;fmt&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="s"&gt;&amp;quot;time&amp;quot;&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="kd"&gt;func&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="c1"&gt;// Use int64 for the counter to handle the large number of iterations.&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kt"&gt;int64&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;

&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nx"&gt;fmt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Starting the nested loop counter...&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="c1"&gt;// Start the timer&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nx"&gt;start&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="c1"&gt;// The outer loop runs 100,000 times&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;100000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;                &lt;/span&gt;&lt;span class="c1"&gt;// The inner loop runs 10,000 times&lt;/span&gt;
&lt;span class="w"&gt;                &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;10000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;                        &lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;
&lt;span class="w"&gt;                &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="c1"&gt;// Stop the timer&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nx"&gt;elapsed&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Since&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;start&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nx"&gt;fmt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;\n--- Execution Finished ---&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nx"&gt;fmt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Total iterations: %d\n&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nx"&gt;fmt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Time taken: %s\n&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;elapsed&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nx"&gt;fmt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;------------------------&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Like Java, Go also has a built-in compiler as part of the Go toolchain. The results of the Go benchmark were as follows:&lt;/p&gt;
&lt;div class="literal-block-wrapper docutils container" id="id7"&gt;
&lt;div class="code-block-caption"&gt;&lt;span class="caption-text"&gt;Output of Go benchmark for one billion nested loop iterations&lt;/span&gt;&lt;/div&gt;
&lt;div class="highlight-console notranslate"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;$ &lt;/span&gt;go&lt;span class="w"&gt; &lt;/span&gt;run&lt;span class="w"&gt; &lt;/span&gt;onebillion.go
&lt;span class="go"&gt;Starting the nested loop counter...&lt;/span&gt;

&lt;span class="go"&gt;--- Execution Finished ---&lt;/span&gt;
&lt;span class="go"&gt;Total iterations: 1000000000&lt;/span&gt;
&lt;span class="go"&gt;Time taken: 130.028666ms&lt;/span&gt;
&lt;span class="go"&gt;------------------------&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The results show that Go is also quite fast for this benchmark, completing the task in just 130 milliseconds. This performance is comparable to Java, demonstrating Go’s efficiency in handling such tasks.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="perl-benchmark"&gt;
&lt;h2&gt;Perl Benchmark&lt;/h2&gt;
&lt;p&gt;Here is the equivalent Perl code for the benchmark:&lt;/p&gt;
&lt;div class="literal-block-wrapper docutils container" id="id8"&gt;
&lt;div class="code-block-caption"&gt;&lt;span class="caption-text"&gt;Perl code for one billion nested loop iterations&lt;/span&gt;&lt;/div&gt;
&lt;div class="highlight-perl notranslate"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;use&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;strict&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;use&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;warnings&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;use&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;Time::HiRes&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="sx"&gt;qw(time)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;# Use a scalar variable for the counter. Perl handles large numbers automatically.&lt;/span&gt;
&lt;span class="k"&gt;my&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$count&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Starting the nested loop counter...\n&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;# Start the timer&lt;/span&gt;
&lt;span class="k"&gt;my&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$start_time&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;time&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;# Outer loop runs 100,000 times&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;my&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;100000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="c1"&gt;# Inner loop runs 10,000 times&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;my&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$j&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$j&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;10000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$j&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nv"&gt;$count&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;# Stop the timer&lt;/span&gt;
&lt;span class="k"&gt;my&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$end_time&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;time&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;# Calculate the total execution time&lt;/span&gt;
&lt;span class="k"&gt;my&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$elapsed_time&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$end_time&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$start_time&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;&amp;quot;\n--- Execution Finished ---\n&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Total iterations: $count\n&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nb"&gt;printf&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Time taken: %.2f seconds\n&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$elapsed_time&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;&amp;quot;------------------------\n&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;For Perl, the interpreter is usually included in the standard installation, but the HiRes module is required for high-resolution timing and needs to be installed separately. The results of the Perl benchmark were as follows:&lt;/p&gt;
&lt;div class="literal-block-wrapper docutils container" id="id9"&gt;
&lt;div class="code-block-caption"&gt;&lt;span class="caption-text"&gt;Output of Perl benchmark for one billion nested loop iterations&lt;/span&gt;&lt;/div&gt;
&lt;div class="highlight-console notranslate"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;$ &lt;/span&gt;perl&lt;span class="w"&gt; &lt;/span&gt;onebillion.pl
&lt;span class="go"&gt;Starting the nested loop counter...&lt;/span&gt;

&lt;span class="go"&gt;--- Execution Finished ---&lt;/span&gt;
&lt;span class="go"&gt;Total iterations: 1000000000&lt;/span&gt;
&lt;span class="go"&gt;Time taken: 15.24 seconds&lt;/span&gt;
&lt;span class="go"&gt;------------------------&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The results show that Perl is indeed faster than Python for this benchmark, completing the task in just 15.24 seconds. While this is faster than Python, it is still slower than both Java and Go.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="clang-benchmark"&gt;
&lt;h2&gt;Clang Benchmark&lt;/h2&gt;
&lt;p&gt;Here is the equivalent C code for the benchmark:&lt;/p&gt;
&lt;div class="literal-block-wrapper docutils container" id="id10"&gt;
&lt;div class="code-block-caption"&gt;&lt;span class="caption-text"&gt;C code for one billion nested loop iterations&lt;/span&gt;&lt;/div&gt;
&lt;div class="highlight-c notranslate"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="cp"&gt;#include&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="cpf"&gt;&amp;lt;stdio.h&amp;gt;&lt;/span&gt;
&lt;span class="cp"&gt;#include&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="cpf"&gt;&amp;lt;time.h&amp;gt;&lt;/span&gt;

&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="c1"&gt;// Use long long for the counter to avoid integer overflow, as 1 billion&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="c1"&gt;// exceeds the maximum value of a standard int on many systems.&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kt"&gt;long&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kt"&gt;long&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Starting the nested loop counter...&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="c1"&gt;// Start the timer&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kt"&gt;clock_t&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;start_time&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;clock&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="c1"&gt;// Outer loop runs 100,000 times&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;long&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kt"&gt;long&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;100000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="c1"&gt;// Inner loop runs 10,000 times&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;long&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kt"&gt;long&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;10000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="c1"&gt;// Stop the timer&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kt"&gt;clock_t&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;end_time&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;clock&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="c1"&gt;// Calculate the total execution time in seconds&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kt"&gt;double&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;elapsed_time&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;double&lt;/span&gt;&lt;span class="p"&gt;)(&lt;/span&gt;&lt;span class="n"&gt;end_time&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;start_time&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;CLOCKS_PER_SEC&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;--- Execution Finished ---&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Total iterations: %lld&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Time taken: %.2f seconds&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;elapsed_time&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;------------------------&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;For C, the GCC compiler is commonly used and is part of the GNU Compiler Collection. The results of the C benchmark were as follows without any optimizations:&lt;/p&gt;
&lt;div class="literal-block-wrapper docutils container" id="id11"&gt;
&lt;div class="code-block-caption"&gt;&lt;span class="caption-text"&gt;Output of C benchmark compiled without optimizations&lt;/span&gt;&lt;/div&gt;
&lt;div class="highlight-console notranslate"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;$ &lt;/span&gt;gcc&lt;span class="w"&gt; &lt;/span&gt;onebillion.c
&lt;span class="gp"&gt;$ &lt;/span&gt;./a.out
&lt;span class="go"&gt;Starting the nested loop counter...&lt;/span&gt;

&lt;span class="go"&gt;--- Execution Finished ---&lt;/span&gt;
&lt;span class="go"&gt;Total iterations: 1000000000&lt;/span&gt;
&lt;span class="go"&gt;Time taken: 0.40 seconds&lt;/span&gt;
&lt;span class="go"&gt;------------------------&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;But with optimizations enabled using the &lt;cite&gt;-O2&lt;/cite&gt; or &lt;cite&gt;-O3&lt;/cite&gt; flag, the performance improved significantly:&lt;/p&gt;
&lt;div class="literal-block-wrapper docutils container" id="id12"&gt;
&lt;div class="code-block-caption"&gt;&lt;span class="caption-text"&gt;C benchmark output with GCC -O3 optimizations enabled&lt;/span&gt;&lt;/div&gt;
&lt;div class="highlight-console notranslate"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;$ &lt;/span&gt;gcc&lt;span class="w"&gt; &lt;/span&gt;-O3&lt;span class="w"&gt; &lt;/span&gt;onebillion.c
&lt;span class="gp"&gt;$ &lt;/span&gt;./a.out
&lt;span class="go"&gt;Starting the nested loop counter...&lt;/span&gt;

&lt;span class="go"&gt;--- Execution Finished ---&lt;/span&gt;
&lt;span class="go"&gt;Total iterations: 1000000000&lt;/span&gt;
&lt;span class="go"&gt;Time taken: 0.00 seconds&lt;/span&gt;
&lt;span class="go"&gt;------------------------&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Maybe a bit too fast to be true, but the compiler optimizations really make a big difference in performance for this benchmark. And secondly the resolution of the timer is not high enough to measure the time accurately. So the actual time is likely a few milliseconds, but it is reported as 0.00 seconds due to rounding.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="rust-benchmark"&gt;
&lt;h2&gt;Rust Benchmark&lt;/h2&gt;
&lt;p&gt;Here is the equivalent Rust code for the benchmark:&lt;/p&gt;
&lt;div class="literal-block-wrapper docutils container" id="id13"&gt;
&lt;div class="code-block-caption"&gt;&lt;span class="caption-text"&gt;Rust code for one billion nested loop iterations&lt;/span&gt;&lt;/div&gt;
&lt;div class="highlight-rust notranslate"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;use&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Instant&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;fn&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="c1"&gt;// Use u64 for the counter and loop variables to ensure they can handle&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="c1"&gt;// a very large number of iterations without overflow.&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;mut&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kt"&gt;u64&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="fm"&gt;println!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Starting the nested loop counter...&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="c1"&gt;// Start the timer&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;start_time&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Instant&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="c1"&gt;// Outer loop runs 100,000 times&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;..&lt;/span&gt;&lt;span class="mi"&gt;100000&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="c1"&gt;// Inner loop runs 10,000 times&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;..&lt;/span&gt;&lt;span class="mi"&gt;10000&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="c1"&gt;// Stop the timer and calculate the duration&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;end_time&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Instant&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;elapsed_time&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;end_time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;duration_since&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;start_time&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="fm"&gt;println!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;--- Execution Finished ---&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="fm"&gt;println!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Total iterations: {}&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="fm"&gt;println!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Time taken: {:.2?} seconds&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;elapsed_time&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="fm"&gt;println!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;------------------------&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Lets see how Rust performs in this benchmark. The results of the Rust benchmark were as follows without any optimizations:&lt;/p&gt;
&lt;div class="literal-block-wrapper docutils container" id="id14"&gt;
&lt;div class="code-block-caption"&gt;&lt;span class="caption-text"&gt;Output of Rust benchmark (no optimizations)&lt;/span&gt;&lt;/div&gt;
&lt;div class="highlight-console notranslate"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;$ &lt;/span&gt;rustc&lt;span class="w"&gt; &lt;/span&gt;onebillion.rs
&lt;span class="go"&gt;warning: unused variable: `i`&lt;/span&gt;
&lt;span class="go"&gt;--&amp;gt; onebillion.rs:14:9&lt;/span&gt;
&lt;span class="go"&gt;|&lt;/span&gt;
&lt;span class="go"&gt;14 |     for i in 0..100000 {&lt;/span&gt;
&lt;span class="go"&gt;|         ^ help: if this is intentional, prefix it with an underscore: `_i`&lt;/span&gt;
&lt;span class="go"&gt;|&lt;/span&gt;
&lt;span class="go"&gt;= note: `#[warn(unused_variables)]` on by default&lt;/span&gt;

&lt;span class="go"&gt;warning: unused variable: `j`&lt;/span&gt;
&lt;span class="go"&gt;--&amp;gt; onebillion.rs:16:13&lt;/span&gt;
&lt;span class="go"&gt;|&lt;/span&gt;
&lt;span class="go"&gt;16 |         for j in 0..10000 {&lt;/span&gt;
&lt;span class="go"&gt;|             ^ help: if this is intentional, prefix it with an underscore: `_j`&lt;/span&gt;

&lt;span class="go"&gt;warning: 2 warnings emitted&lt;/span&gt;

&lt;span class="gp"&gt;$ &lt;/span&gt;./onebillion
&lt;span class="go"&gt;Starting the nested loop counter...&lt;/span&gt;

&lt;span class="go"&gt;--- Execution Finished ---&lt;/span&gt;
&lt;span class="go"&gt;Total iterations: 1000000000&lt;/span&gt;
&lt;span class="go"&gt;Time taken: 2.24s seconds&lt;/span&gt;
&lt;span class="go"&gt;------------------------&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;If we ignore the warnings about unused variables, Rust performs quite well, completing the task in just 2.24 seconds. However, with optimizations enabled using the &lt;cite&gt;-O&lt;/cite&gt; flag, the performance improved significantly:&lt;/p&gt;
&lt;div class="literal-block-wrapper docutils container" id="id15"&gt;
&lt;div class="code-block-caption"&gt;&lt;span class="caption-text"&gt;Rust benchmark output with optimizations (-O flag)&lt;/span&gt;&lt;/div&gt;
&lt;div class="highlight-console notranslate"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;$ &lt;/span&gt;rustc&lt;span class="w"&gt; &lt;/span&gt;-O&lt;span class="w"&gt; &lt;/span&gt;onebillion.rs
&lt;span class="go"&gt;warning: unused variable: `i`&lt;/span&gt;
&lt;span class="go"&gt;--&amp;gt; onebillion.rs:14:9&lt;/span&gt;
&lt;span class="go"&gt;|&lt;/span&gt;
&lt;span class="go"&gt;14 |     for i in 0..100000 {&lt;/span&gt;
&lt;span class="go"&gt;|         ^ help: if this is intentional, prefix it with an underscore: `_i`&lt;/span&gt;
&lt;span class="go"&gt;|&lt;/span&gt;
&lt;span class="go"&gt;= note: `#[warn(unused_variables)]` on by default&lt;/span&gt;

&lt;span class="go"&gt;warning: unused variable: `j`&lt;/span&gt;
&lt;span class="go"&gt;--&amp;gt; onebillion.rs:16:13&lt;/span&gt;
&lt;span class="go"&gt;|&lt;/span&gt;
&lt;span class="go"&gt;16 |         for j in 0..10000 {&lt;/span&gt;
&lt;span class="go"&gt;|             ^ help: if this is intentional, prefix it with an underscore: `_j`&lt;/span&gt;

&lt;span class="go"&gt;warning: 2 warnings emitted&lt;/span&gt;

&lt;span class="gp"&gt;$ &lt;/span&gt;./onebillion
&lt;span class="go"&gt;Starting the nested loop counter...&lt;/span&gt;

&lt;span class="go"&gt;--- Execution Finished ---&lt;/span&gt;
&lt;span class="go"&gt;Total iterations: 1000000000&lt;/span&gt;
&lt;span class="go"&gt;Time taken: 154.00ns seconds&lt;/span&gt;
&lt;span class="go"&gt;------------------------&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;And the results show that with optimizations, Rust can complete the task in just 154 nanoseconds. This performance is comparable to C with optimizations, demonstrating Rust’s efficiency in handling such tasks.&lt;/p&gt;
&lt;p&gt;But lets fix the warnings by prefixing the unused variables with an underscore as Gemini wasn’t aware of this:&lt;/p&gt;
&lt;div class="literal-block-wrapper docutils container" id="id16"&gt;
&lt;div class="code-block-caption"&gt;&lt;span class="caption-text"&gt;Rust benchmark output with optimizations and fixed warnings&lt;/span&gt;&lt;/div&gt;
&lt;div class="highlight-console notranslate"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;$ &lt;/span&gt;rustc&lt;span class="w"&gt; &lt;/span&gt;-O&lt;span class="w"&gt; &lt;/span&gt;onebillion.rs
&lt;span class="gp"&gt;$ &lt;/span&gt;./onebillion
&lt;span class="go"&gt;Starting the nested loop counter...&lt;/span&gt;

&lt;span class="go"&gt;--- Execution Finished ---&lt;/span&gt;
&lt;span class="go"&gt;Total iterations: 1000000000&lt;/span&gt;
&lt;span class="go"&gt;Time taken: 66.00ns seconds&lt;/span&gt;
&lt;span class="go"&gt;------------------------&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This time the performance improved even further, completing the task in just 66 nanoseconds. This shows that addressing compiler warnings can lead to better optimizations and improved performance.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="conclusion-about-performance"&gt;
&lt;h2&gt;Conclusion about performance&lt;/h2&gt;
&lt;p&gt;After running the benchmarks in different languages, the results were as followed: Don’t take these numbers too seriously as they can vary based on the system, compiler/interpreter versions, and other factors. But they do give a general idea of the performance differences between the languages for this specific task. And don’t believe everything you &lt;a class="reference external" href="https://www.linkedin.com/feed/update/urn:li:activity:7370840117663674370/"&gt;read on LinkedIn&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Raw processing performance is only one aspect of a programming language. Other factors like developer productivity, ecosystem, libraries, community support, and specific use cases also play a significant role in choosing the right language for a project. But marking a language as slow or fast based on one benchmark is not a good idea as it doesn’t take into account the full context of software development.&lt;/p&gt;
&lt;/section&gt;
&lt;/section&gt;
</content>
    <link href="https://hansspaans.nl/blog/2025/one-billion-nested-loop-iterations.html"/>
    <summary>A few days ago I was reading a post on LinkedIn about a performance comparison between Python and other languages. The author made a benchmark with a nested loop of one billion iterations in both languages and concluded that C and Rust was much faster than Python. As I was curious about this claim, I decided to replicate the benchmark myself and see if I could achieve similar results and how much of this post was true.This benchmark is mostly done for fun and educational purposes on GitHub Codespaces.</summary>
    <category term="LinkedIn" label="LinkedIn"/>
    <category term="Python" label="Python"/>
    <category term="benchmarking" label="benchmarking"/>
    <category term="fun" label="fun"/>
    <category term="performance" label="performance"/>
    <published>2025-09-09T10:00:00+00:00</published>
  </entry>
  <entry>
    <id>https://hansspaans.nl/blog/2025/time-to-contain-perl.html</id>
    <title>Time to contain Perl?</title>
    <updated>2025-09-06T10:00:00+00:00</updated>
    <author>
      <name>Editor</name>
    </author>
    <content type="html">&lt;section id="time-to-contain-perl"&gt;

&lt;p&gt;In the world of software development, the choice of programming languages can significantly impact the maintainability and longevity of a project. &lt;a class="reference external" href="https://www.perl.org/"&gt;Perl&lt;/a&gt;, once a dominant language for web development and system administration, has seen a decline in popularity over the years. As we look towards the future, it’s worth considering whether it’s time to contain Perl within our projects.&lt;/p&gt;
&lt;p&gt;In this context, “containing” Perl refers to stopping the use of Perl for new development and instead isolating existing Perl code within specific modules or services used within an enterprise. This approach allows us to manage the risks associated with legacy technologies while still leveraging their strengths where appropriate. For personal projects, the reasoning is similar, but often more pragmatic as the impact of legacy code is less critical than in an enterprise setting.&lt;/p&gt;
&lt;section id="the-rise-and-fall-of-perl"&gt;
&lt;h2&gt;The Rise and Fall of Perl&lt;/h2&gt;
&lt;p&gt;Perl was once hailed as the “duct tape of the internet,” thanks to its flexibility and powerful text-processing capabilities. It was widely used for CGI scripting, system administration, and even web application development. However, with the advent of newer languages like Python, Ruby, and JavaScript, Perl’s popularity has waned. These newer languages offer more modern syntax, better libraries, and a more active community, making them more appealing to developers.&lt;/p&gt;
&lt;p&gt;Especially with the rise of web frameworks like &lt;a class="extlink-wiki reference external" href="https://en.wikipedia.org/wiki/Django (web framework)"&gt;Django&lt;/a&gt; (&lt;a class="extlink-wiki reference external" href="https://en.wikipedia.org/wiki/Python (programming language)"&gt;Python&lt;/a&gt;), &lt;a class="extlink-wiki reference external" href="https://en.wikipedia.org/wiki/Ruby on Rails"&gt;Ruby on Rails&lt;/a&gt; (&lt;a class="extlink-wiki reference external" href="https://en.wikipedia.org/wiki/Ruby (programming language)"&gt;Ruby&lt;/a&gt;), and &lt;a class="extlink-wiki reference external" href="https://en.wikipedia.org/wiki/Node.js"&gt;Node.js&lt;/a&gt; (&lt;a class="extlink-wiki reference external" href="https://en.wikipedia.org/wiki/JavaScript"&gt;JavaScript&lt;/a&gt;), developers found more efficient ways to build web applications. Maybe also the &lt;a class="extlink-wiki reference external" href="https://en.wikipedia.org/wiki/PHP"&gt;PHP&lt;/a&gt; ecosystem with frameworks like Laravel and Symfony played a role in this shift as it was easier to learn for many web developers and manage than &lt;a class="reference external" href="https://perl.apache.org/"&gt;mod_perl&lt;/a&gt; or CGI scripts.&lt;/p&gt;
&lt;p&gt;The future of Perl looks uncertain as Perl 6 was &lt;a class="reference external" href="https://www.nntp.perl.org/group/perl.perl6.meta/2000/10/msg424.html"&gt;announced in 2000&lt;/a&gt; and later rebranded to Raku and has not seen widespread adoption. In 2020, Perl 7 was announced, aiming to modernize the language and make it more accessible to new developers. In 2021, this plan was slightly adjusted to keep Perl 5 in long-term maintenance mode with only important security and bug fixes coming to it. However, the impact of Perl 7 remains to be seen as it will &lt;a class="reference external" href="https://blogs.perl.org/users/psc/2022/05/what-happened-to-perl-7.html"&gt;only be released when enough features are ready and stable&lt;/a&gt;.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="the-current-landscape"&gt;
&lt;h2&gt;The Current Landscape&lt;/h2&gt;
&lt;p&gt;As we assess the future of Perl, it’s essential to consider the current landscape of software development. Many organizations are adopting microservices architectures, containerization, and &lt;a class="extlink-wiki reference external" href="https://en.wikipedia.org/wiki/cloud-native"&gt;cloud-native&lt;/a&gt; technologies. These trends emphasize the need for modular, maintainable code that can evolve independently.&lt;/p&gt;
&lt;p&gt;In this context, the case for containing Perl code becomes more compelling. By isolating Perl components, we can better manage their lifecycle and reduce the impact of their limitations on the overall system. And the rise of &lt;a class="extlink-wiki reference external" href="https://en.wikipedia.org/wiki/DevOps"&gt;DevOps&lt;/a&gt; practices and &lt;a class="extlink-wiki reference external" href="https://en.wikipedia.org/wiki/CI/CD"&gt;CI/CD&lt;/a&gt; pipelines also emphasizes the need for maintainable and testable code, which can be challenging with legacy Perl codebases.&lt;/p&gt;
&lt;p&gt;Here are some key considerations for containing Perl in modern software development:&lt;/p&gt;
&lt;ol class="arabic simple"&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Modularity&lt;/strong&gt;: Break down Perl applications into smaller, manageable components that can be developed, tested, and deployed independently. This aligns with microservices architectures and promotes better maintainability.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Containerization&lt;/strong&gt;: Use containerization technologies like Docker to encapsulate Perl applications and their dependencies. This can simplify deployment and ensure consistency across different environments.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Automated Testing&lt;/strong&gt;: Invest in automated testing frameworks and practices to improve the reliability of Perl code. This is crucial for maintaining code quality and facilitating continuous integration.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Documentation&lt;/strong&gt;: Improve documentation for Perl codebases to make them more accessible to new developers. This can help mitigate the challenges posed by a shrinking talent pool.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Hiring and Training&lt;/strong&gt;: Consider the availability of skilled Perl developers when planning projects. Investing in training for existing team members can help bridge the gap.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;While most of these considerations are technology driven, the final one about &lt;a class="extlink-wiki reference external" href="https://en.wikipedia.org/wiki/recruitment"&gt;recruitment&lt;/a&gt; and training is more business driven. The availability of skilled Perl developers is decreasing as newer generations of developers are less likely to learn Perl. This can lead to challenges in maintaining and extending Perl codebases, making it essential for organizations to consider the long-term implications of their technology choices.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="the-challenges-of-perl"&gt;
&lt;h2&gt;The Challenges of Perl&lt;/h2&gt;
&lt;p&gt;Despite its strengths, Perl has several challenges that have contributed to its decline:&lt;/p&gt;
&lt;ol class="arabic simple"&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Readability&lt;/strong&gt;: Perl’s syntax can be complex and difficult to read, especially for those who are not familiar with it. This can lead to maintenance challenges as codebases grow and evolve.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Community Support&lt;/strong&gt;: The Perl community has shrunk over the years, leading to fewer resources, libraries, and frameworks being developed and maintained.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Performance&lt;/strong&gt;: While Perl is powerful, it may not always be the most efficient choice for modern applications, especially when compared to languages optimized for specific tasks.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Talent Pool&lt;/strong&gt;: As newer generations of developers enter the workforce, many are less familiar with Perl, making it harder to find skilled developers to maintain and extend Perl codebases.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Ecosystem&lt;/strong&gt;: The ecosystem around Perl has not kept pace with modern development practices, making it less attractive for new projects.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;While commercial support for Perl exists, it is not as widespread as for other languages like Java, Python, or JavaScript. This can make it challenging for organizations to find the necessary support and resources to manage their Perl code effectively. This also affects the availability of training and development resources for teams working with Perl, as new developers may be difficult to find and hire.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="the-case-for-containment"&gt;
&lt;h2&gt;The Case for Containment&lt;/h2&gt;
&lt;p&gt;In light of these challenges, containing Perl code within specific modules or services can offer several benefits:&lt;/p&gt;
&lt;ol class="arabic simple"&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Maintainability&lt;/strong&gt;: As projects grow and evolve, maintaining code written in Perl can become challenging, especially if the original developers are no longer available. Containing Perl code within specific modules or services can help isolate it from the rest of the codebase, making it easier to manage.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Interoperability&lt;/strong&gt;: By containing Perl code, we can create clear interfaces between different parts of the system. This allows for easier integration with other languages and technologies, facilitating a more modular architecture.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Legacy Systems&lt;/strong&gt;: Many organizations still rely on &lt;a class="extlink-wiki reference external" href="https://en.wikipedia.org/wiki/legacy systems"&gt;legacy systems&lt;/a&gt; built with Perl. Containing these systems can help ensure they continue to function while allowing for gradual migration to more modern technologies.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Security&lt;/strong&gt;: Containing Perl code can also help mitigate security risks associated with outdated libraries and dependencies. By isolating Perl components, we can better manage updates and patches.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Team Dynamics&lt;/strong&gt;: As development teams evolve, the skill sets of team members may change. Containing Perl code can help ensure that new team members can work effectively without needing to learn an older language.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;While the Perl interpreter is still actively maintained, the libraries and frameworks around it are not as actively developed as those for other languages. This can lead to challenges in finding up-to-date resources and tools for working with Perl. Other languages like Python have even begun to drop built-in modules as they are no longer maintained or considered best practice. This can lead to security vulnerabilities and compatibility issues if not managed properly or running outdated versions.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="challenges-of-containment"&gt;
&lt;h2&gt;Challenges of Containment&lt;/h2&gt;
&lt;p&gt;Managing and containing Perl code is not without its challenges like any legacy technology. Some of the key challenges include:&lt;/p&gt;
&lt;ol class="arabic simple"&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Technical Debt&lt;/strong&gt;: Containing Perl code may not eliminate the &lt;a class="extlink-wiki reference external" href="https://en.wikipedia.org/wiki/technical debt"&gt;technical debt&lt;/a&gt; associated with it. Legacy code can still be difficult to work with, and simply isolating it may not address underlying issues.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Integration Complexity&lt;/strong&gt;: As we contain Perl code, we must also consider how it will interact with other parts of the system. This can introduce additional complexity and potential points of failure.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Resource Allocation&lt;/strong&gt;: Containing Perl code may require dedicated resources for maintenance and support. Organizations must weigh the costs and benefits of this approach.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Maintaining legacy systems is done in many organizations on a minimal budget and often with limited resources. This can make it challenging to allocate the necessary time and effort to properly contain and manage Perl code. A clear strategy and prioritization are essential to ensure that containment efforts are effective and sustainable as part of a broader IT and business strategy. Especially the business side must be on board as well to allocate budget and resources, but also accept potential risks and limitations like no new features or performance improvements in the contained Perl parts as long as the transition is not completed.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="the-case-for-keeping-perl"&gt;
&lt;h2&gt;The Case for keeping Perl&lt;/h2&gt;
&lt;p&gt;While the trend is to move away from Perl, there are still valid reasons for keeping Perl code in certain situations:&lt;/p&gt;
&lt;ol class="arabic simple"&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Familiarity&lt;/strong&gt;: Many developers have extensive experience with Perl, and re-training them on a new language can be time-consuming and costly. Keeping Perl code allows organizations to leverage existing expertise.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Proven Solutions&lt;/strong&gt;: Perl has a rich ecosystem of libraries and frameworks that have been battle-tested over the years. These solutions can be valuable assets for organizations that continue to use Perl.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Rapid Prototyping&lt;/strong&gt;: Perl’s flexibility and expressiveness make it an excellent choice for rapid prototyping and scripting tasks. Keeping Perl code can enable teams to quickly iterate on ideas without the overhead of more rigid languages.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Niche Applications&lt;/strong&gt;: In certain domains, such as bioinformatics and text processing, Perl remains a popular choice due to its powerful capabilities. Keeping Perl code in these niche areas can be beneficial.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Legacy Systems&lt;/strong&gt;: Many organizations have significant investments in Perl codebases that would be costly and time-consuming to replace. In such cases, it may be more practical to maintain and contain the existing Perl code rather than attempting a complete rewrite.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In some cases, the cost and effort required to migrate away from Perl may outweigh the benefits. Organizations must carefully evaluate their specific circumstances and make informed decisions about whether to keep or contain Perl code. If the Perl code is stable, well-maintained, and continues to meet the needs of the organization, there may be little incentive to replace it if the risks and costs are too high. We see the same with &lt;a class="extlink-wiki reference external" href="https://en.wikipedia.org/wiki/COBOL"&gt;COBOL&lt;/a&gt; in many financial institutions and mainframe systems that are still in use today where the costs to run today are lower than a complete rewrite or migration.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="conclusion-about-containing-perl"&gt;
&lt;h2&gt;Conclusion about containing Perl&lt;/h2&gt;
&lt;p&gt;In conclusion, containing Perl code within our projects presents both opportunities and challenges. While it can improve maintainability, interoperability, and security, we must also address the technical debt and integration complexities that come with it. By carefully considering these factors, we can make informed decisions about the role of Perl in our software development efforts.&lt;/p&gt;
&lt;p&gt;Ultimately, the decision to contain Perl should be based on the specific needs and context of each project. As we move forward in the ever-evolving landscape of software development, it’s crucial to remain adaptable and open to change, ensuring that our technology choices align with our long-term goals. But from an enterprise architecture perspective, it is indeed time to contain Perl as part of a broader strategy to manage legacy technologies and embrace modern development practices.&lt;/p&gt;
&lt;p&gt;The key is to have a clear strategy, allocate the necessary resources, and involve all stakeholders in the decision-making process. By doing so, we can ensure that our software development efforts remain robust, flexible, and aligned with our long-term objectives. This isn’t just about Perl; it’s about how we maintain and evolve our entire technology stack in a rapidly changing world. We must be proactive in addressing the challenges of legacy technologies while embracing the opportunities presented by modern development practices.&lt;/p&gt;
&lt;p&gt;As closing note, it’s important to remember that technology choices within organizations should always be driven by business needs and goals. While technical considerations are crucial, they must be balanced with the broader context of the organization’s strategy and objectives. By taking a holistic approach to technology management, we can ensure that our software development efforts contribute to the overall success and sustainability of the organization.&lt;/p&gt;
&lt;/section&gt;
&lt;/section&gt;
</content>
    <link href="https://hansspaans.nl/blog/2025/time-to-contain-perl.html"/>
    <summary>In the world of software development, the choice of programming languages can significantly impact the maintainability and longevity of a project. Perl, once a dominant language for web development and system administration, has seen a decline in popularity over the years. As we look towards the future, it’s worth considering whether it’s time to contain Perl within our projects.In this context, “containing” Perl refers to stopping the use of Perl for new development and instead isolating existing Perl code within specific modules or services used within an enterprise. This approach allows us to manage the risks associated with legacy technologies while still leveraging their strengths where appropriate. For personal projects, the reasoning is similar, but often more pragmatic as the impact of legacy code is less critical than in an enterprise setting.</summary>
    <category term="contained" label="contained"/>
    <category term="lifecyclemanagement" label="life cycle management"/>
    <category term="perl" label="perl"/>
    <category term="technicaldebt" label="technical debt"/>
    <published>2025-09-06T10:00:00+00:00</published>
  </entry>
  <entry>
    <id>https://hansspaans.nl/blog/2023/reading-books-for-work-and-pleasure.html</id>
    <title>Reading books for work and pleasure</title>
    <updated>2023-06-01T00:00:00+00:00</updated>
    <author>
      <name>Editor</name>
    </author>
    <content type="html">&lt;section id="reading-books-for-work-and-pleasure"&gt;

&lt;p&gt;In my childhood I basically lived in the library for comics and what can be considered now as business kind of books. The storytelling books never attracted me to seek them out actively and even today most are recommendations from others or an algorithm telling me that I may like those as well.&lt;/p&gt;
&lt;p&gt;It wasn’t until I started to join the workforce that storytelling books really took off as they became available as usenet download and I could read them on my commute to work, or better said listen to them during my commute as they were audiobook downloads. It was a solid 10 to 15 hours every week listening to an audiobook instead of the radio and wasting my hours.&lt;/p&gt;
&lt;p&gt;As YouTuber &lt;a class="reference external" href="https://www.youtube.com/&amp;#64;CGPGrey"&gt;CGP Grey&lt;/a&gt; said in an earlier episode of the &lt;a class="reference external" href="https://www.youtube.com/&amp;#64;cortexFM"&gt;Cortex Podcast&lt;/a&gt; that this is a method to tell your brain about all kinds of situations in the hope it will remember it when the time is there. If it is true time will tell, but in a lot of cases it will also shape your view on certain subjects as you gain more knowledge.&lt;/p&gt;
&lt;p&gt;With this in mind I still buy audiobooks and physical books to gain more knowledge and insight. I even have my wishlist filled with some retailers to buy them when there is a discount and you don’t want to break the bank. Another option are public libraries which are great for storybooks and business books that have earned their place. For more recent IT books buying may be the better option unless you can wait and you know your local library will have them.&lt;/p&gt;
&lt;p&gt;Another benefit of buying those books is that you can sit down and read them, but also to make notes for later and easily go back. Something that doesn’t work for me correctly with just a book in PDF or ePub format, but Google Play Books makes it easier nowaday for you to make remarks and highlight sections that also are visible on Google Drive.&lt;/p&gt;
&lt;p&gt;Especially the changes that are coming with &lt;a class="extlink-wiki reference external" href="https://en.wikipedia.org/wiki/Cloud computing"&gt;cloud&lt;/a&gt;, &lt;a class="extlink-wiki reference external" href="https://en.wikipedia.org/wiki/Big data"&gt;big data&lt;/a&gt;, and &lt;a class="extlink-wiki reference external" href="https://en.wikipedia.org/wiki/Zero trust security model"&gt;zero-trust&lt;/a&gt; require that we start thinking differently about the whole IT-landscape. Taking your time to explore and think about it takes time and I would recommend taking that time now that you have it. It also gives you the freedom to take your chances with another position or company, or even start your own. Always keep exploring, reading, and learning.&lt;/p&gt;
&lt;/section&gt;
</content>
    <link href="https://hansspaans.nl/blog/2023/reading-books-for-work-and-pleasure.html"/>
    <summary>In my childhood I basically lived in the library for comics and what can be considered now as business kind of books. The storytelling books never attracted me to seek them out actively and even today most are recommendations from others or an algorithm telling me that I may like those as well.It wasn’t until I started to join the workforce that storytelling books really took off as they became available as usenet download and I could read them on my commute to work, or better said listen to them during my commute as they were audiobook downloads. It was a solid 10 to 15 hours every week listening to an audiobook instead of the radio and wasting my hours.</summary>
    <category term="books" label="books"/>
    <category term="learning" label="learning"/>
    <published>2023-06-01T00:00:00+00:00</published>
  </entry>
  <entry>
    <id>https://hansspaans.nl/blog/2023/why-start-blogging.html</id>
    <title>Why start blogging</title>
    <updated>2023-05-01T00:00:00+00:00</updated>
    <author>
      <name>Editor</name>
    </author>
    <content type="html">&lt;section id="why-start-blogging"&gt;

&lt;p&gt;Learning new skills and improving existing skills was and still is important, and especially communication and planning skills are in higher demand than ever. These skills aren’t learned and mastered overnights which also came to light in conversations with different software and infrastructure engineers as they were looking on where and how to make their next step in their career.&lt;/p&gt;
&lt;p&gt;One option is to make it part of a development plan to get training and coaching, but this requires that you already have a clear goal. A second option is to start developing yourself to the point where you know what you want or others see a path for you. This seems to be a daunting task but in the current day and age may be easier than ever before.&lt;/p&gt;
&lt;p&gt;Inexpensive courses on any topic can be found on known video streaming sites for free or for about 10 USD on some online-education sites. These courses can teach you anything from coding in Python or Java to become a better technical writer or making presentations to look fantastic. The online thing these courses can’t teach you is to master the course material as that takes time and some say up to 10.000 hours, but at least you should apply the knowledge to really understand it.&lt;/p&gt;
&lt;p&gt;Starting a blog can help you with this as it teaches you so many things like writing understandable articles for strangers to read and finding out what really works in the end. If done correctly and long enough this can also help to become an authority in your field and help others to make better decisions. While blogging has its ups and downs over the years, a lot of useful blogs exist from how to do data governance, running your business, optimizing code, or explaining concepts in a simple form.&lt;/p&gt;
&lt;p&gt;While I’m already writing for other sites, I’m following my own advice to blog as well from a more personal point of view. The other writings are especially more technical instead of telling a story. Lets see how this journey goes and if I can keep up with my own advice but also it inspires others to join this journey on better expressing yourself in writing.&lt;/p&gt;
&lt;/section&gt;
</content>
    <link href="https://hansspaans.nl/blog/2023/why-start-blogging.html"/>
    <summary>Learning new skills and improving existing skills was and still is important, and especially communication and planning skills are in higher demand than ever. These skills aren’t learned and mastered overnights which also came to light in conversations with different software and infrastructure engineers as they were looking on where and how to make their next step in their career.One option is to make it part of a development plan to get training and coaching, but this requires that you already have a clear goal. A second option is to start developing yourself to the point where you know what you want or others see a path for you. This seems to be a daunting task but in the current day and age may be easier than ever before.</summary>
    <category term=""/>
    <category term="blogging" label="blogging"/>
    <category term="learning" label="learning"/>
    <published>2023-05-01T00:00:00+00:00</published>
  </entry>
  <entry>
    <id>https://hansspaans.nl/blog/2023/first-post.html</id>
    <title>First blog post</title>
    <updated>2023-04-01T00:00:00+00:00</updated>
    <author>
      <name>Editor</name>
    </author>
    <content type="html">&lt;section id="first-blog-post"&gt;

&lt;p&gt;This is my first blog post to test Sphinx with Ablog. There isn’t a lot here right now, come check back later.&lt;/p&gt;
&lt;/section&gt;
</content>
    <link href="https://hansspaans.nl/blog/2023/first-post.html"/>
    <summary>This is my first blog post to test Sphinx with Ablog. There isn’t a lot here right now, come check back later.</summary>
    <category term="hello" label="hello"/>
    <category term="world" label="world"/>
    <published>2023-04-01T00:00:00+00:00</published>
  </entry>
</feed>
