Skip to content

ikriv/rapira-samples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

Rapira Programs Written by an LLM

This repository contains programs written in Rapira (Рапира), a Soviet-era educational programming language from the 1980s. The programs were generated by an LLM (Claude) as an experiment in testing LLM capability to write code in a language it has not been explicitly trained on.

Context

Rapira exists in the LLM's training data in some form — the Wikipedia article, a few archived specification documents, and scattered references. However, that information is rather inexact:

  • The language specification provided to the LLM describes the original 1985 Agat/Shkolnitsa dialect, which uses -> for assignment, ИМЕНА: for local variable declarations, КНЦ to end procedures, ВСЕ to end loops, and ; as a statement terminator.
  • The actual interpreter (Rapture) implements a different dialect: := for assignment, свои:/чужие: instead of ИМЕНА:, конец instead of КНЦ, кц instead of ВСЕ for loops, and no semicolons.
  • Rapture also introduces its own scoping model where all variables are local by default and external names must be explicitly imported with чужие: (extern) — including transitive dependencies through the entire call chain.
  • Several features from the original spec are unimplemented in Rapture: file I/O, graphics, modules, the ПРИГЛ function, and more.

The LLM had to discover these discrepancies at runtime and adapt.

Programs

Pascal's Triangle (pascal_triangle.rap)

Prints the first 20 rows of Pascal's triangle. A simple program that exercises loops, sequences, and arithmetic.

rapture.bat pascal_triangle.rap

Markdown-to-HTML Converter (md_to_html/)

A Markdown-to-HTML converter supporting ATX headings, paragraphs, thematic breaks, fenced code blocks (with language tags), blockquotes, ordered and unordered lists, emphasis, strong emphasis, code spans, links, images, backslash escapes, and HTML entity escaping. Tested against 28 CommonMark test cases (all passing).

See md_to_html/README.md for usage instructions.

Getting Started

1. Install Java

Rapture requires a Java Runtime Environment (JRE), version 8 or later. You do not need the full JDK — the JRE is sufficient since Rapture is a pre-built application, not something you compile.

Download from java.com.

Verify the installation:

java -version

2. Download Rapture

Download the latest Rapture release (v1.0.1) from GitHub:

https://github.com/mattmikolay/rapture/releases

Download the rapture-1.0.1.zip archive.

3. Unzip and set up

Extract the archive. The resulting directory contains:

rapture-1.0.1/
  bin/
    rapture         (Unix shell script)
    rapture.bat     (Windows batch file)
  lib/
    rapture-1.0.1.jar
    ... (dependency JARs)

Place the .rap files from this repository so that rapture.bat (or rapture) can find them, or add the Rapture bin/ directory to your PATH.

4. Run

rapture.bat pascal_triangle.rap

Russian Input and Output in the REPL

Rapture's REPL (interactive mode, started with rapture.bat without arguments) requires proper UTF-8 setup to handle Cyrillic characters. On Windows, there are two things to configure:

Use Windows Terminal (wt.exe)

The legacy cmd.exe console host has poor Unicode support. Use Windows Terminal (wt.exe) instead — it ships with Windows 11 and is available from the Microsoft Store for Windows 10. It renders Cyrillic correctly out of the box.

Set the console code page to UTF-8

The rapture.bat included in this repository already does this automatically (chcp 65001), but if you are running java directly or using a custom script, set the code page before launching:

chcp 65001

Set Java encoding flags

Again, the modified rapture.bat handles this, but if running Java directly:

set JAVA_OPTS=-Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stdin.encoding=UTF-8
java %JAVA_OPTS% -classpath "lib/*" com.mattmik.rapira.RaptureCommandKt

Use a Cyrillic-capable font

In Windows Terminal settings, choose a font that covers Cyrillic glyphs. Cascadia Code (the default in Windows Terminal) works well. If using the legacy console, switch to Consolas or Lucida Console via the window properties.

Summary

For the smoothest experience on Windows:

  1. Open Windows Terminal (wt.exe)
  2. Use the provided rapture.bat (which sets chcp 65001 and the Java encoding flags)
  3. Ensure the terminal font supports Cyrillic (Cascadia Code, Consolas, etc.)

With this setup, both the REPL and file execution will correctly display Russian keywords and Cyrillic identifiers.

References

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published