💾 Archived View for gemini.ctrl-c.club › ~nttp › toys › ripen captured on 2023-04-26 at 14:03:59. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2021-12-03)

➡️ Next capture (2023-07-22)

-=-=-=-=-=-=-

Ripen scripting engine

Welcome to Ripen, a stack-based language with highly readable syntax, that can be implemented with little code and effort in a language like C++ or D. It's informed by RetroForth and PostScript, but diverges from either in important ways, not least due to its string-threaded nature. Surprisingly, Ripen only seems to be about 6 times slower than the host language on a quick test — much better than for other language families.

Ripen is based on the principles explained in this interpreter construction tutorial:

More about tiny scripting engines

The point is having a tiny engine, easily copy-pasted into any application, even hidden inside a bigger module. For this reason, the default vocabulary is kept small.

As of 11 May 2021, Ripen is used as the scripting language of Tipsy Turtle.

Tipsy Turtle

Download

As of 27 April 2021, you can take Ripen for a spin right on this web page (via Javascript) or else via one of these:

32-bit Linux edition (85K)

64-bit Linux edition (80K)

Implementations in Python, Nim and D are also available:

source code archive (25K)

All archives include the available documentation.

LICENSE.txt

Ripen is free and open source software under the Artistic License 2.0.

News

As of 4 May 2021, Ripen "May the Fourth" edition (I couldn't resist) brings several small improvements:

Breaking change: the sigil for assignment is now = instead of the > sign.

(These apply to the Nim implementation.)

Overview

At a basic level, Ripen works like most similar languages:

	? 3 2 + . cr
	5	 
	ok
	? :squared dup * ;
	ok
	? 3 2 + squared . cr
	25
	ok

Note the lack of a space after the colon: Ripen doesn't use parsing words, instead relying on sigils to achieve similar functionality. E.g. variables work like this:

	? 3 2 - >a
	ok
	? $a . cr
	1
	ok

On the minus side, there are no proper quoted strings; words in parentheses are simply joined by a space. Note that the closing paren is a word too, so it *must* be space-separated itself, on both sides:

	? (  Hello,  world!  ) .
	Hello, world!
	ok

Speaking of which, comments are C-style instead. They're also executable, so you'll want to leave them on the outside of word definitions:

	? /* s -- */ :say . cr ;
	ok
	? ( Hello, world! ) say
	Hello, world!
	ok

Last but not least, control structures are inspired by Logo, to make them a lot more readable than in other stack-based languages:

	? 3 2 + 3 2 * > [ ( Yes! ) . ] iftrue
	Yes!
	ok
	? [ $i . cr ] 3 times
	0
	1
	2
	ok

In the above, square brackets delimit lists of words, that control structures treat as blocks of code. Curly braces are synonymous:

	? { dup * } /squared
	ok
	? 5 squared . cr
	25
	ok

The reason both are provided is that lists of the same kind can't nest. And yes, that's another way to define words; beware that an older definition by the same name will be overwritten, and the entire script will see the new one right away.

Otherwise, Ripen only provides a minimum of vocabulary:

and a few more conveniences. Enter `words` for a complete list. See also:

gcd.rpn

for a small example.

More small things