Husband, father, kabab lover, history buff, chess fan and software engineer. Believes creating software must resemble art: intuitive creation and joyful discovery.

🌎 linktr.ee/bahmanm

Views are my own.

  • 21 Posts
  • 10 Comments
Joined 2 years ago
cake
Cake day: June 26th, 2023

help-circle


  • Not really I’m afraid. Effects can be anywhere and they are not wrapped at all.

    In technical terms it’s stack-oriented meaning the only way for functions (called “words”) to interact with each other is via a parameter stack.

    Here’s an example:

    : TIMES-10  ( x -- y )
      10 
      * 
    ;
    
    12
    TIMES-10
    .S
    120
    

    TIMES-10 is a word which pops one parameter from stack and pushes the result of its calculation onto stack. The ( x -- y) is a comment which conventionally documents the “stack effect” of the word.

    Now when you type 12 and press RETURN, the integer 12 is pushed onto stack. Then TIMES-10 is called which in turn pushes 10 onto stack and invokes * which pops two values from stack and multiplies them and pushes the result onto stack.

    That’s why when type .S to see the contents of the stack, you get 120 in response.

    Another example is

    5 10 20 - *
    .S
    50
    

    This simple example demonstrates the reverse Polish notation (RPN) Forth uses. The arithmetic expression is equal to 5 * (20 - 10) the result of which is pushed onto stack.

    PS: One of the strengths of Forth is the ability to build a vocabulary (of words) around a particular problem in bottom-to-top fashion, much like Lisp. PPS: If you’re ever interested to learn Forth, Starting Forth is a fantastic resource.


  • Besides the fun of stretching your mental muscles to think in a different paradigm, Forth is usually used in the embedded devices domain (like that of the earlier Mars rover I forgot the name of).

    This project for me is mostly for the excitement and joy I get out of implementing a Forth (which is usually done in Assembler and C) on the JVM. While I managed to keep the semantics the same the underlying machinery is vastly different from, say, GForth. I find this quite a pleasing exercise.

    Last but not least, if you like concatenative but were unable to practice fun on the JVM, bjForth may be what you’re looking for.

    Hope this answers your question.






  • That’s impossible unless you’ve got a Forth machine.

    Where the OS native API is accessible via C API, you’re bound to write, using C/C++/Rust/etc, a small bootstrap programme to then write your Forth on top of. That’s essentially what bjForth is at the moment: the bootstrap using JVM native API.

    Currently I’m working on a set of libraries to augment the 80-something words bjForth bootstrap provides. These libraries will be, as you suggested, written in Forth not Java because they can tap into the power of JVM via the abstraction API that bootstrap primitives provide.

    Hope this makes sense.









  • Good question!

    IMO a good way to help a FOSS maintainer is to actually use the software (esp pre-release) and report bugs instead of working around them. Besides helping the project quality, I’d find it very heart-warming to receive feedback from users; it means people out there are actually not only using the software but care enough for it to take their time, report bugs and test patches.



  • RE Go: Others have already mentioned the right way, thought I’d personally prefer ~/opt/go over what was suggested.


    RE Perl: To instruct Perl to install to another directory, for example to ~/opt/perl5, put the following lines somewhere in your bash init files.

    export PERL5LIB="$HOME/opt/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"
    export PERL_LOCAL_LIB_ROOT="$HOME/opt/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"
    export PERL_MB_OPT="--install_base \"$HOME/opt/perl5\""
    export PERL_MM_OPT="INSTALL_BASE=$HOME/opt/perl5"
    export PATH="$HOME/opt/perl5/bin${PATH:+:${PATH}}"
    

    Though you need to re-install the Perl packages you had previously installed.









  • The GNU GPL is not Mr. Nice Guy. It says no to some of the things that people sometimes want to do. There are users who say that this is a bad thing—that the GPL “excludes” some proprietary software developers who “need to be brought into the free software community.”

    But we are not excluding them from our community; they are choosing not to enter. Their decision to make software proprietary is a decision to stay out of our community. Being in our community means joining in cooperation with us; we cannot “bring them into our community” if they don’t want to join.