HP Forums
The Joy of Programming? - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: Not HP Calculators (/forum-7.html)
+--- Forum: Not quite HP Calculators - but related (/forum-8.html)
+--- Thread: The Joy of Programming? (/thread-15509.html)



The Joy of Programming? - John Keith - 08-28-2020 12:12 AM

I ran across this via a search on RosettaCode. It may look familiar to HP-48 and HP-71 folks...

Joy


RE: The Joy of Programming? - Dave Frederickson - 08-28-2020 05:24 PM

I give up. Why should Joy look familiar to 71 users?


RE: The Joy of Programming? - rprosperi - 08-28-2020 05:34 PM

(08-28-2020 05:24 PM)Dave Frederickson Wrote:  I give up. Why should Joy look familiar to 71 users?

It's very Forth-like, and the 71 is most associated with Forth among HP models.


RE: The Joy of Programming? - Sylvain Cote - 08-28-2020 06:05 PM

(08-28-2020 05:34 PM)rprosperi Wrote:  
(08-28-2020 05:24 PM)Dave Frederickson Wrote:  I give up. Why should Joy look familiar to 71 users?

It's very Forth-like, and the 71 is most associated with Forth among HP models.
Yep!
I just looked at the source code (kernel in C, everything else seems to be in Joy), it is a stack based language with word definition like Forth.
More time would be needed on my part to do a basic and honest comparison between the two languages.


RE: The Joy of Programming? - John Keith - 08-29-2020 12:23 PM

The main difference is that Joy is a pure functional language, sort of "Reverse Polish Haskell". Big Grin


RE: The Joy of Programming? - ijabbott - 08-29-2020 05:30 PM

I have thought Joy would make a good RPL alternative for a few years, but the language itself seems to have fallen by the wayside since its initial development.


RE: The Joy of Programming? - toml_12953 - 08-29-2020 07:43 PM

(08-28-2020 12:12 AM)John Keith Wrote:  I ran across this via a search on RosettaCode. It may look familiar to HP-48 and HP-71 folks...

Joy

I tried to learn it but no joy.


RE: The Joy of Programming? - Jonathan Busby - 09-02-2020 07:48 PM

(08-28-2020 12:12 AM)John Keith Wrote:  I ran across this via a search on RosettaCode. It may look familiar to HP-48 and HP-71 folks...

Joy

Joy has been around for quite some time Smile

The reason Joy looks and operates a lot like RPL is because both Joy and RPL ( at least System-RPL ) are *concatenative* programming languages, and also dynamically typed and inspired by Forth and stack-based. A concatenative programming language is a functional programming language that, instead of using the semantics from the typed λ-calculus, which most other functional programming languages do ( eg. Lisp, Haskell etc. ), uses *function composition* with *no formal parameters* ( eg. lambdas -- meaning that it's a "point free" language like RPL or Forth ) which is syntactically represented in Joy by juxtaposing ( ie. "concatenating" ) two functions ( and in RPL it's the same in most cases as ":: :: a b c ; :: d e f ; ;" is the same as ":: a b c d e f ;" ** although RPL is not a *pure* functional language and contains many imperative constructs and *side-effects* ). In Joy, everything is a function which takes the stack as an argument and returns the stack as the result. In Joy, the "meaning function" ( ie. EVAL ) represents a homomorphism between the *syntactic monoid* and the *semantic monoid* ( Here, "monoid" means a semigroup with an ( left and right ) identity element ( which is just the identity function ) and a left-associative binary operation which is function composition for the semantic monoid. For the syntactic monoid, the binary operation is function concatenation and the identity element can be eg. "[] concat" or "[a b c] i" ( which is the same as "a b c" ) ). For non-mathematicians, the "homomorphism" can be thought of as a correspondence between the syntax of Joy and its semantics, which preserves all the underlying structure. It's not an *isomorphism* ( ie. exact one-to-one correspondence ) because the syntax allows for expressions that map to the same semantic element(s), such as the identity element which can be something like "dup drop", "dup swap drop" "0 +" etc. There are other concatenative languages that have been inspired by Joy ( Notably Factor, which is well-maintained the last time I checked ), and furthermore, concatenative languages can be constructed in such a way so that *no garbage values in the heap are ever generated*, which obviates the need for a garbage collector.

( N.B. : ** The marked statement is only generally true if the RPL secondaries in question conform to a subset of RPL that is "mostly functional" ie. ERRSET ... ERRTRAP environments, DO ... LOOP environments, local variables, certain RPL words such as COLA etc. break the concatenative property )

I hope this clears things up... Smile

Regards,

Jonathan