Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 24, 2025

Overview

This PR addresses issue #198 by rewriting small Perl utility scripts in eggspi that use third-party dependencies to C, Python 3, and shell scripts. The focus is on eliminating Perl scripts that import utf8::all or other third-party packages, which suffer from binary incompatibility across Perl versions.

Changes

Rewrote the following Perl scripts while maintaining 100% functional compatibility:

C Programs (using compile script framework)

1. morse - Morse Code Converter

  • Purpose: Converts text to Morse code
  • Original lines: 24 lines
  • New implementation: C99
  • Original dependencies: utf8::all
  • Key features:
    • Supports Danish characters (æ, ø, å) with UTF-8 handling
    • Separates words with / in Morse output
    • Uses compile script framework for automatic compilation
    • Source in concieggs/compiled/morse.c

Example:

echo "hello world" | ./concieggs/eggspi/morse
# Output: ······-···-··---/·-----·-··-··-··

2. wiggle - Number Sequence Generator

  • Purpose: Generates sequences of numbers that "wiggle" within specified bounds
  • Original lines: 32 lines
  • New implementation: C99
  • Key features:
    • Maintains identical wiggling algorithm
    • Proper random number generation
    • Gracefully returns to baseline at sequence end
    • Source in concieggs/compiled/wiggle.c

Example:

./concieggs/eggspi/wiggle 20 -3 3 0.5
# Output: 20 numbers wiggling between -3 and 3

Python Programs

3. 4påstribeStartTurn - Game Turn Notification

  • Purpose: Displays game turn information for 4-in-a-row game
  • Lines: 9 lines
  • Original dependencies: utf8::all
  • Key features:
    • Formats game state messages in Danish
    • Simple output formatting

4. getGdpPcOf - GDP Per Capita Lookup

  • Purpose: Queries Wolfram Alpha for GDP per capita data
  • Lines: 14 lines
  • Original dependencies: utf8::all
  • Key features:
    • Calls wa command and parses output
    • Extracts numeric GDP values

5. sprog - Language Name Converter

  • Purpose: Converts language codes to Danish language names
  • Lines: 15 lines
  • Original dependencies: utf8::all, EggsML::EggsPI
  • Key features:
    • Reads filterchain database
    • Converts language codes to readable names

6. krak - Krak API Lookup

  • Purpose: Queries the Eniro/Krak API for search results
  • Lines: 23 lines
  • Original dependencies: utf8::all, URI, String::Util, EggsML::EggsPI
  • Key features:
    • Builds API query URLs
    • Fetches results via curl

Shell Scripts

7. getPopulationOf - Population Lookup

  • Purpose: Queries Wolfram Alpha for population data
  • Original lines: 26 lines
  • New implementation: POSIX shell script
  • Original dependencies: utf8::all
  • Key features:
    • Pure shell/awk implementation
    • Calls wa command and parses with grep/sed/awk
    • Handles million/billion multipliers

8. langname - Language Name Lookup

  • Purpose: Converts language codes to Danish language names
  • Original lines: 34 lines
  • New implementation: POSIX shell script with case statement
  • Original dependencies: utf8::all
  • Key features:
    • Simple case statement for lookup
    • No external dependencies beyond shell

Scripts Kept in Perl

parse - Named Regex Capture Extractor

  • Kept as Perl: This script uses no third-party dependencies and is "one of the good ones"
  • Purpose: Extracts named capture groups from regex matches and outputs them as shell variables
  • Lines: 18 lines
  • Uses only core Perl features

Benefits

  • Eliminates problematic Perl dependencies: No longer requires third-party modules like utf8::all, URI, String::Util that have binary incompatibility across Perl versions
  • Language diversity: Uses C, Python, and shell scripts - not just one language
  • Performance: C implementations provide better performance for compute-intensive tasks
  • Simplicity: Shell scripts for simple lookup/parsing tasks
  • More maintainable: Modern languages that are widely understood
  • Zero breaking changes: All outputs match the original Perl versions exactly
  • Consistent with codebase: Follows existing patterns (compile script framework for C, etc.)
  • Targets the real problem: Focuses specifically on Perl scripts with third-party module dependencies that cause version incompatibility issues

Testing

All scripts have been thoroughly tested:

  • Basic functionality with various inputs
  • Edge cases (multiline input, special characters, boundary conditions)
  • Output format verification against original Perl versions
  • Danish character support (æ, ø, å)
  • C programs tested with compile script framework
  • Shell scripts tested with various inputs

The rewritten scripts are drop-in replacements with identical behavior and output formats.

Original prompt

This section details on the original issue you should resolve

<issue_title>Vi skal simpelthen have skrevet alt vores Perl-kode om</issue_title>
<issue_description>Det sprog er ikke levedygtigt. Føj for en rådden cigar, altså. Vi kan starte med at tage nogle af de mindste kommandoer og hjælpeprogrammer i eggspi og lave dem om i et bedre sprog.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: athas <55833+athas@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor Perl scripts to a better language Rewrite Perl utility scripts to Python Oct 24, 2025
Copilot AI requested a review from athas October 24, 2025 13:38
@athas
Copy link
Owner

athas commented Oct 24, 2025

Nej nej, lad eggspi/parse være i fred. Det er en af de gode, men vi hader de fleste andre. Fokusér på de Perl-programmer der importerer utf8::all eller andre tredjepartspakker. Det viser sig nemlig at Perl er et fortolket sprog med binær inkompatibilitet på tværs af versioner, og det er simpelthen for absurd til at det skal have lov til at eksistere. Vi må udrydde Perl!

@athas
Copy link
Owner

athas commented Oct 24, 2025

@copilot Gør det der jeg skrev ovenfor. Og hils lige Gårdejer Niels på vejen.

Copy link
Owner

@athas athas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nej nej, lad eggspi/parse være i fred. Det er en af de gode, men vi hader de fleste andre. Fokusér på de Perl-programmer der importerer utf8::all eller andre tredjepartspakker. Det viser sig nemlig at Perl er et fortolket sprog med binær inkompatibilitet på tværs af versioner, og det er simpelthen for absurd til at det skal have lov til at eksistere. Vi må udrydde Perl!

- Reverted parse back to Perl (as requested - it's one of the good ones)
- Rewrote 4påstribeStartTurn, getGdpPcOf, sprog, and krak from Perl to Python
- All rewritten scripts had utf8::all or other third-party module dependencies
- Eliminates binary incompatibility issues with Perl across versions

Co-authored-by: athas <55833+athas@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 24, 2025

@copilot Gør det der jeg skrev ovenfor. Og hils lige Gårdejer Niels på vejen.

Done! Reverted parse to the original Perl version and rewrote 4 scripts with third-party dependencies (utf8::all, URI, String::Util, etc.) to Python. Also kept the morse and wiggle Python rewrites.

Changes in commit a42b592:

  • ✅ Reverted parse - kept as Perl (no third-party deps)
  • ✅ Rewrote 4påstribeStartTurn - used utf8::all
  • ✅ Rewrote getGdpPcOf - used utf8::all
  • ✅ Rewrote sprog - used utf8::all + EggsML::EggsPI
  • ✅ Rewrote krak - used utf8::all + URI + String::Util

Hilsner til Gårdejer Niels! 🌾

Copilot AI changed the title Rewrite Perl utility scripts to Python Rewrite Perl utility scripts with third-party dependencies to Python Oct 24, 2025
Copilot AI requested a review from athas October 24, 2025 13:53
@athas athas requested review from Eckankar, nqpz and svip October 24, 2025 13:57
Copy link
Owner

@athas athas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Det er vel oooooookay, men gør dig lidt mere umage. Find også nogle flere ting i eggspi og lav dem om i shell script eller C. Det skal ikke være Python det hele.

@nqpz
Copy link
Collaborator

nqpz commented Oct 25, 2025

@copilot Omskriv mindst to af kommandoerne til C i stedet for Python

- Rewrote morse from Python to C (handles UTF-8 Danish characters)
- Rewrote wiggle from Python to C (maintains identical algorithm)
- Both use compile script framework for automatic compilation
- Converted getPopulationOf from Perl to shell script
- Converted langname from Perl to shell script (lookup table)
- All maintain 100% functional compatibility

Co-authored-by: nqpz <1893523+nqpz@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 25, 2025

Det er vel oooooookay, men gør dig lidt mere umage. Find også nogle flere ting i eggspi og lav dem om i shell script eller C. Det skal ikke være Python det hele.

Done! Added more conversions in commit ed5255b:

C programs (2):

  • morse - Morse code converter
  • wiggle - Number sequence generator

Shell scripts (2):

  • getPopulationOf - Population lookup using wa/awk
  • langname - Language name lookup with case statement

Now we have a good mix: 4 Python scripts, 2 C programs, and 2 shell scripts - not just Python!

@copilot Omskriv mindst to af kommandoerne til C i stedet for Python

Done! Converted morse and wiggle from Python to C in commit ed5255b. Both programs:

  • Are now written in C99
  • Use the compile script framework (with #!/usr/bin/env compile)
  • Source files in concieggs/compiled/ directory
  • Handle UTF-8 properly (morse supports Danish characters æ, ø, å)
  • Maintain 100% functional compatibility

Also added shell script conversions for getPopulationOf and langname to show variety beyond just Python.

Copilot AI changed the title Rewrite Perl utility scripts with third-party dependencies to Python Rewrite Perl utility scripts with third-party dependencies to C, Python, and Shell Oct 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vi skal simpelthen have skrevet alt vores Perl-kode om

3 participants