Jump to content
IGNORED

Why no standard Forth library?


Gemintronic

Recommended Posts

I kinda posted off-topic in the Forth Tutorial section. Figured it might be better as a seperate topic.

 

I know nothing of Forth. But, what I've been hearing is that it's much more fragmented than C or BASIC. What little I do know of Forth is that it seems like to have to define many things from the ground up. Why hasn't anyone taken the common features in various Forth compilers and create a standardized library? Wouldn't that make Forth easier to teach?

 

Again, I know nothing of Forth so I hardly understand even the question I posit.

Link to comment
Share on other sites

Do you mean there should be one standard flavour of Forth ? Forth for some reason or another never had to comply to any form of ANSI or anything (ANSI is some American standardisation for such as BASIC, the TI has ANSI basic)

 

There are many version of Forth, perhaps quite a few for the TI alone .... I'm certainly not a Forth guy (it took long enough for me to learn BASIC, I was like a chimpanzee with a rubiks cube) .... Also, different flavours of any language can more often be tailored to suit the particular hardware of a certain machine. Such as, the Commodore 64 would have a different library set to the Commodore PET for example, since one has bitmapped graphics and the other one is only just higher up the ranks than a shopping till.

 

I hope this answers your question, but if it doesn't, I'm pretty sure one of our Forth guys could help you a lot more than me :)

Edited by Retrospect
Link to comment
Share on other sites

Hi guys.

 

Forth has been standardised over the years. A number of the standards were informal (FIG, Forth 79, Forth 83). In 1994 Forth was officially standardised by the American National Standards Institute. It's woth spending 10 minutes reading the Wikipedia entry on Forth. It's actually really interesting seeing how Forth has evolved over the years.

 

Now, on the subject of standard libraries; it's a rather emotive issue in the Forth world, I'm afraid. Forth itself is a language that seems to appeal to mavericks! Perhaps this isn't surprising, as Chuck Moore (the inventor of Forth) is definitely a maverick, turning his back on the 'perceived wisdom' of how computing was done in the 1960's and 70's and coming up with his own (and completely different) way: Forth.

 

Anyway, since Forth is such a low-level language, and is so malleable, programmers often tend to simply implement *only* what they need for the particular project at hand, and implement it exactly how they *want* it to be done, to suit the exact requirements of the project they are working on.

 

Here's an example: Forth does not have arrays. This often comes as a shock to people when they are learning Forth (it did to me!); "What? How can you not have arrays???" etc. Well, the answer is, Forth doesn't have arrays because it's falling-off-a-log simple to implement them yourself, in actual Forth (try doing that in Basic, or Pascal, or C - actually extending the language itself. It's trivial in Forth). So, rather than accepting and using a shrink-wrapped (i.e. fixed) way of working with arrays, like we have in C or BASIC etc, in Forth, the philosophy is to implement them yourself, however you want, to suit the application that you are working on.

 

Having said all of that, over the years, and since the official ANS94 Forth standard, standard libraries have emerged. The words (i.e. commands) that make up the library are captured in the ANS94 standards document, and are optional (i.e. to be ANS compliant, the Forth system must obey the ANS core specification, and the other libraries (e.g. string handling) are optional.

 

So, there are some libraries. For example, if you want to do object oriented programming, there are a raft of libraries available (all written in Forth - yay! OOP in Forth, with full inheritance, polymorphism, interface abstraction etc, all written in Forth!).

 

You gotta love it!

 

Forth is a simply fascinating language. I am totally hooked on it. It's like a black hole - get too close to it, and it will pull you in - and once it has you in its gravity field, there's no escape - you'll never go back!

 

It's an astonishingly simple language to learn if you have never used any other programming language! Unfortunately, if you have used other, more traditional (i.e infix) languages, then it's a total mind-f**k for a while. But, just like learning to walk, or talk, or ride a bike, or drive a car, once you have got it, you wonder what all the fuss was about!

 

Here's some interesting links if you fancy reading more:

 

The Journal of Forth Application and Research

Forth Foundation Library

Forth Library Action Group

Forth Interest Group

Forth Dimensions Magazine (20 volumes of Forth magazines in PDF format)

 

:-D

  • Like 1
Link to comment
Share on other sites

As a good example of my earlier point (just rolling your own code when you need a particular bit of functionality) have a look at the attached PDF where the author submits code for easily handling multi-dimensional arrays. He actually introduces the word DIM which he obviously borowed from BASIC.

 

It's only a short PDF - 4 pages I think. It looks like it's 16-bit Forth 83 standard code. Having quickly run my eye over it, it looks like it will run in TurboForth with no changes at all. Where's the "smug grin" icon when you need it? :grin:

 

ForthArrays.pdf

Link to comment
Share on other sites

I completely concur with @Willsy! There is a very good book available online about Forth, its philosophy, program design and much more: Thinking Forth: A Language and Philosophy for Solving Problems by Leo Brodie available free on SourceForge.

 

One very nice thing about Forth is that words (Forth's name for any executable, be it function, subroutine, constant or variable) can be executed as soon as you write them. You do not need to set up a program framework every time you need to test a new word. I'm hooked and pretty much have been since 1983 or 1984 when TI released TI Forth into the public domain.

 

...lee

Edited by Lee Stewart
  • Like 1
Link to comment
Share on other sites

There is only one problem here: Once you start digging Forth (I'm starting to), going back to a standard language will seem very restrictive. As a beginner to Forth, it still takes me 3-4 times as much effort and time to come up with the same code that would have been a breeze to code in say XB or Pascal. It's actually more at the same level as assembly because it is so low-level.

Learning Forth at the ripe age of 47 is not a walk in the park let me assure you, but it's looking to be well worth the effort.

Link to comment
Share on other sites

Something else in the study pointed to that though they were better at driving cabs on other data they seemed to get worse.

Obviously the problem is you give up other things to specialize in something else.

Previous associations were modified or changed to add in new ones so old connections of memory were abandoned or modified for new data.

Humans have a finite amount of data we can retain at one time.

 

Fill a glass with to much and it overflows, same with the human brain.

Link to comment
Share on other sites

Something else in the study pointed to that though they were better at driving cabs on other data they seemed to get worse.

Obviously the problem is you give up other things to specialize in something else.

Previous associations were modified or changed to add in new ones so old connections of memory were abandoned or modified for new data.

Humans have a finite amount of data we can retain at one time.

 

Fill a glass with to much and it overflows, same with the human brain.

 

In other words, idiot savant :)

Link to comment
Share on other sites

My transition to Forth programming has been a little easier because I began using an HP-35 calculator back in the late

1960's, early 1970's. Just knowing Reverse Polish Notation (RPN) and thinking in it automatically helped to make Forth

a lot easier. Forth is EXTENSIBLE ------ And it (in my opinion) is more powerful than any of the C language variations, and

is a lot more easier to handle than trying to do everything in assembler. Knowing RPN and assembly languages will help

your efforts as Forth grows on you (and it will).........

 

Rod Van Orden

San Diego, CA

Link to comment
Share on other sites

Good evening Rod

 

My first job had me working in the oil industry with surveying teams who used HP Calculators such as the HP48. I converted a program from their old calculator to the HP48 and programmed in RPL - I did not realise then that it is actually a forth variant - http://en.wikipedia.org/wiki/RPL_(programming_language)

 

Even earlier was when I was in high school and a friend bought a copy of a product called White Lightning for the Sinclair Spectrum. This was hailed as a game designer tool and used Forth for part of its system.

 

In my time in computers Forth has kind of kept reaching out and saying learn me learn me but i never jumped on the hook - until now :-)

 

lastly did you know the wikireader device that you can now get at amazon.com for 15 dollars actually has a forth interpreter onboard and you can create and load forth apps just by dropping them in text form onto the MicroSD. The card also has many sample apps so writing apps / games and more can be achieved. The device also has a hackable serial port that will respond to a terminal program and let you code in forth directly.

 

Most recently, i discovered a product called MacForth from CSI. This is a very rich forth for the Mac. I actually managed to find a new sealed copy of it which still had a price of 695 dollars on it.

 

Little did i know when I found out about a new product called TurboForth what an adventure it would launch ;-)

Edited by JonnyBritish
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...