• RE: Re: What attributes of a programming language simplify its implemen

    From Roger L Costello@21:1/5 to minf...@arcor.de on Tue Nov 15 11:52:00 2022
    minf...@arcor.de wrote:

    use Forth as your toolbox to make your own DSL
    and you can go _very_ far without diving into all
    those dragon books and gigabyte compilers and
    toolsets.

    Fascinating!

    What is it about the Forth programming language that makes it easy to implement DSL's?

    /Roger
    [It has small efficient implementations, it generally lets you get close to the hardware,
    and the RPN syntax lets you define new operators that work like the built-in ones. -John]

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From minforth@arcor.de@21:1/5 to Roger L Costello on Tue Nov 15 09:48:16 2022
    Roger L Costello schrieb am Dienstag, 15. November 2022 um 17:52:01 UTC+1:
    minf...@arcor.de wrote:

    use Forth as your toolbox to make your own DSL
    and you can go _very_ far without diving into all
    those dragon books and gigabyte compilers and
    toolsets.
    Fascinating!

    What is it about the Forth programming language that makes it easy to
    implement DSL's?

    /Roger
    [It has small efficient implementations, it generally lets you get close to the hardware,
    and the RPN syntax lets you define new operators that work like the built-in ones. -John]

    Forth comprises a _very_ simple interpreter and compiler. Both can be
    modified and enhanced easily to the problem domain. IOW Forth is
    extensible to the core of the language while still being small and
    simple enough to fit into one single person's head.

    Citing its inventor Chuck Moore:
    "By permitting the program to dynamically modify its control language,
    we mark a qualitative change in capability. In a sense, our program
    has evolved into a meta-language which we apply to the application.”

    Another citation (Bernd Paysan):

    “In this respect, Forth is quite similar to Lisp and its descendants…
    [but] Forth differs from Lisp in that it doesn’t use lists, neither
    for calling, nor for storing multiple values. Forth uses a stack to
    pass data between words, and it uses the raw memory (as seen by the
    assembler programmer) for more permanent storage. It’s much lower
    leveled than Lisp, and that’s one of the reason why it is fast.

    It’s not only fast, the simplicity makes it very small, too. Forth is
    the ultimate language for building extensions. Programming in Forth is generating higher levels of abstractions, until you have a language
    well fitted to solve your problem. The simplicity of the underlying
    system allows it to rely on it, which is important when you search
    bugs.

    The usual approach for application programming is to keep each layer
    simple, too. This is essential for rapid development of critical
    applications."

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From gah4@21:1/5 to minf...@arcor.de on Tue Nov 15 16:11:26 2022
    On Tuesday, November 15, 2022 at 1:15:04 PM UTC-8, minf...@arcor.de wrote:

    (snip on Forth, and its simple implementation)

    [It has small efficient implementations, it generally lets you get close
    to the hardware,
    and the RPN syntax lets you define new operators that work like the
    built-in ones. -John]

    Forth comprises a _very_ simple interpreter and compiler. Both can be modified and enhanced easily to the problem domain. IOW Forth is
    extensible to the core of the language while still being small and
    simple enough to fit into one single person's head.

    Citing its inventor Chuck Moore:
    "By permitting the program to dynamically modify its control language,
    we mark a qualitative change in capability. In a sense, our program
    has evolved into a meta-language which we apply to the application.”

    PostScript is also based on an RPN language interpreter, though I
    am not sure that the above quotes apply in the same way.

    One that I know about PostScript, and maybe not be true for Forth,
    is the bind operator.

    Before def, which defines a new operator, you can bind, which binds any operators inside the new definition to their current value. (I believe it
    also optimizes them to the address of the routine, saving the time for searching
    for the name in a symbol table.)

    Some years ago, working on converting TeX output for a book to
    PostScript, we had to write macros which redefine def.

    The DVI conversion was designed for 300dpi laser printers, and
    didn't have a convenient way to change to a higher resolution.

    So we wrote a header with new macros, and which then redefined
    def such that later macros wouldn't override them.
    (I think we always called them macros, not operators, but I am not
    sure by now what the right name is.)

    The Sun boot roms also use Forth, or something Forth-like as the
    built-in control language.
    [The FreeBSD boot also uses Forth for boot-time configuration. It's a nice little language but we're drifting away from compilers. -John]

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From minforth@arcor.de@21:1/5 to All on Wed Nov 16 04:54:53 2022
    gah4 schrieb am Mittwoch, 16. November 2022 um 11:57:18 UTC+1:
    The Sun boot roms also use Forth, or something Forth-like as the
    built-in control language.
    [The FreeBSD boot also uses Forth for boot-time configuration. It's a nice little language but we're drifting away from compilers. -John]

    You are right when it would only be about Forth, but we were musing about simplified compilation without all the usual ballast.

    So the capability in a (meta)language for compile-time execution comes into play.
    Forth is only one example. TCL would be my next candidate. I don't know Seed7 but its author claims to be able to e.g. redefine and create new operators which
    means new semantics.
    [There was a vogue in the 1970s for extensible languages like EL1 at Harvard and IMP72 at Yale. You could add new grammar rules on the fly. What that meant was that no two programs were written in the same language and they were unreadable and often undebuggable. OOP, which lets you add new types and semantics without changing the syntax, turned out to be a lot more useful.
    See https://en.wikipedia.org/wiki/Extensible_programming -John]

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From minforth@arcor.de@21:1/5 to minf...@arcor.de on Wed Nov 16 05:39:00 2022
    minf...@arcor.de schrieb am Mittwoch, 16. November 2022 um 14:16:47 UTC+1:
    So the capability in a (meta)language for compile-time execution comes into play.
    Forth is only one example. TCL would be my next candidate. I don't know Seed7 but its author claims to be able to e.g. redefine and create new operators which
    means new semantics.
    [There was a vogue in the 1970s for extensible languages like EL1 at Harvard and IMP72 at Yale. You could add new grammar rules on the fly. What that meant was that no two programs were written in the same language and they were
    unreadable and often undebuggable. OOP, which lets you add new types and semantics without changing the syntax, turned out to be a lot more useful. See https://en.wikipedia.org/wiki/Extensible_programming -John]

    A more important aspect of 'usefulness' is the available ecosystem. Experimental
    and toy compilers can be useful for individuals, perhaps (very) small teams. This
    stops when you have to run a business responsibly, including documentation, production, maintenance and what you have.

    OTOH a good DSL built within and managed by the existing ecosystem can give you a competitive edge.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anton Ertl@21:1/5 to gah4@u.washington.edu on Wed Nov 16 18:12:17 2022
    gah4 <gah4@u.washington.edu> writes:
    On Tuesday, November 15, 2022 at 1:15:04 PM UTC-8, minf...@arcor.de wrote:
    Citing its inventor Chuck Moore:
    "By permitting the program to dynamically modify its control language,
    we mark a qualitative change in capability. In a sense, our program
    has evolved into a meta-language which we apply to the application.”

    PostScript is also based on an RPN language interpreter, though I
    am not sure that the above quotes apply in the same way.

    IMO it does.

    One that I know about PostScript, and maybe not be true for Forth,
    is the bind operator.

    Postscript uses run-time name binding (like Lisp), Forth binds the
    names statically. Postscript's bind makes Postscript more Forth-like,
    but note that it statically binds only operators (built-ins), names
    that are bound to non-operators are still resolved dynamically.

    Before def, which defines a new operator, you can bind, which binds any >operators inside the new definition to their current value. (I believe it >also optimizes them to the address of the routine, saving the time for searching
    for the name in a symbol table.)

    Yes, it replaces the names that are bound to operators in the
    definition with the operators. So there is no name lookup for those
    at run-time.

    So we wrote a header with new macros, and which then redefined
    def such that later macros wouldn't override them.
    (I think we always called them macros, not operators, but I am not
    sure by now what the right name is.)

    procedures

    The Sun boot roms also use Forth, or something Forth-like as the
    built-in control language.

    Yes, the base language of Open Firmware is Forth.

    - anton
    --
    M. Anton Ertl
    anton@mips.complang.tuwien.ac.at
    http://www.complang.tuwien.ac.at/anton/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)