$Lang

From Esolang
Jump to navigation Jump to search

Note: Not to be confused with the word "Slang"

$Lang
Designed by User:Intiha
Appeared in 2025
Computational class Unknown
Major implementations Python

Overview

Dollarlang (or $Lang) is a minimalistic esoteric programming language by User:Intiha where programs consist entirely of $ symbols and the #$# sequence. It is intentionally verbose: each ASCII character requires repeated $ symbols, making even simple programs extremely large.

Syntax

  • $ – Partial increment.
  • 1,600 $ symbols = 1 increment** toward the ASCII value of the current character.
  • #$# – Commit current counter to output character and reset.
  • Anything else is ignored (treated as comments).

Example

To output A (ASCII 65): $ repeated 65*1600 times + #$# (This is 104,000 $ symbols followed by #$#.)

Program Structure

  • Programs are sequences of $ and #$#.
  • Each character’s ASCII value is built by repeated increments of 12 or 1,600 $ (configurable).
  • #$# finalizes the current character and resets counters for the next character.

Features

  • Extremely verbose and minimalistic.
  • Supports literal text output.
  • Can be automated via a generator script.
  • Programs can be gigantic; e.g., “99 Bottles of Beer” ≈ 865 million `$` symbols.

Implementations

Python implementation by the creator of $Lang:

import sys

THRESHOLD = 1600  # $ per increment

def generate_dollarlang_from_file(input_file, output_file):
    """
    Reads input text from file and generates $Lang program.
    """
    with open(input_file, 'r', encoding='utf-8') as f:
        text = f.read()

    lines = []
    for ch in text:
        ascii_val = ord(ch)
        total_dollars = ascii_val * THRESHOLD
        lines.append('$' * total_dollars + '#$#')

    with open(output_file, 'w', encoding='utf-8') as f:
        f.write('\n'.join(lines))

    print(f"$Lang program generated: {output_file}")

def run_dollarlang_file(filename):
    output = ''
    counter = 0
    temp = 0
    threshold = THRESHOLD
    buffer_size = 1024 * 1024

    with open(filename, 'r', encoding='utf-8') as f:
        while True:
            chunk = f.read(buffer_size)
            if not chunk:
                break
            i = 0
            while i < len(chunk):
                if chunk[i] == '$':
                    temp += 1
                    if temp == threshold:
                        counter += 1
                        temp = 0
                elif chunk[i:i+3] == '#$#':
                    output += chr(counter)
                    counter = 0
                    temp = 0
                    i += 2
                i += 1
    return output

if __name__ == "__main__":
    if len(sys.argv) < 3:
        print("Usage:")
        print("  python dollarlang.py generate input.txt -o output.dl")
        print("  python dollarlang.py run program.dl")
        sys.exit(1)

    command = sys.argv[1]
    if command == "generate":
        input_file = sys.argv[2]
        if len(sys.argv) >= 5 and sys.argv[3] == "-o":
            output_file = sys.argv[4]
        else:
            output_file = "program.dollarlang"
        generate_dollarlang_from_file(input_file, output_file)

    elif command == "run":
        program_file = sys.argv[2]
        result = run_dollarlang_file(program_file)
        print(result)
    else:
        print("Unknown command")

Generate Program

python dollarlang.py generate input.txt -o output.dl

Reads `input.txt` and creates a $Lang program in `output.dl`.

Run Program

python dollarlang.py run program.dl

Runs the $Lang program and prints its output.