Forth

Drop in for a chat and a cup of tea

22 posts
by jmr » Sat Feb 11, 2012 12:34 pm
Hi,

When I begin to ply/use computers ( 40 years ago ! ), my first engine was an Sinclair Zx81, after a short time I swap to Oric withFORTH  and that was a pleasant experience.

Now I remember that, I have a look on the web for a Forth running on ARM, I found this link "http://pygmy.utoh.org/riscy/" .

I am not a guru, so I would have opinions of the community : this Forth would run on the Rasberry-Pi B ?

Sorry for my fuzzy english [ a froggie ;-) ]  and thank you for read this one !
Posts: 3
Joined: Wed Jan 25, 2012 11:55 am
by Gert van Loo » Sat Feb 11, 2012 1:43 pm
I had Forth running on my 6809 8-bit computer. That had a 1MHz processor and 32K of RAM so I think the Raspberry-Pi should be able to run Forth seeing that it is ~1400 times more power full and has ~7000 times more memory.
User avatar
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2112
Joined: Tue Aug 02, 2011 7:27 am
by Lynbarn » Sat Feb 11, 2012 3:20 pm
I thought the Oric was only available with BASIC, but I do remember the Jupiter Ace, which looked a bit like a Sinclair Spectrum, but in white, and ran FORTH. Maybe things were different in France. Actually, FORTH would be a good language to have available on the 'Pi - I'd certainly want a copy for mine :)

Don't worry about your English - it is a lot better than my Francais!
Posts: 464
Joined: Wed Jan 04, 2012 11:03 pm
by ukscone » Sat Feb 11, 2012 3:30 pm
jmr said:


Hi,

When I begin to ply/use computers ( 40 years ago ! ), my first engine was an Sinclair Zx81, after a short time I swap to Oric withFORTH  and that was a pleasant experience.

Now I remember that, I have a look on the web for a Forth running on ARM, I found this link "http://pygmy.utoh.org/riscy/" .

I am not a guru, so I would have opinions of the community : this Forth would run on the Rasberry-Pi B ?

Sorry for my fuzzy english [ a froggie ;-) ]  and thank you for read this one !


Not sure if that one will actually work out of the box on the raspberry pi as it seems to designed to run on baremetal (embedded devices with no OS support) but even if it won't there are several linux forths that will and do run very nicely on ARM and thus the raspberry pi.

4tH http://thebeez.home.xs4all.nl/4tH/ runs really well on ARM and almost all of the ones listed on freecode as well
User avatar
Forum Moderator
Forum Moderator
Posts: 2893
Joined: Fri Jul 29, 2011 2:51 pm
by drgeoff » Sun Feb 12, 2012 10:54 pm
jmr said:


Hi,

When I begin to ply/use computers ( 40 years ago ! ), my first engine was an Sinclair Zx81, ...


2012 1980 - .

Not as long ago as you think :-)

My early history:

Sinclair Scientific calculator kit

Science of Cambridge MK14 kit (512 byte ROM, 256 byte RAM)

ZX80 kit (4K ROM, 1K RAM).  (That 1K RAM included the display memory!)

8K ROM and 16K RAM upgrade for ZX80

48K Spectrum

Microdrives for Spectrum

QL

Qcom modules (1200/75 baud modem) and Prestel subscription

Gold card (2Mbyte RAM +FDC) and twin floppy drives for QL

Minerva ROMs and mouse interface for QL.  Later versions of those ROMs included a Forth.

A Spectrum 128 and 2 more QLs.  (Fun with Sinclair's networking :-) . )

Cambridge Computer Z88.  (That Z88 travelled to many parts of the world and a CCITT Recommendation was drafted on it.)

Replaced Z88's internal 32K RAM chip with 128K

.....

I was quite into the cassette based Spectrum Forth and I understood it enough to take it completely apart and rebuild it to work with microdrives - all the addresses needed to change as the microdrive stuff moved everything up a few hundred bytes in RAM compared to a non-microdrive machine. I offered it to the Spectrum Forth publishers but they declined :-(
Posts: 3150
Joined: Wed Jan 25, 2012 6:39 pm
by JonB » Mon Feb 13, 2012 12:38 pm
Google Fignition.

This is a cheap (about £18 IIRC) SBC based on an Atmel 168 that implements an '80s style home computer that runs Forth (basically, just like a Jupiter Ace, only much, much faster). All you need to use it is a monitor / TV that accepts composite in. And, you build it yourself, which is educational.

I think Forth is great, but not if it implements program saving in "blocks" as Fignition and the Jupiter Ace do. Blocks suck immensely because they impose page limitations on your code. I'd like to write Forth in a text editior, then compile. That'd be nice!
Posts: 218
Joined: Tue Nov 29, 2011 9:26 pm
by rurwin » Mon Feb 13, 2012 1:42 pm
As someone who has programmed in Forth in a commercial environment for ten years, just let me say this:

NO! LET IT DIE!

Pardon me. Please carry on.

*twitch* ;-)
User avatar
Forum Moderator
Forum Moderator
Posts: 2949
Joined: Mon Jan 09, 2012 3:16 pm
by drgeoff » Mon Feb 13, 2012 1:53 pm
There are reasons it has been termed a "write-only language". :-)
Posts: 3150
Joined: Wed Jan 25, 2012 6:39 pm
by andyl » Mon Feb 13, 2012 6:32 pm
drgeoff said:


There are reasons it has been termed a "write-only language". :-)


Nah, that is APL.  Forth (or FORTH) is easy to read in comparison - and you don't need a special keyboard.
Posts: 265
Joined: Tue Jan 10, 2012 11:05 am
by JonB » Tue Feb 14, 2012 1:01 pm
No, FORTH is NOT easy to read:

: STAR ( -- )

42 EMIT ;

: STARS ( n -- )

0 DO STAR LOOP ;

: SQUARE ( n -- )

DUP 0 DO

DUP STARS CR

LOOP DROP ;

: TRIANGLE

1 + 1 DO

I STARS CR

LOOP ;

: TOWER ( n -- )

DUP

1 - TRIANGLE

SQUARE ;

See what I mean? Gibberish... :D
Posts: 218
Joined: Tue Nov 29, 2011 9:26 pm
by Lynbarn » Tue Feb 14, 2012 1:38 pm
JonB said:


No, FORTH is NOT easy to read:

...

See what I mean? Gibberish... :D



All languages (natural OR machine-based) are gibberish if you don't know them. Look at Greek, Russian or Chinese (or even French) to an English-only speaker. Hey! we have enough trouble translating between British and American English!

All have strengths and weaknesses, and it often very much depends on what you started with. For that reason I still quite like COBOL, 'cos that's what I learned first.
Posts: 464
Joined: Wed Jan 04, 2012 11:03 pm
by rurwin » Tue Feb 14, 2012 2:16 pm
Here's just one reason, and it's enough to have any seasoned programmer whimpering in a corner:

My application was an industrial controller. It had 76 source files comprising 3.5MB of Forth code and around 4,400 FORTH words (and that's just the colon definitions.)

It had one, global, name-space.

No separate name-spaces for structure members, no local variables in files, never mind functions. One name-space. Every word had to be globally unique. Every word was globally available.

(Yes, I know about VOCABULARY; we had a few, but it does not solve the problem. We also had a solution for local variables in functions, variables with such obvious names as L0, L1, L2,...)
User avatar
Forum Moderator
Forum Moderator
Posts: 2949
Joined: Mon Jan 09, 2012 3:16 pm
by andyl » Tue Feb 14, 2012 3:00 pm
rurwin said:


Here's just one reason, and it's enough to have any seasoned programmer whimpering in a corner:

My application was an industrial controller. It had 76 source files comprising 3.5MB of Forth code and around 4,400 FORTH words (and that's just the colon definitions.)

It had one, global, name-space.

No separate name-spaces for structure members, no local variables in files, never mind functions. One name-space. Every word had to be globally unique. Every word was globally available.


Wow - that is the largest Forth program I've ever heard of.

Also it sounds like a rather conservative implementation.  I've definitely seen a number of approaches to make larger programs easier to handle - even OO extension words.

As people have posted some Forth I will retaliate with some APL (the worst real language for readability IMO)



See http://catpad.net/michael/apl/ - the above code is Conway's Game Of Life.
Posts: 265
Joined: Tue Jan 10, 2012 11:05 am
by roelfrenkema » Tue Feb 14, 2012 3:08 pm
andyl said:

 Wow - that is the largest Forth program I've ever heard of.
Also it sounds like a rather conservative implementation.  I've definitely seen a number of approaches to make larger programs easier to handle - even OO extension words.

As people have posted some Forth I will retaliate with some APL (the worst real language for readability IMO)



See http://catpad.net/michael/apl/ - the above code is Conway's Game Of Life.



Well nothing that grep can't beat really :-P And lets face it they, all do grep or else it's a worthless piece of tool :-D
Posts: 105
Joined: Sat Jan 07, 2012 5:17 pm
by rurwin » Tue Feb 14, 2012 3:38 pm
andyl said:

I've definitely seen a number of approaches to make larger programs easier to handle - even OO extension words.

We had that sort of stuff, we wrote it ourselves, but it did not help with the name-space problem.

The APL is bad. Very bad. :-D
User avatar
Forum Moderator
Forum Moderator
Posts: 2949
Joined: Mon Jan 09, 2012 3:16 pm
by Bakul Shah » Tue Feb 14, 2012 5:06 pm
andyl said:


Wow – that is the largest Forth program I"ve ever heard of.
Also it sounds like a rather conservative implementation.  I"ve definitely seen a number of approaches to make larger programs easier to handle – even OO extension words.

As people have posted some Forth I will retaliate with some APL (the worst real language for readability IMO)



See http://catpad.net/michael/apl/ – the above code is Conway"s Game Of Life.


This YouTube video shows how this was developed. The thing is, even if APL is harder to read, a solution in it is likely to be hundreds of times shorter so you save time in the end! As someone once quipped, if you need more than one line of APL to solve a problem, you do not understand the problem well — and I am not sure if he was joking:-)
At any rate, Ken Iverson's "Notation as a Tool of Thought" Turing Award paper is a must read if you want to understand APL and the thought process that went into designing it.
Posts: 293
Joined: Sun Sep 25, 2011 1:25 am
by bzimmerly » Sun Sep 30, 2012 5:42 am
Ah the pathetic language wars continue. As a seasoned programmer myself, having built my career on programming in FORTH for over 30 years, I say that FORTH is not dead, and if a "programmer" has trouble with using this incredibly powerful tool, perhaps he should leave the comments to those who DO have the skill to use it.

"…FORTH is an amplifier. A good programmer can do a fantastic job with FORTH; a bad programmer can do a disastrous one."
- Charles Moore, the inventor of FORTH

That saying is as true today as it was when he said it in 1979.

The power of FORTH is found in understanding that with FORTH --> NOTHING is sacred! Everything is under the control of the programmer. (The behavior of the compiler, the interpreter, etc.) This means that if you have trouble with issues like, say, "name space," -YOU- do something about it like properly using the VOCABULARY word or creating your own scheme that makes it easy to do what you seek to accomplish.

I know that such a thing requires obtaining a certain level of skill, much like -ANY- programming language does, but if you LACK that skill, then you certainly can't blame it *on the language*, sheesh. :roll:
Posts: 1
Joined: Sun Sep 30, 2012 5:27 am
by rurwin » Sun Sep 30, 2012 11:29 am
Nice thread-necromancy.

No language is sacred, witness the thousands of Domain Specific Languages that are implemented by translating them to C.

But in creating such wholesale changes to a language environment, one creates an individual language and an individual environment. It increases the learning curve when one comes back to a project months or years later, or when a new programmer comes on the team. A higher level language has standardised features that in Forth have to be programmed. That programming takes time and to do the job well and re-usably takes even longer. The Forth version may or may not be more efficient, but a more efficient version will generally be less re-usable, resulting in several versions of the same feature with subtle variations.

I was on a Senior Programmers course many years ago, and we were asked to estimate the time required to implement a simple application. My estimate was an order of magnitude larger than the others, because they were intending to implement it in PL/1 on a mainframe with all the database stuff built-in, whereas I was intending to implement it in C with text files. It was so simple that using a full database was unnecessary, and my implementation would have been orders of magnitude more efficient, but writing that code would have taken time.

As Python is to C, so Forth is to Assembler. The same arguments and justifications apply; each language has its place and its adherents, and each has its faults and its detractors. I would rather use Forth over Assembler, and I would rather use Python over C. But I would never use Forth where I would otherwise use C or Python.
User avatar
Forum Moderator
Forum Moderator
Posts: 2949
Joined: Mon Jan 09, 2012 3:16 pm
by jackokring » Sun Sep 30, 2012 3:17 pm
Code: Select all
sudo apt-get install gforth


I made a jconsole file in some other thread. It prints an error due to no profile.ijs I think. J is the modern keyboard using version and a derivative work of APL. It's all ASCII. :D
Pi=B256R0USB CL4SD8GB Raspbian Stock. https://sites.google.com/site/rubikcompression/strictly-long https://dl.dropboxusercontent.com/u/1615413/Own%20Work/Leptronics.pdf https://groups.google.com/forum/#!topic/comp.compression/t22ct_BKi9w
User avatar
Posts: 784
Joined: Tue Jul 31, 2012 8:27 am
Location: London, UK
by antiloquax » Sat Nov 03, 2012 11:33 am
You could try compiling GNU Forth. It doesn't seem to be in the Arch Arm repository.
gforth
Posts: 406
Joined: Sun Nov 20, 2011 11:37 am
by malcolmf » Tue Nov 20, 2012 7:45 pm
You could try compiling GNU Forth. It doesn't seem to be in the Arch Arm repository.
gforth


I've been intrigued by Forth, and occasionally look at it: there're quite extensive tutorials online, but I've never been clear what it's used for (I'm sure I saw a mention of radio telescopes some years back..),

Anyway, if you're running Wheezy, gforth is in the debian repository, and the usual
Code: Select all
sudo apt-get install gforth

works fine.
Posts: 11
Joined: Tue Jun 19, 2012 2:20 pm
by rurwin » Wed Nov 21, 2012 9:04 am
malcolmf wrote:I've never been clear what it's used for (I'm sure I saw a mention of radio telescopes some years back..).


Forth is a very light-weight OS and language environment that can be implemented quickly and efficiently even on the smallest of 8-bit microprocessors, while still offering high-level language features.

Because it is efficient and allows assembler programming mixed with Forth language programming, and because it's timing is determinate, it is a good solution to control hardware. The first project, in fact the reason the language was developed, was to control a telescope.

Because it is so simple to implement, it is also a good solution for providing a development environment on new hardware.
User avatar
Forum Moderator
Forum Moderator
Posts: 2949
Joined: Mon Jan 09, 2012 3:16 pm