Best search algorithm to find condition within a range

Steven D'Aprano steve+comp.lang.python at pearwood.info
Mon Apr 20 04:53:50 CEST 2015


On Mon, 20 Apr 2015 12:56 am, Marko Rauhamaa wrote:

> Steven D'Aprano <steve+comp.lang.python at pearwood.info>:
> 
>> Yay! I'm not the only one who uses or likes Forth!
> 
> Out of interest, is Forth different from PostScript? I have done some
> small-time programming in PostScript but nothing in Forth.


Both Forth and PostScript are concatenative stack-based languages with a
reverse Polish notation syntax. Other than that, I imagine that they are
very different. I have zero experience with Postscript and only a little
with Forth (enough to know that I like it more in principle than practice),
so the following is mostly inferred rather than from experience.

Postscript is interpreted, with strong dynamic typing, Lisp-like data
structures, and garbage collection. It is designed for generating vector
images. It can be used for general purpose programming, but that's not its
strong suit.

Technically, Forth is also interpreted, but that may be misleading if you
think of it in traditional terms. The runtime interpreter (virtual machine)
may be as simple as a handful of commands to follow a linked list of
subroutines calling each one in turn.

One of the design principles of Forth is that compiled code is extremely
compact and fast, which makes it ideal for running at a very low level on
constrained hardware.

Older Forths are untyped. All data is a machine word on a stack. Arrays and
equivalent are implemented by dropping the address of the array on the
stack and then using redirection to access the array, which makes it rather
like C.

Unlike C, Forth puts the book-keeping related to function calls on a
separate stack, which simplifies the runtime significantly.

Newer Forths added a third stack for floating point values.


The two classic Forth books back in the 80s were Starting Forth and Thinking
Forth, by Leo Brodie:

http://www.forth.com/starting-forth/

http://thinking-forth.sourceforge.net/


They're a bit old, and the Starting Forth book in particular has a level of
whimsy which feels a bit odd to many people, but you can browse them to get
a feel for the language.



-- 
Steven




More information about the Python-list mailing list