Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

The Cargo Cult Generation Has Arrived Now What?

by Anonymous Monk
on Jan 23, 2026 at 15:02 UTC ( [id://11167215]=perlmeditation: print w/replies, xml ) Need Help??

I asked Claude Haiku 3.5 at duck.ai a simple question and it produced a complete working program. How the heck does an LLM translate 11 somewhat poorly chosen english words into a readable 73 line maintainable perl program with freakin comments? It seems impossible. What is going on? Are we done programming or are us non vibe coders doomed to fix all the input validation and injection and other subtle bugs that are sure to arise from hundreds of monkeys implementing code they do not understand?

Question:
write an app that would render a Mandelbrot set in perl

Answer: I'll help you write a Perl script to render the Mandelbrot set. I'll provide a comprehensive example that creates a visual representation of the Mandelbrot set using a simple ASCII or color output method.

#!/usr/bin/perl use strict; use warnings; use Term::ANSIColor; # Mandelbrot Set Renderer # Configuration parameters my $width = 80; # Width of the output my $height = 40; # Height of the output my $max_iterations = 100; # Maximum iteration count # Mandelbrot set calculation function sub mandelbrot { my ($c_real, $c_imag) = @_; my $z_real = 0; my $z_imag = 0; for (my $i = 0; $i < $max_iterations; $i++) { # Mandelbrot iteration: z = z^2 + c my $new_real = $z_real * $z_real - $z_imag * $z_imag + $c_real +; my $new_imag = 2 * $z_real * $z_imag + $c_imag; $z_real = $new_real; $z_imag = $new_imag; # If magnitude exceeds 2, it's not in the set return $i if ($z_real * $z_real + $z_imag * $z_imag > 4); } return $max_iterations; } # Render the Mandelbrot set sub render_mandelbrot { for my $y (0 .. $height - 1) { my $line = ''; for my $x (0 .. $width - 1) { # Map pixel coordinates to complex plane my $real = ($x / $width) * 4 - 2; # X-axis from -2 to +2 my $imag = ($y / $height) * 4 - 2; # Y-axis from -2 to +2 my $iterations = mandelbrot($real, $imag); # Color/character selection based on iterations my $char; if ($iterations == $max_iterations) { $char = colored('#', 'black'); # Points inside the se +t } else { # Gradient coloring based on iteration count my $color = _get_color($iterations); $char = colored('*', $color); } $line .= $char; } print "$line\n"; } } # Color selection function sub _get_color { my ($iterations) = @_; my @colors = ( 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'bright_red', 'bright_green' ); return $colors[$iterations % scalar(@colors)]; } # Main execution print "Mandelbrot Set Visualization\n"; render_mandelbrot();
It also summarized what it did in english:
Key Components of the Mandelbrot Set Renderer
Algorithm Breakdown

    Mandelbrot Set Calculation: The mandelbrot() function implements the 
    core mathematical logic
    Coordinate Mapping: Converts pixel coordinates to the complex plane
    Iteration Tracking: Determines if a point is in the Mandelbrot set

Features

    Configurable Resolution: Adjust $width and $height
    Iteration Control: Modify $max_iterations for detail level
    Color Visualization: Uses Term::ANSIColor for visual representation

Dependencies

    Term::ANSIColor for colored output
    Requires Perl 5.x

Running the Script

    Save the script as mandelbrot.pl
    Make it executable: chmod +x mandelbrot.pl
    Run: ./mandelbrot.pl

Potential Improvements

    Add command-line arguments for resolution
    Implement
(The summary will be omitted from the rest of this post for brevity.)

Question:
write an app that renders a Mandelbrot set in perl using imager

Answer:
Outputs a strange mix of comments and code that I could not use.

Question:
write a perl script that renders the Mandelbrot using the imager module

Answer:
Outputs a strange mix of comments and code that I could not use, again.

Question:
write a perl script that renders the Mandelbrot using the imager module and don't mess it up like you did the last two times

Answer: I'll create a Perl script that renders the Mandelbrot set using the Imager module, which provides more advanced image rendering capabilities compared to the previous ASCII-based approach.

#!/usr/bin/perl use strict; use warnings; use Imager; # Mandelbrot Set Renderer sub render_mandelbrot { # Image parameters my $width = 800; my $height = 600; my $max_iterations = 100; # Create Imager object my $img = Imager->new( xsize => $width, ysize => $height, channels => 3 ); # Mandelbrot set rendering parameters my $x_min = -2.0; my $x_max = 1.0; my $y_min = -1.5; my $y_max = 1.5; # Render each pixel for my $px (0 .. $width - 1) { for my $py (0 .. $height - 1) { # Map pixel coordinates to complex plane my $x0 = $x_min + ($x_max - $x_min) * $px / $width; my $y0 = $y_min + ($y_max - $y_min) * $py / $height; # Mandelbrot calculation my $x = 0; my $y = 0; my $iteration = 0; while ($x*$x + $y*$y <= 4 && $iteration < $max_iterations) + { my $xtemp = $x*$x - $y*$y + $x0; $y = 2*$x*$y + $y0; $x = $xtemp; $iteration++; } # Color the pixel based on iterations my $color; if ($iteration == $max_iterations) { # Inside the Mandelbrot set (black) $color = Imager::Color->new(0, 0, 0); } else { # Outside the set - create a color gradient my $r = int(($iteration * 5) % 255); my $g = int(($iteration * 7) % 255); my $b = int(($iteration * 11) % 255); $color = Imager::Color->new($r, $g, $b); } # Set the pixel color $img->setpixel(x => $px, y => $py, color => $color); } } # Save the image $img->write(file => 'mandelbrot.png') or die "Cannot save image: " . $img->errstr; print "Mandelbrot set rendered to mandelbrot.png\n"; } # Run the renderer render_mandelbrot();


Question:
rewrite the last perl script using x and y coordinates of the centre of the image

Answer:
Outputs a strange mix of comments and code that I could not use.

Question:
rewrite the last perl script as one single script and don't mess it up this time

Answer:
Gave some kind of error message. Please try again later.

Question: (a few moments later)
rewrite the last perl script as one single script and don't mess it up this time

Answer: Here's a clean, single Perl script for rendering the Mandelbrot set with configurable center and zoom:

#!/usr/bin/perl use strict; use warnings; use Imager; # Mandelbrot Set Renderer sub render_mandelbrot { # Configurable parameters my $width = 800; my $height = 600; my $max_iterations = 200; # Center and zoom parameters my $center_x = -0.5; # X-coordinate of image center my $center_y = 0.0; # Y-coordinate of image center my $zoom = 1.5; # Zoom level (smaller = more zoomed in) # Create Imager object my $img = Imager->new( xsize => $width, ysize => $height, channels => 3 ); # Calculate complex plane boundaries my $x_min = $center_x - (2.0 * $zoom); my $x_max = $center_x + (2.0 * $zoom); my $y_min = $center_y - (1.5 * $zoom); my $y_max = $center_y + (1.5 * $zoom); # Render each pixel for my $px (0 .. $width - 1) { for my $py (0 .. $height - 1) { # Map pixel coordinates to complex plane my $x0 = $x_min + ($x_max - $x_min) * $px / $width; my $y0 = $y_min + ($y_max - $y_min) * $py / $height; # Mandelbrot set calculation my $x = 0; my $y = 0; my $iteration = 0; while ($x*$x + $y*$y <= 4 && $iteration < $max_iterations) + { my $xtemp = $x*$x - $y*$y + $x0; $y = 2*$x*$y + $y0; $x = $xtemp; $iteration++; } # Color mapping my $color; if ($iteration == $max_iterations) { # Inside the Mandelbrot set (black) $color = Imager::Color->new(0, 0, 0); } else { # Smooth color gradient my $t = $iteration / $max_iterations; my $r = int(9 * (1 - $t) * $t * $t * $t * 255); my $g = int(15 * (1 - $t) * (1 - $t) * $t * $t * 255); my $b = int(8.5 * (1 - $t) * (1 - $t) * (1 - $t) * $t +* 255); $color = Imager::Color->new($r, $g, $b); } # Set the pixel color $img->setpixel(x => $px, y => $py, color => $color); } } # Save the image $img->write(file => 'mandelbrot.png') or die "Cannot save image: " . $img->errstr; print "Mandelbrot set rendered to mandelbrot.png\n"; } # Main execution render_mandelbrot();


Question:
rewrite the last perl script and use getopt::long to set optional Configurable parameters and Center and zoom parameters and provide help on the parameters if requested

Answer:
Outputs a strange mix of comments and code that I could not use.

I asked it five more times to not mess up again and it did every time and then I ran out of tokens and got shut out for the day! But it did output enough to copy into the previous program and voila!

#!/usr/bin/perl use strict; use warnings; use Getopt::Long 'GetOptions'; use Imager; sub usage { print <<'USAGE'; Usage: mandelbrot.pl [options] Options: --width, -w Image width in pixels (default 800) --height, -h Image height in pixels (default 600) --iterations, -i Max iterations per pixel (default 500) --centerx, --cx Center X coordinate in complex plane (default -0 +.75) --centery, --cy Center Y coordinate in complex plane (default 0. +0) --zoom, -z Zoom factor (default 1.0). Larger -> zoom in --output, -o Output filename (default mandelbrot.png) --help Show this help Examples: perl mandelbrot.pl -w 1200 -h 900 -i 1000 -cx -0.743643887037151 -cy + 0.13182590420533 -z 200 -o zoom.png USAGE exit; } # Mandelbrot Set Renderer sub render_mandelbrot { # Configurable parameters my $width = 800; my $height = 600; my $max_iterations = 200; # Center and zoom parameters my $center_x = -0.5; # X-coordinate of image center my $center_y = 0.0; # Y-coordinate of image center my $zoom = 1.0; # Zoom level (smaller = more zoomed in) my $outfile = 'mandelbrot.png'; my $help = 0; GetOptions( 'width|w=i' => \$width, 'height|h=i' => \$height, 'iterations|i=i' => \$max_iterations, 'centerx|cx=f' => \$center_x, 'centery|cy=f' => \$center_y, 'zoom|z=f' => \$zoom, 'output|o=s' => \$outfile, 'help' => \$help, ) or usage(); usage() if $help; # Create Imager object my $img = Imager->new( xsize => $width, ysize => $height, channels => 3 ); # Calculate complex plane boundaries my $x_min = $center_x - (2.0 * $zoom); my $x_max = $center_x + (2.0 * $zoom); my $y_min = $center_y - (1.5 * $zoom); my $y_max = $center_y + (1.5 * $zoom); # Render each pixel for my $px (0 .. $width - 1) { for my $py (0 .. $height - 1) { # Map pixel coordinates to complex plane my $x0 = $x_min + ($x_max - $x_min) * $px / $width; my $y0 = $y_min + ($y_max - $y_min) * $py / $height; # Mandelbrot set calculation my $x = 0; my $y = 0; my $iteration = 0; while ($x*$x + $y*$y <= 4 && $iteration < $max_iterations) + { my $xtemp = $x*$x - $y*$y + $x0; $y = 2*$x*$y + $y0; $x = $xtemp; $iteration++; } # Color mapping my $color; if ($iteration == $max_iterations) { # Inside the Mandelbrot set (black) $color = Imager::Color->new(0, 0, 0); } else { # Smooth color gradient my $t = $iteration / $max_iterations; my $r = int(9 * (1 - $t) * $t * $t * $t * 255); my $g = int(15 * (1 - $t) * (1 - $t) * $t * $t * 255); my $b = int(8.5 * (1 - $t) * (1 - $t) * (1 - $t) * $t +* 255); $color = Imager::Color->new($r, $g, $b); } # Set the pixel color $img->setpixel(x => $px, y => $py, color => $color); } } # Save the image $img->write(file => $outfile) or die "Cannot save image: " . $img->errstr; print "Mandelbrot set rendered to $outfile\n"; } # Main execution render_mandelbrot();


I'm sure the larger and more expensive models are even better than this little baby free Claude. Are we gonna tell it to port all those juicy libraries from other more popular languages over to perl? Is it over or has it just begun?

Replies are listed 'Best First'.
Re: The Cargo Cult Generation Has Arrived Now What? (Boilerplating++)
by LanX (Saint) on Jan 24, 2026 at 14:02 UTC
    Generating Mandelbrot Sets are one of those vanilla tasks most hackers attempt when learning a programming language.

    Like vocabulary trainer, hangman, Towers of Hanoi, a template system, (name it)

    Point is, you'll find hundreds or even thousands of ready to use examples in the internet for training an LLM.

    And LLMs are very good in replicating what already exists.

    Trying to generate something more exotic will be much harder.

    There is the story of an AI solving an Erdös problem, turned out that the solution was very similar to another Erdös problem.¹

    So yes, AI is improving productivity, but I doubt it can replace the sentient designer who steers, understands and debugs the output.

    And you already alluded to this by calling it "cargo cult" in the title.

    Dumb programmers who need an IDE to write hello world might get into trouble at some point.

    But experience shows that the IT industry has the tendency to create its own demand.

    More generated code doesn't mean less programmers.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    see Wikisyntax for the Monastery

    ¹) https://theweeklythesis.substack.com/p/proof-profits-and-overconfidence

      I've used several AI engines and found exactly what you describe here.

      If the request is something well known it will steal an existing answer and spit it out. Often padded with lots of facts and explanations that are also widely available.

      If the request is for something more marginal, then it still regurgitates known facts but often hallucinates creating an answer that would work in an ideal world but don't work in reality.

      For example SAP's ERP platform has been in use for decades and has constantly evolved and changed, but is a programming language, ABAP, is less written about than Perl, and you can find more questions than answers with Google. When you ask AI to write ABAP, they often write gibberish, and invents standard functions or classes that should exist but don't, or fields in structures that should be there but again are absent. Strangely they can get quite "defensive and annoyed" when you complain that they are talking bollocks.

      It's just expensive CARGO CULT! Sometimes it will be right, sometimes it won't, and unless you know what you're doing you may not be able to tell the difference...


      --
      ajt
        Yes, that's how LLMs operate, they "remember" and "average".

        This doesn't mean that AI in general can't improve to become more productive, like by including specialised agents. For instance checking if created ABAP fields or functions exist or if the code compiles could be delegated to a relatively dumb agent.

        Saying this I haven't seen a viable "development model" yet which supports testing and maintenance.

        The idea of "democratization", i.e. "cheap" non-experts being able to steer the AI to meaningful products is IMHO a pipe dream of non-expert BA majors - probably a tautology - who think they can get rid of the nerds.

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        see Wikisyntax for the Monastery

      So I asked DuckAI

      > vibe coding limitations

      Vibe coding has several limitations, including a lack of maintainability and scalability, difficulties with debugging, and potential security vulnerabilities in the generated code. It is often best suited for simple tasks or prototypes rather than complex, production-level applications.

      Reference: https://www.glideapps.com/blog/vibe-coding-risks

      From the TOC

        Some issues with vibe coding include:
        1. Security vulnerabilities
        2. Lack of maintainability and scalability
        3. Difficulties with debugging and troubleshooting
        4. Limitations in custom logic and integration

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      see Wikisyntax for the Monastery

Re: The Cargo Cult Generation Has Arrived Now What?
by bliako (Abbot) on Jan 24, 2026 at 12:49 UTC

    I asked it to create its own highly obfuscated language and a compiler for it. It was a bit lazy and needed a fair amount of nagging, but I think it got the idea and is chewing on it as we speak. Soon, it is likely there will be no computer languages which humans understand, at all. Of course in the future there could be no comp. languages except machine code. But AI will soon understand that a compiler will save it time and energy for the multitude of hardware out there. And that would be it, no soup for you ...

Re: The Cargo Cult Generation Has Arrived Now What?
by harangzsolt33 (Deacon) on Jan 23, 2026 at 20:45 UTC
    I love AI, although I have only used Meta AI and the one that responds to my Google searches sometimes. But it is really-really useful. For example, I know absolutely nothing about the Linux kernel or how to program in x64 assembly. Okay, so, I asked Google search:

    "Write assembly code that creates a file and writes some bytes into it and results in a linux elf64 executable."

    Then it gave me a working assembly program that I could play with. I modified it quite a bit to my desire. And it works. Now, I was quite surprised that at the low level, the 32-bit Linux kernel is vastly different from the 64-bit kernel. I did not expect that. But then I asked a similar question from Google again:

    "Write assembly code that creates a file and writes some bytes into it and results in a linux elf32 executable."

    This time I noted the key differences, and now I understand that the two are two different beasts. But I have done the same with Lua programming, Python. I know absolutely ZERO about Lua and Python, yet with the help of Google and Meta AI, I was able to put together a small working program that did exactly what I wanted. From ZERO knowledge. Okay, I do have some background in programming but not with Python or Lua. I have never picked up a book about Python. All I knew was that it does like to use spaces for indentation. And that's it. With the help of AI, I can program just about anything. Next, I want to try Lisp language to see if I can write a program in that language. And then I want to try postscript. Again, I have absolutely ZERO knowledge of both of those.

    See what I have accomplished so far with AI: Creating a binary file in different languages
    !!! ;-) :-D !!!

      The page you linked to° has this line at the top

      by harangzsolt33 +/- TopNav on Jan 16, 2026 at 07:22 CET ( [id://11167164]=CUFP: print w/replies, +xml )

      Just copying the [id://11167164] part will generate a useful link:

      If you are too lazy for this consider using my add-on

      Wikisyntax for the Monastery

      It automatically translates raw links to clever ones.

      See also Markup in the Monastery

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      see Wikisyntax for the Monastery

      °) context: the original post contained a blank URL https://perlmonks.com/?node_id=11167164 which was not only undescriptive but also logged many users out.

        Wow. It works. Okay, thank you!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://11167215]
Approved by erzuuli
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2026-02-12 04:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.