Author Topic: is it Forth to discuss?  (Read 12036 times)

0 Members and 1 Guest are viewing this topic.

Offline VtileTopic starter

  • Super Contributor
  • ***
  • Posts: 1144
  • Country: fi
  • Ingineer
is it Forth to discuss?
« on: March 28, 2017, 01:22:49 pm »
With quick searh I couldn't find anything forthwhile on this topic. Do someone still use Forth to program things. I wonder, the underlying concept and structure of forth is really tempting. It seems to be like gods gift to empedded programming (where it kind of did born).

There seems to be a few compilers (for us who aren't cooking own) for ie. arduino.

« Last Edit: March 28, 2017, 02:25:32 pm by Vtile »
 

Offline borjam

  • Supporter
  • ****
  • Posts: 908
  • Country: es
  • EA2EKH
Re: is it Forth to discuss?
« Reply #1 on: March 28, 2017, 01:51:16 pm »
I used it many years ago, an awesome language :)

The main reference you can find is the webpage of the now defunct Forth Interest Group (www.forth.org).

 
The following users thanked this post: Vtile

Offline VtileTopic starter

  • Super Contributor
  • ***
  • Posts: 1144
  • Country: fi
  • Ingineer
Re: is it Forth to discuss?
« Reply #2 on: March 28, 2017, 02:30:49 pm »
Yep, the 100% modularity of it is really tempting. I need to cut my teeth on it, I just need to find a programming cable for the arduino nano.  ;D 

Code: [Select]
1
1
= +
2
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9890
  • Country: us
Re: is it Forth to discuss?
« Reply #3 on: March 28, 2017, 02:33:03 pm »
I wouldn't consider Forth a blessing for embedded programming but, then, opinions vary.  I'm not sure how to write an RTOS is Forth.  Heck, I'm not even sure how to write an interrupt handler.

What I do like about it is the ability to build programs from the bottom up.  I think that's about the only way they can be built.

MANY years ago ('80), I was visiting a disk drive manufacturer.  They did all their testing in Forth because they could simply add a new test to lower level code already known to work.  Literally, it was as simple as typing a single command string to create an entirely new test pattern.

I'm pretty sure Forth is a dead issue.  There are still pockets of folks using it, the same as there is with BASIC.
 
The following users thanked this post: Vtile

Offline VtileTopic starter

  • Super Contributor
  • ***
  • Posts: 1144
  • Country: fi
  • Ingineer
Re: is it Forth to discuss?
« Reply #4 on: March 28, 2017, 02:39:36 pm »
I wouldn't consider Forth a blessing for embedded programming but, then, opinions vary.  I'm not sure how to write an RTOS is Forth.  Heck, I'm not even sure how to write an interrupt handler.

What I do like about it is the ability to build programs from the bottom up.  I think that's about the only way they can be built.

MANY years ago ('80), I was visiting a disk drive manufacturer.  They did all their testing in Forth because they could simply add a new test to lower level code already known to work.  Literally, it was as simple as typing a single command string to create an entirely new test pattern.

I'm pretty sure Forth is a dead issue.  There are still pockets of folks using it, the same as there is with BASIC.
Well as far as I understand it you do not need to write RTOS on Forth as it is already RTOS by nature. The interrupt handler might be interesting, but if it can be written on ASM it should be possible on Forth. Yes, I'm rookie what comes to "baremetal" programming (or any non-niche programming in general).
 

Offline borjam

  • Supporter
  • ****
  • Posts: 908
  • Country: es
  • EA2EKH
Re: is it Forth to discuss?
« Reply #5 on: March 28, 2017, 02:52:15 pm »
I wouldn't consider Forth a blessing for embedded programming but, then, opinions vary.  I'm not sure how to write an RTOS is Forth.  Heck, I'm not even sure how to write an interrupt handler.
Times have changed. Forth offered the possibility of running the whole development system in an 8 bit processor with some KB of RAM. Other approaches demanded a separate compiler and debugger, an ICE, etc.

But still Forth has some advantages of its own depending on what you want to do. You program by extending the language instead of just writing functions. Many years ago I saw an awesome example on an issue of Dr Dobbs Journal. By extending the language it was possible for a non-programming engineer to write a program to operate some machinery.

http://collaboration.cmc.ec.gc.ca/science/rpn/biblio/ddj/Website/articles/DDJ/1989/8902/8902e/8902e.htm

Regarding the RTOS, it was quite easy to write a multitasking kernel in Forth. I wrote one for the HD6303 back in 1991. Again, it worked by extending the language, and I added a new type of function definition: a task.

A task had an "initialization section" and a "task body". When the whole thing was compiled, everything was stored in memory so that it would be copied to an EPROM.

During the boot process, the kernel created the process control blocks in RAM, and executed the "initialization section" of each of the processes, giving control to the "task body" which would be the main program for each task. It was a simple round robin approach, but I could have added priorities and real time constraints.

The Forth system I used, which was a version of fig-Forth running on a TDS9092 board, included support to write interrupt routines in Forth. But of course in a 8 bit processor at 1 MHz it was better to write the interrupt handlers in assembly. I actually wrote small assembly language routines to catch interrupts that needed a timely service, and those handlers registered the event description together with a timestamp in an event queue, to be serviced by the higher level code with lesser time constraints.

Nowadays you could do some of that work in Python running on a Raspberry Pi, with the same advantage of interactive debugging and testing, but back in 1990 that was unthinkable!

And, unlike my friends at the university writing a multitasking kernel for an Intel 8031 in the classical way (assembly), I did not use an in circuit emulator. Just a serial terminal and a bunch of hex dumps after executing code blocks from the command line.

Quote
do like about it is the ability to build programs from the bottom up.  I think that's about the only way they can be built.

MANY years ago ('80), I was visiting a disk drive manufacturer.  They did all their testing in Forth because they could simply add a new test to lower level code already known to work.  Literally, it was as simple as typing a single command string to create an entirely new test pattern.

Was it Maxtor? I think I saw them mentioned in a magazine.
« Last Edit: March 28, 2017, 02:59:51 pm by borjam »
 

Offline borjam

  • Supporter
  • ****
  • Posts: 908
  • Country: es
  • EA2EKH
Re: is it Forth to discuss?
« Reply #6 on: March 28, 2017, 02:54:02 pm »
Well as far as I understand it you do not need to write RTOS on Forth as it is already RTOS by nature. The interrupt handler might be interesting, but if it can be written on ASM it should be possible on Forth. Yes, I'm rookie what comes to "baremetal" programming (or any non-niche programming in general).

No, Forth was not a RTOS, although some Forth implementations included some kind of RTOS built in. But as I said the language gave you some nice facilities if you wished to implement your own multitasking or even RTOS on top of it.
 
The following users thanked this post: Vtile

Offline eugenenine

  • Frequent Contributor
  • **
  • Posts: 865
  • Country: us
Re: is it Forth to discuss?
« Reply #7 on: March 28, 2017, 03:01:21 pm »
Been playing with flashforth a little myself, on the PIC.
 
The following users thanked this post: Vtile

Offline Howardlong

  • Super Contributor
  • ***
  • Posts: 5319
  • Country: gb
Re: is it Forth to discuss?
« Reply #8 on: March 28, 2017, 03:02:41 pm »
I got quite into Forth in the early 80s. I already had a fairly reasonable background in assembly language so it was an obvious way to go. The various BASIC based machines of the time were pretty slow, and in comparison Forth by its very nature encourages you to write your code in an efficient manner that can be easily and quickly be compiled or interpreted.

When you first encounter it, it looks daunting, but it's really quick to get over the initial learning curve and become quite proficient. I did however find it incredibly difficult to teach to people without machine/assembly language experience.

I remember writing a Breakout in an afternoon on a Jupiter Ace once as a demonstration as to what could be achieved in a short time frame. Some acquaintances of mine took Forth and altered it for use as a real time spacecraft OS which was still in use in the last decade. It ticks a lot of boxes for resource-constrained systems.
 
The following users thanked this post: Vtile

Offline VtileTopic starter

  • Super Contributor
  • ***
  • Posts: 1144
  • Country: fi
  • Ingineer
Re: is it Forth to discuss?
« Reply #9 on: March 28, 2017, 03:08:01 pm »
Interesting, really interesting.
Nowadays you could do some of that work in Python running on a Raspberry Pi, with the same advantage of interactive debugging and testing, but back in 1990 that was unthinkable!
. ..But Raspberry Pi isn't embedded, but a PC with ARM processor!!  >:D
 

Offline borjam

  • Supporter
  • ****
  • Posts: 908
  • Country: es
  • EA2EKH
Re: is it Forth to discuss?
« Reply #10 on: March 28, 2017, 03:17:25 pm »
Interesting, really interesting.
Nowadays you could do some of that work in Python running on a Raspberry Pi, with the same advantage of interactive debugging and testing, but back in 1990 that was unthinkable!
. ..But Raspberry Pi isn't embedded, but a PC with ARM processor!!  >:D
It depends on how you use it! ;)

 
The following users thanked this post: Vtile

Offline VtileTopic starter

  • Super Contributor
  • ***
  • Posts: 1144
  • Country: fi
  • Ingineer
Re: is it Forth to discuss?
« Reply #11 on: March 28, 2017, 03:23:42 pm »
Interesting, really interesting.
Nowadays you could do some of that work in Python running on a Raspberry Pi, with the same advantage of interactive debugging and testing, but back in 1990 that was unthinkable!
. ..But Raspberry Pi isn't embedded, but a PC with ARM processor!!  >:D
It depends on how you use it! ;)
By running some linux derived general OS. :D  The "once clear " line (note the scientific wording) between embedded and general computers have gone.  :-[
 

Offline borjam

  • Supporter
  • ****
  • Posts: 908
  • Country: es
  • EA2EKH
Re: is it Forth to discuss?
« Reply #12 on: March 28, 2017, 03:35:15 pm »
It depends on how you use it! ;)
By running some linux derived general OS. :D  The "once clear " line (note the scientific wording) between embedded and general computers have gone.  :-[
[/quote]
Well, it's kinda blurry. Would you say that QNX qualifies as an embedded OS? VxWorks?

 
The following users thanked this post: Vtile

Offline VtileTopic starter

  • Super Contributor
  • ***
  • Posts: 1144
  • Country: fi
  • Ingineer
Re: is it Forth to discuss?
« Reply #13 on: March 28, 2017, 03:45:51 pm »
It depends on how you use it! ;)
By running some linux derived general OS. :D  The "once clear " line (note the scientific wording) between embedded and general computers have gone.  :-[
Well, it's kinda blurry. Would you say that QNX qualifies as an embedded OS? VxWorks?
[/quote]Can you retype it to your device from design papers?  :-//  :wtf:
 

Offline Gibson486

  • Frequent Contributor
  • **
  • Posts: 324
  • Country: us
Re: is it Forth to discuss?
« Reply #14 on: March 28, 2017, 04:31:37 pm »
I could see why you would like this if you coded in assembly and you only had 512 bytes of memory space....other than that, I do not see that as a gift to embedded programming. To each his own.
 
The following users thanked this post: Vtile

Offline VtileTopic starter

  • Super Contributor
  • ***
  • Posts: 1144
  • Country: fi
  • Ingineer
Re: is it Forth to discuss?
« Reply #15 on: March 28, 2017, 04:42:12 pm »
I could see why you would like this if you coded in assembly and you only had 512 bytes of memory space....other than that, I do not see that as a gift to embedded programming. To each his own.
Why only then, if your system is not fully bloated IOT mini PC. what makes the Forth something comparable as a curse?
 

Offline jnz

  • Frequent Contributor
  • **
  • Posts: 593
Re: is it Forth to discuss?
« Reply #16 on: March 28, 2017, 05:14:21 pm »
I wouldn't consider Forth a blessing for embedded programming but, then, opinions vary.  I'm not sure how to write an RTOS is Forth.  Heck, I'm not even sure how to write an interrupt handler.
I'm pretty sure Forth is a dead issue.  There are still pockets of folks using it, the same as there is with BASIC.

100% agree. Not only is forth dead, but unless you're familiar with it and the utterly stupid concept of "reverse polish notation" where 3 6 + is the command for 3+6 (small rant, WTF, you have all the right characters and demanded the wrong order? C was developed only a little after forth, one is CLEARLY superior). Basically, there are a few people using and recommending forth but no one seriously suggesting it get rolled into even low end ARM projects. IMO for embedded, the last nail in the coffin for forth was 32bit processors under $5.


but if it can be written on ASM it should be possible on Forth.

That's exactly right. Forth is platform independent assembly. That's all. It's directly dealing with the stack and managing that to get things done a single step at a time but seriously... Unless your entire program is written in ASM and you need bleeding edge speed or control over every single cycle, what is the point?

To all those ideas of people using it as an interpreter - LOL - OK, look, if you can code in Forth to run some machine - you could have EASILY learned another language. To say, I can't code, but I can write in forth is to say, "nah, I can't take you to the mall, but I drive rally cars in competition".

I could see why you would like this if you coded in assembly and you only had 512 bytes of memory space....other than that, I do not see that as a gift to embedded programming. To each his own.

Exactly.

On this forum it was suggested to me to run a forth interpreter instead of a domain specific language, but I would be the ONLY person I know in my life that could ever write those forth scripts, even the other programmers I know would stumble at that, it's just so obscure. I'm glad I found a lightweight javascript interpreter instead of spending even more than a day on forth.
 
The following users thanked this post: Vtile

Offline VtileTopic starter

  • Super Contributor
  • ***
  • Posts: 1144
  • Country: fi
  • Ingineer
Re: is it Forth to discuss?
« Reply #17 on: March 28, 2017, 05:30:19 pm »
 ;D ;D

Forth must be really good as it greates so much hatred in assumed C growd.

Makes me even more tempted to start to fiddle with forth. Besides I actually feel that HPs RPN calculators are a gods gift for a mankind. 

My brain myst be NOT Wired.
« Last Edit: March 28, 2017, 05:32:30 pm by Vtile »
 

Online joeqsmith

  • Super Contributor
  • ***
  • Posts: 11737
  • Country: us
Re: is it Forth to discuss?
« Reply #18 on: March 28, 2017, 05:32:24 pm »
I used Miller Microsystems Forth back in the early 80s with it's Turtle graphics.  Borland's Turbo Pascal would run circles around it.
 
The following users thanked this post: Vtile

Offline NivagSwerdna

  • Super Contributor
  • ***
  • Posts: 2495
  • Country: gb
Re: is it Forth to discuss?
« Reply #19 on: March 28, 2017, 05:40:05 pm »
Makes me even more tempted to start to fiddle with forth.
Definitely worth a play.  I did alot of FORTH in the 1980s and every now and again I get the urge to build a Jupiter Ace or equivalent... (maybe with a souped up display)...

... however IMHO FORTH programs become a bit of a nightmare as they scale and with the advent of more powerful computers and the possibility of testing code on a host platform, emulation etc and C compilers that produce tight code the advantages of C meant I hung up my FORTH boots a while back.

(I still have an RPN calculator to scare the kids)
 
The following users thanked this post: Vtile

Offline VtileTopic starter

  • Super Contributor
  • ***
  • Posts: 1144
  • Country: fi
  • Ingineer
Re: is it Forth to discuss?
« Reply #20 on: March 28, 2017, 05:44:01 pm »
Makes me even more tempted to start to fiddle with forth.
Definitely worth a play.  I did alot of FORTH in the 1980s and every now and again I get the urge to build a Jupiter Ace or equivalent... (maybe with a souped up display)...

... however IMHO FORTH programs become a bit of a nightmare as they scale and with the advent of more powerful computers and the possibility of testing code on a host platform, emulation etc and C compilers that produce tight code the advantages of C meant I hung up my FORTH boots a while back.

(I still have an RPN calculator to scare the kids)
Nice. The RPL is also so nice language as a bastard child of Lisp and Forth.  ;D
« Last Edit: March 28, 2017, 05:46:38 pm by Vtile »
 

Offline jnz

  • Frequent Contributor
  • **
  • Posts: 593
Re: is it Forth to discuss?
« Reply #21 on: March 28, 2017, 05:50:33 pm »
Nice. The RPL is also so nice language as a bastard child of Lisp and Forth.  ;D

Don't take any offense to this... But are you trying to solve a problem? Or are you trying to be a code hipster?  ^-^
 

Offline VtileTopic starter

  • Super Contributor
  • ***
  • Posts: 1144
  • Country: fi
  • Ingineer
Re: is it Forth to discuss?
« Reply #22 on: March 28, 2017, 06:02:12 pm »
Nice. The RPL is also so nice language as a bastard child of Lisp and Forth.  ;D

Don't take any offense to this... But are you trying to solve a problem? Or are you trying to be a code hipster?  ^-^
Heh, No I don't have any problem in hand to solve. I'm also trying to avoid being a code hipster.  :D I just find the basic concept of Forth really neat and fascinating, more so than C ( the one that is closest to the religion after ++ ), ObjPascal, (Visual)Basic(.net), ASM (the anticrist), Python etc.  The bonus is that it doesn't have brackets, were they curly or not. ^-^
« Last Edit: March 28, 2017, 06:09:34 pm by Vtile »
 

Offline VtileTopic starter

  • Super Contributor
  • ***
  • Posts: 1144
  • Country: fi
  • Ingineer
Re: is it Forth to discuss?
« Reply #23 on: March 28, 2017, 08:09:43 pm »
I think I start my journey of poking around with Forth and Arduino Nano that have have been garhering dust on my desk with AmForth.

https://youtu.be/gFE6oK7jkq4?t=6m24s

It is just so, uh. :)
« Last Edit: March 28, 2017, 08:15:45 pm by Vtile »
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4199
  • Country: us
Re: is it Forth to discuss?
« Reply #24 on: March 29, 2017, 05:56:42 am »
I find Forth sort-of nice if you want/need a semi-interactive thing with a parser.
Being able to have appropriate action just HAPPEN when you type/send "<bunch of standard math/etc expression stuff> MYFUNC <with possible looping>", without having to deal with your own string handling, or parsing, or expression evaluation, can be great.  If that's what you need to do.

Other than that, Forth seems unpleasantly mired in 1970s-era language philosophy.   And a particular subset of that philosophy where you didn't have cross-compilers or even cross-assemblers, and loading your code involved 30-minutes in a UV-eraser and 5 minutes in a separate device programmer, if you were lucky.   So you needed to fit everything on your target system.  And it's actually rather ugly.  I mean, redefining the meaning of standard functions isn't "clever"; it's pretty close to "evil", and if the language allows it, that is NOT a 'feature' !
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf