Shop OBEX P1 Docs P2 Docs Learn Events
Interactive Forth as a development language and tool vs "sealed" compiled code - Page 4 — Parallax Forums

Interactive Forth as a development language and tool vs "sealed" compiled code

1246

Comments

  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2013-12-04 18:08
    Martin_H wrote: »
    Peter's ability to dynamically extend his web server without shutdown is impressive. I really should try Tachyon Forth sometime soon.

    Actually it's not my ability, just the way it's implemented in that the FTP and HTTP server commands are not parsed through a table of commands but are simply passed to Forth to parse in the usual manner. So a HTTP "GET" will simply find the latest occurrence of GET in the dictionary and since it's set to immediate mode it executes straight-away to read in the rest of the request. Of course character I/O redirection to the relevant socket also helps. So in this context you could consider Forth acting as a scripting language (vs compiled threaded code), one well suited for this application.
  • Heater.Heater. Posts: 21,230
    edited 2013-12-05 00:25
    D.P.
    I really like the portability non-sense I hear as if you could take a C/C++ program designed specifically for the Prop and "run it" on your PC since after
    all it's in C/C++ and that language is portable.
    Sure you can.

    I have an FFT written in C that only exists because of the Propeller, it uses only integer arithmetic. It runs on the PC just fine.

    Of course if your program needs Prop specific features, like video, you are out of luck. Unless you provide some kind of emulation on the PC of the features you need. Which can be very useful for debugging your app. That is how a lot of embedded code is developed.

    Then there is the Arduino code, C++, that now runs on the Prop.

    Sounds portable enough to me.
    Also all the linker damage I see over on the C++ SD card thread is really amusing as well. Need a PHD in GCC just to understand the tools let alone have any brain space left for the actual problem. Can you say accidental complexity.
    I agree. Something seems to have gone wrong with the SimpleIDE/propgcc combination.

    I always imagined that SimpleIDE would stay as simple as the Arduino IDE where users program in C++ without ever knowing it and never have to deal with all the issues of how their programs are built.

    However SimpleIDE is still in development and I'm sure these issues will be worked out.
    ...as you see Peter has release a very basic webserver which you can extend dynamically teaching it new "words" while never shutting down the server and watch users come in and hit the new words. Is that silence I hear or are you all busy trying to figure out how to dynamically inject new binary into sealed libraries because "whatever FORTH can do C/++ must do better"
    I agree. I think that's very impressive. I would never dream to try and do that in C++. At least not in the confined space of a micro-controller.
  • David BetzDavid Betz Posts: 14,516
    edited 2013-12-05 03:52
    D.P wrote: »
    Also all the linker damage I see over on the C++ SD card thread is really amusing as well. Need a PHD in GCC just to understand the tools let alone have any brain space left for the actual problem. Can you say accidental complexity.
    Where is this thread? I must have missed it.
  • KC_RobKC_Rob Posts: 465
    edited 2013-12-05 07:35
    Heater. wrote: »
    I agree. I think that's very impressive. I would never dream to try and do that in C++. At least not in the confined space of a micro-controller.
    I have to second (third, fourth,... whatever) this. A very impressive example of Forth's capabilities/advantages.
  • jazzedjazzed Posts: 11,803
    edited 2013-12-05 09:34
    I've avoided this thread until now out of respect for Peter.

    However this needs to be clarified.
    Heater. wrote: »
    (referring to "linker damage" ...) I agree. Something seems to have gone wrong with the SimpleIDE/propgcc combination.
    This is not a SimpleIDE problem. SimpleIDE and PropellerGCC work fine together. The issue is that someone is being adventurous and blazing a trail outside of SimpleIDE. It's great to see so much interest in the products and help people when necessary. It feels nice to be making a difference.
  • iammegatroniammegatron Posts: 40
    edited 2014-01-16 09:56
    This forth tradition of self-sufficient and interactive (live) development is very much the spirit kept in smalltalk (nowadays squeak, pharo for example) as well.

    It's amazing that these early pioneers in computing just got it right.
  • Heater.Heater. Posts: 21,230
    edited 2014-01-16 10:19
    Jazzed,
    This is not a SimpleIDE problem....
    Sorry yes, it's not a SimpleIDE issue, I went back and read that again.

    iammegatron,
    It's amazing that these early pioneers in computing just got it right.
    Yes, Ritchie and Kernighan did us proud. (C - 1969) :)

    As did Bauer, Bottenbruch, Rutishauser, Samelson, Backus, Katz, Perlis, Wegstein. (ALGOL - 1958).

    And Backus (FORTRAN - 1953)

    And McCarthy (LISP - 1960)

    Moore (Forth - 1970) was kind of late to the game.
  • David BetzDavid Betz Posts: 14,516
    edited 2014-01-16 10:26
    (referring to "linker damage" ...) I agree. Something seems to have gone wrong with the SimpleIDE/propgcc combination.
    I still don't know what you're talking about when you say "linker damage". Where is there any linker damage? What do you mean by that?
  • Heater.Heater. Posts: 21,230
    edited 2014-01-16 10:58
    "linker damage" ?

    That was not me that was D.P in post #85. I think Jazzed clarified the issue just above.
  • David BetzDavid Betz Posts: 14,516
    edited 2014-01-16 11:08
    Heater. wrote: »
    "linker damage" ?

    That was not me that was D.P in post #85. I think Jazzed clarified the issue just above.
    Well, all Steve really said is that it isn't a SimpleIDE problem. That still leaves open the possiblity that people think it is a PropGCC compiler/linker problem. I would agree that linker scripts can be complex to construct but the flexiblity that they give you is not matched by simpler solutions and certainly not by Spin. If you don't need that complexity you can just use the built-in linker scripts and you never need that "PhD" but at least it's there if you really need it.
  • prof_brainoprof_braino Posts: 4,313
    edited 2014-01-16 11:25
    Heater. wrote: »
    Yes, Ritchie and Kernighan did us proud. (C - 1969) :)
    Moore (Forth - 1970) was kind of late to the game.

    ???

    You mean he missed the 60's? By 4 months? That's a big deal? Got it. :)

    Remember, Moore was building on the the previous efforts, to make a 4th generation language. I'm pretty sure Moore's effort was the FIRST of that genre. Whether or not he succeded, and to what degree, and in comparison to what other efforts, is a separate set of questions.
  • Heater.Heater. Posts: 21,230
    edited 2014-01-16 11:38
    Well, I was being a bit playful with the K and R thing. Perhaps too much so. I was just pointing out that most of what we have in language design today was on the table by about 1960. Those pioneers in language development are remembered and highly regarded still today. Most modern languages can trace ideas in their design back to those early languages. However Forth is not on the family tree of any modern language in common use.

    Except of course Fourth is not any kind of 4th generation language. At least not in the way I have ever heard the term used or in the way wikipedia describes a 4th generation language: http://en.wikipedia.org/wiki/Fourth-generation_programming_language#History
    Given that Fourth lacks any basic language features I fail to see how it is 4th gen.
  • prof_brainoprof_braino Posts: 4,313
    edited 2014-01-16 11:50
    Heater. wrote: »
    I was just pointing out that most of what we have in language design today was on the table by about 1960.
    Except C
    Forth is not on the family tree of any modern language in common use.

    postscript isn't common? I have a bunch of printers that might disagree with that.
    Except of course Fourth is not any kind of 4th generation language. At least not in the way I have ever heard the term used

    Well, that is your choice. You might also define it as a "poor example" of a 4th generation language according to heater's 2013 definition, or one might define it as an interesteding first try for 1970. But all that is moot, because Moore has dibs on the name.
  • Heater.Heater. Posts: 21,230
    edited 2014-01-16 12:16
    Brino,
    Except C
    Including C. The C language embodies language design ideas that sprouted with ALGOL, FORTRAN etc. You know, variables, data types, block structuring (structured programming), functions and so on. C is very much on that family tree.
    postscript isn't common?
    Do you know anyone who writes programs in postscript?

    I tried it once. There is a nice book on postscript programming. You can achieve some whacky graphics effects in PS if you are up for the hard work.

    To this day I'm not sure why printers use postscript.
    ...according to heater's 2013 definition...
    [/COLOR]
    Not my definition. Common usage for decades. From the first line of that wikipedia article "The term "fourth-generation programming language" (1970s-1990) (abbreviated 4GL)..."

    It is commonly accepted that those block structured languages like ALGOL, FORTRAN, C etc were 3rd generation languages. 4GL was obviously an idea to do something even higher level.
  • iammegatroniammegatron Posts: 40
    edited 2014-01-20 09:44
    This forth tradition of self-sufficient and interactive (live) development is very much the spirit kept in smalltalk (nowadays squeak, pharo for example) as well.

    It's amazing that these early pioneers in computing just got it right.

    Forget to mention, the nowadays popular "test driven" or "behavior driven" software development is very much like Peter's interactive Forth development. In fact, it was well supported in smalltalk environment very early.

    In addition, the smalltalk VM are very forth-like indeed.
  • potatoheadpotatohead Posts: 10,261
    edited 2014-01-20 11:34
    The only serious Postscript discussion and programming I recall was Don Lancaster. He actually would generate books, the compile the whole thing down to one big, low compute file. His first few were delivered on an Apple //e computer with some large storage attached.

    You can author a Postscript file and just FTP put it to a Xerox printer, which will then print the output for you.

    Fun stuff to tinker with, but that is about it.
  • Heater.Heater. Posts: 21,230
    edited 2014-01-20 14:53
    Yep, you can do some wacky stuff in straight postscript.
    http://paulbourke.net/dataformats/postscript/
    http://www.mostlymaths.net/2008/12/quick-postscript-programming-tutorial.html

    I once used it to create my company logo on letter heads.
  • richaj45richaj45 Posts: 179
    edited 2014-01-20 14:54
    Hello:

    I was reading today that the Comet-chasing probe, Rosetta, wakes up, calls home. That is a space probe that has in in space for tens years catching of with a comet to study it. I was curious what processor was on board and it turns out the main data processing unit uses a RTX2010 which is a direct execution Forth machine. They use it because of low power, good performance, and most important is radiation hardness.

    What i looked up said it is programmed in native Forth and compile 'C'. That would be 'C' compiled to Forth.

    There is no embedded Pentium out there were reliability really counts.

    cheers,
    rich
  • Dave HeinDave Hein Posts: 6,347
    edited 2014-01-20 17:31
    richaj45 wrote: »
    I was reading today that the Comet-chasing probe, Rosetta, wakes up, calls home. That is a space probe that has in in space for tens years catching of with a comet to study it. I was curious what processor was on board and it turns out the main data processing unit uses a RTX2010 which is a direct execution Forth machine. They use it because of low power, good performance, and most important is radiation hardness.
    Do you have a link for that? From what I could tell it seems to use a 1750 processor. There are several sensors, and probably several processors, so it probably uses a variety of processors.
  • kuronekokuroneko Posts: 3,623
    edited 2014-01-20 17:44
    Dave Hein wrote: »
    ... use a 1750 processor.
    Memories ... I used that one when I did my diploma. So it's still around :)
  • richaj45richaj45 Posts: 179
    edited 2014-01-21 17:45
    @Dave Heine

    The link is:
    http://www.researchgate.net/publication/234265387_Embedded_Computer_System_on_the_Rosetta_Spacecraft

    Click on the view on the right of the web page to see the article.

    rich
  • Dave HeinDave Hein Posts: 6,347
    edited 2014-01-21 19:20
    The article has an interesting comment about Forth.
    All the software components have been written in FORTH language with its exotic and challenging instruction set.
    I'm not sure if they picked the processor because it supported Forth, or they programmed in Forth because it was the processor's native language.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2014-01-21 19:44
    Dave Hein wrote: »
    The article has an interesting comment about Forth.

    I'm not sure if they picked the processor because it supported Forth, or they programmed in Forth because it was the processor's native language.

    Exotic is a relative term, a remote island might seem exotic to all but those who live there. Here's an interesting article from someone who had to choose which language to use. I would surmise that Forth HLL was much slower than Forth assembler though twice as fast as the C compiler due to not optimizing the language for the processor perhaps as I can see no reason why it couldn't run at full native speeds.
  • Dave HeinDave Hein Posts: 6,347
    edited 2014-01-22 06:37
    I thought the comment was interesting because of the use of the word "challenging" rather than the word "exotic". It seems that the programming environment for this chip is to use Forth as "sealed" compiled code instead of using an interactive Forth interpreter. I get the sense that Forth was chosen because it directly maps into the processor architecture, and not so much because the developers preferred using Forth. If I had to program this chip I would probably go with a mix of Forth and assembly. I'd have to try out the C compiler first to see how well it works. On todays machines, the compile times probably wouldn't be that bad.
  • prof_brainoprof_braino Posts: 4,313
    edited 2014-01-24 11:09
    Dave Hein wrote: »
    I thought the comment was interesting because of the use of the word "challenging" rather than the word "exotic". It seems that the programming environment for this chip is to use Forth as "sealed" compiled code instead of using an interactive Forth interpreter. I get the sense that Forth was chosen because it directly maps into the processor architecture, and not so much because the developers preferred using Forth. If I had to program this chip I would probably go with a mix of Forth and assembly. I'd have to try out the C compiler first to see how well it works. On todays machines, the compile times probably wouldn't be that bad.

    I think on the Harris RTX2010 the assembly language IS forth. These were used in a lot of spacecraft and are radiation hardened. On power up and reset it jumps right into the forth interpreter, so its easy to recover from software bugs. If you can get it to reset, you can talk to it and reload corrections, etc. They said it was the processor of choice for applications where you would never again have physical access to the hardware. I never had an RTX2010, but I still have an RTX2001. In case I need to launch a space probe or something, ya' never know.
  • Dave HeinDave Hein Posts: 6,347
    edited 2014-01-24 13:14
    The data sheet does show that the RTX2010 implements low-level Forth instructions, but I don't see anything in the data sheet that says it boots up into a Forth interpreter. It mentions that the development tools include C and Forth cross-compilers. On bootup the chip run a Forth inner-loop in hardware. I think a Forth interpreter, or outer-loop would have to be stored in external ROM. I don't see any internal memory in the chip except for the return and data stacks.
  • prof_brainoprof_braino Posts: 4,313
    edited 2014-01-24 14:14
    I might be talking out my butt again, but maybe check the data sheet for the assembler instructions. Some of those would be forth words like dup, swap etc. It would have same forth RPN syntax, and it would say something like high level forth code can be entered directly. At least thats what I recall from the RTX2001. Otherwise, ignore my previous post.

    I remember that I would connect a dumb terminal to the dev board, and it would auto set the baud based on the first character typed, and accept forth code. But it was a very RTX specific dialect, and I never had an application to use it.
  • Dave HeinDave Hein Posts: 6,347
    edited 2014-01-24 14:21
    Yes, I agree that the assembler instructions are low-level Forth words, but I don't believe the chip implements an assembler or a high-level Forth interpreter since it doesn't have any memory. The dev board probably has a ROM that is interfaced to the RTX2001 chip that provides the Forth interpreter.
  • max72 wrote: »
    I'm a lame programmer, so my post is strictly related to this aspect. Please consider other stuff is filling my time, so my propeller time is 0 at the moment.
    I have not issues with stack, but forth is quite unique under many other aspects.
    While with my programming level all the others language are more or less the same (Ok, I'm a very lame programmer), forth is quite different.
    I really like the interactive approach, the possibility to modify remotely and on the fly.
    I have issues learning how to use it, and how to exploit the prop power. Syntax is quite different, and needs time to digest.
    One of the main prop features in my opinion is the obex. For instance I use a lot of stuff requiring serial protocol.
    With spin I simply grab the 4port object and I'm done. Same applies to many other examples. A forth way to load an adapted pasm module would be great (v3?).

    I used a lot the obex also for learning prop programming. I started with very simple objects and the demo file, and started playing with it, but that's my way.

    I for sure think many of my past and future projects would benefit from forth, but in my case the learning curve is quite steep.
    I posted a figure of eight done with tachyon and it was fun, but I have a lot to learn.

    So bottom line is:
    thanks for opening a new programming world to me, even if it is causing me frustration...

    Massimo

    As an interactive programming experience is works well for me too. It has helped a great deal to understand the Propeller by just using one. Reading the Propeller Manual and other stuff just gets too dry.
  • Heater.Heater. Posts: 21,230
    edited 2015-12-11 20:38
    Wow, a rave from the grave. I had to go back and read a dozen pages to remind myself what the conversation is about.

    Still, the bottom line for me is that if I am going to invest hundreds of hours into developing a software solution to anything it had better be portable to other machines and preferably testable on my PC.

    On the other hand if portability is not an issue, but perhaps speed is, then PASM is easy and quite interactive enough from the Prop Tool or whatever you use.

    None of this has anything to do with the merits of Forth as a language. Apart from the fact that it is totally non-portable.

    Oh, yes, the Prop manual may be "dry". That is the nature of rigorous technical documents. Many of us might say it is not dry enough, there is no formal definition of the Spin language or the byte code interpreter built into the Prop for example.



Sign In or Register to comment.