r/altprog • • Oct 14 '26

Rank — an array-oriented language for small screens, inspired by BASIC and APL

web: https://rank.viewflow.io/

A little over a month ago, inspired by old pocket computers, I started building Rank—a language I could comfortably write on my phone. I'm even thinking about making a dedicated handheld with a physical QWERTY keyboard and multi-function keys like the ZX Spectrum had

The language combines ideas from BASIC and APL: array operations, words instead of special symbols, and data-first function calls

Here is what it looks like:

rem Largest Palindrome Product
rem https://projecteuler.net/problem=4 
use sequences

Factors = 100 to 999
Products = Factors Factors outer *
Candidates = Products merge .descending
Candidates filter palindrome first print

fun palindrome X
  Text = X text
  return Text reverse equal Text
end

I'd like to try a little challenge: suggest me a programming puzzle or a small data-processing task, and I'll post a solution in Rank

Let's explore where the language a still needs more work!

9 Upvotes

3 comments sorted by

3

u/6502zx81 Oct 14 '26

So what is the computational model / mental model that the user should hav in mind? Looking at the exsmples I guess it is Forth-like or HP 48 RPL like. A stack is filled with objects and then operaions are applied to the stack. Is this correct?

1

u/kmmbvnr Oct 15 '26

Not quite. I started language design with 3 constraints: code should fit within 40 columns, easy to type on a standard phone keyboard such as Gboard or the iPhone keyboard, and have a BASIC/calculator-like feel. So I wanted to avoid punctuation-heavy syntax like [, ,, and ( that is common in many languages. And to be typed and read from left to right to avoid cursor movements

After writing dozens of solutions to popular programming contest problems by hand, hundreds with AI assistance, I came to a model like common binary operations has +/-/* but extended to functions with more arguments.

A B matmul

or

A B outer *

The mental model is basically data first, operation after it, with additional modifiers or operation arguments following when needed.

This also gives a nice calculator-like REPL experience: you can see intermediate results early, and unary operations chain naturally without parentheses, for example:

A first print

With only 40 columns available, i think this tends to produce compact, math-like statements. I'm still evaluating the UX and readability of the proposed solution.

1

u/6502zx81 Oct 15 '26

Ok, thanks. That's an interesting approach.