We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

PrimeScript

From Esolang
Jump to navigation Jump to search

PrimeScript is an esoteric programming language designed by User:AndrewBayly in 2026. It is based on JavaScript, but encoded in such a way that running a program requires solving a computationally hard mathematical problem — specifically, integer factorization. Writing a PrimeScript program is simple. Interpreting one is, depending on your choice of parameters, anywhere between mildly inconvenient and cosmologically impossible.


PrimeScript inverts the usual relationship between human effort and machine effort. A programmer writes ordinary JavaScript. The encoder converts it to a single large integer in milliseconds. The interpreter must then factor that integer — a problem for which no efficient classical algorithm is known — before it can read a single token of the source.


Computational model

A PrimeScript program is a single positive integer N, constructed as follows:

Encoding

  1. Take the JavaScript source text and encode it as a UTF-8 byte sequence.
  2. Interpret that byte sequence as a big-endian integer m.
  3. Generate a large random prime P of a chosen bit length k.
  4. Compute N = m × P.
  5. The program is N. Distribute N. Discard nothing else — but keep P private if you want the program to remain unrunnable.

Decoding

  1. Find the factor of N whose bit-length is exactly k.
  2. Call that factor P. Compute m = N / P.
  3. Interpret m as a big-endian UTF-8 byte sequence.
  4. Execute the result as JavaScript.

The decoder does not need to know P in advance. It needs only to know k, the bit length of P, which is part of the language specification for a given PrimeScript variant. The convention resolves the ambiguity inherent in factorisation: given two factors of N, the one with exactly k bits is P, and the other is m.


See also

  • Malbolge — execution difficulty through deliberate obfuscation
  • brainfuck — minimalism in language design
  • Befunge — unconventional program representation

External links

  • Reference implementation (encoder + interactive decoder): PrimeScript