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

0 Members and 1 Guest are viewing this topic.

Offline gmb42

  • Frequent Contributor
  • **
  • Posts: 294
  • Country: gb
Re: is it Forth to discuss?
« Reply #25 on: March 29, 2017, 11:53:59 am »
For those interested in Forth on embedded systems jcw over at JeeLabs has made a series of posts on using Forth on his new JeeNode Zero.
 

Offline VtileTopic starter

  • Super Contributor
  • ***
  • Posts: 1144
  • Country: fi
  • Ingineer
Re: is it Forth to discuss?
« Reply #26 on: March 29, 2017, 04:52:58 pm »
^^ Thanks. I'll look it up.

Here is somesort of Forth Standard page. The official ISO standard is from 1997.

http://forth-standard.org/
« Last Edit: March 29, 2017, 05:07:57 pm by Vtile »
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9889
  • Country: us
Re: is it Forth to discuss?
« Reply #27 on: March 29, 2017, 05:56:19 pm »
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.


That sounds a lot like interactive BASIC with RPN.

[/quote]

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' !
[/quote]

Self-modifying code was fairly common in the '60s.  I thought we tried to get away from that with the Harvard Architecture and the way GCC puts code and data in different segments and enforces access rights.

I do like the idea of the inverted pyramid coding.  Always building on things that were written before.  In a way, I find it kind of elegant.  But I don't think I'll spend any more time with it.  I had enough of that when I was programming an HP48GX calculator.  It wasn't Forth but it was pretty close.
 
The following users thanked this post: Vtile

Offline VtileTopic starter

  • Super Contributor
  • ***
  • Posts: 1144
  • Country: fi
  • Ingineer
Re: is it Forth to discuss?
« Reply #28 on: March 29, 2017, 07:21:46 pm »
I think I start to see some pitfals on Forth, but still it will be really interesting language / development environment in many cases.

Definedly not a language for writing a graphical and windowed OS, but something that interacts or controls the environment and even more so in cases where you do not have a full understanding of it and you learn by doing. Also interesting aspect is the fact that the toolchain is on the device itself so you don't need to hunt down the proper OS and virtual machine 20 years from now, just plug in terminal and keep programming (in case of some real world long living devices).

For me what makes it tempting also is that I can easily hack around the uC, which I'm not too familiar with or I don't have comp. science education/background which would restrict me to favor certain architecture or philosophy. The one similar feature of mentioned RPL programming is the ability to test around in normal environment and when working solution is found repeat the same command sequence between program delimers to use next time needed.

Also one thing which puts me away on the ie. Arduino C -environment is the peripheral libraries it turns the development a really boring action of "filling the whitespace in worksheet with functions". I don't want to file a report to communicate with computer, I want to talk with it!  ;D

Definedly not a solution for everything.
« Last Edit: March 29, 2017, 07:34:56 pm by Vtile »
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 16607
  • Country: us
  • DavidH
Re: is it Forth to discuss?
« Reply #29 on: March 29, 2017, 07:34:53 pm »
Open Firmware from Sun Microsystems used Forth for processor independent device drivers among other things.  Unfortunately the world moved to UEFI.
 
The following users thanked this post: Vtile

Offline Sal Ammoniac

  • Super Contributor
  • ***
  • Posts: 1668
  • Country: us
Re: is it Forth to discuss?
« Reply #30 on: March 30, 2017, 04:57:16 pm »
I recently decided I needed a small extension language for my microcontroller projects and decided to implement a Forth interpreter and compiler. I wrote it entirely in ARM assembly language for the Cortex-M parts and the whole thing is around a thousand lines of code. It's not as fast as compiled C, but I wanted it to be able to do quick and dirty things with an interactive command line. It fulfills that purpose quite well, but I wouldn't want to write anything larger than a few dozen lines in it as it starts to look like unreadable gobbledygook very quickly.

After using it for a few months, I've rethought my decision and have decided to write a Scheme interpreter instead. Languages like Scheme seem to fit my way of thinking better than Forth does.

As for the historical perspective, Forth's heyday (if it ever had one) was probably in the late 70s through the mid 80s. Open Firmware is probably the most well-known mainstream use of Forth. Other than that it's rarely used now, and most people who weren't around back then have never heard of it. It did have a reputation as a "hippy" language back in the day.
Complexity is the number-one enemy of high-quality code.
 

Offline VtileTopic starter

  • Super Contributor
  • ***
  • Posts: 1144
  • Country: fi
  • Ingineer
Re: is it Forth to discuss?
« Reply #31 on: March 30, 2017, 06:06:55 pm »
I recently decided I needed a small extension language for my microcontroller projects and decided to implement a Forth interpreter and compiler. I wrote it entirely in ARM assembly language for the Cortex-M parts and the whole thing is around a thousand lines of code. It's not as fast as compiled C, but I wanted it to be able to do quick and dirty things with an interactive command line. It fulfills that purpose quite well, but I wouldn't want to write anything larger than a few dozen lines in it as it starts to look like unreadable gobbledygook very quickly.

After using it for a few months, I've rethought my decision and have decided to write a Scheme interpreter instead. Languages like Scheme seem to fit my way of thinking better than Forth does.

As for the historical perspective, Forth's heyday (if it ever had one) was probably in the late 70s through the mid 80s. Open Firmware is probably the most well-known mainstream use of Forth. Other than that it's rarely used now, and most people who weren't around back then have never heard of it. It did have a reputation as a "hippy" language back in the day.
Thank you for the insights.

I needed to googe about scheme (Lisp) and found on the wiki: "Scheme Steering Committee calls it "the world's most unportable programming language""  ;D I read similar comment about early Forth implementations. (IIRC someone somewhere spoke similarly on the C compilers of the 80s with all sorts of partial implementations) It would be interesting to know what it status would be if it would have been invented hacked together in some "cool place" like Bell Labs or in MIT instead of beeing some hackjob of entrepreneur.
« Last Edit: March 30, 2017, 06:10:43 pm by Vtile »
 

Offline borjam

  • Supporter
  • ****
  • Posts: 908
  • Country: es
  • EA2EKH
Re: is it Forth to discuss?
« Reply #32 on: March 31, 2017, 12:07:43 pm »
I don't understand some angry reactions at it. Or yes :)

I used it for several years and it did a great job. Back in the old days it had several advantages. Now, as some have pointed out, resources are not so scarce and you don't really need to run a complete development environment in a tiny processor.

That said.

There are several free versions in source form. The old fig-Forth implementations are available for several old processors, and Mitch Bradley, the main author of Open Firmware as far as I know, has a Forth implementation in C available on Github.

https://github.com/MitchBradley/cforth
 
The following users thanked this post: Vtile

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9889
  • Country: us
Re: is it Forth to discuss?
« Reply #33 on: March 31, 2017, 03:10:06 pm »
In the early years (prior to '80), I did a lot of work with one-off 8085 designs.  First code to bring up was a simple Intel Monitor that would allow me to load other programs, read and write memory, etc.  Low level stuff but easy to get running.  Page 33 et seq here:

http://www.retro.co.za/ccc/8080/SDK-80/MCS-80%20System%20Design%20Kit%20Users%20Guide.pdf

The second (and sometimes last) thing to bring up was Palo Alto Tiny Basic:

https://en.wikipedia.org/wiki/Tiny_BASIC

The advantage was the ability to write more complex diagnostics in a somewhat higher level language.  The interpreter was ROM resident so only the application code needed to be downloaded.  Later, PATB was modified to use the CP/M Operating System for file storage.

FORTH came along about the same time and there were several incantations of full blown BASIC.  FORTRAN came along as did C but the real programming environment came with UCSD Pascal.  Real, serious, business programs were being written in Pascal right up until UCSD cancelled all the licenses.

https://en.wikipedia.org/wiki/UCSD_Pascal


 
The following users thanked this post: Vtile

Offline guenthert

  • Frequent Contributor
  • **
  • Posts: 712
  • Country: de
Re: is it Forth to discuss?
« Reply #34 on: April 02, 2017, 04:09:14 pm »
I still have a weak spot for FORTH.  The simplicity is quite elegant, the inner interpreter seems 'discovered' rather than 'invented'.  Creating a FORTH system (similar to Lisp, applications are typically delivered as 'whole world' system, i.e. one image containing user and system code) is easy - you can do it, give it a try (well, pick an early, small version, not ANS Forth).  Unfortunately, it's so easy everyone who ever programmed in FORTH created their own system.  While Lisp might not scale to projects with dozens of programmers, FORTH doesn't scale beyond teams with member count greater than one.  Collaboration in FORTH typically means someone shares his/her code and someone else re-implements it with his/her improvements.

It's great fun though, if you need to start from scratch.  Perfectly suited for a 70's-80's retro computing project with a few KiB of RAM; otherwise just forget about it.  It's a grand idea whose time has come and gone.
« Last Edit: April 02, 2017, 04:35:41 pm by guenthert »
 
The following users thanked this post: NivagSwerdna, Vtile

Offline legacy

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
Re: is it Forth to discuss?
« Reply #35 on: April 03, 2017, 10:59:15 am »
 
The following users thanked this post: jnz, Vtile

Offline VtileTopic starter

  • Super Contributor
  • ***
  • Posts: 1144
  • Country: fi
  • Ingineer
Re: is it Forth to discuss?
« Reply #36 on: April 03, 2017, 07:59:07 pm »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf