Friday, February 24, 2006

Y is for ...

Y
Y is a stack-oriented FORTH-type programming language derived from Wouter van Oortmerssen's "FALSE".

Like FALSE, Y is cryptic to the extreme. (But it is much more powerful. Virtually all of the example programs in "Kernighan & Ritchie - Programming in C" can be done in Y in a fraction of time and code. :-) )

This stuff is provided as-is, I won't take any responsibility for damaged software, hardware, or brains. Since I'm still developing (well, something like that...), this is a very early beta version. Y looks stable and the small Y programs I tested worked fine, but this doesn't have to mean anything.

Y is what you get when you cross a programmable pocket calculator with a programming language like C. For some, Y is merely a toy. (But a very powerful one.) For others, it's just another cryptic unixlike command which probably can save you much time in special situations.

There are many good programming languages for doing large projects, but what do you use if you want a quick solution for those small but nasty everyday's problems which can't be managed with common commands? One day, I had recieved an ascii data file which must have gone through some noise-producing 7/8-Bit-gate. About twenty per cent of the characters had their highest bit set, so the text was totally corrupted. With Y, it took me less than twenty keystrokes to solve the problem by writing a binary filter. Here it is:
(^$1_=~#127&,)%


Yabasic
implements the most common and simple elements of the basic language It comes with goto/gosub, with various loops, with user defined subroutines and Libraries. Yabasic does monochrome line graphics and printing. Yabasic runs under Unix and Windows it is small (around 200KB) and free.

Yeti
does the same job for Tcl that yacc or bison do for C. You can specify a grammar in a form similar to the Backus-Naur Form (BNF), and define scripts that are executed whenever a rule is matched.

After all rules have been added, Yeti dumps code for a [incr Tcl] class that implements the parser. This parser uses a deterministic state machine computed from the rules. This has the advantage of using only linear runtime and memory for parsing, but the disadvantage that it is not possible to update the parser after parsing has started. It is common usage to generate a parser once at package installation time, and to store the parser in a file, from where it is then sourced.

Parsers need a scanner to their job. The purpose of a scanner is to read tokens (terminals) from an input source. A scanner generator called Ylex is included in the Yeti package; after adding rules, it also dumps code for a scanner class.

Yeti is written in Tcl. It requires Tcl 8.x, [incr Tcl] 3.x. The parser generator also requires the struct module from tcllib; this module is not needed to run generated scanners and parsers.

Yorick
is an interpreted programming language, designed for postprocessing or steering large scientific simulation codes. Smaller scientific simulations or calculations, such as the flow past an airfoil or the motion of a drumhead, can be written as standalone yorick programs. The language features a compact syntax for many common array operations, so it processes large arrays of numbers very efficiently. Unlike most interpreters, which are several hundred times slower than compiled code for number crunching, yorick can approach to within a factor of four or five of compiled speed for many common tasks. Superficially, yorick code resembles C code, but yorick variables are never explicitly declared and have a dynamic scoping similar to many Lisp dialects. The yorick language is designed to be typed interactively at a keyboard, as well as stored in files for later use. Yorick includes an interactive graphics package, and a binary file package capable of translating to and from the raw numeric formats of all modern computers.

No comments: